KevinRizzoTO opened PR #6119 from wasmtime-winch-integration
to main
:
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->Another big thank you to @alexcrichton for helping out with this and wiring up some of the initial pieces!
What this includes:
- wiring up the
wasmtime_environ::Compiler
trait for Winch withwasmtime
- including a new compilation strategy for winch to be used in the
Config
- the new
compiler
flag for the CLI, which will help us a lot in testing winch features- an initial implementation of the host-to-wasm trampoline for winch so it can be called in
wasmtime
Things to note:
- only supports
x86_64
, as winch is interacting on it should fill out other architectures- support for
Typed
functions isn't included, these don't use trampolines which winch requires at this time- no changes to support the
Wasmtime*
calling conventions- the new trampoline doesn't all callee-saved registers prior to the function call, nor does it restore them prior to the epilogue
KevinRizzoTO requested elliottt for a review on PR #6119.
KevinRizzoTO requested wasmtime-compiler-reviewers for a review on PR #6119.
KevinRizzoTO requested jameysharp for a review on PR #6119.
KevinRizzoTO requested wasmtime-core-reviewers for a review on PR #6119.
KevinRizzoTO requested wasmtime-default-reviewers for a review on PR #6119.
KevinRizzoTO edited PR #6119 from wasmtime-winch-integration
to main
:
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->Another big thank you to @alexcrichton for helping out with this and wiring up some of the initial pieces!
What this includes:
- wiring up the
wasmtime_environ::Compiler
trait for Winch withwasmtime
- including a new compilation strategy for winch to be used in the
Config
- the new
compiler
flag for the CLI, which will help us a lot in testing winch features- an initial implementation of the host-to-wasm trampoline for winch so it can be called in
wasmtime
Things to note:
- only supports
x86_64
, as winch is interacting on it should fill out other architectures- support for
Typed
functions isn't included, these don't use trampolines which winch requires at this time- no changes to support the
Wasmtime*
calling conventions- the new trampoline doesn't all callee-saved registers prior to the function call, nor does it restore them prior to the epilogue
The intention is to work on the above iteratively, but this first pass will make it much easier to test winch. We've been manually running it's output in a test environment, but moving that over to
wasmtime
would greatly simplify the process.
jameysharp submitted PR review.
jameysharp created PR review comment:
I think the
Strategy
variants for Cranelift and Winch need to be present even if the corresponding features are disabled. Bothcli-flags
and thebuild_compiler
function here will fail to build if either is disabled otherwise.
jameysharp created PR review comment:
Could you put this
winch
feature declaration next to thecranelift
feature above? A brief comment resembling the one for thecranelift
feature would be nice too.
jameysharp created PR review comment:
FYI, @fitzgen and I are working on changing how all the trampolines work. No need to block merging this PR for that, but we may call on you to help with the Winch side of that work once we've sorted out how the Cranelift version needs to go.
jameysharp submitted PR review.
alexcrichton submitted PR review.
saulecabrera submitted PR review.
saulecabrera created PR review comment:
Thanks for bringing this up @jameysharp. This is something that we've discussed during the Winch meetings. We are aware that these changes are coming with support for tail calls.
but we may call on you to help with the Winch side of that work once we've sorted out how the Cranelift version needs to go.
Absolutely. I'll note that since Winch is still in development we can easily adjust here moving forward.
saulecabrera submitted PR review.
saulecabrera submitted PR review.
saulecabrera created PR review comment:
Small nit: can we remove this comment?
saulecabrera created PR review comment:
I had introduced https://github.com/bytecodealliance/wasmtime/blob/main/winch/environ/src/lib.rs to be able to share the implementation of this trait with Winch's CLI and
wasmtime-winch
. Could we use it here instead?
saulecabrera created PR review comment:
// For now, winch is only supported on x86_64 when running through Wasmtime.
saulecabrera created PR review comment:
// The host to wasm trampoline is currently hard coded (see vmcontext.rs in the // wasmtime-runtime crate, VMTrampoline). // The first two parameters are VMContexts (not used at this time). // The third parameter is the function pointer to call. // The fourth parameter is an address to storage space for both the return value and the // arguments to the function.
saulecabrera created PR review comment:
// How much we need to adjust the stack pointer by to account for the alignment // required by the ISA.
saulecabrera created PR review comment:
// Hard-coding the size in bytes of the trampoline arguments since it's static, based on // the current signature we should always have 4 arguments, each of which is 8 bytes. ~~~
saulecabrera created PR review comment:
Could you apply the same suggestion to the rest of the comments in the file?
KevinRizzoTO updated PR #6119 from wasmtime-winch-integration
to main
.
KevinRizzoTO updated PR #6119 from wasmtime-winch-integration
to main
.
KevinRizzoTO submitted PR review.
KevinRizzoTO created PR review comment:
I was able to use this with a few modifications! I had to change the signature to accept a reference to a box so it could e used from the
wasmtime-winch
side.
KevinRizzoTO updated PR #6119 from wasmtime-winch-integration
to main
.
KevinRizzoTO submitted PR review.
KevinRizzoTO created PR review comment:
Good catch here! I've removed the feature gates, so we can let the errors throw when building the compiler if the right features aren't set.
KevinRizzoTO updated PR #6119 from wasmtime-winch-integration
to main
.
saulecabrera submitted PR review.
KevinRizzoTO edited PR #6119:
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->Another big thank you to @alexcrichton for helping out with this and wiring up some of the initial pieces!
What this includes:
- wiring up the
wasmtime_environ::Compiler
trait for Winch withwasmtime
- including a new compilation strategy for winch to be used in the
Config
- the new
compiler
flag for the CLI, which will help us a lot in testing winch features- an initial implementation of the host-to-wasm trampoline for winch so it can be called in
wasmtime
Things to note:
- only supports
x86_64
, as winch is iterating on it should fill out other architectures- support for
Typed
functions isn't included, these don't use trampolines which winch requires at this time- no changes to support the
Wasmtime*
calling conventions- the new trampoline doesn't all callee-saved registers prior to the function call, nor does it restore them prior to the epilogue
The intention is to work on the above iteratively, but this first pass will make it much easier to test winch. We've been manually running it's output in a test environment, but moving that over to
wasmtime
would greatly simplify the process.
KevinRizzoTO edited PR #6119:
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->Another big thank you to @alexcrichton for helping out with this and wiring up some of the initial pieces!
What this includes:
- wiring up the
wasmtime_environ::Compiler
trait for Winch withwasmtime
- including a new compilation strategy for winch to be used in the
Config
- the new
compiler
flag for the CLI, which will help us a lot in testing winch features- an initial implementation of the host-to-wasm trampoline for winch so it can be called in
wasmtime
Things to note:
- only supports
x86_64
, as winch is iterating on it should fill out other architectures- support for
Typed
functions isn't included, these don't use trampolines which winch requires at this time- no changes to support the
Wasmtime*
calling conventions- the new trampoline doesn't save all callee-saved registers prior to the function call, nor does it restore them prior to the epilogue
The intention is to work on the above iteratively, but this first pass will make it much easier to test winch. We've been manually running it's output in a test environment, but moving that over to
wasmtime
would greatly simplify the process.
KevinRizzoTO updated PR #6119.
KevinRizzoTO updated PR #6119.
KevinRizzoTO updated PR #6119.
KevinRizzoTO updated PR #6119.
KevinRizzoTO submitted PR review.
KevinRizzoTO created PR review comment:
@jameysharp (and possibly @alexcrichton) for additional context, adding this feature here allows the docs creation to pass. Attempting to add it the the
wasmtime/Cargo.toml
doesn't for some reason :thinking: (at least when run locally)
jameysharp submitted PR review.
jameysharp created PR review comment:
I have a hypothesis about proximate cause, but there are several things that don't make sense about this to me.
It seems like different crates are disagreeing about whether the
component-model
feature should be enabled.I think wasmtime-winch has it disabled, while wasmtime-environ and wasmtime have it enabled. Adding the
winch
feature to the wasmtime crate causes it to forward its value for this feature to wasmtime-winch, making it agree with wasmtime-environ.But I don't see why either wasmtime or wasmtime-environ would have this feature enabled given that
cargo doc
invocation.Since Alex is out of the office right now, I'm wondering if @fitzgen can figure anything out about this.
KevinRizzoTO created PR review comment:
Ah yeah the only thing that I see that could possibly explain it is this. The curious part is adding
winch
to this doesn't fix the error when I run thecargo doc
command locally :thinking:
KevinRizzoTO submitted PR review.
saulecabrera submitted PR review.
saulecabrera created PR review comment:
@jameysharp I spent some time on this issue today, but still can't quite figure out why
wasmtime-environ
is expecting acomponent_compiler
implementation even though the feature is not explicitly enabled forcargo doc
and as far as I can tell, it's not set as default feature anywhere in the workspace. One thing that I discovered though, is that everything works as expected if thecomponent-model
feature is passed to thecargo doc
invocation in the github workflow, which would match the invocation that doc.rs will make according to docs metadata entry:[package.metadata.docs.rs] rustdoc-args = ["--cfg", "nightlydoc"] features = ["component-model"]
So I think that using the
component-model
feature in the CI workflow is preferred over usingwinch
since this is what docs.rs will use for the documentation anyway.I was wondering if you'd be good with this change as a short term fix and I'll circle back with Alex when is back.
saulecabrera edited PR review comment.
saulecabrera updated PR #6119.
saulecabrera submitted PR review.
saulecabrera created PR review comment:
Your previous comment around the doc attribute was added in https://github.com/bytecodealliance/wasmtime/pull/6119/commits/4d16393b202f594c79eca7ea080a4a9bf65e6fc6 and the approach described in my previous comment was added in https://github.com/bytecodealliance/wasmtime/pull/6119/commits/82e119485ed68dba122655139e9c6d2393aa6b64.
saulecabrera edited PR review comment.
jameysharp submitted PR review.
jameysharp created PR review comment:
Yup, that feels entirely reasonable to me. I appreciate that you also added comments to the CI config mentioning the docs.rs configuration. Would you also add the reverse direction—a brief comment in the docs.rs metadata pointing to the CI config? With that, I think this is good to merge.
saulecabrera updated PR #6119.
saulecabrera has enabled auto merge for PR #6119.
saulecabrera updated PR #6119.
saulecabrera has enabled auto merge for PR #6119.
saulecabrera updated PR #6119.
saulecabrera has enabled auto merge for PR #6119.
saulecabrera updated PR #6119.
saulecabrera updated PR #6119.
saulecabrera has enabled auto merge for PR #6119.
saulecabrera merged PR #6119.
Last updated: Nov 22 2024 at 16:03 UTC