Bug 1288944 - Baldr: mark all calls as preserving the TLS reg (r=jolesen)
authorLuke Wagner <luke@mozilla.com>
Thu, 04 Aug 2016 11:44:35 -0500
changeset 308291 b5ae1861ac1fd7d487c5d010e606eb51c5e3bf34
parent 308290 575b04a64ab8f06b9b5668ae22123d8fd78fc067
child 308292 62134495d26bf4766c4985a8bbe28823f7bc1883
push id31092
push usercbook@mozilla.com
push dateFri, 05 Aug 2016 10:16:59 +0000
treeherderautoland@b97dd7dd3cb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjolesen
bugs1288944
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1288944 - Baldr: mark all calls as preserving the TLS reg (r=jolesen) MozReview-Commit-ID: 3WcKCPGRaFv
js/src/asmjs/WasmIonCompile.cpp
js/src/jit/MIR.cpp
js/src/jit/MIR.h
js/src/jit/shared/LIR-shared.h
--- a/js/src/asmjs/WasmIonCompile.cpp
+++ b/js/src/asmjs/WasmIonCompile.cpp
@@ -966,32 +966,31 @@ class FunctionCompiler
             stackBytes = Max(stackBytes, call->maxChildStackBytes_);
         }
 
         propagateMaxStackArgBytes(stackBytes);
         return true;
     }
 
   private:
-    bool callPrivate(MWasmCall::Callee callee, MWasmCall::PreservesTlsReg preservesTlsReg,
-                     const CallCompileState& call, ExprType ret, MDefinition** def)
+    bool callPrivate(MWasmCall::Callee callee, const CallCompileState& call, ExprType ret,
+                     MDefinition** def)
     {
         MOZ_ASSERT(!inDeadCode());
 
         CallSiteDesc::Kind kind = CallSiteDesc::Kind(-1);
         switch (callee.which()) {
           case MWasmCall::Callee::Internal: kind = CallSiteDesc::Relative; break;
           case MWasmCall::Callee::Import:   kind = CallSiteDesc::Register; break;
           case MWasmCall::Callee::Dynamic:  kind = CallSiteDesc::Register; break;
           case MWasmCall::Callee::Builtin:  kind = CallSiteDesc::Register; break;
         }
 
-        MWasmCall* ins =
-          MWasmCall::New(alloc(), CallSiteDesc(call.lineOrBytecode_, kind), callee, call.regArgs_,
-                          ToMIRType(ret), call.spIncrement_, preservesTlsReg);
+        auto* ins = MWasmCall::New(alloc(), CallSiteDesc(call.lineOrBytecode_, kind), callee,
+                                   call.regArgs_, ToMIRType(ret), call.spIncrement_);
         if (!ins)
             return false;
 
         curBlock_->add(ins);
         *def = ins;
         return true;
     }
 
@@ -1000,17 +999,17 @@ class FunctionCompiler
                       MDefinition** def)
     {
         if (inDeadCode()) {
             *def = nullptr;
             return true;
         }
 
         auto callee = MWasmCall::Callee::internal(funcIndex);
-        return callPrivate(callee, MWasmCall::PreservesTlsReg::True, call, sig.ret(), def);
+        return callPrivate(callee, call, sig.ret(), def);
     }
 
     bool funcPtrCall(uint32_t sigIndex, uint32_t length, uint32_t globalDataOffset,
                      MDefinition* index, const CallCompileState& call, MDefinition** def)
     {
         if (inDeadCode()) {
             *def = nullptr;
             return true;
@@ -1028,44 +1027,42 @@ class FunctionCompiler
             callee = MWasmCall::Callee(ptrFun);
             MOZ_ASSERT(mg_.sigs[sigIndex].id.kind() == SigIdDesc::Kind::None);
         } else {
             MInstruction* ptrFun = MAsmJSLoadFuncPtr::New(alloc(), index, length, globalDataOffset);
             curBlock_->add(ptrFun);
             callee = MWasmCall::Callee(ptrFun, mg_.sigs[sigIndex].id);
         }
 
-        return callPrivate(callee, MWasmCall::PreservesTlsReg::True, call,
-                           mg_.sigs[sigIndex].ret(), def);
+        return callPrivate(callee, call, mg_.sigs[sigIndex].ret(), def);
     }
 
     bool callImport(unsigned globalDataOffset, const CallCompileState& call, ExprType ret,
                     MDefinition** def)
     {
         if (inDeadCode()) {
             *def = nullptr;
             return true;
         }
 
         MOZ_ASSERT(call.tlsStackOffset_ != UINT32_MAX);
 
         auto callee = MWasmCall::Callee::import(globalDataOffset, call.tlsStackOffset_);
-        return callPrivate(callee, MWasmCall::PreservesTlsReg::False, call, ret, def);
+        return callPrivate(callee, call, ret, def);
     }
 
     bool builtinCall(SymbolicAddress builtin, const CallCompileState& call, ValType type,
                      MDefinition** def)
     {
         if (inDeadCode()) {
             *def = nullptr;
             return true;
         }
 
-        return callPrivate(MWasmCall::Callee(builtin), MWasmCall::PreservesTlsReg::False,
-                           call, ToExprType(type), def);
+        return callPrivate(MWasmCall::Callee(builtin), call, ToExprType(type), def);
     }
 
     /*********************************************** Control flow generation */
 
     inline bool inDeadCode() const {
         return curBlock_ == nullptr;
     }
 
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -5374,20 +5374,19 @@ MAsmJSUnsignedToFloat32::foldsTo(TempAll
             return MConstant::NewAsmJS(alloc, JS::Float32Value(float(dval)), MIRType::Float32);
     }
 
     return this;
 }
 
 MWasmCall*
 MWasmCall::New(TempAllocator& alloc, const wasm::CallSiteDesc& desc, Callee callee,
-               const Args& args, MIRType resultType, size_t spIncrement,
-               PreservesTlsReg preservesTlsReg)
-{
-    MWasmCall* call = new(alloc) MWasmCall(desc, callee, spIncrement, preservesTlsReg);
+               const Args& args, MIRType resultType, size_t spIncrement)
+{
+    MWasmCall* call = new(alloc) MWasmCall(desc, callee, spIncrement);
     call->setResultType(resultType);
 
     if (!call->argRegs_.init(alloc, args.length()))
         return nullptr;
     for (size_t i = 0; i < call->argRegs_.length(); i++)
         call->argRegs_[i] = args[i].reg;
 
     if (!call->init(alloc, call->argRegs_.length() + (callee.which() == Callee::Dynamic ? 1 : 0)))
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -13581,49 +13581,40 @@ class MWasmCall final
             return u.dynamic.sigId_;
         }
         wasm::SymbolicAddress builtin() const {
             MOZ_ASSERT(which_ == Builtin);
             return u.builtin_;
         }
     };
 
-    enum PreservesTlsReg {
-        False = false,
-        True = true
-    };
-
   private:
     wasm::CallSiteDesc desc_;
     Callee callee_;
     FixedList<AnyRegister> argRegs_;
     size_t spIncrement_;
-    bool preservesTlsReg_;
-
-    MWasmCall(const wasm::CallSiteDesc& desc, Callee callee, size_t spIncrement,
-               PreservesTlsReg preservesTlsReg)
-      : desc_(desc)
-      , callee_(callee)
-      , spIncrement_(spIncrement)
-      , preservesTlsReg_(bool(preservesTlsReg))
+
+    MWasmCall(const wasm::CallSiteDesc& desc, Callee callee, size_t spIncrement)
+      : desc_(desc),
+        callee_(callee),
+        spIncrement_(spIncrement)
     { }
 
   public:
     INSTRUCTION_HEADER(WasmCall)
 
     struct Arg {
         AnyRegister reg;
         MDefinition* def;
         Arg(AnyRegister reg, MDefinition* def) : reg(reg), def(def) {}
     };
     typedef Vector<Arg, 8, SystemAllocPolicy> Args;
 
     static MWasmCall* New(TempAllocator& alloc, const wasm::CallSiteDesc& desc, Callee callee,
-                          const Args& args, MIRType resultType, size_t spIncrement,
-                          PreservesTlsReg preservesTlsReg);
+                          const Args& args, MIRType resultType, size_t spIncrement);
 
     size_t numArgs() const {
         return argRegs_.length();
     }
     AnyRegister registerForArg(size_t index) const {
         MOZ_ASSERT(index < numArgs());
         return argRegs_[index];
     }
@@ -13637,21 +13628,16 @@ class MWasmCall final
         MOZ_ASSERT(callee_.which() == Callee::Dynamic);
         MOZ_ASSERT(numArgs() == numOperands() - 1);
         return numArgs();
     }
     size_t spIncrement() const {
         return spIncrement_;
     }
 
-    // Does this call preserve the value of the TLS pointer register?
-    bool preservesTlsReg() const {
-        return preservesTlsReg_;
-    }
-
     bool possiblyCalls() const override {
         return true;
     }
 };
 
 class MAsmSelect
   : public MTernaryInstruction,
     public NoTypePolicy::Data
--- a/js/src/jit/shared/LIR-shared.h
+++ b/js/src/jit/shared/LIR-shared.h
@@ -8289,20 +8289,21 @@ class LWasmCallBase : public LInstructio
     MWasmCall* mir() const {
         return mir_->toWasmCall();
     }
 
     bool isCall() const override {
         return true;
     }
     bool isCallPreserved(AnyRegister reg) const override {
-        // WebAssembly functions preserve the TLS pointer register.
-        if (reg.isFloat() || reg.gpr() != WasmTlsReg)
-            return false;
-        return mir()->preservesTlsReg();
+        // All MWasmCalls preserve the TLS register:
+        //  - internal/indirect calls do by the internal wasm ABI
+        //  - import calls do by explicitly saving/restoring at the callsite
+        //  - builtin calls do because the TLS reg is non-volatile
+        return !reg.isFloat() && reg.gpr() == WasmTlsReg;
     }
 
     // LInstruction interface
     size_t numOperands() const override {
         return numOperands_;
     }
     LAllocation* getOperand(size_t index) override {
         MOZ_ASSERT(index < numOperands_);