Ignore:
Timestamp:
Oct 22, 2007, 4:36:36 PM (18 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Geoff.

One of the JavaScriptCore tests was failing; it failed because of
my change to NumberImp::getUInt32. The incorrect code I copied was
from JSImmediate::getUInt32, and was a pre-existing bug.

This patch fixes correctness, but will surely slow down SunSpider.
We may be able to code this tighter and get the speed back.

  • kjs/JSImmediate.h: (KJS::JSImmediate::getInt32): Renamed from toInt32 to more accurately reflect the fact that this function only returns true if the value is accurate (no fractional part, etc.). Changed code so that it returns false when the value has a fraction. (KJS::JSImmediate::getUInt32): Ditto.
  • kjs/internal.cpp: (KJS::NumberImp::getInt32): Changed code so that it returns false when the value has a fraction. Restores the old behavior. (KJS::NumberImp::getUInt32): Ditto.
  • kjs/value.h: (KJS::JSValue::getInt32): Updated for name change. (KJS::JSValue::getUInt32): Ditto. (KJS::JSValue::toInt32): Ditto. (KJS::JSValue::toUInt32): Ditto.

LayoutTests:

Reviewed by Geoff.

Added tests for cases where you use something that looks like an array
index, but it has a fractional part.

  • fast/js/kde/resources/Array.js: Added tests.
  • fast/js/kde/Array-expected.txt: Updated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/internal.cpp

    r26892 r26899  
    114114bool NumberImp::getInt32(int32_t& int32) const
    115115{
    116     if (!(val >= -2147483648.0 && val < 2147483648.0))
    117         return false;
    118116    int32 = static_cast<int32_t>(val);
    119     return true;
     117    return int32 == val;
    120118}
    121119
    122120bool NumberImp::getUInt32(uint32_t& uint32) const
    123121{
    124     if (!(val >= 0.0 && val < 4294967296.0))
    125         return false;
    126122    uint32 = static_cast<uint32_t>(val);
    127     return true;
     123    return uint32 == val;
    128124}
    129125
Note: See TracChangeset for help on using the changeset viewer.