wasmtime icon indicating copy to clipboard operation
wasmtime copied to clipboard

cranelift: stack-switching support

Open posborne opened this issue 6 months ago • 1 comments

These changes pull in the cranelift changes from #10177 with some additional stacked changes to resolve conflicts, align with previous changes in the stack-switching series, and address feedback items which were raised on previous iterations of the PR (but mostly not changing anything of significant substance). Tracking Issue: #10248.

The stack-switching feature flag is retained and used minimally in this changeset in order to avoid compilation problems, but not really used beyond that. There is at least one item in the tracking issue already related to likely finding a way to drop these compilation flags in most places but I think it is worth deferring that here as it will required touching code more broadly.

CC @frank-emrich @dhil

posborne avatar Jun 10 '25 17:06 posborne

Pushed most of the updates but still need to make the suggested updates around the fat pointer stuff and resolve conflicts with upstream.

posborne avatar Jun 16 '25 16:06 posborne

@fitzgen I believe this is ready for review again, let me know if there's pieces I missed in my previous updates. As noted, I chose to defer fatpointer changes for now to be potentially addressed as part of (or following) changes to the translation stack.

posborne avatar Jun 23 '25 16:06 posborne

@fitzgen I am hunting down one regression with the latest, probably around the changes to table ops based on wasm types (though I haven't found a smoking gun yet). These tests passed prior to some of the latest changes on this branch and the test is doing a table.grow of continuations followed by a resume of the first added to the table which traps on a null reference.

posborne avatar Jul 01 '25 17:07 posborne

Pulled in and resolved conflicts (some pretty mild ones from https://github.com/bytecodealliance/wasmtime/pull/11216. @fitzgen Review would be appreciated; I think in our last convos I had played around with a different fatpointer impl but I'm fine with this as-is (possibly to revisit later on).

posborne avatar Jul 14 '25 17:07 posborne

@posborne is this ready for review now?

fitzgen avatar Aug 27 '25 15:08 fitzgen

@fitzgen Yes, should be ready for review -- I'll just push a fixup for the CI issues. I sent a side note in zulip but I'll repost here:

Ok, I got around to updating the branch with (hopefully) a final set of changes. Since we had been going back-and-forth on VMContObj alignment a bit I did end up changing this to natural alignment with revision now being defined as a usize.

Along with that I updated the cranelift fatpointer code and libcalls to work with the usize and to use an appropriate fat pointer container ir type for two words -- for this I had to plumb through a size type for that layer matching what exists for components (https://github.com/bytecodealliance/wasmtime/pull/11003/commits/078002aa024fe825f148f9dbcf864049bcf708ba).

Since the changes were a bit more substantive I will wait for a fresh review of that -- there were some merge conflicts related to the other changes in func_environ but they were pretty straightforward to address.

In parallel, I'll work on a rebase of the test changes to get a bit of extra validation as there isn't a lot in tree to cover things end-to-end on its own.

posborne avatar Aug 27 '25 16:08 posborne

@fitzgen I did run the test changes now -- a subset of those tests are now failing as it looks like there are some codepaths hit due to upstream changes where we end up calling Val::null_top which currently panics for continuation types.

posborne avatar Aug 27 '25 19:08 posborne

@fitzgen I did run the test changes now -- a subset of those tests are now failing as it looks like there are some codepaths hit due to upstream changes where we end up calling Val::null_top which currently panics for continuation types.

To get tests going with the upstream stuff, I did end up adding a minimal Val::ContRef member which doesn't seem avoidable. I tried to keep this as small and I could bundle it with the test changes, but it does appear to be required in order to have ref.null globals for continuations and some other cases.

posborne avatar Aug 27 '25 22:08 posborne

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "cranelift", "cranelift:area:x64", "wasmtime:api", "wasmtime:ref-types"

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

  • fitzgen: wasmtime:ref-types

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

Learn more.

github-actions[bot] avatar Aug 28 '25 02:08 github-actions[bot]

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "fuzzing", "wasmtime:c-api"

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

  • fitzgen: fuzzing

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

Learn more.

github-actions[bot] avatar Aug 28 '25 17:08 github-actions[bot]