Ignore:
Timestamp:
Jul 30, 2009, 1:57:44 PM (16 years ago)
Author:
[email protected]
Message:

Merged nitro-extreme branch into trunk.

File:
1 edited

Legend:

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

    r43153 r46598  
    2323#define JSImmediate_h
    2424
     25#include <wtf/Platform.h>
     26
     27#if !USE(JSVALUE32_64)
     28
    2529#include <wtf/Assertions.h>
    2630#include <wtf/AlwaysInline.h>
     
    4347    class UString;
    4448
    45 #if USE(ALTERNATE_JSIMMEDIATE)
     49#if USE(JSVALUE64)
    4650    inline intptr_t reinterpretDoubleToIntptr(double value)
    4751    {
     
    99103    /*
    100104     * On 64-bit platforms, we support an alternative encoding form for immediates, if
    101      * USE(ALTERNATE_JSIMMEDIATE) is defined.  When this format is used, double precision
     105     * USE(JSVALUE64) is defined.  When this format is used, double precision
    102106     * floating point values may also be encoded as JSImmediates.
    103107     *
     
    156160        friend JSValue jsNumber(JSGlobalData* globalData, unsigned long long i);
    157161
    158 #if USE(ALTERNATE_JSIMMEDIATE)
     162#if USE(JSVALUE64)
    159163        // If all bits in the mask are set, this indicates an integer number,
    160164        // if any but not all are set this value is a double precision number.
     
    178182        static const intptr_t FullTagTypeNull      = TagBitTypeOther;
    179183
    180 #if USE(ALTERNATE_JSIMMEDIATE)
     184#if USE(JSVALUE64)
    181185        static const int32_t IntegerPayloadShift  = 0;
    182186#else
     
    201205        static ALWAYS_INLINE bool isIntegerNumber(JSValue v)
    202206        {
    203 #if USE(ALTERNATE_JSIMMEDIATE)
     207#if USE(JSVALUE64)
    204208            return (rawValue(v) & TagTypeNumber) == TagTypeNumber;
    205209#else
     
    208212        }
    209213
    210 #if USE(ALTERNATE_JSIMMEDIATE)
    211         static ALWAYS_INLINE bool isDoubleNumber(JSValue v)
     214#if USE(JSVALUE64)
     215        static ALWAYS_INLINE bool isDouble(JSValue v)
    212216        {
    213217            return isNumber(v) && !isIntegerNumber(v);
     
    257261        static ALWAYS_INLINE bool areBothImmediateIntegerNumbers(JSValue v1, JSValue v2)
    258262        {
    259 #if USE(ALTERNATE_JSIMMEDIATE)
     263#if USE(JSVALUE64)
    260264            return (rawValue(v1) & rawValue(v2) & TagTypeNumber) == TagTypeNumber;
    261265#else
     
    268272        static JSObject* toObject(JSValue, ExecState*);
    269273        static JSObject* toThisObject(JSValue, ExecState*);
    270         static UString toString(JSValue);
    271274
    272275        static bool getUInt32(JSValue, uint32_t&);
     
    287290
    288291    private:
    289 #if USE(ALTERNATE_JSIMMEDIATE)
     292#if USE(JSVALUE64)
    290293        static const int minImmediateInt = ((-INT_MAX) - 1);
    291294        static const int maxImmediateInt = INT_MAX;
     
    301304        }
    302305
    303         // With USE(ALTERNATE_JSIMMEDIATE) we want the argument to be zero extended, so the
     306        // With USE(JSVALUE64) we want the argument to be zero extended, so the
    304307        // integer doesn't interfere with the tag bits in the upper word.  In the default encoding,
    305308        // if intptr_t id larger then int32_t we sign extend the value through the upper word.
    306 #if USE(ALTERNATE_JSIMMEDIATE)
     309#if USE(JSVALUE64)
    307310        static ALWAYS_INLINE JSValue makeInt(uint32_t value)
    308311#else
     
    313316        }
    314317       
    315 #if USE(ALTERNATE_JSIMMEDIATE)
     318#if USE(JSVALUE64)
    316319        static ALWAYS_INLINE JSValue makeDouble(double value)
    317320        {
     
    338341        static JSValue fromNumberOutsideIntegerRange(T);
    339342
    340 #if USE(ALTERNATE_JSIMMEDIATE)
     343#if USE(JSVALUE64)
    341344        static ALWAYS_INLINE double doubleValue(JSValue v)
    342345        {
     
    364367            return v.immediateValue();
    365368        }
    366 
    367         static double nonInlineNaN();
    368369    };
    369370
     
    375376    ALWAYS_INLINE JSValue JSImmediate::oneImmediate() { return makeInt(1); }
    376377
    377 #if USE(ALTERNATE_JSIMMEDIATE)
     378#if USE(JSVALUE64)
    378379    inline bool doubleToBoolean(double value)
    379380    {
     
    402403    }
    403404
    404 #if USE(ALTERNATE_JSIMMEDIATE)
     405#if USE(JSVALUE64)
    405406    template<typename T>
    406407    inline JSValue JSImmediate::fromNumberOutsideIntegerRange(T value)
     
    443444    ALWAYS_INLINE JSValue JSImmediate::from(int i)
    444445    {
    445 #if !USE(ALTERNATE_JSIMMEDIATE)
     446#if !USE(JSVALUE64)
    446447        if ((i < minImmediateInt) | (i > maxImmediateInt))
    447448            return fromNumberOutsideIntegerRange(i);
     
    509510            return intValue(v);
    510511
    511 #if USE(ALTERNATE_JSIMMEDIATE)
     512#if USE(JSVALUE64)
    512513        if (isNumber(v)) {
    513             ASSERT(isDoubleNumber(v));
     514            ASSERT(isDouble(v));
    514515            return doubleValue(v);
    515516        }
     
    542543    }
    543544
    544     // These are identical logic to the JSValue functions above, and faster than jsNumber(number).toInt32().
    545     int32_t toInt32(double);
    546     uint32_t toUInt32(double);
    547     int32_t toInt32SlowCase(double, bool& ok);
    548     uint32_t toUInt32SlowCase(double, bool& ok);
    549 
    550545    inline JSValue::JSValue(JSNullTag)
    551546    {
     
    576571    {
    577572        return JSImmediate::isBoolean(asValue());
     573    }
     574
     575    inline bool JSValue::isTrue() const
     576    {
     577        return asValue() == JSImmediate::trueImmediate();
     578    }
     579
     580    inline bool JSValue::isFalse() const
     581    {
     582        return asValue() == JSImmediate::falseImmediate();
    578583    }
    579584
     
    593598    }
    594599
    595     ALWAYS_INLINE int32_t JSValue::toInt32(ExecState* exec) const
    596     {
    597         int32_t i;
    598         if (getTruncatedInt32(i))
    599             return i;
    600         bool ignored;
    601         return toInt32SlowCase(toNumber(exec), ignored);
    602     }
    603 
    604     inline uint32_t JSValue::toUInt32(ExecState* exec) const
    605     {
    606         uint32_t i;
    607         if (getTruncatedUInt32(i))
    608             return i;
    609         bool ignored;
    610         return toUInt32SlowCase(toNumber(exec), ignored);
    611     }
    612 
    613     inline int32_t toInt32(double val)
    614     {
    615         if (!(val >= -2147483648.0 && val < 2147483648.0)) {
    616             bool ignored;
    617             return toInt32SlowCase(val, ignored);
    618         }
    619         return static_cast<int32_t>(val);
    620     }
    621 
    622     inline uint32_t toUInt32(double val)
    623     {
    624         if (!(val >= 0.0 && val < 4294967296.0)) {
    625             bool ignored;
    626             return toUInt32SlowCase(val, ignored);
    627         }
    628         return static_cast<uint32_t>(val);
    629     }
    630 
    631     inline int32_t JSValue::toInt32(ExecState* exec, bool& ok) const
    632     {
    633         int32_t i;
    634         if (getTruncatedInt32(i)) {
    635             ok = true;
    636             return i;
    637         }
    638         return toInt32SlowCase(toNumber(exec), ok);
    639     }
    640 
    641     inline uint32_t JSValue::toUInt32(ExecState* exec, bool& ok) const
    642     {
    643         uint32_t i;
    644         if (getTruncatedUInt32(i)) {
    645             ok = true;
    646             return i;
    647         }
    648         return toUInt32SlowCase(toNumber(exec), ok);
    649     }
    650 
    651600    inline bool JSValue::isCell() const
    652601    {
     
    654603    }
    655604
    656     inline bool JSValue::isInt32Fast() const
     605    inline bool JSValue::isInt32() const
    657606    {
    658607        return JSImmediate::isIntegerNumber(asValue());
    659608    }
    660609
    661     inline int32_t JSValue::getInt32Fast() const
    662     {
    663         ASSERT(isInt32Fast());
     610    inline int32_t JSValue::asInt32() const
     611    {
     612        ASSERT(isInt32());
    664613        return JSImmediate::getTruncatedInt32(asValue());
    665614    }
    666615
    667     inline bool JSValue::isUInt32Fast() const
     616    inline bool JSValue::isUInt32() const
    668617    {
    669618        return JSImmediate::isPositiveIntegerNumber(asValue());
    670619    }
    671620
    672     inline uint32_t JSValue::getUInt32Fast() const
    673     {
    674         ASSERT(isUInt32Fast());
     621    inline uint32_t JSValue::asUInt32() const
     622    {
     623        ASSERT(isUInt32());
    675624        return JSImmediate::getTruncatedUInt32(asValue());
    676     }
    677 
    678     inline JSValue JSValue::makeInt32Fast(int32_t i)
    679     {
    680         return JSImmediate::from(i);
    681     }
    682 
    683     inline bool JSValue::areBothInt32Fast(JSValue v1, JSValue v2)
    684     {
    685         return JSImmediate::areBothImmediateIntegerNumbers(v1, v2);
    686625    }
    687626
     
    736675        {
    737676            ASSERT(canDoFastRshift(val, shift) || canDoFastUrshift(val, shift));
    738 #if USE(ALTERNATE_JSIMMEDIATE)
     677#if USE(JSVALUE64)
    739678            return JSImmediate::makeValue(static_cast<intptr_t>(static_cast<uint32_t>(static_cast<int32_t>(JSImmediate::rawValue(val)) >> ((JSImmediate::rawValue(shift) >> JSImmediate::IntegerPayloadShift) & 0x1f))) | JSImmediate::TagTypeNumber);
    740679#else
     
    784723} // namespace JSC
    785724
     725#endif // !USE(JSVALUE32_64)
     726
    786727#endif // JSImmediate_h
Note: See TracChangeset for help on using the changeset viewer.