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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.