Changeset 26912 in webkit for trunk/JavaScriptCore/kjs/value.cpp


Ignore:
Timestamp:
Oct 22, 2007, 11:44:27 PM (18 years ago)
Author:
darin
Message:

Reviewed by Maciej.

This should restore correctness and make speed better too, restoring some
of the optimization we lost in my last check-in.

  • kjs/JSImmediate.h: (KJS::JSImmediate::getTruncatedInt32): Added. Uses the range checking idiom I used in my patch yesterday. (KJS::JSImmediate::getTruncatedUInt32): Ditto.
  • kjs/internal.h: Removed getInt32 and added getTruncatedInt/UInt32.
  • kjs/internal.cpp: (KJS::NumberImp::getUInt32): Changed to always use double, since I can't find a way to write this more efficiently for float. (KJS::NumberImp::getTruncatedInt32): Added. (KJS::NumberImp::getTruncatedUInt32): Added.
  • kjs/value.h: Removed getInt32 and added getTruncatedInt/UInt32. (KJS::JSValue::getUInt32): (KJS::JSValue::getTruncatedInt32): Added. (KJS::JSValue::getTruncatedUInt32): Added. (KJS::JSValue::toInt32): Changed getInt32 call to getTruncatedInt32. (KJS::JSValue::toUInt32): Changed getUInt32 call to getTruncatedUInt32.
  • kjs/value.cpp: (KJS::JSCell::getTruncatedInt32): Added. (KJS::JSCell::getTruncatedUInt32): Added. (KJS::JSValue::toInteger): Changed getUInt32 call to getTruncatedInt32. (KJS::JSValue::toInt32SlowCase): Removed extra getInt32 call I accidentally had left in here. (KJS::JSValue::toUInt32SlowCase): Ditto. (KJS::JSValue::toUInt16): Changed getUInt32 call to getTruncatedUInt32.
File:
1 edited

Legend:

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

    r26892 r26912  
    4141}
    4242
    43 bool JSCell::getInt32(int32_t&) const
     43bool JSCell::getUInt32(uint32_t&) const
    4444{
    4545    return false;
    4646}
    4747
    48 bool JSCell::getUInt32(uint32_t&) const
     48bool JSCell::getTruncatedInt32(int32_t&) const
     49{
     50    return false;
     51}
     52
     53bool JSCell::getTruncatedUInt32(uint32_t&) const
    4954{
    5055    return false;
     
    5459double JSValue::toInteger(ExecState *exec) const
    5560{
    56     uint32_t i;
    57     if (getUInt32(i))
     61    int32_t i;
     62    if (getTruncatedInt32(i))
    5863        return i;
    5964    return roundValue(exec, const_cast<JSValue*>(this));
     
    6368{
    6469    ok = true;
    65 
    66     int32_t i;
    67     if (getInt32(i))
    68         return i;
    6970
    7071    double d = roundValue(exec, const_cast<JSValue*>(this));
     
    9091    ok = true;
    9192
    92     uint32_t i;
    93     if (getUInt32(i))
    94         return i;
    95 
    9693    double d = roundValue(exec, const_cast<JSValue*>(this));
    9794    if (d >= 0.0 && d < D32)
     
    113110{
    114111    uint32_t i;
    115     if (getUInt32(i))
     112    if (getTruncatedUInt32(i))
    116113        return static_cast<uint16_t>(i);
    117114
Note: See TracChangeset for help on using the changeset viewer.