Bug 1316156: Use a constant-or-register for int64 pass-stack-arg; r=luke
authorBenjamin Bouvier <benj@benj.me>
Wed, 09 Nov 2016 17:09:16 +0100
changeset 351969 56280cec9fe25cd3da50e3efc2e131c75b2bef66
parent 351968 f28db33d51f15a0f1ee7b9916b1c3ae59641cd6e
child 351970 56f7c0be1ddaab2c5e3752814443c206c23f6e9c
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1316156
milestone52.0a1
Bug 1316156: Use a constant-or-register for int64 pass-stack-arg; r=luke MozReview-Commit-ID: 2ce0srABGpt
js/src/jit-test/tests/wasm/regress/pass-stack-int64.js
js/src/jit/LIR.h
js/src/jit/Lowering.cpp
js/src/jit/shared/Lowering-shared-inl.h
js/src/jit/shared/Lowering-shared.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/regress/pass-stack-int64.js
@@ -0,0 +1,17 @@
+load(libdir + "wasm.js");
+
+var params = '';
+var locals = '';
+for (let i = 0; i < 20; i++) {
+    params += '(param i64) ';
+    locals += `(get_local ${i}) `;
+}
+
+wasmEvalText(`
+(module
+    (func
+        ${params}
+        (call 0 ${locals})
+    )
+)
+`);
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -185,17 +185,16 @@ class LAllocation : public TempObject
 
     HashNumber hash() const {
         return bits_;
     }
 
     UniqueChars toString() const;
     bool aliases(const LAllocation& other) const;
     void dump() const;
-
 };
 
 class LUse : public LAllocation
 {
     static const uint32_t POLICY_BITS = 3;
     static const uint32_t POLICY_SHIFT = 0;
     static const uint32_t POLICY_MASK = (1 << POLICY_BITS) - 1;
     static const uint32_t REG_BITS = 6;
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -4277,17 +4277,17 @@ LIRGenerator::visitWasmReturnVoid(MWasmR
 
     add(lir);
 }
 
 void
 LIRGenerator::visitWasmStackArg(MWasmStackArg* ins)
 {
     if (ins->arg()->type() == MIRType::Int64) {
-        add(new(alloc()) LWasmStackArgI64(useInt64OrConstantAtStart(ins->arg())), ins);
+        add(new(alloc()) LWasmStackArgI64(useInt64RegisterOrConstantAtStart(ins->arg())), ins);
     } else if (IsFloatingPointType(ins->arg()->type()) || IsSimdType(ins->arg()->type())) {
         MOZ_ASSERT(!ins->arg()->isEmittedAtUses());
         add(new(alloc()) LWasmStackArg(useRegisterAtStart(ins->arg())), ins);
     } else {
         add(new(alloc()) LWasmStackArg(useRegisterOrConstantAtStart(ins->arg())), ins);
     }
 }
 
--- a/js/src/jit/shared/Lowering-shared-inl.h
+++ b/js/src/jit/shared/Lowering-shared-inl.h
@@ -834,12 +834,25 @@ LIRGeneratorShared::useInt64OrConstant(M
         return LInt64Allocation(LAllocation(mir->toConstant()), LAllocation());
 #else
         return LInt64Allocation(LAllocation(mir->toConstant()));
 #endif
     }
     return useInt64(mir, useAtStart);
 }
 
+LInt64Allocation
+LIRGeneratorShared::useInt64RegisterOrConstant(MDefinition* mir, bool useAtStart)
+{
+    if (mir->isConstant()) {
+#if defined(JS_NUNBOX32)
+        return LInt64Allocation(LAllocation(mir->toConstant()), LAllocation());
+#else
+        return LInt64Allocation(LAllocation(mir->toConstant()));
+#endif
+    }
+    return useInt64Register(mir, useAtStart);
+}
+
 } // namespace jit
 } // namespace js
 
 #endif /* jit_shared_Lowering_shared_inl_h */
--- a/js/src/jit/shared/Lowering-shared.h
+++ b/js/src/jit/shared/Lowering-shared.h
@@ -183,21 +183,25 @@ class LIRGeneratorShared : public MDefin
     inline LBoxAllocation useBoxOrTypedOrConstant(MDefinition* mir, bool useConstant);
 
     // Returns an int64 allocation for an Int64-typed instruction.
     inline LInt64Allocation useInt64(MDefinition* mir, LUse::Policy policy, bool useAtStart);
     inline LInt64Allocation useInt64(MDefinition* mir, bool useAtStart = false);
     inline LInt64Allocation useInt64AtStart(MDefinition* mir);
     inline LInt64Allocation useInt64OrConstant(MDefinition* mir, bool useAtStart = false);
     inline LInt64Allocation useInt64Register(MDefinition* mir, bool useAtStart = false);
+    inline LInt64Allocation useInt64RegisterOrConstant(MDefinition* mir, bool useAtStart = false);
     inline LInt64Allocation useInt64Fixed(MDefinition* mir, Register64 regs, bool useAtStart = false);
 
     LInt64Allocation useInt64RegisterAtStart(MDefinition* mir) {
         return useInt64Register(mir, /* useAtStart = */ true);
     }
+    LInt64Allocation useInt64RegisterOrConstantAtStart(MDefinition* mir) {
+        return useInt64RegisterOrConstant(mir, /* useAtStart = */ true);
+    }
     LInt64Allocation useInt64OrConstantAtStart(MDefinition* mir) {
         return useInt64OrConstant(mir, /* useAtStart = */ true);
     }
 
     // Rather than defining a new virtual register, sets |ins| to have the same
     // virtual register as |as|.
     inline void redefine(MDefinition* ins, MDefinition* as);