Bug 1357370: Manually preserve WasmTlsReg before an ABI call; r=luke
authorBenjamin Bouvier <benj@benj.me>
Wed, 19 Apr 2017 13:37:32 +0200
changeset 354676 6477b1b7808857c3df4be01c13eb2fbe984eb185
parent 354675 18c3c29e52b4cb97e62a762a99a7b672b6e79495
child 354677 3301d5530ddd21e8278f96314797425e8f7b5192
push id31709
push userihsiao@mozilla.com
push dateTue, 25 Apr 2017 03:21:59 +0000
treeherdermozilla-central@85932a5027c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1357370
milestone55.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 1357370: Manually preserve WasmTlsReg before an ABI call; r=luke
js/src/jit/MacroAssembler.cpp
--- a/js/src/jit/MacroAssembler.cpp
+++ b/js/src/jit/MacroAssembler.cpp
@@ -2769,26 +2769,32 @@ MacroAssembler::callWithABINoProfiler(vo
 }
 
 void
 MacroAssembler::callWithABI(wasm::BytecodeOffset callOffset, wasm::SymbolicAddress imm,
                             MoveOp::Type result)
 {
     MOZ_ASSERT(wasm::NeedsBuiltinThunk(imm));
 
+    // We clobber WasmTlsReg below in the loadWasmTlsRegFromFrame(), but Ion
+    // assumes it is non-volatile, so preserve it manually.
+    Push(WasmTlsReg);
+
     uint32_t stackAdjust;
     callWithABIPre(&stackAdjust, /* callFromWasm = */ true);
 
     // The TLS register is used in builtin thunks and must be set, by ABI:
     // reload it after passing arguments, which might have used it at spill
     // points when placing arguments.
     loadWasmTlsRegFromFrame();
 
     call(wasm::CallSiteDesc(callOffset.bytecodeOffset, wasm::CallSite::Symbolic), imm);
     callWithABIPost(stackAdjust, result, /* callFromWasm = */ true);
+
+    Pop(WasmTlsReg);
 }
 
 // ===============================================================
 // Exit frame footer.
 
 void
 MacroAssembler::linkExitFrame(Register cxreg)
 {