Ignore:
Timestamp:
Nov 23, 2009, 6:30:04 PM (16 years ago)
Author:
[email protected]
Message:

Streamlined some Math functions where we expect or know the result not
to be representable as an int.

Reviewed by Oliver Hunt.

SunSpider says 0.6% faster.

  • runtime/JSNumberCell.h:

(JSC::JSValue::JSValue):

  • runtime/JSValue.h:

(JSC::JSValue::):
(JSC::jsDoubleNumber):
(JSC::JSValue::JSValue): Added a function for making a numeric JSValue
and skipping the "can I encode this as an int?" check, avoiding the
overhead of int <-> double roundtripping and double <-> double comparison
and branching.

  • runtime/MathObject.cpp:

(JSC::mathProtoFuncACos):
(JSC::mathProtoFuncASin):
(JSC::mathProtoFuncATan):
(JSC::mathProtoFuncATan2):
(JSC::mathProtoFuncCos):
(JSC::mathProtoFuncExp):
(JSC::mathProtoFuncLog):
(JSC::mathProtoFuncRandom):
(JSC::mathProtoFuncSin):
(JSC::mathProtoFuncSqrt):
(JSC::mathProtoFuncTan): For these functions, which we expect or know
to produce results not representable as ints, call jsDoubleNumber instead
of jsNumber.

File:
1 edited

Legend:

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

    r49734 r51334  
    8181        enum JSTrueTag { JSTrue };
    8282        enum JSFalseTag { JSFalse };
     83        enum EncodeAsDoubleTag { EncodeAsDouble };
    8384
    8485        JSValue();
     
    9192
    9293        // Numbers
     94        JSValue(EncodeAsDoubleTag, ExecState*, double);
    9395        JSValue(ExecState*, double);
    9496        JSValue(ExecState*, char);
     
    280282    }
    281283
     284    ALWAYS_INLINE JSValue jsDoubleNumber(ExecState* exec, double d)
     285    {
     286        return JSValue(JSValue::EncodeAsDouble, exec, d);
     287    }
     288
    282289    ALWAYS_INLINE JSValue jsNumber(ExecState* exec, double d)
    283290    {
     
    584591    }
    585592
     593    ALWAYS_INLINE JSValue::JSValue(EncodeAsDoubleTag, ExecState*, double d)
     594    {
     595        u.asDouble = d;
     596    }
     597
    586598    inline JSValue::JSValue(ExecState* exec, double d)
    587599    {
Note: See TracChangeset for help on using the changeset viewer.