X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..217a6308cd6a1dc049a0bb69263bd4c91f91c4d0:/interpreter/Register.h diff --git a/interpreter/Register.h b/interpreter/Register.h index ecd7403..bc23356 100644 --- a/interpreter/Register.h +++ b/interpreter/Register.h @@ -29,70 +29,73 @@ #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; + class JSScope; + struct InlineCallFrame; struct Instruction; 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=(JSScope*); Register& operator=(Instruction*); + Register& operator=(InlineCallFrame*); 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; + JSScope* scope() const; Instruction* vPC() const; + InlineCallFrame* asInlineCallFrame() const; + int32_t unboxedInt32() const; + bool unboxedBoolean() 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; + InlineCallFrame* inlineCallFrame; + EncodedValueDescriptor encodedValue; } u; }; @@ -105,17 +108,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 +122,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,40 +141,23 @@ namespace JSC { return *this; } - ALWAYS_INLINE Register& Register::operator=(JSFunction* function) - { - u.function = function; - return *this; - } - ALWAYS_INLINE Register& Register::operator=(Instruction* vPC) { u.vPC = vPC; return *this; } - ALWAYS_INLINE Register& Register::operator=(ScopeChainNode* scopeChain) + ALWAYS_INLINE Register& Register::operator=(InlineCallFrame* inlineCallFrame) { - u.scopeChain = scopeChain; - return *this; - } - - ALWAYS_INLINE Register& Register::operator=(JSPropertyNameIterator* propertyNameIterator) - { - u.propertyNameIterator = propertyNameIterator; + u.inlineCallFrame = inlineCallFrame; return *this; } ALWAYS_INLINE int32_t Register::i() const { - return u.i; - } - - ALWAYS_INLINE JSActivation* Register::activation() const - { - return u.activation; + return jsValue().asInt32(); } - + ALWAYS_INLINE CallFrame* Register::callFrame() const { return u.callFrame; @@ -188,25 +167,54 @@ namespace JSC { { return u.codeBlock; } - - ALWAYS_INLINE JSFunction* Register::function() const + + ALWAYS_INLINE Instruction* Register::vPC() const { - return u.function; + return u.vPC; } - - ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const + + ALWAYS_INLINE InlineCallFrame* Register::asInlineCallFrame() const { - return u.propertyNameIterator; + return u.inlineCallFrame; } - - ALWAYS_INLINE ScopeChainNode* Register::scopeChain() const + + ALWAYS_INLINE int32_t Register::unboxedInt32() const { - return u.scopeChain; + return payload(); } - - ALWAYS_INLINE Instruction* Register::vPC() const + + ALWAYS_INLINE bool Register::unboxedBoolean() const { - return u.vPC; + return !!payload(); + } + + ALWAYS_INLINE JSCell* Register::unboxedCell() const + { +#if USE(JSVALUE64) + return u.encodedValue.ptr; +#else + return bitwise_cast(payload()); +#endif + } + + ALWAYS_INLINE int32_t Register::payload() const + { + return u.encodedValue.asBits.payload; + } + + ALWAYS_INLINE int32_t Register::tag() const + { + return u.encodedValue.asBits.tag; + } + + ALWAYS_INLINE int32_t& Register::payload() + { + return u.encodedValue.asBits.payload; + } + + ALWAYS_INLINE int32_t& Register::tag() + { + return u.encodedValue.asBits.tag; } } // namespace JSC