]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - interpreter/Register.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / interpreter / Register.h
index fb02c12089b21ad3dcc1a4e99d862865b74d5123..e41da6271bac184b2f5b7f5d5413d15edb9777cc 100644 (file)
@@ -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,7 +29,7 @@
 #ifndef Register_h
 #define Register_h
 
-#include "JSValue.h"
+#include "JSCJSValue.h"
 #include <wtf/Assertions.h>
 #include <wtf/VectorTraits.h>
 
@@ -37,12 +37,9 @@ namespace JSC {
 
     class CodeBlock;
     class ExecState;
-    class JSActivation;
+    class JSLexicalEnvironment;
     class JSObject;
-    class JSPropertyNameIterator;
-    class ScopeChainNode;
-
-    struct Instruction;
+    class JSScope;
 
     typedef ExecState CallFrame;
 
@@ -58,17 +55,25 @@ namespace JSC {
         
         Register& operator=(CallFrame*);
         Register& operator=(CodeBlock*);
-        Register& operator=(ScopeChainNode*);
-        Register& operator=(Instruction*);
+        Register& operator=(JSScope*);
+        Register& operator=(JSObject*);
 
         int32_t i() const;
-        JSActivation* activation() const;
+        JSLexicalEnvironment* lexicalEnvironment() const;
         CallFrame* callFrame() const;
         CodeBlock* codeBlock() const;
-        JSObject* function() const;
-        JSPropertyNameIterator* propertyNameIterator() const;
-        ScopeChainNode* scopeChain() const;
-        Instruction* vPC() const;
+        JSObject* object() 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)
         {
@@ -76,14 +81,14 @@ namespace JSC {
             return r;
         }
 
-        static inline Register withCallee(JSObject* callee);
-
     private:
         union {
             EncodedJSValue value;
             CallFrame* callFrame;
             CodeBlock* codeBlock;
-            Instruction* vPC;
+            EncodedValueDescriptor encodedValue;
+            double number;
+            int64_t integer;
         } u;
     };
 
@@ -96,17 +101,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;
     }
@@ -135,12 +134,6 @@ namespace JSC {
         return *this;
     }
 
-    ALWAYS_INLINE Register& Register::operator=(Instruction* vPC)
-    {
-        u.vPC = vPC;
-        return *this;
-    }
-
     ALWAYS_INLINE int32_t Register::i() const
     {
         return jsValue().asInt32();
@@ -156,9 +149,58 @@ namespace JSC {
         return u.codeBlock;
     }
 
-    ALWAYS_INLINE Instruction* Register::vPC() const
+    ALWAYS_INLINE int32_t Register::unboxedInt32() const
+    {
+        return payload();
+    }
+
+    ALWAYS_INLINE int64_t Register::unboxedInt52() const
+    {
+        return u.integer >> JSValue::int52ShiftAmount;
+    }
+
+    ALWAYS_INLINE int64_t Register::unboxedStrictInt52() const
+    {
+        return u.integer;
+    }
+
+    ALWAYS_INLINE bool Register::unboxedBoolean() const
+    {
+        return !!payload();
+    }
+
+    ALWAYS_INLINE double Register::unboxedDouble() const
+    {
+        return u.number;
+    }
+
+    ALWAYS_INLINE JSCell* Register::unboxedCell() const
+    {
+#if USE(JSVALUE64)
+        return u.encodedValue.ptr;
+#else
+        return bitwise_cast<JSCell*>(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.vPC;
+        return u.encodedValue.asBits.tag;
     }
 
 } // namespace JSC