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


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

    r26899 r26912  
    7777
    7878    // Extracting integer values.
    79     bool getInt32(int32_t&) const;
    8079    bool getUInt32(uint32_t&) const;
     80    bool getTruncatedInt32(int32_t&) const;
     81    bool getTruncatedUInt32(uint32_t&) const;
    8182
    8283    // Basic conversions.
     
    141142
    142143    // Extracting integer values.
    143     virtual bool getInt32(int32_t&) const;
    144144    virtual bool getUInt32(uint32_t&) const;
     145    virtual bool getTruncatedInt32(int32_t&) const;
     146    virtual bool getTruncatedUInt32(uint32_t&) const;
    145147
    146148    // Basic conversions.
     
    333335}
    334336
    335 inline bool JSValue::getInt32(int32_t& v) const
    336 {
    337     return JSImmediate::isImmediate(this) ? JSImmediate::getInt32(this, v) : asCell()->getInt32(v);
    338 }
    339 
    340337inline bool JSValue::getUInt32(uint32_t& v) const
    341338{
    342339    return JSImmediate::isImmediate(this) ? JSImmediate::getUInt32(this, v) : asCell()->getUInt32(v);
     340}
     341
     342inline bool JSValue::getTruncatedInt32(int32_t& v) const
     343{
     344    return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedInt32(this, v) : asCell()->getTruncatedInt32(v);
     345}
     346
     347inline bool JSValue::getTruncatedUInt32(uint32_t& v) const
     348{
     349    return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedUInt32(this, v) : asCell()->getTruncatedUInt32(v);
    343350}
    344351
     
    387394{
    388395    int32_t i;
    389     if (JSImmediate::isImmediate(this) && JSImmediate::getInt32(this, i))
     396    if (JSImmediate::isImmediate(this) && JSImmediate::getTruncatedInt32(this, i))
    390397        return i;
    391398    bool ok;
     
    396403{
    397404    uint32_t i;
    398     if (JSImmediate::isImmediate(this) && JSImmediate::getUInt32(this, i))
     405    if (JSImmediate::isImmediate(this) && JSImmediate::getTruncatedUInt32(this, i))
    399406        return i;
    400407    bool ok;
     
    405412{
    406413    int32_t i;
    407     if (JSImmediate::isImmediate(this) && JSImmediate::getInt32(this, i)) {
     414    if (JSImmediate::isImmediate(this) && JSImmediate::getTruncatedInt32(this, i)) {
    408415        ok = true;
    409416        return i;
     
    415422{
    416423    uint32_t i;
    417     if (JSImmediate::isImmediate(this) && JSImmediate::getUInt32(this, i)) {
     424    if (JSImmediate::isImmediate(this) && JSImmediate::getTruncatedUInt32(this, i)) {
    418425        ok = true;
    419426        return i;
Note: See TracChangeset for help on using the changeset viewer.