[JSC] Store Wasm::Instance* in |codeBlock| slot#8815
Conversation
|
EWS run on previous version of this PR (hash b51a8b2) Details |
|
Ah, will do a bit more drastic change. |
b51a8b2 to
e43938c
Compare
|
EWS run on previous version of this PR (hash e43938c) Details |
e43938c to
ad91996
Compare
|
EWS run on previous version of this PR (hash ad91996) Details |
ad91996 to
1fec380
Compare
|
EWS run on previous version of this PR (hash 1fec380) Details |
1fec380 to
3184e4b
Compare
|
EWS run on previous version of this PR (hash 3184e4b) Details |
3184e4b to
c2820e4
Compare
|
EWS run on previous version of this PR (hash c2820e4) Details |
c2820e4 to
b0ecd3f
Compare
|
EWS run on previous version of this PR (hash b0ecd3f) Details |
b0ecd3f to
53df791
Compare
|
EWS run on previous version of this PR (hash 53df791) Details |
53df791 to
75abe4a
Compare
|
EWS run on previous version of this PR (hash 75abe4a) Details |
|
Need some clarification on what you mean in parts of the commit msg.
/It is randomly configured/Previously, it is randomly configured/
2 internal slots in what? I'm not sure I understand what is claimed here: it sounds like we'll consistently use |codeBlock| for the
Regarding these 3 cases, are you saying that this is how we previously do it? Or are you saying that this is the new way of doing it? Can you make that clear?
What is the "it" that we need to keep alive? Do you mean the
Do you mean we'll move the
Here, do you mean that when A calls B, A needs to stash B's Jumping into the code now ... |
LLInt's slots. See WebAssembly.asm's code doing that. As the same to LLInt's callee-save register area, we allocate 2 slots, and use it for WasmCodeBlock purpose.
WasmCodeBlock slot. "this slot for Wasm::Callee* instead. This slot is "WasmCodeBlock""
No, they are the new way in this patch.
"wasm function"
Not move. Store
No. Just storing B's
|
75abe4a to
b7d4d04
Compare
|
EWS run on current version of this PR (hash b7d4d04) Details
|
|
EWS run on previous version of this PR (hash b7d4d04) Details |
b7d4d04 to
014af4f
Compare
|
EWS run on previous version of this PR (hash 014af4f) Details |
014af4f to
e93a5c3
Compare
|
EWS run on current version of this PR (hash e93a5c3) Details |
There was a problem hiding this comment.
I almost think we should have a second enum mirroring CallFrameSlot that has all the wasm slots. But we can do that another day. Alternatively, we could rename this to CallFrameSlot::jsCodeBlockOrWasmInstance but I think having two enums is clearer.
There was a problem hiding this comment.
Ditto, on the comment here.
https://bugs.webkit.org/show_bug.cgi?id=250822 rdar://104410328 Reviewed by Mark Lam. This patch fixes wasm calling convention problems. The new one becomes much simpler and robust (and fixing existing bugs). 1. We remove vm.wasmContext.instance field. Previously, it was randomly configured and a lot code is missing the update of this thing (for example, wasm context switching inside wasm -> wasm call missed the update). We should not have this kind of "global" variable and instead we should query to CallFrame about Wasm::Instance* of the current CallFrame*. 2. Each wasm function stores Wasm::Instance* to the CallFrame. We use |codeBlock| slot for that purpose. Since it is next to |callee| slot, we can use storePairPtr in ARM64, no code size increase. Plus, because we are already writing |callee| slot, it does not add new performance problem. This change makes CallFrame::lexicalGlobalObjectFromWasmCallee super simple since we can just get this slot from CallFrame instead of getting it from vm.wasmContext.instance. And it also makes Interpreter::unwind much simpler since we no longer need to book-keep this variable in unwinding case. And this also contributes to code size reduction in Wasm IC since we no longer need to have store and load code for vm.wasmContext.instance. 3. We use |codeBlock| slot for Wasm::Instance*. However, Wasm LLInt already used it for Wasm::Callee* (wasm's codeblock). This patch allocates 2 internal slots for Wasm::LLInt code and use this slot for Wasm::Callee* instead. This slot is "WasmCodeBlock". 4. We revise the use of |this| slot for wasm functions. Previously, it was randomly used. But we use this slot to anchor JSWebAssemblyInstance from conservative GC root. While we are keeping Wasm::Instance* in the stack, it is not GC-managed cell. To keep Wasm functions alive while running, we need to anchor JSWebAssemblyInstance* from conservative GC root. We use this slot in three cases. (1) Calling wasm function from JS world / C++ world so that we need to keep wasm function alive. (2) We wasm-tail-call to a new function. Since tail-call can wipe the previous frame, if it is the entrance frame created by (1), we miss the anchor. Conservatively, we always store this cell in tail-call case. (3) And we do this when calling wasm function indirectly. This could switch to a new wasm instance, so we should keep a new instance anchored from the stack. This change wipes a lot of weird things in wasm and makes calling convention much simpler. * Source/JavaScriptCore/interpreter/Interpreter.cpp: (JSC::UnwindFunctor::operator() const): * Source/JavaScriptCore/interpreter/ProtoCallFrame.h: * Source/JavaScriptCore/llint/WebAssembly.asm: * Source/JavaScriptCore/wasm/WasmAirIRGeneratorBase.h: (JSC::Wasm::ExpressionType>::AirIRGeneratorBase): * Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::insertConstants): * Source/JavaScriptCore/wasm/WasmCallingConvention.h: * Source/JavaScriptCore/wasm/WasmIRGeneratorHelpers.h: (JSC::Wasm::emitCatchPrologueShared): * Source/JavaScriptCore/wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): Canonical link: https://commits.webkit.org/259139@main
e93a5c3 to
c9c2f34
Compare
|
Committed 259139@main (c9c2f34): https://commits.webkit.org/259139@main Reviewed commits have been landed. Closing PR #8815 and removing active labels. |
🧪 style
c9c2f34
e93a5c3
🛠 🧪 win🛠 wincairo🧪 ios-wk2🧪 api-mac🧪 api-ios🧪 mac-wk1🧪 mac-wk2🧪 mac-AS-debug-wk2🧪 mac-wk2-stress