Commit a631d20
cranelift: stack-switching support (#11003)
* cranelift: stack-switching support
This initial commit represents the "pr2" base commit with
minimal merge conflicts resolved. Due to OOB conflicts, this
commit is not functional as-is, but using it as a base in
order to allow for easier reviewing of the delta from
this commit to what will be used for the PR against upstream.
Co-authored-by: Daniel Hillerström <[email protected]>
Co-authored-by: Paul Osborne <[email protected]>
* cranelift: stack-switching updates pass 1
This first set of changes updates the base pr in order to
compiled and pass basic checks (compile, clippy, fmt) with
the biggest part of the change being to eliminate injection
of tracing/assertions in JIT'ed code.
* cranelift: stack-switching: restore original visibility for a few func_environ members
* cranelift: stack-switching conditional compilation
At this point, the only bit we really branch on is what we
do in order to avoid problems tying into wasmtime_environ.
This is basd on the approach and macro used by the gc code for
converting presence/absence of the cranelift feature flag to
cranelift compile time. This is a bit of a half-measure for now
as we still compile most stack-switching code in cranelift, but
this does enough to avoid causing problems with missing definitions
in wasmtime_environ.
* cranelift: avoid "as" casts in stack-switching
Replace either with infallible From or fallible, panicing
TryFrom alternatives where required.
* cranelift: cleanup stack-switching control_effect signatures
After removing emission of runtime trace logging and assertions,
there were several unused parameters. Remove those from the
ControlEffect signatures completely.
* cranelift: rename stack-switching VMArray to VMHostArray
This matches a change to the mirrored runtime type in
the upstream changes.
* stack-switching: fix typo
Co-authored-by: Daniel Hillerström <[email protected]>
* stack-switching: used Index impl for get_stack_slot_data
* stack-switching: use smallvec over vec in several cases
* stack-switching: avoid resumetable naming confusion
* stack-switching: cleanup unused params from unchecked_get_continuation
The extra parameters here used to be used for emitting runtime
assertions, but with those gone we just had unused params
and lifetimes, clean those out.
* stack_switching: simplify store_data_entries assertion
* stack-switching: simplify translate_table_{grow,fill} control flow
* stack-switching: remove translate_resume_throw stub
There's already a stub elsewhere and this is not called, when
exceptions are added and it is time to revisit, this method
can be restored.
* stack-switching: compute control_context_size based on target triple
* stack-switching: VMHostArrayRef updates
Rename VMHostArray -> VMHostArrayRef
Change impl to compute address with offset upfront rather than
on each load.
* stack-switching: move cranelift code to live under func_environ
This matches the directory structure for gc and aids in visibility
for a few members required by stack-switching code in cranelift.
* stack-switching: formatting fix
* stack-switching: reduce visibility on a few additional items
* stack-switching: simplify contobj fatptr con/de-struction
* stack-switching: add disas tests to cover new instructions
* stack-switching: fix layout of VMContObj
In the course of the various runtime updates, the layout of the
runtime VMContObj got switched around. This resulted in failures
when doing certain table operations on continuations.
This change fixes that layout problem and adds some tests with
offsets to avoid the problem. Due to the way that we interact
with the VMContObj in cranelift, we don't use these offsets outside
of the tests.
* Fix formatting of merge conflict resolution
* cranelift: remove ir::function::get_stack_slot_data
This method isn't required as sized_stack_slots is already pub.
* stack-switching: reduce visibility of a couple func_environ methods
* stack-switching: define VMContObj as two words
This change migrates VMContObj and its usages in cranelift and runtime
to work with the VMContObj fat pointer as two words in order to better
target different architectures (still gated to x86_64 for now).
To support this, a size type was plumbed into the builtins function
signature types (as is done for component types) that maps to
usize.
* fixup! stack-switching: define VMContObj as two words
* stack-switching: add stub Val::ContRef
This type is not fully complete until continuation/gc integration
is revisited (#10248) but without these changes, test cases are
now failing on panics as we need some representation of
continuation references in the runtime Val enumeration.
Runtime errors with TODO notes are added for the stubbed
code paths to revisit later.
* fixup! stack-switching: add stub Val::ContRef
* fixup! stack-switching: add stub Val::ContRef
* fixup! stack-switching: define VMContObj as two words
prtest:full
* stack-switching: don't conflate host and target pointer sizes
Disas tests were failing on i686 targeting x86_64 as the size of the
host pointer was leaking into what we were using to do codegen
in a few paths. This patch is a bit of a hack as it seems like
using a generic <T> for T: *mut u8 (as an example) is a bit
questionable. To keep things small, I do a hacky typecheck to map
pointers to the target pointer size here.
* stack-switching: VMHostArray entry sizes based off env PtrSize
Revisiting the previous commit with an approach that should be
less brittle.
---------
Co-authored-by: Frank Emrich <[email protected]>
Co-authored-by: Daniel Hillerström <[email protected]>1 parent 5764da5 commit a631d20
File tree
31 files changed
+3582
-102
lines changed- cranelift/codegen/src/isa/x64
- crates
- c-api/src
- cranelift/src
- func_environ/stack_switching
- translate
- environ/src
- fuzzing/src
- generators
- oracles
- wasmtime/src/runtime
- externals
- trampoline
- vm
- gc/enabled
- wave
- src/commands
- tests/disas/stack-switching
31 files changed
+3582
-102
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
184 | 190 | | |
185 | 191 | | |
186 | 192 | | |
| |||
194 | 200 | | |
195 | 201 | | |
196 | 202 | | |
| 203 | + | |
197 | 204 | | |
198 | 205 | | |
199 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
258 | 259 | | |
259 | 260 | | |
260 | 261 | | |
| 262 | + | |
261 | 263 | | |
262 | 264 | | |
263 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
174 | 185 | | |
175 | 186 | | |
176 | 187 | | |
| |||
224 | 235 | | |
225 | 236 | | |
226 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
227 | 241 | | |
228 | 242 | | |
229 | 243 | | |
| |||
1958 | 1972 | | |
1959 | 1973 | | |
1960 | 1974 | | |
1961 | | - | |
1962 | | - | |
1963 | 1975 | | |
1964 | 1976 | | |
1965 | 1977 | | |
| |||
1977 | 1989 | | |
1978 | 1990 | | |
1979 | 1991 | | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
1980 | 1995 | | |
1981 | 1996 | | |
1982 | 1997 | | |
| |||
2267 | 2282 | | |
2268 | 2283 | | |
2269 | 2284 | | |
2270 | | - | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
2271 | 2288 | | |
2272 | 2289 | | |
2273 | 2290 | | |
| |||
2320 | 2337 | | |
2321 | 2338 | | |
2322 | 2339 | | |
2323 | | - | |
2324 | | - | |
2325 | | - | |
2326 | | - | |
2327 | | - | |
2328 | | - | |
2329 | | - | |
2330 | 2340 | | |
2331 | 2341 | | |
2332 | | - | |
2333 | 2342 | | |
2334 | 2343 | | |
2335 | | - | |
2336 | | - | |
2337 | | - | |
2338 | | - | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
2339 | 2366 | | |
2340 | 2367 | | |
2341 | 2368 | | |
| |||
2367 | 2394 | | |
2368 | 2395 | | |
2369 | 2396 | | |
2370 | | - | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
2371 | 2406 | | |
2372 | 2407 | | |
2373 | 2408 | | |
| |||
2415 | 2450 | | |
2416 | 2451 | | |
2417 | 2452 | | |
2418 | | - | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
2419 | 2458 | | |
2420 | 2459 | | |
2421 | 2460 | | |
| |||
2429 | 2468 | | |
2430 | 2469 | | |
2431 | 2470 | | |
2432 | | - | |
2433 | | - | |
2434 | | - | |
2435 | 2471 | | |
2436 | | - | |
2437 | | - | |
2438 | | - | |
2439 | | - | |
2440 | | - | |
2441 | | - | |
2442 | | - | |
| 2472 | + | |
| 2473 | + | |
2443 | 2474 | | |
2444 | 2475 | | |
2445 | | - | |
2446 | | - | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
2447 | 2496 | | |
2448 | 2497 | | |
2449 | 2498 | | |
| |||
2795 | 2844 | | |
2796 | 2845 | | |
2797 | 2846 | | |
2798 | | - | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
2799 | 2851 | | |
2800 | 2852 | | |
2801 | 2853 | | |
| |||
2811 | 2863 | | |
2812 | 2864 | | |
2813 | 2865 | | |
2814 | | - | |
2815 | | - | |
2816 | | - | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
2817 | 2878 | | |
2818 | 2879 | | |
2819 | 2880 | | |
| |||
3556 | 3617 | | |
3557 | 3618 | | |
3558 | 3619 | | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
3559 | 3732 | | |
3560 | 3733 | | |
3561 | 3734 | | |
| |||
4138 | 4311 | | |
4139 | 4312 | | |
4140 | 4313 | | |
4141 | | - | |
4142 | | - | |
4143 | | - | |
4144 | | - | |
4145 | | - | |
4146 | | - | |
4147 | | - | |
4148 | | - | |
4149 | | - | |
4150 | | - | |
4151 | | - | |
4152 | | - | |
4153 | | - | |
4154 | | - | |
| |||
0 commit comments