Skip to content
New issue

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

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

Already on GitHub? # to your account

s390x: Support tail calls #9052

Merged
merged 1 commit into from
Aug 1, 2024
Merged

Conversation

uweigand
Copy link
Member

This adds support for a newly defined tail-call ABI for s390x as well as supporting tail calls themselves.

We now use the tail-call ABI by default for Wasmtime, and enable tail calls by default.

This also allows getting rid of a number of special case and test exclusions for s390x.

Fixes: #6530

@uweigand uweigand requested review from a team as code owners July 31, 2024 15:11
@uweigand uweigand requested review from elliottt and removed request for a team July 31, 2024 15:11
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. isle Related to the ISLE domain-specific language wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime labels Jul 31, 2024
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "cranelift", "cranelift:area:machinst", "isle", "wasmtime:api", "wasmtime:config"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link

Label Messager: wasmtime:config

It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:

  • If you added a new Config method, you wrote extensive documentation for
    it.

    Our documentation should be of the following form:

    Short, simple summary sentence.
    
    More details. These details can be multiple paragraphs. There should be
    information about not just the method, but its parameters and results as
    well.
    
    Is this method fallible? If so, when can it return an error?
    
    Can this method panic? If so, when does it panic?
    
    # Example
    
    Optional example here.
    
  • If you added a new Config method, or modified an existing one, you
    ensured that this configuration is exercised by the fuzz targets.

    For example, if you expose a new strategy for allocating the next instance
    slot inside the pooling allocator, you should ensure that at least one of our
    fuzz targets exercises that new strategy.

    Often, all that is required of you is to ensure that there is a knob for this
    configuration option in wasmtime_fuzzing::Config (or one
    of its nested structs).

    Rarely, this may require authoring a new fuzz target to specifically test this
    configuration. See our docs on fuzzing for more details.

  • If you are enabling a configuration option by default, make sure that it
    has been fuzzed for at least two weeks before turning it on by default.


To modify this label's message, edit the .github/label-messager/wasmtime-config.md file.

To add new label messages or remove existing label messages, edit the
.github/label-messager.json configuration file.

Learn more.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Nice!

I didn't evaluate the details of the calling convention, as s390x isn't my area of expertise, but everything looks great in general, and I was very pleased to see the updates to the runtests and fuzzgen. Couple nitpick-y suggestions below, but I think this is basically good to go.

Thanks, Ulrich!!

&MemArg::InitialSPOffset { off } => MemArg::InitialSPOffset { off: off + offset },
&MemArg::NominalSPOffset { off } => MemArg::NominalSPOffset { off: off + offset },
&MemArg::SlotOffset { off } => MemArg::SlotOffset { off: off + offset },
_ => unreachable!(),
Copy link
Member

Choose a reason for hiding this comment

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

What cases is this matching? I think it might be better to explicitly list them, rather than using _, so that if more MemArg variants are added in the future we don't forget to consider/update this case.

Comment on lines 1316 to 1321
pub struct EmitState {
pub(crate) initial_sp_offset: i64,
pub(crate) nominal_sp_offset: u32,
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some documentation for what the nominal SP is and what its relation to the actual SP is? This was something that I always forgot the nitty-gritty details of in the old system, so if we are bringing part of it back, I think it would be helpful to have comments spelling those things out.

Comment on lines 1338 to 1341
/// Get the return area pointer register.
pub fn ret_area_ptr(&self) -> Reg {
self.ret_area_ptr.unwrap()
}
Copy link
Member

Choose a reason for hiding this comment

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

We don't always have a return area pointer, so I think this should return an Option<Reg> and let callers do the unwrap if they have knowledge of why it definitely exists in their specific case.

Suggested change
/// Get the return area pointer register.
pub fn ret_area_ptr(&self) -> Reg {
self.ret_area_ptr.unwrap()
}
/// Get the return area pointer register, if any.
pub fn ret_area_ptr(&self) -> Option<Reg> {
self.ret_area_ptr
}

Comment on lines 1004 to 1006
;; Incoming return area pointer.
(decl abi_ret_area_ptr () Reg)
(extern constructor abi_ret_area_ptr abi_ret_area_ptr)
Copy link
Member

Choose a reason for hiding this comment

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

And then this external constructor could be called unwrap_abi_ret_area_ptr or some such.

Comment on lines 25 to +26
(
false,
true,
Copy link
Member

Choose a reason for hiding this comment

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

\o/

This adds support for a newly defined tail-call ABI for s390x
as well as supporting tail calls themselves.

We now use the tail-call ABI by default for Wasmtime, and
enable tail calls by default.

This also allows getting rid of a number of special case
and test exclusions for s390x.

Fixes: bytecodealliance#6530
@uweigand
Copy link
Member Author

uweigand commented Aug 1, 2024

Thanks for the review, @fitzgen ! The latest version should address all review comments.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Thanks!

@fitzgen fitzgen added this pull request to the merge queue Aug 1, 2024
Merged via the queue into bytecodealliance:main with commit a7272b8 Aug 1, 2024
68 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cranelift: get tail calls working on s390x
2 participants