X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..2656c66b5b30d5597e842a751c7f19ad6c2fe31a:/interpreter/Register.h diff --git a/interpreter/Register.h b/interpreter/Register.h index ecd7403..054b570 100644 --- a/interpreter/Register.h +++ b/interpreter/Register.h @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -29,70 +29,69 @@ #ifndef Register_h #define Register_h -#include "JSValue.h" +#include "JSCJSValue.h" #include -#include #include namespace JSC { - class Arguments; class CodeBlock; class ExecState; class JSActivation; - class JSFunction; + class JSObject; class JSPropertyNameIterator; - class ScopeChainNode; - - struct Instruction; + class JSScope; typedef ExecState CallFrame; - class Register : public WTF::FastAllocBase { + class Register { + WTF_MAKE_FAST_ALLOCATED; public: Register(); Register(const JSValue&); Register& operator=(const JSValue&); JSValue jsValue() const; + EncodedJSValue encodedJSValue() const; - Register& operator=(JSActivation*); Register& operator=(CallFrame*); Register& operator=(CodeBlock*); - Register& operator=(JSFunction*); - Register& operator=(JSPropertyNameIterator*); - Register& operator=(ScopeChainNode*); - Register& operator=(Instruction*); + Register& operator=(JSScope*); int32_t i() const; JSActivation* activation() const; - Arguments* arguments() const; CallFrame* callFrame() const; CodeBlock* codeBlock() const; - JSFunction* function() const; + JSObject* function() const; JSPropertyNameIterator* propertyNameIterator() const; - ScopeChainNode* scopeChain() const; - Instruction* vPC() const; + JSScope* scope() const; + int32_t unboxedInt32() const; + int64_t unboxedInt52() const; + int64_t unboxedStrictInt52() const; + bool unboxedBoolean() const; + double unboxedDouble() const; + JSCell* unboxedCell() const; + int32_t payload() const; + int32_t tag() const; + int32_t& payload(); + int32_t& tag(); static Register withInt(int32_t i) { - Register r; - r.u.i = i; + Register r = jsNumber(i); return r; } + static Register withCallee(JSObject* callee); + private: union { - int32_t i; EncodedJSValue value; - - JSActivation* activation; CallFrame* callFrame; CodeBlock* codeBlock; - JSFunction* function; - JSPropertyNameIterator* propertyNameIterator; - ScopeChainNode* scopeChain; - Instruction* vPC; + EncodedValueDescriptor encodedValue; + double number; + int64_t integer; } u; }; @@ -105,17 +104,11 @@ namespace JSC { ALWAYS_INLINE Register::Register(const JSValue& v) { -#if ENABLE(JSC_ZOMBIES) - ASSERT(!v.isZombie()); -#endif u.value = JSValue::encode(v); } ALWAYS_INLINE Register& Register::operator=(const JSValue& v) { -#if ENABLE(JSC_ZOMBIES) - ASSERT(!v.isZombie()); -#endif u.value = JSValue::encode(v); return *this; } @@ -125,14 +118,13 @@ namespace JSC { return JSValue::decode(u.value); } - // Interpreter functions - - ALWAYS_INLINE Register& Register::operator=(JSActivation* activation) + ALWAYS_INLINE EncodedJSValue Register::encodedJSValue() const { - u.activation = activation; - return *this; + return u.value; } + // Interpreter functions + ALWAYS_INLINE Register& Register::operator=(CallFrame* callFrame) { u.callFrame = callFrame; @@ -145,68 +137,73 @@ namespace JSC { return *this; } - ALWAYS_INLINE Register& Register::operator=(JSFunction* function) + ALWAYS_INLINE int32_t Register::i() const { - u.function = function; - return *this; + return jsValue().asInt32(); } - ALWAYS_INLINE Register& Register::operator=(Instruction* vPC) + ALWAYS_INLINE CallFrame* Register::callFrame() const { - u.vPC = vPC; - return *this; + return u.callFrame; + } + + ALWAYS_INLINE CodeBlock* Register::codeBlock() const + { + return u.codeBlock; } - ALWAYS_INLINE Register& Register::operator=(ScopeChainNode* scopeChain) + ALWAYS_INLINE int32_t Register::unboxedInt32() const { - u.scopeChain = scopeChain; - return *this; + return payload(); } - ALWAYS_INLINE Register& Register::operator=(JSPropertyNameIterator* propertyNameIterator) + ALWAYS_INLINE int64_t Register::unboxedInt52() const { - u.propertyNameIterator = propertyNameIterator; - return *this; + return u.integer >> JSValue::int52ShiftAmount; } - ALWAYS_INLINE int32_t Register::i() const + ALWAYS_INLINE int64_t Register::unboxedStrictInt52() const { - return u.i; + return u.integer; } - - ALWAYS_INLINE JSActivation* Register::activation() const + + ALWAYS_INLINE bool Register::unboxedBoolean() const { - return u.activation; + return !!payload(); } - - ALWAYS_INLINE CallFrame* Register::callFrame() const + + ALWAYS_INLINE double Register::unboxedDouble() const { - return u.callFrame; + return u.number; } - - ALWAYS_INLINE CodeBlock* Register::codeBlock() const + + ALWAYS_INLINE JSCell* Register::unboxedCell() const { - return u.codeBlock; +#if USE(JSVALUE64) + return u.encodedValue.ptr; +#else + return bitwise_cast(payload()); +#endif } - - ALWAYS_INLINE JSFunction* Register::function() const + + ALWAYS_INLINE int32_t Register::payload() const { - return u.function; + return u.encodedValue.asBits.payload; } - - ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const + + ALWAYS_INLINE int32_t Register::tag() const { - return u.propertyNameIterator; + return u.encodedValue.asBits.tag; } - - ALWAYS_INLINE ScopeChainNode* Register::scopeChain() const + + ALWAYS_INLINE int32_t& Register::payload() { - return u.scopeChain; + return u.encodedValue.asBits.payload; } - - ALWAYS_INLINE Instruction* Register::vPC() const + + ALWAYS_INLINE int32_t& Register::tag() { - return u.vPC; + return u.encodedValue.asBits.tag; } } // namespace JSC