Changeset 36434 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Sep 15, 2008, 2:39:26 AM (17 years ago)
Author:
[email protected]
Message:

2008-09-15 Cameron Zwarich <[email protected]>

Reviewed by Maciej Stachowiak.

Bug 20851: REGRESSION (r36410): fast/js/kde/GlobalObject.html fails
<https://bugs.webkit.org/show_bug.cgi?id=20851>

r36410 introduced an optimization for parseInt() that is incorrect when
its argument is larger than the range of a 32-bit integer. If the
argument is a number that is not an immediate integer, then the correct
behaviour is to return the floor of its value, unless it is an infinite
value, in which case the correct behaviour is to return 0.

JavaScriptCore:

  • kjs/JSGlobalObjectFunctions.cpp: (JSC::globalFuncParseInt):

LayoutTests:

  • fast/js/numeric-conversion-expected.txt:
  • fast/js/resources/numeric-conversion.js:
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r36429 r36434  
     12008-09-15  Cameron Zwarich  <[email protected]>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Bug 20851: REGRESSION (r36410): fast/js/kde/GlobalObject.html fails
     6        <https://bugs.webkit.org/show_bug.cgi?id=20851>
     7
     8        r36410 introduced an optimization for parseInt() that is incorrect when
     9        its argument is larger than the range of a 32-bit integer. If the
     10        argument is a number that is not an immediate integer, then the correct
     11        behaviour is to return the floor of its value, unless it is an infinite
     12        value, in which case the correct behaviour is to return 0.
     13
     14        * kjs/JSGlobalObjectFunctions.cpp:
     15        (JSC::globalFuncParseInt):
     16
    1172008-09-15  Sam Weinig  <[email protected]>
    218
  • trunk/JavaScriptCore/kjs/JSGlobalObjectFunctions.cpp

    r36410 r36434  
    298298    int32_t radix = args.at(exec, 1)->toInt32(exec);
    299299
    300     if (value->isNumber() && (radix == 0 || radix == 10))
    301         return jsNumber(exec, value->toInt32(exec));
     300    if (value->isNumber() && (radix == 0 || radix == 10)) {
     301        if (JSImmediate::isImmediate(value))
     302            return value;
     303        double d = value->uncheckedGetNumber();
     304        if (!isfinite(d))
     305            return JSImmediate::zeroImmediate();
     306        return jsNumber(exec, floor(d));
     307    }
    302308
    303309    return jsNumber(exec, parseInt(value->toString(exec), radix));
Note: See TracChangeset for help on using the changeset viewer.