The default bug view has changed. See this FAQ.

TI+JM: incorrect result with +=, parseFloat

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: jandem, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
This test is reduced from the Mochitest-2 orange.
--
function f() {
    var x = 0;
    for(var i=0; i<5; i++) {
        (function() {
            x += parseFloat("2");
        })();
    }
    return x;
}
assertEq(f(), 10);
--
$ ./js -m -n -a test.js
test.js:10: Error: Assertion failed: got 2, expected 10

parseFloat has TypeHandlerFloat and returns an int32 value. Similar functions like (2).valueOf() also fail.
It's OK for natives to return ints when their handler is a float, we'll convert it to a float when merging back into the inline path.  The problem here was that when generating a PIC for the GETXPROP used in the '+=' we did not update the possible types pushed by the PIC, as we do for GETPROP and NAME ICs (grumble...)

http://hg.mozilla.org/projects/jaegermonkey/rev/aec367836312
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.