Closed Bug 361312 Opened 18 years ago Closed 18 years ago

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

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: dschaffe, Unassigned)

Details

Attachments

(4 files)

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.
Attached file pow.as
Attached file 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
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.

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)
Attachment #247710 - Flags: review?(stejohns) → review+
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
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?
Attachment #247730 - Flags: review? → review+
Transfer Bug from Core->Tamarin to Tamarin Product.
Component: Tamarin → Virtual Machine
Product: Core → Tamarin
Version: Trunk → unspecified
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: