We don't do context switches for Wasm->Wasm call indirect
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 May 2017 00:23:56 +0000 (00:23 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 May 2017 00:23:56 +0000 (00:23 +0000)
commit82928d500aa3a20fdfd287efb48a4007d1bac61c
treec624c5978b0e17cd353c04031ae5c7cc03abbfbc
parent4b394f8625845b2800918a775cf48e2f24a01213
We don't do context switches for Wasm->Wasm call indirect
https://bugs.webkit.org/show_bug.cgi?id=172188
<rdar://problem/32231828>

Reviewed by Keith Miller.

JSTests:

* wasm/function-tests/context-switch.js: Added.
(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance2):
(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.const.i2.makeInstance2):
(makeInstance):
(makeInstance2):
(assert.eq.makeInstance):
(assert.eq.makeInstance2):
(assert.eq):

Source/JavaScriptCore:

We did not do a context switch when doing an indirect call.
This is clearly wrong, since the thing we're making an indirect
call to could be from another instance. This patch fixes this
oversight by doing a very simple context switch. I've also opened
a bug to make indirect calls fast: https://bugs.webkit.org/show_bug.cgi?id=172197
since this patch adds yet another branch to the indirect call path.
I've also added tests that either throw or crash before this change.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* wasm/WasmB3IRGenerator.cpp:
* wasm/js/JSWebAssemblyTable.h:
(JSC::JSWebAssemblyTable::offsetOfJSFunctions):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::visitChildren):
(JSC::WebAssemblyFunction::finishCreation): Deleted.
* wasm/js/WebAssemblyFunction.h:
(JSC::WebAssemblyFunction::instance): Deleted.
(JSC::WebAssemblyFunction::offsetOfInstance): Deleted.
* wasm/js/WebAssemblyFunctionBase.cpp: Added.
(JSC::WebAssemblyFunctionBase::WebAssemblyFunctionBase):
(JSC::WebAssemblyFunctionBase::visitChildren):
(JSC::WebAssemblyFunctionBase::finishCreation):
* wasm/js/WebAssemblyFunctionBase.h: Added.
(JSC::WebAssemblyFunctionBase::instance):
(JSC::WebAssemblyFunctionBase::offsetOfInstance):
* wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::link):
(JSC::WebAssemblyModuleRecord::evaluate):
* wasm/js/WebAssemblyWrapperFunction.cpp:
(JSC::WebAssemblyWrapperFunction::create):
(JSC::WebAssemblyWrapperFunction::finishCreation):
(JSC::WebAssemblyWrapperFunction::visitChildren):
* wasm/js/WebAssemblyWrapperFunction.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217017 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
JSTests/ChangeLog
JSTests/wasm/function-tests/context-switch.js [new file with mode: 0644]
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyTable.h
Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h
Source/JavaScriptCore/wasm/js/WebAssemblyFunctionBase.cpp [new file with mode: 0644]
Source/JavaScriptCore/wasm/js/WebAssemblyFunctionBase.h [new file with mode: 0644]
Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h