Bug 1045948 - IonMonkey: Obviate LAllocation's tag bit. r=bhackett
authorDan Gohman <sunfish@mozilla.com>
Sat, 16 Aug 2014 13:13:13 -0700
changeset 200003 14246833d2096dfa38e3f9083d06a7c55f59ad30
parent 200002 4173a2b47c5a35b97b26bf20ad8083c839cd1aab
child 200004 59aa0319941b936234c51af7a70e857689fb969e
push id9784
push userryanvm@gmail.com
push dateSat, 16 Aug 2014 21:45:40 +0000
treeherderb2g-inbound@94ba78a42305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1045948
milestone34.0a1
Bug 1045948 - IonMonkey: Obviate LAllocation's tag bit. r=bhackett
js/src/jit/LIR.h
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -52,44 +52,40 @@ static const uint32_t PAYLOAD_INDEX = 1;
 #endif
 
 // Represents storage for an operand. For constants, the pointer is tagged
 // with a single bit, and the untagged pointer is a pointer to a Value.
 class LAllocation : public TempObject
 {
     uintptr_t bits_;
 
-    static const uintptr_t TAG_BIT = 1;
-    static const uintptr_t TAG_SHIFT = 0;
-    static const uintptr_t TAG_MASK = 1 << TAG_SHIFT;
+    // 3 bits gives us enough for an interesting set of Kinds and also fits
+    // within the alignment bits of pointers to Value, which are always
+    // 8-byte aligned.
     static const uintptr_t KIND_BITS = 3;
-    static const uintptr_t KIND_SHIFT = TAG_SHIFT + TAG_BIT;
+    static const uintptr_t KIND_SHIFT = 0;
     static const uintptr_t KIND_MASK = (1 << KIND_BITS) - 1;
 
   protected:
-    static const uintptr_t DATA_BITS = (sizeof(uint32_t) * 8) - KIND_BITS - TAG_BIT;
+    static const uintptr_t DATA_BITS = (sizeof(uint32_t) * 8) - KIND_BITS;
     static const uintptr_t DATA_SHIFT = KIND_SHIFT + KIND_BITS;
     static const uintptr_t DATA_MASK = (1 << DATA_BITS) - 1;
 
   public:
     enum Kind {
         USE,            // Use of a virtual register, with physical allocation policy.
         CONSTANT_VALUE, // Constant js::Value.
         CONSTANT_INDEX, // Constant arbitrary index.
         GPR,            // General purpose register.
         FPU,            // Floating-point register.
         STACK_SLOT,     // Stack slot.
         ARGUMENT_SLOT   // Argument slot.
     };
 
   protected:
-    bool isTagged() const {
-        return !!(bits_ & TAG_MASK);
-    }
-
     int32_t data() const {
         return int32_t(bits_) >> DATA_SHIFT;
     }
     void setData(int32_t data) {
         JS_ASSERT(int32_t(data) <= int32_t(DATA_MASK));
         bits_ &= ~(DATA_MASK << DATA_SHIFT);
         bits_ |= (data << DATA_SHIFT);
     }
@@ -112,27 +108,25 @@ class LAllocation : public TempObject
     static LAllocation *New(TempAllocator &alloc) {
         return new(alloc) LAllocation();
     }
     template <typename T>
     static LAllocation *New(TempAllocator &alloc, const T &other) {
         return new(alloc) LAllocation(other);
     }
 
-    // The value pointer must be rooted in MIR and have its low bit cleared.
+    // The value pointer must be rooted in MIR and have its low bits cleared.
     explicit LAllocation(const Value *vp) {
         bits_ = uintptr_t(vp);
-        JS_ASSERT(!isTagged());
-        bits_ |= TAG_MASK;
+        JS_ASSERT((bits_ & (KIND_MASK << KIND_SHIFT)) == 0);
+        bits_ |= CONSTANT_VALUE << KIND_SHIFT;
     }
     inline explicit LAllocation(AnyRegister reg);
 
     Kind kind() const {
-        if (isTagged())
-            return CONSTANT_VALUE;
         return (Kind)((bits_ >> KIND_SHIFT) & KIND_MASK);
     }
 
     bool isUse() const {
         return kind() == USE;
     }
     bool isConstant() const {
         return isConstantValue() || isConstantIndex();
@@ -170,17 +164,17 @@ class LAllocation : public TempObject
     inline const LFloatReg *toFloatReg() const;
     inline const LStackSlot *toStackSlot() const;
     inline const LArgument *toArgument() const;
     inline const LConstantIndex *toConstantIndex() const;
     inline AnyRegister toRegister() const;
 
     const Value *toConstant() const {
         JS_ASSERT(isConstantValue());
-        return reinterpret_cast<const Value *>(bits_ & ~TAG_MASK);
+        return reinterpret_cast<const Value *>(bits_ & ~(KIND_MASK << KIND_SHIFT));
     }
 
     bool operator ==(const LAllocation &other) const {
         return bits_ == other.bits_;
     }
 
     bool operator !=(const LAllocation &other) const {
         return bits_ != other.bits_;