Ignore:
Timestamp:
Aug 19, 2010, 2:03:38 PM (15 years ago)
Author:
[email protected]
Message:

2010-08-19 Andreas Kling <[email protected]>

Reviewed by Geoffrey Garen.

JSC: Move the static_cast into to(U)Int32 fast case
https://bugs.webkit.org/show_bug.cgi?id=44037

Do the static_cast<(u)int32_t> inline to avoid the function call overhead
for easily converted values (within (u)int32_t range.)

  • runtime/JSValue.cpp: (JSC::toInt32SlowCase): (JSC::toUInt32SlowCase):
  • runtime/JSValue.h: (JSC::JSValue::toInt32): (JSC::JSValue::toUInt32):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSValue.h

    r64684 r65698  
    398398        if (isInt32())
    399399            return asInt32();
     400
     401        double val = toNumber(exec);
     402
     403        if (val >= -2147483648.0 && val < 2147483648.0)
     404            return static_cast<int32_t>(val);
     405
    400406        bool ignored;
    401         return toInt32SlowCase(toNumber(exec), ignored);
     407        return toInt32SlowCase(val, ignored);
    402408    }
    403409
     
    406412        if (isUInt32())
    407413            return asInt32();
     414
     415        double val = toNumber(exec);
     416
     417        if (val >= 0.0 && val < 4294967296.0)
     418            return static_cast<uint32_t>(val);
     419
    408420        bool ignored;
    409         return toUInt32SlowCase(toNumber(exec), ignored);
     421        return toUInt32SlowCase(val, ignored);
    410422    }
    411423
     
    416428            return asInt32();
    417429        }
    418         return toInt32SlowCase(toNumber(exec), ok);
     430
     431        double val = toNumber(exec);
     432
     433        if (val >= -2147483648.0 && val < 2147483648.0) {
     434            ok = true;
     435            return static_cast<int32_t>(val);
     436        }
     437
     438        return toInt32SlowCase(val, ok);
    419439    }
    420440
     
    425445            return asInt32();
    426446        }
    427         return toUInt32SlowCase(toNumber(exec), ok);
     447
     448        double val = toNumber(exec);
     449
     450        if (val >= 0.0 && val < 4294967296.0) {
     451            ok = true;
     452            return static_cast<uint32_t>(val);
     453        }
     454
     455        return toUInt32SlowCase(val, ok);
    428456    }
    429457
Note: See TracChangeset for help on using the changeset viewer.