<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[214384] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/214384">214384</a></dd>
<dt>Author</dt> <dd>jfbastien@apple.com</dd>
<dt>Date</dt> <dd>2017-03-24 16:25:16 -0700 (Fri, 24 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebAssembly: store state in TLS instead of on VM
https://bugs.webkit.org/show_bug.cgi?id=169611

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

Using thread-local storage instead of VM makes code more position
independent. We used to store the WebAssembly top Instance (the
latest one in the call stack) on VM, now we instead store it in
TLS. This top Instance is used to access a bunch of state such as
Memory location, size, table (for call_indirect), etc.

Instead of calling it &quot;top&quot;, which is confusing, we now just call
it WasmContext.

Making the code PIC means future patches will be able to
postMessage and structured clone into IDB without having to
recompile the code. This wasn't possible before because we
hard-coded the address of VM at compilation time. That doesn't
work between workers, and doesn't work across reloads (which IDB
is intended to do).

It'll also potentially make code faster once we start tuning
what's in TLS, what's in which of the 4 free slots, and what's in
pinned registers. I'm leaving this tuning for later because
there's lower lying fruit for us to pick.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* assembler/AbstractMacroAssembler.h:
* assembler/AllowMacroScratchRegisterUsageIf.h: Copied from assembler/AllowMacroScratchRegisterUsage.h.
(JSC::AllowMacroScratchRegisterUsageIf::AllowMacroScratchRegisterUsageIf):
(JSC::AllowMacroScratchRegisterUsageIf::~AllowMacroScratchRegisterUsageIf):
* assembler/MacroAssembler.h:
(JSC::MacroAssembler::storeToTLSPtr): we previously didn't have
the code required to store to TLS, only to load
* assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::loadFromTLSPtrNeedsMacroScratchRegister):
(JSC::MacroAssemblerARM64::storeToTLS32):
(JSC::MacroAssemblerARM64::storeToTLS64):
(JSC::MacroAssemblerARM64::storeToTLSPtrNeedsMacroScratchRegister):
* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::loadFromTLSPtrNeedsMacroScratchRegister):
(JSC::MacroAssemblerX86Common::storeToTLS32):
(JSC::MacroAssemblerX86Common::storeToTLSPtrNeedsMacroScratchRegister):
* assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::loadFromTLS64): was loading 32-bit instead of 64-bit
(JSC::MacroAssemblerX86_64::storeToTLS64):
* assembler/X86Assembler.h:
(JSC::X86Assembler::movl_rm):
(JSC::X86Assembler::movq_rm):
* b3/testb3.cpp:
(JSC::B3::testFastTLSLoad):
(JSC::B3::testFastTLSStore):
(JSC::B3::run):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::loadWasmContext):
(JSC::AssemblyHelpers::storeWasmContext):
(JSC::AssemblyHelpers::loadWasmContextNeedsMacroScratchRegister):
(JSC::AssemblyHelpers::storeWasmContextNeedsMacroScratchRegister):
* jit/Repatch.cpp:
(JSC::webAssemblyOwner):
* jit/ThunkGenerators.cpp:
(JSC::throwExceptionFromWasmThunkGenerator):
* runtime/Options.h:
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::loadWasmContext):
(JSC::Wasm::storeWasmContext):
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::getMemoryBaseAndSize):
(JSC::Wasm::restoreWebAssemblyGlobalState):
(JSC::Wasm::createJSToWasmWrapper):
(JSC::Wasm::parseAndCompile):
* wasm/WasmBinding.cpp:
(JSC::Wasm::materializeImportJSCell):
(JSC::Wasm::wasmToJs):
(JSC::Wasm::wasmToWasm):
* wasm/WasmContext.cpp: Added.
(JSC::loadWasmContext):
(JSC::storeWasmContext):
* wasm/WasmContext.h: Added. Replaces &quot;top&quot; JSWebAssemblyInstance.
* wasm/js/WebAssemblyFunction.cpp:
(JSC::callWebAssemblyFunction):
* wasm/js/WebAssemblyInstanceConstructor.h:

Source/WTF:

* wtf/FastTLS.h: reserve one key for WebAssembly, delete a bunch
of dead code which clang couldn't compile (it's valid GCC assembly
which LLVM dislikes).</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerAbstractMacroAssemblerh">trunk/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerMacroAssemblerh">trunk/Source/JavaScriptCore/assembler/MacroAssembler.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerMacroAssemblerARM64h">trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerMacroAssemblerX86Commonh">trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerMacroAssemblerX86_64h">trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreassemblerX86Assemblerh">trunk/Source/JavaScriptCore/assembler/X86Assembler.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3testb3cpp">trunk/Source/JavaScriptCore/b3/testb3.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitAssemblyHelpersh">trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitRepatchcpp">trunk/Source/JavaScriptCore/jit/Repatch.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitThunkGeneratorscpp">trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeOptionsh">trunk/Source/JavaScriptCore/runtime/Options.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMcpp">trunk/Source/JavaScriptCore/runtime/VM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMh">trunk/Source/JavaScriptCore/runtime/VM.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmB3IRGeneratorcpp">trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmBindingcpp">trunk/Source/JavaScriptCore/wasm/WasmBinding.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyFunctioncpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfFastTLSh">trunk/Source/WTF/wtf/FastTLS.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreassemblerAllowMacroScratchRegisterUsageIfh">trunk/Source/JavaScriptCore/assembler/AllowMacroScratchRegisterUsageIf.h</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmContextcpp">trunk/Source/JavaScriptCore/wasm/WasmContext.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmContexth">trunk/Source/JavaScriptCore/wasm/WasmContext.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -932,6 +932,7 @@
</span><span class="cx">     wasm/WasmB3IRGenerator.cpp
</span><span class="cx">     wasm/WasmBinding.cpp
</span><span class="cx">     wasm/WasmCallingConvention.cpp
</span><ins>+    wasm/WasmContext.cpp
</ins><span class="cx">     wasm/WasmFaultSignalHandler.cpp
</span><span class="cx">     wasm/WasmFormat.cpp
</span><span class="cx">     wasm/WasmMemory.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1,5 +1,94 @@
</span><span class="cx"> 2017-03-24  JF Bastien  &lt;jfbastien@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        WebAssembly: store state in TLS instead of on VM
+        https://bugs.webkit.org/show_bug.cgi?id=169611
+
+        Reviewed by Filip Pizlo.
+
+        Using thread-local storage instead of VM makes code more position
+        independent. We used to store the WebAssembly top Instance (the
+        latest one in the call stack) on VM, now we instead store it in
+        TLS. This top Instance is used to access a bunch of state such as
+        Memory location, size, table (for call_indirect), etc.
+
+        Instead of calling it &quot;top&quot;, which is confusing, we now just call
+        it WasmContext.
+
+        Making the code PIC means future patches will be able to
+        postMessage and structured clone into IDB without having to
+        recompile the code. This wasn't possible before because we
+        hard-coded the address of VM at compilation time. That doesn't
+        work between workers, and doesn't work across reloads (which IDB
+        is intended to do).
+
+        It'll also potentially make code faster once we start tuning
+        what's in TLS, what's in which of the 4 free slots, and what's in
+        pinned registers. I'm leaving this tuning for later because
+        there's lower lying fruit for us to pick.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * assembler/AbstractMacroAssembler.h:
+        * assembler/AllowMacroScratchRegisterUsageIf.h: Copied from assembler/AllowMacroScratchRegisterUsage.h.
+        (JSC::AllowMacroScratchRegisterUsageIf::AllowMacroScratchRegisterUsageIf):
+        (JSC::AllowMacroScratchRegisterUsageIf::~AllowMacroScratchRegisterUsageIf):
+        * assembler/MacroAssembler.h:
+        (JSC::MacroAssembler::storeToTLSPtr): we previously didn't have
+        the code required to store to TLS, only to load
+        * assembler/MacroAssemblerARM64.h:
+        (JSC::MacroAssemblerARM64::loadFromTLSPtrNeedsMacroScratchRegister):
+        (JSC::MacroAssemblerARM64::storeToTLS32):
+        (JSC::MacroAssemblerARM64::storeToTLS64):
+        (JSC::MacroAssemblerARM64::storeToTLSPtrNeedsMacroScratchRegister):
+        * assembler/MacroAssemblerX86Common.h:
+        (JSC::MacroAssemblerX86Common::loadFromTLSPtrNeedsMacroScratchRegister):
+        (JSC::MacroAssemblerX86Common::storeToTLS32):
+        (JSC::MacroAssemblerX86Common::storeToTLSPtrNeedsMacroScratchRegister):
+        * assembler/MacroAssemblerX86_64.h:
+        (JSC::MacroAssemblerX86_64::loadFromTLS64): was loading 32-bit instead of 64-bit
+        (JSC::MacroAssemblerX86_64::storeToTLS64):
+        * assembler/X86Assembler.h:
+        (JSC::X86Assembler::movl_rm):
+        (JSC::X86Assembler::movq_rm):
+        * b3/testb3.cpp:
+        (JSC::B3::testFastTLSLoad):
+        (JSC::B3::testFastTLSStore):
+        (JSC::B3::run):
+        * jit/AssemblyHelpers.h:
+        (JSC::AssemblyHelpers::loadWasmContext):
+        (JSC::AssemblyHelpers::storeWasmContext):
+        (JSC::AssemblyHelpers::loadWasmContextNeedsMacroScratchRegister):
+        (JSC::AssemblyHelpers::storeWasmContextNeedsMacroScratchRegister):
+        * jit/Repatch.cpp:
+        (JSC::webAssemblyOwner):
+        * jit/ThunkGenerators.cpp:
+        (JSC::throwExceptionFromWasmThunkGenerator):
+        * runtime/Options.h:
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        * runtime/VM.h:
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::loadWasmContext):
+        (JSC::Wasm::storeWasmContext):
+        (JSC::Wasm::B3IRGenerator::B3IRGenerator):
+        (JSC::Wasm::getMemoryBaseAndSize):
+        (JSC::Wasm::restoreWebAssemblyGlobalState):
+        (JSC::Wasm::createJSToWasmWrapper):
+        (JSC::Wasm::parseAndCompile):
+        * wasm/WasmBinding.cpp:
+        (JSC::Wasm::materializeImportJSCell):
+        (JSC::Wasm::wasmToJs):
+        (JSC::Wasm::wasmToWasm):
+        * wasm/WasmContext.cpp: Added.
+        (JSC::loadWasmContext):
+        (JSC::storeWasmContext):
+        * wasm/WasmContext.h: Added. Replaces &quot;top&quot; JSWebAssemblyInstance.
+        * wasm/js/WebAssemblyFunction.cpp:
+        (JSC::callWebAssemblyFunction):
+        * wasm/js/WebAssemblyInstanceConstructor.h:
+
+2017-03-24  JF Bastien  &lt;jfbastien@apple.com&gt;
+
</ins><span class="cx">         WebAssembly: spec-tests/memory.wast.js fails in debug
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=169794
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -349,7 +349,7 @@
</span><span class="cx">                 0F37308C1C0BD29100052BFA /* B3PhiChildren.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F37308A1C0BD29100052BFA /* B3PhiChildren.cpp */; };
</span><span class="cx">                 0F37308D1C0BD29100052BFA /* B3PhiChildren.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F37308B1C0BD29100052BFA /* B3PhiChildren.h */; };
</span><span class="cx">                 0F37308F1C0CD68500052BFA /* DisallowMacroScratchRegisterUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F37308E1C0CD68500052BFA /* DisallowMacroScratchRegisterUsage.h */; };
</span><del>-                0F3730911C0CD70C00052BFA /* AllowMacroScratchRegisterUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3730901C0CD70C00052BFA /* AllowMacroScratchRegisterUsage.h */; };
</del><ins>+                0F3730911C0CD70C00052BFA /* AllowMacroScratchRegisterUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3730901C0CD70C00052BFA /* AllowMacroScratchRegisterUsage.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 0F3730931C0D67EE00052BFA /* AirUseCounts.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F3730921C0D67EE00052BFA /* AirUseCounts.h */; };
</span><span class="cx">                 0F38B01117CF078000B144D3 /* LLIntEntrypoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F38B00F17CF077F00B144D3 /* LLIntEntrypoint.cpp */; };
</span><span class="cx">                 0F38B01217CF078300B144D3 /* LLIntEntrypoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F38B01017CF077F00B144D3 /* LLIntEntrypoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -1638,6 +1638,7 @@
</span><span class="cx">                 969A079B0ED1D3AE00F1F681 /* Opcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 969A07950ED1D3AE00F1F681 /* Opcode.h */; };
</span><span class="cx">                 978801401471AD920041B016 /* JSDateMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9788FC221471AD0C0068CE2D /* JSDateMath.cpp */; };
</span><span class="cx">                 978801411471AD920041B016 /* JSDateMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9788FC231471AD0C0068CE2D /* JSDateMath.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                981ED82328234D91BAECCADE /* MachineContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 28806E21155E478A93FA7B02 /* MachineContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 990DA67F1C8E316A00295159 /* generate_objc_protocol_type_conversions_implementation.py in Headers */ = {isa = PBXBuildFile; fileRef = 990DA67E1C8E311D00295159 /* generate_objc_protocol_type_conversions_implementation.py */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 9928FF3B18AC4AEC00B8CF12 /* JSReplayInputs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9928FF3918AC4AEC00B8CF12 /* JSReplayInputs.cpp */; };
</span><span class="cx">                 9928FF3C18AC4AEC00B8CF12 /* JSReplayInputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 9928FF3A18AC4AEC00B8CF12 /* JSReplayInputs.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2081,6 +2082,8 @@
</span><span class="cx">                 AD2FCC301DB83D4900B3E736 /* JSWebAssembly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCC2E1DB839F700B3E736 /* JSWebAssembly.cpp */; };
</span><span class="cx">                 AD2FCC311DB83D4900B3E736 /* JSWebAssembly.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC2F1DB839F700B3E736 /* JSWebAssembly.h */; };
</span><span class="cx">                 AD2FCC331DC4045400B3E736 /* WasmFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */; };
</span><ins>+                AD412B331E7B2E99008AF157 /* WasmContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD412B311E7B2E8A008AF157 /* WasmContext.cpp */; };
+                AD412B341E7B2E9E008AF157 /* WasmContext.h in Headers */ = {isa = PBXBuildFile; fileRef = AD412B321E7B2E8A008AF157 /* WasmContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 AD4252511E5D0E14009D2A97 /* FullCodeOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4252501E5D0DEB009D2A97 /* FullCodeOrigin.h */; };
</span><span class="cx">                 AD4252531E5D0F47009D2A97 /* FullCodeOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4252521E5D0F22009D2A97 /* FullCodeOrigin.cpp */; };
</span><span class="cx">                 AD4937C31DDBE6140077C807 /* AbstractModuleRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4937C11DDBE60A0077C807 /* AbstractModuleRecord.cpp */; };
</span><span class="lines">@@ -2441,7 +2444,6 @@
</span><span class="cx">                 FEE43FCE1E6641710077D6D1 /* PlatformThread.h in Headers */ = {isa = PBXBuildFile; fileRef = FEE43FCD1E6641400077D6D1 /* PlatformThread.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */; };
</span><span class="cx">                 FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                981ED82328234D91BAECCADE /* MachineContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 28806E21155E478A93FA7B02 /* MachineContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx"> /* End PBXBuildFile section */
</span><span class="cx"> 
</span><span class="cx"> /* Begin PBXContainerItemProxy section */
</span><span class="lines">@@ -3732,6 +3734,7 @@
</span><span class="cx">                 264091FA1BE2FD4100684DB2 /* AirOpcode.opcodes */ = {isa = PBXFileReference; lastKnownFileType = text; name = AirOpcode.opcodes; path = b3/air/AirOpcode.opcodes; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2684D4371C00161C0081D663 /* AirLiveness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirLiveness.h; path = b3/air/AirLiveness.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 269D636D1BFBE5D000101B1D /* FTLOutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLOutput.h; path = ftl/FTLOutput.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                28806E21155E478A93FA7B02 /* MachineContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachineContext.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2A05ABD31961DF2400341750 /* JSPropertyNameEnumerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPropertyNameEnumerator.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2A05ABD41961DF2400341750 /* JSPropertyNameEnumerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPropertyNameEnumerator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2A111243192FCE79005EE18D /* CustomGetterSetter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomGetterSetter.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4648,6 +4651,9 @@
</span><span class="cx">                 AD2FCC2E1DB839F700B3E736 /* JSWebAssembly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebAssembly.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD2FCC2F1DB839F700B3E736 /* JSWebAssembly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebAssembly.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmFormat.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                AD412B311E7B2E8A008AF157 /* WasmContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmContext.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                AD412B321E7B2E8A008AF157 /* WasmContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmContext.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                AD412B351E7B57C0008AF157 /* AllowMacroScratchRegisterUsageIf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllowMacroScratchRegisterUsageIf.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 AD4252501E5D0DEB009D2A97 /* FullCodeOrigin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullCodeOrigin.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD4252521E5D0F22009D2A97 /* FullCodeOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FullCodeOrigin.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD4937C11DDBE60A0077C807 /* AbstractModuleRecord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractModuleRecord.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5039,7 +5045,6 @@
</span><span class="cx">                 FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                28806E21155E478A93FA7B02 /* MachineContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MachineContext.h; path = MachineContext.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx"> /* End PBXFileReference section */
</span><span class="cx"> 
</span><span class="cx"> /* Begin PBXFrameworksBuildPhase section */
</span><span class="lines">@@ -6249,6 +6254,8 @@
</span><span class="cx">                                 AD4B1DF81DF244D70071AE32 /* WasmBinding.h */,
</span><span class="cx">                                 53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */,
</span><span class="cx">                                 53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */,
</span><ins>+                                AD412B311E7B2E8A008AF157 /* WasmContext.cpp */,
+                                AD412B321E7B2E8A008AF157 /* WasmContext.h */,
</ins><span class="cx">                                 79DAE2791E03C82200B526AA /* WasmExceptionType.h */,
</span><span class="cx">                                 AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */,
</span><span class="cx">                                 7BC547D21B69599B00959B58 /* WasmFormat.h */,
</span><span class="lines">@@ -7391,6 +7398,7 @@
</span><span class="cx">                                 0F2C63BF1E660EA500C13839 /* AbstractMacroAssembler.cpp */,
</span><span class="cx">                                 860161DF0F3A83C100F84710 /* AbstractMacroAssembler.h */,
</span><span class="cx">                                 0F3730901C0CD70C00052BFA /* AllowMacroScratchRegisterUsage.h */,
</span><ins>+                                AD412B351E7B57C0008AF157 /* AllowMacroScratchRegisterUsageIf.h */,
</ins><span class="cx">                                 8640923B156EED3B00566CB2 /* ARM64Assembler.h */,
</span><span class="cx">                                 86D3B2BF10156BDE002865E7 /* ARMAssembler.cpp */,
</span><span class="cx">                                 86D3B2C010156BDE002865E7 /* ARMAssembler.h */,
</span><span class="lines">@@ -8562,6 +8570,7 @@
</span><span class="cx">                                 0FEA0A0C170513DB00BB722C /* FTLCompile.h in Headers */,
</span><span class="cx">                                 E322E5A71DA644A8006E7709 /* FTLDOMJITPatchpointParams.h in Headers */,
</span><span class="cx">                                 0F9D4C0D1C3E1C11006CD984 /* FTLExceptionTarget.h in Headers */,
</span><ins>+                                AD412B341E7B2E9E008AF157 /* WasmContext.h in Headers */,
</ins><span class="cx">                                 0F235BD417178E1C00690C7F /* FTLExitArgument.h in Headers */,
</span><span class="cx">                                 0F235BD617178E1C00690C7F /* FTLExitArgumentForOperand.h in Headers */,
</span><span class="cx">                                 0F2B9CF519D0BAC100B1D1B5 /* FTLExitPropertyValue.h in Headers */,
</span><span class="lines">@@ -10693,6 +10702,7 @@
</span><span class="cx">                                 BCDE3B430E6C832D001453A7 /* Structure.cpp in Sources */,
</span><span class="cx">                                 7E4EE70F0EBB7A5B005934AA /* StructureChain.cpp in Sources */,
</span><span class="cx">                                 2AF7382C18BBBF92008A5A37 /* StructureIDTable.cpp in Sources */,
</span><ins>+                                AD412B331E7B2E99008AF157 /* WasmContext.cpp in Sources */,
</ins><span class="cx">                                 C2F0F2D116BAEEE900187C19 /* StructureRareData.cpp in Sources */,
</span><span class="cx">                                 0FB438A319270B1D00E1FBC9 /* StructureSet.cpp in Sources */,
</span><span class="cx">                                 0F766D3815AE4A1C008F363E /* StructureStubClearingWatchpoint.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerAbstractMacroAssemblerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1108,6 +1108,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     friend class AllowMacroScratchRegisterUsage;
</span><ins>+    friend class AllowMacroScratchRegisterUsageIf;
</ins><span class="cx">     friend class DisallowMacroScratchRegisterUsage;
</span><span class="cx">     unsigned m_tempRegistersValidBits;
</span><span class="cx">     bool m_allowScratchRegister { true };
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerAllowMacroScratchRegisterUsageIfhfromrev214383trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/assembler/AllowMacroScratchRegisterUsageIf.h (from rev 214383, trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h) (0 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/AllowMacroScratchRegisterUsageIf.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/assembler/AllowMacroScratchRegisterUsageIf.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#pragma once
+
+#if ENABLE(ASSEMBLER)
+
+#include &quot;MacroAssembler.h&quot;
+
+namespace JSC {
+
+class AllowMacroScratchRegisterUsageIf {
+public:
+    AllowMacroScratchRegisterUsageIf(MacroAssembler&amp; masm, bool allowIfTrue)
+        : m_masm(masm)
+        , m_allowIfTrue(allowIfTrue)
+        , m_oldValueOfAllowScratchRegister(masm.m_allowScratchRegister)
+    {
+        if (m_allowIfTrue)
+            masm.m_allowScratchRegister = true;
+    }
+
+    ~AllowMacroScratchRegisterUsageIf()
+    {
+        if (m_allowIfTrue)
+            m_masm.m_allowScratchRegister = m_oldValueOfAllowScratchRegister;
+    }
+
+private:
+    MacroAssembler&amp; m_masm;
+    bool m_allowIfTrue;
+    bool m_oldValueOfAllowScratchRegister;
+};
+
+} // namespace JSC
+
+#endif // ENABLE(ASSEMBLER)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerMacroAssemblerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/MacroAssembler.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/MacroAssembler.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/assembler/MacroAssembler.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -657,6 +657,11 @@
</span><span class="cx">     {
</span><span class="cx">         loadFromTLS32(offset, dst);
</span><span class="cx">     }
</span><ins>+
+    void storeToTLSPtr(RegisterID src, uint32_t offset)
+    {
+        storeToTLS32(src, offset);
+    }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     DataLabel32 loadPtrWithAddressOffsetPatch(Address address, RegisterID dest)
</span><span class="lines">@@ -971,6 +976,10 @@
</span><span class="cx">     {
</span><span class="cx">         loadFromTLS64(offset, dst);
</span><span class="cx">     }
</span><ins>+    void storeToTLSPtr(RegisterID src, uint32_t offset)
+    {
+        storeToTLS64(src, offset);
+    }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     DataLabel32 loadPtrWithAddressOffsetPatch(Address address, RegisterID dest)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerMacroAssemblerARM64h"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -3600,7 +3600,7 @@
</span><span class="cx">     
</span><span class="cx"> #if ENABLE(FAST_TLS_JIT)
</span><span class="cx">     // This will use scratch registers if the offset is not legal.
</span><del>-    
</del><ins>+
</ins><span class="cx">     void loadFromTLS32(uint32_t offset, RegisterID dst)
</span><span class="cx">     {
</span><span class="cx">         m_assembler.mrs_TPIDRRO_EL0(dst);
</span><span class="lines">@@ -3614,6 +3614,34 @@
</span><span class="cx">         and64(TrustedImm32(~7), dst);
</span><span class="cx">         load64(Address(dst, offset), dst);
</span><span class="cx">     }
</span><ins>+
+    static bool loadFromTLSPtrNeedsMacroScratchRegister()
+    {
+        return true;
+    }
+
+    void storeToTLS32(RegisterID src, uint32_t offset)
+    {
+        RegisterID tmp = getCachedDataTempRegisterIDAndInvalidate();
+        ASSERT(src != tmp);
+        m_assembler.mrs_TPIDRRO_EL0(tmp);
+        and64(TrustedImm32(~7), tmp);
+        store32(src, Address(tmp, offset));
+    }
+    
+    void storeToTLS64(RegisterID src, uint32_t offset)
+    {
+        RegisterID tmp = getCachedDataTempRegisterIDAndInvalidate();
+        ASSERT(src != tmp);
+        m_assembler.mrs_TPIDRRO_EL0(tmp);
+        and64(TrustedImm32(~7), tmp);
+        store64(src, Address(tmp, offset));
+    }
+
+    static bool storeToTLSPtrNeedsMacroScratchRegister()
+    {
+        return true;
+    }
</ins><span class="cx"> #endif // ENABLE(FAST_TLS_JIT)
</span><span class="cx">     
</span><span class="cx">     // Misc helper functions.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerMacroAssemblerX86Commonh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -3864,6 +3864,23 @@
</span><span class="cx">         m_assembler.gs();
</span><span class="cx">         m_assembler.movl_mr(offset, dst);
</span><span class="cx">     }
</span><ins>+
+
+    static bool loadFromTLSPtrNeedsMacroScratchRegister()
+    {
+        return false;
+    }
+
+    void storeToTLS32(RegisterID src, uint32_t offset)
+    {
+        m_assembler.gs();
+        m_assembler.movl_rm(src, offset);
+    }
+
+    static bool storeToTLSPtrNeedsMacroScratchRegister()
+    {
+        return false;
+    }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     static void replaceWithBreakpoint(CodeLocationLabel instructionStart)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerMacroAssemblerX86_64h"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1705,8 +1705,14 @@
</span><span class="cx">     void loadFromTLS64(uint32_t offset, RegisterID dst)
</span><span class="cx">     {
</span><span class="cx">         m_assembler.gs();
</span><del>-        m_assembler.movl_mr(offset, dst);
</del><ins>+        m_assembler.movq_mr(offset, dst);
</ins><span class="cx">     }
</span><ins>+
+    void storeToTLS64(RegisterID src, uint32_t offset)
+    {
+        m_assembler.gs();
+        m_assembler.movq_rm(src, offset);
+    }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     void truncateDoubleToUint32(FPRegisterID src, RegisterID dest)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreassemblerX86Assemblerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/assembler/X86Assembler.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/assembler/X86Assembler.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/assembler/X86Assembler.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -2360,6 +2360,11 @@
</span><span class="cx">         m_formatter.oneByteOpAddr(OP_MOV_GvEv, dst, addr);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void movl_rm(RegisterID src, uint32_t addr)
+    {
+        m_formatter.oneByteOpAddr(OP_MOV_EvGv, src, addr);
+    }
+
</ins><span class="cx"> #if CPU(X86_64)
</span><span class="cx">     void movq_rr(RegisterID src, RegisterID dst)
</span><span class="cx">     {
</span><span class="lines">@@ -2381,6 +2386,11 @@
</span><span class="cx">         m_formatter.oneByteOp64(OP_MOV_EvGv, src, base, index, scale, offset);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void movq_rm(RegisterID src, int offset)
+    {
+        m_formatter.oneByteOp64Addr(OP_MOV_EvGv, src, offset);
+    }
+
</ins><span class="cx">     void movq_mEAX(const void* addr)
</span><span class="cx">     {
</span><span class="cx">         m_formatter.oneByteOp64(OP_MOV_EAXOv);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3testb3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/testb3.cpp (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/testb3.cpp        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/b3/testb3.cpp        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -15211,7 +15211,7 @@
</span><span class="cx">         CHECK_EQ(numToStore, value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void testFastTLS()
</del><ins>+void testFastTLSLoad()
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(FAST_TLS_JIT)
</span><span class="cx">     _pthread_setspecific_direct(WTF_TESTING_KEY, bitwise_cast&lt;void*&gt;(static_cast&lt;uintptr_t&gt;(0xbeef)));
</span><span class="lines">@@ -15226,7 +15226,7 @@
</span><span class="cx">             AllowMacroScratchRegisterUsage allowScratch(jit);
</span><span class="cx">             jit.loadFromTLSPtr(fastTLSOffsetForKey(WTF_TESTING_KEY), params[0].gpr());
</span><span class="cx">         });
</span><del>-    
</del><ins>+
</ins><span class="cx">     root-&gt;appendNew&lt;Value&gt;(proc, Return, Origin(), patchpoint);
</span><span class="cx">     
</span><span class="cx">     CHECK_EQ(compileAndRun&lt;uintptr_t&gt;(proc), static_cast&lt;uintptr_t&gt;(0xbeef));
</span><span class="lines">@@ -15233,6 +15233,30 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void testFastTLSStore()
+{
+#if ENABLE(FAST_TLS_JIT)
+    Procedure proc;
+    BasicBlock* root = proc.addBlock();
+
+    PatchpointValue* patchpoint = root-&gt;appendNew&lt;PatchpointValue&gt;(proc, Void, Origin());
+    patchpoint-&gt;clobber(RegisterSet::macroScratchRegisters());
+    patchpoint-&gt;numGPScratchRegisters = 1;
+    patchpoint-&gt;setGenerator(
+        [&amp;] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp; params) {
+            AllowMacroScratchRegisterUsage allowScratch(jit);
+            GPRReg scratch = params.gpScratch(0);
+            jit.move(CCallHelpers::TrustedImm32(0xdead), scratch);
+            jit.storeToTLSPtr(scratch, fastTLSOffsetForKey(WTF_TESTING_KEY));
+        });
+
+    root-&gt;appendNewControlValue(proc, Return, Origin());
+
+    compileAndRun&lt;void&gt;(proc);
+    CHECK_EQ(bitwise_cast&lt;uintptr_t&gt;(_pthread_getspecific_direct(WTF_TESTING_KEY)), static_cast&lt;uintptr_t&gt;(0xdead));
+#endif
+}
+
</ins><span class="cx"> // Make sure the compiler does not try to optimize anything out.
</span><span class="cx"> NEVER_INLINE double zero()
</span><span class="cx"> {
</span><span class="lines">@@ -16760,7 +16784,8 @@
</span><span class="cx">     RUN(testWasmBoundsCheck(std::numeric_limits&lt;unsigned&gt;::max() - 5));
</span><span class="cx">     RUN(testWasmAddress());
</span><span class="cx">     
</span><del>-    RUN(testFastTLS());
</del><ins>+    RUN(testFastTLSLoad());
+    RUN(testFastTLSStore());
</ins><span class="cx"> 
</span><span class="cx">     if (isX86()) {
</span><span class="cx">         RUN(testBranchBitAndImmFusion(Identity, Int64, 1, Air::BranchTest32, Air::Arg::Tmp));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitAssemblyHelpersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include &quot;SuperSampler.h&quot;
</span><span class="cx"> #include &quot;TypeofType.h&quot;
</span><span class="cx"> #include &quot;VM.h&quot;
</span><ins>+#include &lt;wtf/FastTLS.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="lines">@@ -1634,7 +1635,47 @@
</span><span class="cx"> #if USE(JSVALUE64)
</span><span class="cx">     void wangsInt64Hash(GPRReg inputAndResult, GPRReg scratch);
</span><span class="cx"> #endif
</span><del>-    
</del><ins>+
+    void loadWasmContext(GPRReg dst)
+    {
+#if ENABLE(FAST_TLS_JIT)
+        if (Options::useWebAssemblyFastTLS()) {
+            loadFromTLSPtr(fastTLSOffsetForKey(WTF_WASM_CONTEXT_KEY), dst);
+            return;
+        }
+#endif
+        // FIXME: Save this state elsewhere to allow PIC. https://bugs.webkit.org/show_bug.cgi?id=169773
+        loadPtr(&amp;m_vm-&gt;wasmContext, dst);
+    }
+
+    void storeWasmContext(GPRReg src)
+    {
+#if ENABLE(FAST_TLS_JIT)
+        if (Options::useWebAssemblyFastTLS())
+            storeToTLSPtr(src, fastTLSOffsetForKey(WTF_WASM_CONTEXT_KEY));
+#endif
+        // FIXME: Save this state elsewhere to allow PIC. https://bugs.webkit.org/show_bug.cgi?id=169773
+        storePtr(src, &amp;m_vm-&gt;wasmContext);
+    }
+
+    static bool loadWasmContextNeedsMacroScratchRegister()
+    {
+#if ENABLE(FAST_TLS_JIT)
+        if (Options::useWebAssemblyFastTLS())
+            return loadFromTLSPtrNeedsMacroScratchRegister();
+#endif
+        return true;
+    }
+
+    static bool storeWasmContextNeedsMacroScratchRegister()
+    {
+#if ENABLE(FAST_TLS_JIT)
+        if (Options::useWebAssemblyFastTLS())
+            return storeToTLSPtrNeedsMacroScratchRegister();
+#endif
+        return true;
+    }
+
</ins><span class="cx"> protected:
</span><span class="cx">     VM* m_vm;
</span><span class="cx">     CodeBlock* m_codeBlock;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitRepatchcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/Repatch.cpp (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/Repatch.cpp        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/jit/Repatch.cpp        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2011-2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> #include &quot;StructureStubClearingWatchpoint.h&quot;
</span><span class="cx"> #include &quot;StructureStubInfo.h&quot;
</span><span class="cx"> #include &quot;ThunkGenerators.h&quot;
</span><ins>+#include &quot;WasmContext.h&quot;
</ins><span class="cx"> #include &lt;wtf/CommaPrinter.h&gt;
</span><span class="cx"> #include &lt;wtf/ListDump.h&gt;
</span><span class="cx"> #include &lt;wtf/StringPrintStream.h&gt;
</span><span class="lines">@@ -592,7 +593,7 @@
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx">     // Each WebAssembly.Instance shares the stubs from their WebAssembly.Module, which are therefore the appropriate owner.
</span><del>-    return vm.topJSWebAssemblyInstance-&gt;module();
</del><ins>+    return loadWasmContext(vm)-&gt;module();
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(vm);
</span><span class="cx">     RELEASE_ASSERT_NOT_REACHED();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitThunkGeneratorscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2012-2014, 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010, 2012-2014, 2016-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -32,12 +32,13 @@
</span><span class="cx"> #include &quot;JITOperations.h&quot;
</span><span class="cx"> #include &quot;JSArray.h&quot;
</span><span class="cx"> #include &quot;JSBoundFunction.h&quot;
</span><del>-#include &quot;MathCommon.h&quot;
-#include &quot;MaxFrameExtentForSlowPathCall.h&quot;
</del><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyInstance.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyRuntimeError.h&quot;
</span><ins>+#include &quot;MathCommon.h&quot;
+#include &quot;MaxFrameExtentForSlowPathCall.h&quot;
</ins><span class="cx"> #include &quot;SpecializedThunkJIT.h&quot;
</span><ins>+#include &quot;WasmContext.h&quot;
</ins><span class="cx"> #include &quot;WasmExceptionType.h&quot;
</span><span class="cx"> #include &lt;wtf/InlineASM.h&gt;
</span><span class="cx"> #include &lt;wtf/StringPrintStream.h&gt;
</span><span class="lines">@@ -1156,7 +1157,7 @@
</span><span class="cx"> 
</span><span class="cx">         {
</span><span class="cx">             auto throwScope = DECLARE_THROW_SCOPE(*vm);
</span><del>-            JSGlobalObject* globalObject = vm-&gt;topJSWebAssemblyInstance-&gt;globalObject();
</del><ins>+            JSGlobalObject* globalObject = loadWasmContext(*vm)-&gt;globalObject();
</ins><span class="cx"> 
</span><span class="cx">             JSWebAssemblyRuntimeError* error = JSWebAssemblyRuntimeError::create(exec, *vm, globalObject-&gt;WebAssemblyRuntimeErrorStructure(), Wasm::errorMessageForExceptionType(type));
</span><span class="cx">             throwException(exec, throwScope, error);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Options.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Options.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/runtime/Options.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -429,7 +429,8 @@
</span><span class="cx">     \
</span><span class="cx">     v(bool, useWebAssembly, true, Normal, &quot;Expose the WebAssembly global object.&quot;) \
</span><span class="cx">     v(bool, simulateWebAssemblyLowMemory, false, Normal, &quot;If true, the Memory object won't mmap the full 'maximum' range and instead will allocate the minimum required amount.&quot;) \
</span><del>-    v(bool, useWebAssemblyFastMemory, true, Normal, &quot;If true, we will try to use a 32-bit address space with a signal handler to bounds check wasm memory.&quot;)
</del><ins>+    v(bool, useWebAssemblyFastMemory, true, Normal, &quot;If true, we will try to use a 32-bit address space with a signal handler to bounds check wasm memory.&quot;) \
+    v(bool, useWebAssemblyFastTLS, true, Normal, &quot;If true, we will try to use fast thread-local storage if available on the current platform.&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> enum OptionEquivalence {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.cpp (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -177,7 +177,6 @@
</span><span class="cx">     , clientData(0)
</span><span class="cx">     , topVMEntryFrame(nullptr)
</span><span class="cx">     , topCallFrame(CallFrame::noCaller())
</span><del>-    , topJSWebAssemblyInstance(nullptr)
</del><span class="cx">     , m_atomicStringTable(vmType == Default ? wtfThreadData().atomicStringTable() : new AtomicStringTable)
</span><span class="cx">     , propertyNames(nullptr)
</span><span class="cx">     , emptyList(new ArgList)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/runtime/VM.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -315,7 +315,8 @@
</span><span class="cx">     // FIXME: This should be a void*, because it might not point to a CallFrame.
</span><span class="cx">     // https://bugs.webkit.org/show_bug.cgi?id=160441
</span><span class="cx">     ExecState* topCallFrame { nullptr };
</span><del>-    JSWebAssemblyInstance* topJSWebAssemblyInstance;
</del><ins>+    // FIXME: Save this state elsewhere to allow PIC. https://bugs.webkit.org/show_bug.cgi?id=169773
+    JSWebAssemblyInstance* wasmContext { nullptr };
</ins><span class="cx">     Strong&lt;Structure&gt; structureStructure;
</span><span class="cx">     Strong&lt;Structure&gt; structureRareDataStructure;
</span><span class="cx">     Strong&lt;Structure&gt; terminatedExecutionErrorStructure;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmB3IRGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx"> 
</span><ins>+#include &quot;AllowMacroScratchRegisterUsageIf.h&quot;
</ins><span class="cx"> #include &quot;B3BasicBlockInlines.h&quot;
</span><span class="cx"> #include &quot;B3CCallValue.h&quot;
</span><span class="cx"> #include &quot;B3Compile.h&quot;
</span><span class="lines">@@ -48,6 +49,7 @@
</span><span class="cx"> #include &quot;JSWebAssemblyRuntimeError.h&quot;
</span><span class="cx"> #include &quot;VirtualRegister.h&quot;
</span><span class="cx"> #include &quot;WasmCallingConvention.h&quot;
</span><ins>+#include &quot;WasmContext.h&quot;
</ins><span class="cx"> #include &quot;WasmExceptionType.h&quot;
</span><span class="cx"> #include &quot;WasmFunctionParser.h&quot;
</span><span class="cx"> #include &quot;WasmMemory.h&quot;
</span><span class="lines">@@ -226,9 +228,36 @@
</span><span class="cx">     GPRReg m_memoryBaseGPR;
</span><span class="cx">     GPRReg m_memorySizeGPR;
</span><span class="cx">     Value* m_zeroValues[numTypes];
</span><del>-    Value* m_instanceValue;
</del><ins>+    Value* m_instanceValue; // FIXME: make this lazy https://bugs.webkit.org/show_bug.cgi?id=169792
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+static Value* loadWasmContext(Procedure&amp; proc, BasicBlock* block)
+{
+    PatchpointValue* patchpoint = block-&gt;appendNew&lt;PatchpointValue&gt;(proc, pointerType(), Origin());
+    if (CCallHelpers::loadWasmContextNeedsMacroScratchRegister())
+        patchpoint-&gt;clobber(RegisterSet::macroScratchRegisters());
+    patchpoint-&gt;setGenerator(
+        [&amp;] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp; params) {
+            AllowMacroScratchRegisterUsageIf allowScratch(jit, CCallHelpers::loadWasmContextNeedsMacroScratchRegister());
+            jit.loadWasmContext(params[0].gpr());
+        });
+
+    return block-&gt;appendNew&lt;Value&gt;(proc, Identity, Origin(), patchpoint);
+}
+
+static void storeWasmContext(Procedure&amp; proc, BasicBlock* block, Value* arg)
+{
+    PatchpointValue* patchpoint = block-&gt;appendNew&lt;PatchpointValue&gt;(proc, B3::Void, Origin());
+    if (CCallHelpers::storeWasmContextNeedsMacroScratchRegister())
+        patchpoint-&gt;clobber(RegisterSet::macroScratchRegisters());
+    patchpoint-&gt;append(ConstrainedValue(arg, ValueRep::SomeRegister));
+    patchpoint-&gt;setGenerator(
+        [&amp;] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp; params) {
+            AllowMacroScratchRegisterUsageIf allowScratch(jit, CCallHelpers::storeWasmContextNeedsMacroScratchRegister());
+            jit.storeWasmContext(params[0].gpr());
+        });
+}
+
</ins><span class="cx"> B3IRGenerator::B3IRGenerator(VM&amp; vm, const ModuleInformation&amp; info, Procedure&amp; procedure, WasmInternalFunction* compilation, Vector&lt;UnlinkedWasmToWasmCall&gt;&amp; unlinkedWasmToWasmCalls)
</span><span class="cx">     : m_vm(vm)
</span><span class="cx">     , m_info(info)
</span><span class="lines">@@ -270,8 +299,7 @@
</span><span class="cx"> 
</span><span class="cx">     wasmCallingConvention().setupFrameInPrologue(&amp;compilation-&gt;wasmCalleeMoveLocation, m_proc, Origin(), m_currentBlock);
</span><span class="cx"> 
</span><del>-    m_instanceValue = m_currentBlock-&gt;appendNew&lt;MemoryValue&gt;(m_proc, Load, pointerType(), Origin(),
-        m_currentBlock-&gt;appendNew&lt;ConstPtrValue&gt;(m_proc, Origin(), &amp;m_vm.topJSWebAssemblyInstance));
</del><ins>+    m_instanceValue = loadWasmContext(m_proc, m_currentBlock);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> struct MemoryBaseAndSize {
</span><span class="lines">@@ -283,8 +311,8 @@
</span><span class="cx"> {
</span><span class="cx">     Value* memoryObject = block-&gt;appendNew&lt;MemoryValue&gt;(proc, Load, pointerType(), Origin(), instance, JSWebAssemblyInstance::offsetOfMemory());
</span><span class="cx"> 
</span><del>-    static_assert(sizeof(decltype(vm.topJSWebAssemblyInstance-&gt;memory()-&gt;memory().memory())) == sizeof(void*), &quot;codegen relies on this size&quot;);
-    static_assert(sizeof(decltype(vm.topJSWebAssemblyInstance-&gt;memory()-&gt;memory().size())) == sizeof(uint64_t), &quot;codegen relies on this size&quot;);
</del><ins>+    static_assert(sizeof(decltype(loadWasmContext(vm)-&gt;memory()-&gt;memory().memory())) == sizeof(void*), &quot;codegen relies on this size&quot;);
+    static_assert(sizeof(decltype(loadWasmContext(vm)-&gt;memory()-&gt;memory().size())) == sizeof(uint64_t), &quot;codegen relies on this size&quot;);
</ins><span class="cx">     MemoryBaseAndSize result;
</span><span class="cx">     result.base = block-&gt;appendNew&lt;MemoryValue&gt;(proc, Load, pointerType(), Origin(), memoryObject, JSWebAssemblyMemory::offsetOfMemory());
</span><span class="cx">     result.size = block-&gt;appendNew&lt;MemoryValue&gt;(proc, Load, Int64, Origin(), memoryObject, JSWebAssemblyMemory::offsetOfSize());
</span><span class="lines">@@ -292,9 +320,9 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void restoreWebAssemblyGlobalState(VM&amp; vm, const MemoryInformation&amp; memory, Value* instance, Procedure&amp; proc, BasicBlock* block)
</del><ins>+static void restoreWebAssemblyGlobalState(const MemoryInformation&amp; memory, Value* instance, Procedure&amp; proc, BasicBlock* block)
</ins><span class="cx"> {
</span><del>-    block-&gt;appendNew&lt;MemoryValue&gt;(proc, Store, Origin(), instance, block-&gt;appendNew&lt;ConstPtrValue&gt;(proc, Origin(), &amp;vm.topJSWebAssemblyInstance));
</del><ins>+    storeWasmContext(proc, block, instance);
</ins><span class="cx"> 
</span><span class="cx">     if (!!memory) {
</span><span class="cx">         const PinnedRegisterInfo* pinnedRegs = &amp;PinnedRegisterInfo::get();
</span><span class="lines">@@ -395,7 +423,7 @@
</span><span class="cx">         VM&amp; vm = exec-&gt;vm();
</span><span class="cx">         auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx"> 
</span><del>-        JSWebAssemblyInstance* instance = vm.topJSWebAssemblyInstance;
</del><ins>+        JSWebAssemblyInstance* instance = loadWasmContext(vm);
</ins><span class="cx">         JSWebAssemblyMemory* wasmMemory = instance-&gt;memory();
</span><span class="cx"> 
</span><span class="cx">         if (delta &lt; 0)
</span><span class="lines">@@ -414,7 +442,7 @@
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;ConstPtrValue&gt;(m_proc, Origin(), bitwise_cast&lt;void*&gt;(growMemory)),
</span><span class="cx">         m_currentBlock-&gt;appendNew&lt;B3::Value&gt;(m_proc, B3::FramePointer, Origin()), delta);
</span><span class="cx"> 
</span><del>-    restoreWebAssemblyGlobalState(m_vm, m_info.memory, m_instanceValue, m_proc, m_currentBlock);
</del><ins>+    restoreWebAssemblyGlobalState(m_info.memory, m_instanceValue, m_proc, m_currentBlock);
</ins><span class="cx"> 
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="lines">@@ -901,7 +929,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // The call could have been to another WebAssembly instance, and / or could have modified our Memory.
</span><del>-        restoreWebAssemblyGlobalState(m_vm, m_info.memory, m_instanceValue, m_proc, continuation);
</del><ins>+        restoreWebAssemblyGlobalState(m_info.memory, m_instanceValue, m_proc, continuation);
</ins><span class="cx">     } else {
</span><span class="cx">         result = wasmCallingConvention().setupCall(m_proc, m_currentBlock, Origin(), args, toB3Type(returnType),
</span><span class="cx">             [&amp;] (PatchpointValue* patchpoint) {
</span><span class="lines">@@ -995,7 +1023,7 @@
</span><span class="cx">         });
</span><span class="cx"> 
</span><span class="cx">     // The call could have been to another WebAssembly instance, and / or could have modified our Memory.
</span><del>-    restoreWebAssemblyGlobalState(m_vm, m_info.memory, m_instanceValue, m_proc, m_currentBlock);
</del><ins>+    restoreWebAssemblyGlobalState(m_info.memory, m_instanceValue, m_proc, m_currentBlock);
</ins><span class="cx"> 
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="lines">@@ -1037,7 +1065,7 @@
</span><span class="cx">     dataLogLn();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void createJSToWasmWrapper(VM&amp; vm, CompilationContext&amp; compilationContext, WasmInternalFunction&amp; function, const Signature* signature, const ModuleInformation&amp; info)
</del><ins>+static void createJSToWasmWrapper(CompilationContext&amp; compilationContext, WasmInternalFunction&amp; function, const Signature* signature, const ModuleInformation&amp; info)
</ins><span class="cx"> {
</span><span class="cx">     CCallHelpers&amp; jit = *compilationContext.jsEntrypointJIT;
</span><span class="cx"> 
</span><span class="lines">@@ -1165,7 +1193,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!!info.memory) {
</span><span class="cx">         GPRReg baseMemory = pinnedRegs.baseMemoryPointer;
</span><del>-        jit.loadPtr(&amp;vm.topJSWebAssemblyInstance, baseMemory);
</del><ins>+        jit.loadWasmContext(baseMemory);
</ins><span class="cx">         jit.loadPtr(CCallHelpers::Address(baseMemory, JSWebAssemblyInstance::offsetOfMemory()), baseMemory);
</span><span class="cx">         const auto&amp; sizeRegs = pinnedRegs.sizeRegisters;
</span><span class="cx">         ASSERT(sizeRegs.size() &gt;= 1);
</span><span class="lines">@@ -1227,7 +1255,7 @@
</span><span class="cx">         result-&gt;wasmEntrypoint.calleeSaveRegisters = procedure.calleeSaveRegisters();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    createJSToWasmWrapper(vm, compilationContext, *result, signature, info);
</del><ins>+    createJSToWasmWrapper(compilationContext, *result, signature, info);
</ins><span class="cx">     return WTFMove(result);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmBindingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmBinding.cpp (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmBinding.cpp        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/wasm/WasmBinding.cpp        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &quot;LinkBuffer.h&quot;
</span><span class="cx"> #include &quot;NativeErrorConstructor.h&quot;
</span><span class="cx"> #include &quot;WasmCallingConvention.h&quot;
</span><ins>+#include &quot;WasmContext.h&quot;
</ins><span class="cx"> #include &quot;WasmExceptionType.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace Wasm {
</span><span class="lines">@@ -42,10 +43,10 @@
</span><span class="cx"> 
</span><span class="cx"> typedef CCallHelpers JIT;
</span><span class="cx"> 
</span><del>-static void materializeImportJSCell(VM* vm, JIT&amp; jit, unsigned importIndex, GPRReg result)
</del><ins>+static void materializeImportJSCell(JIT&amp; jit, unsigned importIndex, GPRReg result)
</ins><span class="cx"> {
</span><del>-    // We're calling out of the current WebAssembly.Instance, which is identified on VM. That Instance has a list of all its import functions.
-    jit.loadPtr(&amp;vm-&gt;topJSWebAssemblyInstance, result);
</del><ins>+    // We're calling out of the current WebAssembly.Instance. That Instance has a list of all its import functions.
+    jit.loadWasmContext(result);
</ins><span class="cx">     jit.loadPtr(JIT::Address(result, JSWebAssemblyInstance::offsetOfImportFunction(importIndex)), result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -101,7 +102,7 @@
</span><span class="cx"> 
</span><span class="cx">                 {
</span><span class="cx">                     auto throwScope = DECLARE_THROW_SCOPE(*vm);
</span><del>-                    JSGlobalObject* globalObject = vm-&gt;topJSWebAssemblyInstance-&gt;globalObject();
</del><ins>+                    JSGlobalObject* globalObject = loadWasmContext(*vm)-&gt;globalObject();
</ins><span class="cx">                     auto* error = ErrorInstance::create(exec, *vm, globalObject-&gt;typeErrorConstructor()-&gt;errorStructure(), ASCIILiteral(&quot;i64 not allowed as return type or argument to an imported function&quot;));
</span><span class="cx">                     throwException(exec, throwScope, error);
</span><span class="cx">                 }
</span><span class="lines">@@ -254,7 +255,7 @@
</span><span class="cx">     GPRReg importJSCellGPRReg = GPRInfo::regT0; // Callee needs to be in regT0 for slow path below.
</span><span class="cx">     ASSERT(!wasmCC.m_calleeSaveRegisters.get(importJSCellGPRReg));
</span><span class="cx"> 
</span><del>-    materializeImportJSCell(vm, jit, importIndex, importJSCellGPRReg);
</del><ins>+    materializeImportJSCell(jit, importIndex, importJSCellGPRReg);
</ins><span class="cx"> 
</span><span class="cx">     jit.store64(importJSCellGPRReg, calleeFrame.withOffset(CallFrameSlot::callee * static_cast&lt;int&gt;(sizeof(Register))));
</span><span class="cx">     jit.store32(JIT::TrustedImm32(numberOfParameters), calleeFrame.withOffset(CallFrameSlot::argumentCount * static_cast&lt;int&gt;(sizeof(Register)) + PayloadOffset));
</span><span class="lines">@@ -426,13 +427,13 @@
</span><span class="cx">     GPRReg scratch = GPRInfo::nonPreservedNonArgumentGPR;
</span><span class="cx"> 
</span><span class="cx">     // B3's call codegen ensures that the JSCell is a WebAssemblyFunction.
</span><del>-    materializeImportJSCell(vm, jit, importIndex, scratch);
</del><ins>+    materializeImportJSCell(jit, importIndex, scratch);
</ins><span class="cx"> 
</span><del>-    // Get the callee's WebAssembly.Instance and set it as vm.topJSWebAssemblyInstance. The caller will take care of restoring its own Instance.
</del><ins>+    // Get the callee's WebAssembly.Instance and set it as WasmContext. The caller will take care of restoring its own Instance.
</ins><span class="cx">     GPRReg baseMemory = pinnedRegs.baseMemoryPointer;
</span><span class="cx">     ASSERT(baseMemory != scratch);
</span><span class="cx">     jit.loadPtr(JIT::Address(scratch, WebAssemblyFunction::offsetOfInstance()), baseMemory); // Instance*.
</span><del>-    jit.storePtr(baseMemory, &amp;vm-&gt;topJSWebAssemblyInstance);
</del><ins>+    jit.storeWasmContext(baseMemory);
</ins><span class="cx"> 
</span><span class="cx">     // FIXME the following code assumes that all WebAssembly.Instance have the same pinned registers. https://bugs.webkit.org/show_bug.cgi?id=162952
</span><span class="cx">     // Set up the callee's baseMemory register as well as the memory size registers.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmContextcppfromrev214383trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/wasm/WasmContext.cpp (from rev 214383, trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h) (0 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmContext.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WasmContext.cpp        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;WasmContext.h&quot;
+
+#if ENABLE(WEBASSEMBLY)
+
+#include &quot;VM.h&quot;
+#include &lt;mutex&gt;
+#include &lt;wtf/FastTLS.h&gt;
+
+namespace JSC {
+
+JSWebAssemblyInstance* loadWasmContext(VM&amp; vm)
+{
+#if ENABLE(FAST_TLS_JIT)
+    if (Options::useWebAssemblyFastTLS())
+        return bitwise_cast&lt;JSWebAssemblyInstance*&gt;(_pthread_getspecific_direct(WTF_WASM_CONTEXT_KEY));
+#endif
+    // FIXME: Save this state elsewhere to allow PIC. https://bugs.webkit.org/show_bug.cgi?id=169773
+    return vm.wasmContext;
+}
+
+void storeWasmContext(VM&amp; vm, JSWebAssemblyInstance* instance)
+{
+#if ENABLE(FAST_TLS_JIT)
+    if (Options::useWebAssemblyFastTLS())
+        _pthread_setspecific_direct(WTF_WASM_CONTEXT_KEY, bitwise_cast&lt;void*&gt;(instance));
+#endif
+    // FIXME: Save this state elsewhere to allow PIC. https://bugs.webkit.org/show_bug.cgi?id=169773
+    vm.wasmContext = instance;
+}
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmContexthfromrev214383trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh"></a>
<div class="copfile"><h4>Copied: trunk/Source/JavaScriptCore/wasm/WasmContext.h (from rev 214383, trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h) (0 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmContext.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/wasm/WasmContext.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBASSEMBLY)
+
+namespace JSC {
+
+class JSWebAssemblyInstance;
+class VM;
+
+JSWebAssemblyInstance* loadWasmContext(VM&amp;);
+void storeWasmContext(VM&amp;, JSWebAssemblyInstance*);
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyFunctioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &quot;LLIntThunks.h&quot;
</span><span class="cx"> #include &quot;ProtoCallFrame.h&quot;
</span><span class="cx"> #include &quot;VM.h&quot;
</span><ins>+#include &quot;WasmContext.h&quot;
</ins><span class="cx"> #include &quot;WasmFormat.h&quot;
</span><span class="cx"> #include &quot;WasmMemory.h&quot;
</span><span class="cx"> #include &lt;wtf/SystemTracing.h&gt;
</span><span class="lines">@@ -120,11 +121,12 @@
</span><span class="cx">     protoCallFrame.init(nullptr, wasmFunction, firstArgument, argCount, remainingArgs);
</span><span class="cx"> 
</span><span class="cx">     // FIXME Do away with this entire function, and only use the entrypoint generated by B3. https://bugs.webkit.org/show_bug.cgi?id=166486
</span><del>-    JSWebAssemblyInstance* prevJSWebAssemblyInstance = vm.topJSWebAssemblyInstance;
-    vm.topJSWebAssemblyInstance = wasmFunction-&gt;instance();
</del><ins>+    JSWebAssemblyInstance* prevJSWebAssemblyInstance = loadWasmContext(vm);
+    storeWasmContext(vm, wasmFunction-&gt;instance());
</ins><span class="cx">     ASSERT(wasmFunction-&gt;instance());
</span><ins>+    ASSERT(wasmFunction-&gt;instance() == loadWasmContext(vm));
</ins><span class="cx">     EncodedJSValue rawResult = vmEntryToWasm(wasmFunction-&gt;jsEntrypoint(), &amp;vm, &amp;protoCallFrame);
</span><del>-    vm.topJSWebAssemblyInstance = prevJSWebAssemblyInstance;
</del><ins>+    storeWasmContext(vm, prevJSWebAssemblyInstance);
</ins><span class="cx">     RETURN_IF_EXCEPTION(scope, { });
</span><span class="cx"> 
</span><span class="cx">     switch (signature-&gt;returnType()) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyInstanceConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><ins>+class JSWebAssemblyInstance;
</ins><span class="cx"> class JSWebAssemblyModule;
</span><span class="cx"> class WebAssemblyInstancePrototype;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/WTF/ChangeLog        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-03-24  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly: store state in TLS instead of on VM
+        https://bugs.webkit.org/show_bug.cgi?id=169611
+
+        Reviewed by Filip Pizlo.
+
+        * wtf/FastTLS.h: reserve one key for WebAssembly, delete a bunch
+        of dead code which clang couldn't compile (it's valid GCC assembly
+        which LLVM dislikes).
+
</ins><span class="cx"> 2017-03-24  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r214351.
</span></span></pre></div>
<a id="trunkSourceWTFwtfFastTLSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/FastTLS.h (214383 => 214384)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/FastTLS.h        2017-03-24 23:16:52 UTC (rev 214383)
+++ trunk/Source/WTF/wtf/FastTLS.h        2017-03-24 23:25:16 UTC (rev 214384)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;pthread.h&gt;
</span><span class="cx"> #include &lt;System/pthread_machdep.h&gt;
</span><ins>+#include &lt;wtf/Platform.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><span class="lines">@@ -44,52 +45,20 @@
</span><span class="cx"> // accidentally use the same key for more than one thing.
</span><span class="cx"> 
</span><span class="cx"> #define WTF_THREAD_DATA_KEY WTF_FAST_TLS_KEY0
</span><ins>+#define WTF_WASM_CONTEXT_KEY WTF_FAST_TLS_KEY1
</ins><span class="cx"> #define WTF_TESTING_KEY WTF_FAST_TLS_KEY3
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(FAST_TLS_JIT)
</span><del>-// Below is the code that the JIT will emit.
-
-#if CPU(X86_64)
-inline uintptr_t loadFastTLS(unsigned offset)
-{
-    uintptr_t result;
-    asm volatile(
-        &quot;movq %%gs:%1, %0&quot;
-        : &quot;=r&quot;(result)
-        : &quot;r&quot;(offset)
-        : &quot;memory&quot;);
-    return result;
-}
-#elif CPU(ARM64)
-inline uintptr_t loadFastTLS(unsigned passedOffset)
-{
-    uintptr_t result;
-    uintptr_t offset = passedOffset;
-    asm volatile(
-        &quot;mrs %0, TPIDRRO_EL0\n\t&quot;
-        &quot;and %0, %0, #0xfffffffffffffff8\n\t&quot;
-        &quot;ldr %0, [%0, %1]&quot;
-        : &quot;=r&quot;(result)
-        : &quot;r&quot;(offset)
-        : &quot;memory&quot;);
-    return result;
-}
-#else
-#error &quot;Bad architecture&quot;
-#endif
-#endif // ENABLE(FAST_TLS_JIT)
-
</del><span class="cx"> inline unsigned fastTLSOffsetForKey(unsigned long slot)
</span><span class="cx"> {
</span><span class="cx">     return slot * sizeof(void*);
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WTF
</span><span class="cx"> 
</span><ins>+#if ENABLE(FAST_TLS_JIT)
</ins><span class="cx"> using WTF::fastTLSOffsetForKey;
</span><del>-
-#if ENABLE(FAST_TLS_JIT)
-using WTF::loadFastTLS;
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #endif // HAVE(FAST_TLS)
</span></span></pre>
</div>
</div>

</body>
</html>