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/internal.cpp

    r26899 r26912  
    112112}
    113113
    114 bool NumberImp::getInt32(int32_t& int32) const
    115 {
    116     int32 = static_cast<int32_t>(val);
    117     return int32 == val;
    118 }
    119 
    120114bool NumberImp::getUInt32(uint32_t& uint32) const
    121115{
    122116    uint32 = static_cast<uint32_t>(val);
    123117    return uint32 == val;
     118}
     119
     120bool NumberImp::getTruncatedInt32(int32_t& int32) const
     121{
     122    if (!(val >= -2147483648.0 && val < 2147483648.0))
     123        return false;
     124    int32 = static_cast<int32_t>(val);
     125    return true;
     126}
     127
     128bool NumberImp::getTruncatedUInt32(uint32_t& uint32) const
     129{
     130    if (!(val >= 0.0 && val < 4294967296.0))
     131        return false;
     132    uint32 = static_cast<uint32_t>(val);
     133    return true;
    124134}
    125135
Note: See TracChangeset for help on using the changeset viewer.