You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 599f35b
Browse filesBrowse the repository at this point in the historyBrowse files
https://bugs.webkit.org/show_bug.cgi?id=311838
rdar://174428575
Reviewed by Yusuke Suzuki.
Rework how stack results are read after wasm calls so that they match
the location of equivalent arguments. This is preliminary work so tail
calls don't require whole-module analysis to determine where to restore
instance/memory pinned registers. In that world there may or may not be
an injected frame between any caller and callee shift the result
location by some constant. This makes the current calling convention
difficult to maintain as we don't know exactly which of the two offsets
to find results.
In this patch we go back to the original multi-value calling convention,
where arguments and results match. Any caller should copy stack results
before restoring SP.
Extracting the results differs based on the caller. For BBQ/IPInt we
move the stack results to their canonical location. In OMG,
createCallPatchpoint stack return value constraints use WarmAny so B3
can place results whereever it wants as they have to be copied anyway.
Due to an outstanding issue when graph coloring is enabled where we run
out of colors (aka registers) we use still use the argument's stack slot.
JSToWasm makes space for registers below the callee frame and fills the
register results there then calls to the appropriate operation to build
the result Array.
Old Wasm calling convention (before this patch):
Stack results were offset to the top of the area, so resultK was NOT at
the same address as argK:
+----------------------------+
| result1 | arg3 | <- resultStackOffset = headerSize + aligned - resultSize
+----------------------------+
| result0 | arg2 | <- results shifted, don't align with args
+----------------------------+
| | arg1 |
+----------------------------+
| | arg0 | <- argStackOffset = headerSize
+----------------------------+
| instance |
+----------------------------+
| wasmCallee |
+----------------------------+
| returnAddress |
+----------------------------+
| callerFrame | <- cfr
+----------------------------+
New Wasm calling convention (this patch):
Arguments and results share the same stack addresses. argK and resultK
occupy the same slot. The area is sized to max(args, results):
+----------------------------+ higher addresses
| ...... | |
+----------------------------+ |
| arg/result N | |
+----------------------------+ |
| ... | |
+----------------------------+ |
| arg/result 1 | |
+----------------------------+ |
| arg/result 0 | <- headerSize (args & results start here)
+----------------------------+ v lower addresses
| instance |
+----------------------------+
| wasmCallee |
+----------------------------+
| returnAddress |
+----------------------------+
| callerFrame | <- cfr
+----------------------------+
The Nth stack argument and the Nth stack result are at the exact same
address.
Also, this broke internal builds since a non-ASCII character was added
to the IPInt .asm file. Add a check we don't make the same mistake again.
No new tests, no behavior change, covered by existing tests.
Canonical link: https://commits.webkit.org/310952@main
# https://commits.webkit.org/310937@main broke builds because the files contained non-ASCII characters. Let's forbid non-ASCII early so we don't hit problems downstream.
// Our callee could have tail called someone else and changed SP so we need to restore it. Do this before restoring our results since results are stored at the top of the reserved stack space.
4510
+
// Push return value(s) onto the expression stack. Read results before restoring SP
4511
+
// since results are at the bottom of the arg/result area, addressable from the callee's SP.
// Our callee could have tail called someone else and changed SP so we need to restore it. Do this before restoring our results since results are stored at the top of the reserved stack space.
4594
+
// Read results before restoring SP since results are at the bottom of the
4595
+
// arg/result area, addressable from the callee's SP.
0 commit comments