Changeset 43121 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
May 1, 2009, 2:20:11 PM (16 years ago)
Author:
[email protected]
Message:

2009-05-01 Geoffrey Garen <[email protected]>

Reviewed by Sam "That doesn't look like what I thought it looks like" Weinig.


Beefed up the JSValuePtr class and removed some non-JSValuePtr dependencies
on JSImmediate, in prepapration for making JSImmediate an implementation
detail of JSValuePtr.


SunSpider reports no change.

  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute):
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass):
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArith_op_mod):
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncParseInt): Updated for interface changes.
  • runtime/JSImmediate.h: (JSC::JSValuePtr::JSValuePtr):
  • runtime/JSValue.h: (JSC::JSValuePtr::): (JSC::jsImpossibleValue): (JSC::jsNull): (JSC::jsUndefined): (JSC::jsBoolean): (JSC::JSValuePtr::encode): (JSC::JSValuePtr::decode): (JSC::JSValuePtr::JSValuePtr): (JSC::JSValuePtr::operator bool): (JSC::JSValuePtr::operator==): (JSC::JSValuePtr::operator!=): (JSC::JSValuePtr::isUndefined): (JSC::JSValuePtr::isNull): Changed jsImpossibleValue(), jsNull(), jsUndefined(), and jsBoolean() to operate in terms of JSValuePtr instead of JSImmediate.
  • wtf/StdLibExtras.h: (WTF::bitwise_cast): Fixed up for clarity.
Location:
trunk/JavaScriptCore/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r42989 r43121  
    307307        if (isnan(d) || isinf(d))
    308308            return jsNaN(&exec->globalData());
    309         return js0();
     309        return jsNumber(exec, 0);
    310310    }
    311311
  • trunk/JavaScriptCore/runtime/JSImmediate.h

    r40046 r43121  
    4343    class UString;
    4444
    45     JSValuePtr js0();
    46     JSValuePtr jsNull();
    47     JSValuePtr jsBoolean(bool b);
    48     JSValuePtr jsUndefined();
    49     JSValuePtr jsImpossibleValue();
    5045    JSValuePtr jsNumber(ExecState* exec, double d);
    5146    JSValuePtr jsNumber(ExecState*, char i);
     
    161156        friend class JSValuePtr;
    162157        friend class JSFastMath;
    163         friend JSValuePtr js0();
    164         friend JSValuePtr jsNull();
    165         friend JSValuePtr jsBoolean(bool b);
    166         friend JSValuePtr jsUndefined();
    167         friend JSValuePtr jsImpossibleValue();
    168158        friend JSValuePtr jsNumber(ExecState* exec, double d);
    169159        friend JSValuePtr jsNumber(ExecState*, char i);
     
    578568    }
    579569
    580     inline JSValuePtr js0()
    581     {
    582         return JSImmediate::zeroImmediate();
    583     }
    584 
    585     inline JSValuePtr jsNull()
    586     {
    587         return JSImmediate::nullImmediate();
    588     }
    589 
    590     inline JSValuePtr jsBoolean(bool b)
    591     {
    592         return b ? JSImmediate::trueImmediate() : JSImmediate::falseImmediate();
    593     }
    594 
    595     inline JSValuePtr jsUndefined()
    596     {
    597         return JSImmediate::undefinedImmediate();
    598     }
    599 
    600     inline JSValuePtr jsImpossibleValue()
    601     {
    602         return JSImmediate::impossibleValue();
    603     }
    604 
    605570    // These are identical logic to the JSValue functions above, and faster than jsNumber(number).toInt32().
    606571    int32_t toInt32(double);
     
    609574    uint32_t toUInt32SlowCase(double, bool& ok);
    610575
    611     inline bool JSValuePtr::isUndefined() const
    612     {
    613         return asValue() == jsUndefined();
    614     }
    615 
    616     inline bool JSValuePtr::isNull() const
    617     {
    618         return asValue() == jsNull();
     576    inline JSValuePtr::JSValuePtr(ImpossibleValueTag)
     577    {
     578        *this = JSImmediate::impossibleValue();
     579    }
     580
     581    inline JSValuePtr::JSValuePtr(JSNullTag)
     582    {
     583        *this = JSImmediate::nullImmediate();
     584    }
     585   
     586    inline JSValuePtr::JSValuePtr(JSUndefinedTag)
     587    {
     588        *this = JSImmediate::undefinedImmediate();
     589    }
     590
     591    inline JSValuePtr::JSValuePtr(JSTrueTag)
     592    {
     593        *this = JSImmediate::trueImmediate();
     594    }
     595
     596    inline JSValuePtr::JSValuePtr(JSFalseTag)
     597    {
     598        *this = JSImmediate::falseImmediate();
    619599    }
    620600
  • trunk/JavaScriptCore/runtime/JSValue.h

    r43103 r43121  
    6262       
    6363    public:
    64         JSValuePtr()
    65             : m_ptr(0)
    66         {
    67         }
    68 
    69         JSValuePtr(JSCell* ptr)
    70             : m_ptr(ptr)
    71         {
    72         }
    73 
    74         JSValuePtr(const JSCell* ptr)
    75             : m_ptr(const_cast<JSCell*>(ptr))
    76         {
    77         }
    78 
    79         operator bool() const
    80         {
    81             return m_ptr;
    82         }
    83 
    84         bool operator==(const JSValuePtr other) const
    85         {
    86             return m_ptr == other.m_ptr;
    87         }
    88 
    89         bool operator!=(const JSValuePtr other) const
    90         {
    91             return m_ptr != other.m_ptr;
    92         }
    93 
    94         static EncodedJSValuePtr encode(JSValuePtr value)
    95         {
    96             return reinterpret_cast<EncodedJSValuePtr>(value.m_ptr);
    97         }
    98 
    99         static JSValuePtr decode(EncodedJSValuePtr ptr)
    100         {
    101             return JSValuePtr(reinterpret_cast<JSCell*>(ptr));
    102         }
     64        enum ImpossibleValueTag { ImpossibleValue };
     65        enum JSNullTag { JSNull };
     66        enum JSUndefinedTag { JSUndefined };
     67        enum JSTrueTag { JSTrue };
     68        enum JSFalseTag { JSFalse };
     69
     70        static EncodedJSValuePtr encode(JSValuePtr value);
     71        static JSValuePtr decode(EncodedJSValuePtr ptr);
     72
     73        JSValuePtr();
     74        JSValuePtr(ImpossibleValueTag);
     75        JSValuePtr(JSNullTag);
     76        JSValuePtr(JSUndefinedTag);
     77        JSValuePtr(JSTrueTag);
     78        JSValuePtr(JSFalseTag);
     79        JSValuePtr(JSCell* ptr);
     80        JSValuePtr(const JSCell* ptr);
     81
     82        operator bool() const;
     83        bool operator==(const JSValuePtr other) const;
     84        bool operator!=(const JSValuePtr other) const;
    10385
    10486        // Querying the type.
     
    207189    };
    208190
     191    // Stand-alone helper functions.
    209192    inline JSValuePtr noValue()
    210193    {
    211194        return JSValuePtr();
     195    }
     196
     197    inline JSValuePtr jsImpossibleValue()
     198    {
     199        return JSValuePtr(JSValuePtr::ImpossibleValue);
     200    }
     201
     202    inline JSValuePtr jsNull()
     203    {
     204        return JSValuePtr(JSValuePtr::JSNull);
     205    }
     206
     207    inline JSValuePtr jsUndefined()
     208    {
     209        return JSValuePtr(JSValuePtr::JSUndefined);
     210    }
     211
     212    inline JSValuePtr jsBoolean(bool b)
     213    {
     214        return b ? JSValuePtr(JSValuePtr::JSTrue) : JSValuePtr(JSValuePtr::JSFalse);
    212215    }
    213216
     
    218221    inline bool operator!=(const JSCell* a, const JSValuePtr b) { return JSValuePtr(a) != b; }
    219222
     223    // JSValuePtr member functions.
     224    inline EncodedJSValuePtr JSValuePtr::encode(JSValuePtr value)
     225    {
     226        return reinterpret_cast<EncodedJSValuePtr>(value.m_ptr);
     227    }
     228
     229    inline JSValuePtr JSValuePtr::decode(EncodedJSValuePtr ptr)
     230    {
     231        return JSValuePtr(reinterpret_cast<JSCell*>(ptr));
     232    }
     233
     234    inline JSValuePtr::JSValuePtr()
     235        : m_ptr(0)
     236    {
     237    }
     238
     239    inline JSValuePtr::JSValuePtr(JSCell* ptr)
     240        : m_ptr(ptr)
     241    {
     242    }
     243
     244    inline JSValuePtr::JSValuePtr(const JSCell* ptr)
     245        : m_ptr(const_cast<JSCell*>(ptr))
     246    {
     247    }
     248
     249    inline JSValuePtr::operator bool() const
     250    {
     251        return m_ptr;
     252    }
     253
     254    inline bool JSValuePtr::operator==(const JSValuePtr other) const
     255    {
     256        return m_ptr == other.m_ptr;
     257    }
     258
     259    inline bool JSValuePtr::operator!=(const JSValuePtr other) const
     260    {
     261        return m_ptr != other.m_ptr;
     262    }
     263
     264    inline bool JSValuePtr::isUndefined() const
     265    {
     266        return asValue() == jsUndefined();
     267    }
     268
     269    inline bool JSValuePtr::isNull() const
     270    {
     271        return asValue() == jsNull();
     272    }
     273
    220274} // namespace JSC
    221275
Note: See TracChangeset for help on using the changeset viewer.