* 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.
*
#ifndef Register_h
#define Register_h
-#include "JSValue.h"
+#include "JSCJSValue.h"
#include <wtf/Assertions.h>
-#include <wtf/FastAllocBase.h>
#include <wtf/VectorTraits.h>
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;
};
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;
}
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;
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<JSCell*>(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