Skip to content

cranelift: stack-switching support #11003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2ab6356
cranelift: stack-switching support
frank-emrich Apr 21, 2025
0853a16
cranelift: stack-switching updates pass 1
posborne Jun 5, 2025
858b22a
cranelift: stack-switching: restore original visibility for a few fun…
posborne Jun 6, 2025
43a3972
cranelift: stack-switching conditional compilation
posborne Jun 6, 2025
100d621
cranelift: avoid "as" casts in stack-switching
posborne Jun 6, 2025
00c2b56
cranelift: cleanup stack-switching control_effect signatures
posborne Jun 6, 2025
e9fa92d
cranelift: rename stack-switching VMArray to VMHostArray
posborne Jun 6, 2025
866fbff
stack-switching: fix typo
posborne Jun 11, 2025
115e503
stack-switching: used Index impl for get_stack_slot_data
posborne Jun 11, 2025
11c6b4a
stack-switching: use smallvec over vec in several cases
posborne Jun 11, 2025
fa8001e
stack-switching: avoid resumetable naming confusion
posborne Jun 11, 2025
51017f2
stack-switching: cleanup unused params from unchecked_get_continuation
posborne Jun 11, 2025
44c2b34
stack_switching: simplify store_data_entries assertion
posborne Jun 11, 2025
b8fb8b3
stack-switching: simplify translate_table_{grow,fill} control flow
posborne Jun 11, 2025
a693350
stack-switching: remove translate_resume_throw stub
posborne Jun 12, 2025
eeab1b1
stack-switching: compute control_context_size based on target triple
posborne Jun 12, 2025
3bd138f
stack-switching: VMHostArrayRef updates
posborne Jun 16, 2025
49313bc
stack-switching: move cranelift code to live under func_environ
posborne Jun 18, 2025
5ccd3f7
Merge remote-tracking branch 'upstream/main' into stack-switching-cra…
posborne Jun 18, 2025
c86b06a
stack-switching: formatting fix
posborne Jun 18, 2025
ab50f6c
stack-switching: reduce visibility on a few additional items
posborne Jun 25, 2025
6797ea2
stack-switching: simplify contobj fatptr con/de-struction
posborne Jun 26, 2025
a6a3ff8
stack-switching: add disas tests to cover new instructions
posborne Jun 30, 2025
71c1e6d
Merge remote-tracking branch 'upstream/main' into stack-switching-cra…
posborne Jun 30, 2025
ba013f9
stack-switching: fix layout of VMContObj
posborne Jul 2, 2025
3a26125
Merge remote-tracking branch 'upstream/main' into stack-switching-cra…
posborne Jul 14, 2025
8d06297
Fix formatting of merge conflict resolution
posborne Jul 14, 2025
cae4878
cranelift: remove ir::function::get_stack_slot_data
posborne Jul 14, 2025
2bdfb25
Merge remote-tracking branch 'upstream/main' into stack-switching-cra…
posborne Jul 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cranelift/codegen/src/isa/x64/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl ABIMachineSpec for X64ABIMachineSpec {
mut args: ArgsAccumulator,
) -> CodegenResult<(u32, Option<usize>)> {
let is_fastcall = call_conv == CallConv::WindowsFastcall;
let is_tail = call_conv == CallConv::Tail;

let mut next_gpr = 0;
let mut next_vreg = 0;
Expand Down Expand Up @@ -181,6 +182,11 @@ impl ABIMachineSpec for X64ABIMachineSpec {
// This is consistent with LLVM's behavior, and is needed for
// some uses of Cranelift (e.g., the rustc backend).
//
// - Otherwise, if the calling convention is Tail, we behave as in
// the previous case, even if `enable_llvm_abi_extensions` is not
// set in the flags: This is a custom calling convention defined
// by Cranelift, LLVM doesn't know about it.
//
// - Otherwise, both SysV and Fastcall specify behavior (use of
// vector register, a register pair, or passing by reference
// depending on the case), but for simplicity, we will just panic if
Expand All @@ -194,6 +200,7 @@ impl ABIMachineSpec for X64ABIMachineSpec {
if param.value_type.bits() > 64
&& !(param.value_type.is_vector() || param.value_type.is_float())
&& !flags.enable_llvm_abi_extensions()
&& !is_tail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Wasm doesn't have 128bit integers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least in this iteration of the changes, the stack switching code is using an i128 for it's vmcontobj fat pointer (consisting of vmcontref pointer and revision). @fitzgen and I have discussed a bit about how we can get rid of this and just have two ir values through the transformation, but it will require some additional changes to how we model the relationship between wasm and clif values to support having one of the former map to two distinct ir values.

{
panic!(
"i128 args/return values not supported unless LLVM ABI extensions are enabled"
Expand Down
Loading
Loading