Remove CallOnMainStack
Categories
(Core :: JavaScript: WebAssembly, task, P1)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox148 | --- | fixed |
People
(Reporter: rhunt, Assigned: rhunt)
References
Details
Attachments
(16 external files)
It'd be really nice if we had the invariant that only wasm code runs on a suspendable stack (with maybe a couple limited exceptions for performance reasons). Right now we have a bunch of native frames that can run on the suspendable stack. These sometimes will use CallOnMainStack to switch to the main stack before performing more work, but not always.
I have patches which update all of our wasm exits (import exit, trap stub, debug stub, and throw unwinder) to be suspendable stack aware and switch to the main stack before re-entering native code. This eliminates the need for CallOnMainStack and gives us a tighter invariant around the main stack and VM code.
| Assignee | ||
Comment 1•11 months ago
|
||
We don't gain much by having SuspenderContext separate from
wasm::Context, and will make future patches harder. This
patch merges them.
One side effect is that SuspenderObject is now a public
interface in WasmPI.h. This is required for other
changes and isn't unusual.
| Assignee | ||
Comment 2•11 months ago
|
||
I'd like to move all the logic for updating the VM state when a
suspender changes into a single location. wasm::Context makes the
most sense to me.
| Assignee | ||
Comment 3•11 months ago
|
||
We can just use activeSuspender for this and reduce the
amount of state we need to update.
| Assignee | ||
Comment 4•11 months ago
|
||
Continue moving more logic into a single place in
wasm::Context.
| Assignee | ||
Comment 5•11 months ago
|
||
Move more suspender switching logic into wasm::Context.
| Assignee | ||
Comment 6•11 months ago
|
||
This simplifies the logic when switching stacks to no longer
have to juggle a linked list. Suspender's also no longer need
to be linked list elements. It also removes the need to track
the suspender context for a given suspender.
| Assignee | ||
Comment 7•11 months ago
|
||
Also add assertions to accessors around current state.
| Assignee | ||
Comment 8•11 months ago
|
||
Now that we don't require a SuspenderObjectData to be a linked list
element, we can merge it with SuspenderObject. This reduces the number
of registers we need to for operations, and indirections to use.
The JIT routines are largely untouched and can be simplified in a
future patch.
| Assignee | ||
Comment 9•11 months ago
|
||
Now that they are actually the same thing, simplify their codegen.
| Assignee | ||
Comment 10•11 months ago
|
||
Now that the sequence of operations performed in a CallOnMain
operation have been simplified, we can perform them relatively
easily in JIT code.
Extend the Exit prologue and epilogues to optionally emit a
dynamic switch to the main stack when they are on a suspender.
| Assignee | ||
Comment 11•11 months ago
|
||
The debug and request tier-up stubs save and restore all allocatable
registers. This is unnecessary and confusing as baseline does not have
any live registers when these stubs are called. Add an assertion
to that effect and drop this code.
| Assignee | ||
Comment 12•11 months ago
|
||
Use the infrastructure added for builtin thunks for the import
interp exit.
| Assignee | ||
Comment 13•11 months ago
|
||
| Assignee | ||
Comment 14•11 months ago
|
||
| Assignee | ||
Comment 15•11 months ago
|
||
Builtin thunks are going to need more scratch registers for the
prologue/epilogue in order to do stack switches. Right now we
are using the sytem ABI for builtin thunks and this leaves us
with only 2 registers for the prologue and 1 register for the
epilogue. It is not feasible to expand this.
We could save/restore non-volatile registers, but this gets
really complicated when the stack is switching to figure out
which stack has the saved register on it.
An easier solution is to move builtin thunks back to using
the wasm ABI, which has no non-volatile registers and therefore
has a good amount of scratch registers that don't alias the
arg/result registers.
We still keep the code to call a builtin using the system ABI
and use that for builtins that don't have a thunk (such as
intgemm). A future commit will expand the number of builtins
which go without a thunk to reduce the overhead of the stack
switch.
A necessary change here is that we must now use saveLive/
restoreLive in some code that is around calling builtins
because we no longer have non-volatile registers.
| Assignee | ||
Comment 16•11 months ago
|
||
This has needed better documentation for a long time.
Driveby fix for ARM64 to ArgRegMask to remove x8. Doesn't appear
to be used anywhere and so it should not be a functional change.
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Comment 17•10 months ago
|
||
Comment 18•10 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/d4639f7a6899
https://hg.mozilla.org/mozilla-central/rev/ad9b3575badb
https://hg.mozilla.org/mozilla-central/rev/c77ba16f9dca
https://hg.mozilla.org/mozilla-central/rev/84638b55a198
https://hg.mozilla.org/mozilla-central/rev/888fe80a6574
https://hg.mozilla.org/mozilla-central/rev/c9b0fc11148f
https://hg.mozilla.org/mozilla-central/rev/d8979e40924d
https://hg.mozilla.org/mozilla-central/rev/e5969ca65b8c
https://hg.mozilla.org/mozilla-central/rev/9ad9ea0557aa
https://hg.mozilla.org/mozilla-central/rev/fb1b7507031d
https://hg.mozilla.org/mozilla-central/rev/9bcfab21ad81
https://hg.mozilla.org/mozilla-central/rev/be72032f10a2
https://hg.mozilla.org/mozilla-central/rev/3c23f9a837d3
https://hg.mozilla.org/mozilla-central/rev/96902a553d37
https://hg.mozilla.org/mozilla-central/rev/8753cd32504b
https://hg.mozilla.org/mozilla-central/rev/5ca5a0667c11
Updated•10 months ago
|
Description
•