Changeset 26899 in webkit for trunk/JavaScriptCore/kjs/value.h


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/value.h

    r26892 r26899  
    335335inline bool JSValue::getInt32(int32_t& v) const
    336336{
    337     return JSImmediate::isImmediate(this) ? JSImmediate::toInt32(this, v) : asCell()->getInt32(v);
     337    return JSImmediate::isImmediate(this) ? JSImmediate::getInt32(this, v) : asCell()->getInt32(v);
    338338}
    339339
    340340inline bool JSValue::getUInt32(uint32_t& v) const
    341341{
    342     return JSImmediate::isImmediate(this) ? JSImmediate::toUInt32(this, v) : asCell()->getUInt32(v);
     342    return JSImmediate::isImmediate(this) ? JSImmediate::getUInt32(this, v) : asCell()->getUInt32(v);
    343343}
    344344
     
    387387{
    388388    int32_t i;
    389     if (JSImmediate::isImmediate(this) && JSImmediate::toInt32(this, i))
     389    if (JSImmediate::isImmediate(this) && JSImmediate::getInt32(this, i))
    390390        return i;
    391391    bool ok;
     
    396396{
    397397    uint32_t i;
    398     if (JSImmediate::isImmediate(this) && JSImmediate::toUInt32(this, i))
     398    if (JSImmediate::isImmediate(this) && JSImmediate::getUInt32(this, i))
    399399        return i;
    400400    bool ok;
     
    405405{
    406406    int32_t i;
    407     if (JSImmediate::isImmediate(this) && JSImmediate::toInt32(this, i)) {
     407    if (JSImmediate::isImmediate(this) && JSImmediate::getInt32(this, i)) {
    408408        ok = true;
    409409        return i;
     
    415415{
    416416    uint32_t i;
    417     if (JSImmediate::isImmediate(this) && JSImmediate::toUInt32(this, i)) {
     417    if (JSImmediate::isImmediate(this) && JSImmediate::getUInt32(this, i)) {
    418418        ok = true;
    419419        return i;
Note: See TracChangeset for help on using the changeset viewer.