difference output on tamarin avmplus executable between Mac and Windows when running Math.pow(Infinity,-1)

VERIFIED FIXED

Status

Tamarin
Virtual Machine
VERIFIED FIXED
11 years ago
8 years ago

People

(Reporter: Dan Schaffer, Unassigned)

Tracking

Details

Attachments

(4 attachments)

(Reporter)

Description

11 years ago
There are 5 failing testcases on mac on the compliance tests.  The reason is the following code differs between mac and windows.  

 print(Math.pow(Infinity,-1));
 print(Math.pow(-Infinity,-1));
 print(Math.pow(-Infinity,-2));

Windows Output:
 NaN
 NaN
 NaN

Mac Output:
 0
 0
 0

the pow.abc code is attached to this bug.
(Reporter)

Comment 1

11 years ago
Created attachment 246064 [details]
pow.as
(Reporter)

Comment 2

11 years ago
Created attachment 246065 [details]
pow.abc
See http://lxr.mozilla.org/mozilla/source/js/src/jsmath.c#301 or so:

#if !JS_USE_FDLIBM_MATH
    /*
     * Because C99 and ECMA specify different behavior for pow(),
     * we need to wrap the libm call to make it ECMA compliant.
     */
    if (!JSDOUBLE_IS_FINITE(y) && (x == 1.0 || x == -1.0)) {
        *rval = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
        return JS_TRUE;
    }
    /* pow(x, +-0) is always 1, even for x = NaN. */
    if (y == 0) {
        *rval = JSVAL_ONE;
        return JS_TRUE;
    }
#endif

/be
(Reporter)

Comment 4

11 years ago
yeah, the expected behavior should be:
pow(Infinity,-1)=0 

so tamarin windows is wrong and tamarin mac is correct. I will update the 5 failing testcases to expect = 0

tested on JavaScript 1.7 (mozilla/js) and it is correct.

Comment 5

11 years ago
Created attachment 247710 [details] [diff] [review]
Fix for Math.pow problem plus 3 other changes

1.  MathUtils.cpp change to fix Math.pow edge cases
2.  AvmCore.cpp change to fix interpreted mode comparison of negative zero and zero (or other theoretical cases where an integer value ends up in a double atom type)
3. 64-bit fix for GCHiddenPointer
4. Some CodegenMIR.cpp optimizations for int/uint operations with mult/add/sub operators.  If result is int/uint and inputs are int/uint, we can safely do integer math instead of promoting to double all the time.
Attachment #247710 - Flags: review?(stejohns)

Updated

11 years ago
Attachment #247710 - Flags: review?(stejohns) → review+

Updated

11 years ago
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
(Reporter)

Comment 6

11 years ago
Created attachment 247730 [details] [diff] [review]
e15_8_2_13.as test fixes

patch for mozilla/js/tamarin/test/ecma3/Math/e15_8_2_13.as fixes 5 failing Windows testcases Math.pow(Infinity,-1)=0
Attachment #247730 - Flags: review?

Updated

11 years ago
Attachment #247730 - Flags: review? → review+

Comment 7

10 years ago
Transfer Bug from Core->Tamarin to Tamarin Product.
Component: Tamarin → Virtual Machine
Product: Core → Tamarin
Version: Trunk → unspecified

Updated

8 years ago
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.