WebAssembly: add fallback to use pinned register to load/store state
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Mar 2017 22:16:01 +0000 (22:16 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Mar 2017 22:16:01 +0000 (22:16 +0000)
commit916cd475f8c814450067a7d5c0910257a569e990
tree1870a88a630bacb8e4db720e10fab506aafbae17
parent66cb3a3a573547ab078b6bbf0efec413a0603e97
WebAssembly: add fallback to use pinned register to load/store state
https://bugs.webkit.org/show_bug.cgi?id=169773

Reviewed by Saam Barati.

This patch adds a new pinned register to hold JSWebAssemblyInstance,
which is used to represent the context of running Wasm code.
While we use fast TLS to hold the context in macOS, we do not have
any system reserved fast TLS slot in the other systems. This pinned
register approach is used in these systems. These changes decouple
VM from Wasm module to make Wasm module position independent code.

While using fast TLS could be beneficial in x64 systems which number of
registers is relatively small, pinned register approach could be
beneficial in ARM64 which has plenty of registers. In macOS, we can
switch the implementation with the runtime flag. Thus macOS port can
compare the performance and decide which implementation is used after
landing this patch.

* heap/MarkedBlock.h:
(JSC::MarkedBlock::offsetOfVM):
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::loadWasmContext):
(JSC::AssemblyHelpers::storeWasmContext):
(JSC::AssemblyHelpers::loadWasmContextNeedsMacroScratchRegister):
(JSC::AssemblyHelpers::storeWasmContextNeedsMacroScratchRegister):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::loadWasmContext): Deleted.
(JSC::AssemblyHelpers::storeWasmContext): Deleted.
(JSC::AssemblyHelpers::loadWasmContextNeedsMacroScratchRegister): Deleted.
(JSC::AssemblyHelpers::storeWasmContextNeedsMacroScratchRegister): Deleted.
* jit/Repatch.cpp:
(JSC::webAssemblyOwner):
(JSC::linkFor):
(JSC::linkPolymorphicCall):
(JSC::isWebAssemblyToJSCallee): Deleted.
* jit/ThunkGenerators.cpp:
(JSC::throwExceptionFromWasmThunkGenerator):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LowLevelInterpreter.asm:
* runtime/JSCell.cpp:
(JSC::JSCell::isAnyWasmCallee):
* runtime/JSCellInlines.h:
(JSC::isWebAssemblyToJSCallee):
* runtime/JSType.h:
* runtime/StackFrame.cpp:
(JSC::StackFrame::functionName):
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:
(JSC::VM::wasmContextOffset):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::materializeWasmContext):
(JSC::Wasm::B3IRGenerator::restoreWasmContext):
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::getMemoryBaseAndSize):
(JSC::Wasm::B3IRGenerator::restoreWebAssemblyGlobalState):
(JSC::Wasm::createJSToWasmWrapper):
(JSC::Wasm::loadWasmContext): Deleted.
(JSC::Wasm::storeWasmContext): Deleted.
(JSC::Wasm::restoreWebAssemblyGlobalState): Deleted.
* wasm/WasmBinding.cpp:
(JSC::Wasm::wasmToJs):
* wasm/WasmContext.cpp:
(JSC::loadWasmContext):
(JSC::storeWasmContext):
* wasm/WasmContext.h:
* wasm/WasmMemoryInformation.cpp:
(JSC::Wasm::getPinnedRegisters):
(JSC::Wasm::PinnedRegisterInfo::get):
(JSC::Wasm::PinnedRegisterInfo::PinnedRegisterInfo):
* wasm/WasmMemoryInformation.h:
(JSC::Wasm::PinnedRegisterInfo::toSave):
(JSC::Wasm::useFastTLS):
(JSC::Wasm::useFastTLSForWasmContext):
* wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::finishCreation):
(JSC::JSWebAssemblyInstance::visitChildren):
* wasm/js/JSWebAssemblyInstance.h:
(JSC::JSWebAssemblyInstance::offsetOfCallee):
* wasm/js/JSWebAssemblyModule.cpp:
(JSC::JSWebAssemblyModule::finishCreation):
(JSC::JSWebAssemblyModule::visitChildren):
* wasm/js/JSWebAssemblyModule.h:
(JSC::JSWebAssemblyModule::callee):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::callWebAssemblyFunction):
(JSC::WebAssemblyFunction::create):
* wasm/js/WebAssemblyToJSCallee.cpp:
(JSC::WebAssemblyToJSCallee::create):
(JSC::WebAssemblyToJSCallee::createStructure):
(JSC::WebAssemblyToJSCallee::finishCreation):
(JSC::WebAssemblyToJSCallee::visitChildren):
(JSC::WebAssemblyToJSCallee::destroy): Deleted.
* wasm/js/WebAssemblyToJSCallee.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/MarkedBlock.h
Source/JavaScriptCore/jit/AssemblyHelpers.cpp
Source/JavaScriptCore/jit/AssemblyHelpers.h
Source/JavaScriptCore/jit/Repatch.cpp
Source/JavaScriptCore/jit/ThunkGenerators.cpp
Source/JavaScriptCore/llint/LLIntData.cpp
Source/JavaScriptCore/llint/LowLevelInterpreter.asm
Source/JavaScriptCore/runtime/JSCell.cpp
Source/JavaScriptCore/runtime/JSCellInlines.h
Source/JavaScriptCore/runtime/JSType.h
Source/JavaScriptCore/runtime/StackFrame.cpp
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
Source/JavaScriptCore/wasm/WasmBinding.cpp
Source/JavaScriptCore/wasm/WasmContext.cpp
Source/JavaScriptCore/wasm/WasmContext.h
Source/JavaScriptCore/wasm/WasmMemoryInformation.cpp
Source/JavaScriptCore/wasm/WasmMemoryInformation.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h
Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyToJSCallee.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyToJSCallee.h