Bug 1434030 - Baldr: re-optimize stack limit and JSContext retrieval (r=jandem)
authorLuke Wagner <luke@mozilla.com>
Tue, 30 Jan 2018 17:53:10 -0600
changeset 454105 1802ba58c11afd39a0d007fc3e7ab62a76f6429f
parent 454104 be82f6125c7502fe00a27d771d3033ceaa9c4d56
child 454106 a6d9bcfa75ae52ed987e706e9e6a2f0a65820cda
push id8799
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 16:46:23 +0000
treeherdermozilla-beta@15334014dc67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1434030
milestone60.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 1434030 - Baldr: re-optimize stack limit and JSContext retrieval (r=jandem)
js/src/jit/MacroAssembler.cpp
js/src/wasm/WasmFrameIter.cpp
js/src/wasm/WasmInstance.cpp
js/src/wasm/WasmTypes.h
--- a/js/src/jit/MacroAssembler.cpp
+++ b/js/src/jit/MacroAssembler.cpp
@@ -3138,20 +3138,18 @@ MacroAssembler::wasmEmitOldTrapOutOfLine
     breakpoint();
 
     oldTrapSites().clear();
 }
 
 void
 MacroAssembler::wasmEmitStackCheck(Register sp, Register scratch, Label* onOverflow)
 {
-    loadPtr(Address(WasmTlsReg, offsetof(wasm::TlsData, addressOfContext)), scratch);
-    loadPtr(Address(scratch, 0), scratch);
     branchPtr(Assembler::AboveOrEqual,
-              Address(scratch, offsetof(JSContext, jitStackLimitNoInterrupt)),
+              Address(WasmTlsReg, offsetof(wasm::TlsData, stackLimit)),
               sp,
               onOverflow);
 }
 
 void
 MacroAssembler::emitPreBarrierFastPath(JSRuntime* rt, MIRType type, Register temp1, Register temp2,
                                        Register temp3, Label* noBarrier)
 {
--- a/js/src/wasm/WasmFrameIter.cpp
+++ b/js/src/wasm/WasmFrameIter.cpp
@@ -309,18 +309,17 @@ PushRetAddr(MacroAssembler& masm, unsign
     // The x86/x64 call instruction pushes the return address.
 #endif
 }
 
 static void
 LoadActivation(MacroAssembler& masm, const Register& dest)
 {
     // WasmCall pushes a JitActivation.
-    masm.loadPtr(Address(WasmTlsReg, offsetof(wasm::TlsData, addressOfContext)), dest);
-    masm.loadPtr(Address(dest, 0), dest);
+    masm.loadPtr(Address(WasmTlsReg, offsetof(wasm::TlsData, cx)), dest);
     masm.loadPtr(Address(dest, JSContext::offsetOfActivation()), dest);
 }
 
 void
 wasm::SetExitFP(MacroAssembler& masm, ExitReason reason, Register scratch)
 {
     MOZ_ASSERT(!reason.isNone());
 
--- a/js/src/wasm/WasmInstance.cpp
+++ b/js/src/wasm/WasmInstance.cpp
@@ -405,17 +405,18 @@ Instance::Instance(JSContext* cx,
 #endif
     MOZ_ASSERT(tables_.length() == metadata().tables.length());
 
     tlsData()->memoryBase = memory ? memory->buffer().dataPointerEither().unwrap() : nullptr;
 #ifndef WASM_HUGE_MEMORY
     tlsData()->boundsCheckLimit = memory ? memory->buffer().wasmBoundsCheckLimit() : 0;
 #endif
     tlsData()->instance = this;
-    tlsData()->addressOfContext = (JSContext**)object->zone()->group()->addressOfOwnerContext();
+    tlsData()->cx = cx;
+    tlsData()->stackLimit = cx->stackLimitForJitCode(JS::StackForUntrustedScript);
     tlsData()->jumpTable = code_->jumpTable();
 
     Tier callerTier = code_->bestTier();
 
     for (size_t i = 0; i < metadata(callerTier).funcImports.length(); i++) {
         HandleFunction f = funcImports[i];
         const FuncImport& fi = metadata(callerTier).funcImports[i];
         FuncImportTls& import = funcImportTls(fi);
--- a/js/src/wasm/WasmTypes.h
+++ b/js/src/wasm/WasmTypes.h
@@ -1501,18 +1501,22 @@ struct TlsData
 #ifndef WASM_HUGE_MEMORY
     // Bounds check limit of memory, in bytes (or zero if there is no memory).
     uint32_t boundsCheckLimit;
 #endif
 
     // Pointer to the Instance that contains this TLS data.
     Instance* instance;
 
-    // Shortcut to instance->zone->group->addressOfOwnerContext
-    JSContext** addressOfContext;
+    // The containing JSContext.
+    JSContext* cx;
+
+    // The native stack limit which is checked by prologues. Shortcut for
+    // cx->stackLimitForJitCode(JS::StackForUntrustedScript).
+    uintptr_t stackLimit;
 
     // Pointer that should be freed (due to padding before the TlsData).
     void* allocatedBase;
 
     // When compiling with tiering, the jumpTable has one entry for each
     // baseline-compiled function.
     void** jumpTable;