Bug 1271972: Add infra for Int64 temporaries; r=jandem
authorBenjamin Bouvier <benj@benj.me>
Wed, 11 May 2016 18:06:14 +0200
changeset 297352 906763ccdf9a5c8a4950a48d28be7231d5090eb2
parent 297351 6b6de61e1364453cceaedcaec9c1e045a1514afe
child 297353 4daee069692632e5d4477a0c5710d835da1feed9
push id19218
push userkwierso@gmail.com
push dateFri, 13 May 2016 23:46:15 +0000
treeherderfx-team@93d60e9db618 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1271972
milestone49.0a1
Bug 1271972: Add infra for Int64 temporaries; r=jandem MozReview-Commit-ID: BGEhahzoKJy
js/src/jit/LIR.h
js/src/jit/shared/Lowering-shared-inl.h
js/src/jit/shared/Lowering-shared.h
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -310,38 +310,41 @@ class LBoxAllocation
     LAllocation payload() const { return payload_; }
 #else
     explicit LBoxAllocation(LAllocation value) : value_(value) {}
 
     LAllocation value() const { return value_; }
 #endif
 };
 
-class LInt64Allocation
+template<class ValT>
+class LInt64Value
 {
 #if JS_BITS_PER_WORD == 32
-    LAllocation high_;
-    LAllocation low_;
+    ValT high_;
+    ValT low_;
 #else
-    LAllocation value_;
+    ValT value_;
 #endif
 
   public:
 #if JS_BITS_PER_WORD == 32
-    LInt64Allocation(LAllocation high, LAllocation low) : high_(high), low_(low) {}
+    LInt64Value(ValT high, ValT low) : high_(high), low_(low) {}
 
-    LAllocation high() const { return high_; }
-    LAllocation low() const { return low_; }
+    ValT high() const { return high_; }
+    ValT low() const { return low_; }
 #else
-    explicit LInt64Allocation(LAllocation value) : value_(value) {}
+    explicit LInt64Value(ValT value) : value_(value) {}
 
-    LAllocation value() const { return value_; }
+    ValT value() const { return value_; }
 #endif
 };
 
+using LInt64Allocation = LInt64Value<LAllocation>;
+
 class LGeneralReg : public LAllocation
 {
   public:
     explicit LGeneralReg(Register reg)
       : LAllocation(GPR, reg.code())
     { }
 
     Register reg() const {
@@ -631,16 +634,18 @@ class LDefinition
         }
     }
 
     UniqueChars toString() const;
 
     void dump() const;
 };
 
+using LInt64Definition = LInt64Value<LDefinition>;
+
 // Forward declarations of LIR types.
 #define LIROP(op) class L##op;
     LIR_OPCODE_LIST(LIROP)
 #undef LIROP
 
 class LSnapshot;
 class LSafepoint;
 class LInstruction;
@@ -1059,16 +1064,24 @@ namespace details {
         }
 
         void setDef(size_t index, const LDefinition& def) final override {
             defs_[index] = def;
         }
         void setTemp(size_t index, const LDefinition& a) final override {
             temps_[index] = a;
         }
+        void setInt64Temp(size_t index, const LInt64Definition& a) {
+#if JS_BITS_PER_WORD == 32
+            temps_[index] = a.low();
+            temps_[index + 1] = a.high();
+#else
+            temps_[index] = a.value();
+#endif
+        }
 
         size_t numSuccessors() const override {
             return 0;
         }
         MBasicBlock* getSuccessor(size_t i) const override {
             MOZ_ASSERT(false);
             return nullptr;
         }
--- a/js/src/jit/shared/Lowering-shared-inl.h
+++ b/js/src/jit/shared/Lowering-shared-inl.h
@@ -564,16 +564,28 @@ LIRGeneratorShared::useFixed(MDefinition
 }
 
 LDefinition
 LIRGeneratorShared::temp(LDefinition::Type type, LDefinition::Policy policy)
 {
     return LDefinition(getVirtualRegister(), type, policy);
 }
 
+LInt64Definition
+LIRGeneratorShared::tempInt64(LDefinition::Policy policy)
+{
+#if JS_BITS_PER_WORD == 32
+    LDefinition high = temp(LDefinition::GENERAL, policy);
+    LDefinition low = temp(LDefinition::GENERAL, policy);
+    return LInt64Definition(high, low);
+#else
+    return LInt64Definition(temp(LDefinition::GENERAL, policy));
+#endif
+}
+
 LDefinition
 LIRGeneratorShared::tempFixed(Register reg)
 {
     LDefinition t = temp(LDefinition::GENERAL);
     t.setOutput(LGeneralReg(reg));
     return t;
 }
 
--- a/js/src/jit/shared/Lowering-shared.h
+++ b/js/src/jit/shared/Lowering-shared.h
@@ -122,16 +122,17 @@ class LIRGeneratorShared : public MDefin
     // |n+1| to the payload. Does not modify the operands, instead expecting a
     // policy to already be set.
     inline void fillBoxUses(LInstruction* lir, size_t n, MDefinition* mir);
 #endif
 
     // These create temporary register requests.
     inline LDefinition temp(LDefinition::Type type = LDefinition::GENERAL,
                             LDefinition::Policy policy = LDefinition::REGISTER);
+    inline LInt64Definition tempInt64(LDefinition::Policy policy = LDefinition::REGISTER);
     inline LDefinition tempFloat32();
     inline LDefinition tempDouble();
     inline LDefinition tempCopy(MDefinition* input, uint32_t reusedInput);
 
     // Note that the fixed register has a GENERAL type.
     inline LDefinition tempFixed(Register reg);
 
     template <size_t Ops, size_t Temps>