-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for v128
to the typed function API
#7010
Conversation
This commit adds a Rust type `V128` which corresponds to the wasm `v128` type. This is intended to perhaps one day have accessors for lanes of various sizes but in the meantime only supports conversion back and forth between `u128`. The intention of this type is to allow platforms to perform typed between to functions that take or return `v128` wasm values. Previously this was not implemented because it's a bit tricky ABI-wise. Typed functions work by passing arguments in registers which requires the calling convention to match in both Cranelift and in Rust. This should be the case for supported platforms and the default calling convention, especially now that the wasm calling convention is separate from the platform calling convention. This does mean, however, that this feature can only be supported on x86_64 and AArch64. Currently neither s390x nor RISC-V have a means of supporting the vector calling convention since the vector types aren't available on stable in Rust itself. This means that it's now unfortunately possible to write a Wasmtime embedding that compiles on x86_64 that doesn't compile on s390x for example, but given how niche this feature is that seems like an ok tradeoff for now and by the time it's a problem Rust might have native stable support for vector types on these platforms. prtest:full
Subscribe to Label Actioncc @fitzgen, @peterhuene
This issue or pull request has been labeled: "fuzzing", "wasmtime:api", "wasmtime:c-api"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
union Reinterpret { | ||
abi: Abi, | ||
u128: u128, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat trick
I should also mention before I forget, it is theoretically possible to support v128 on all platforms. We are in control of our own ABI and we could say that the v128 type always maps to memory or a pair of u64 values. This would require rejiggering not only the Cranelift trampolines generated but additionally the |
* Add support for `v128` to the typed function API This commit adds a Rust type `V128` which corresponds to the wasm `v128` type. This is intended to perhaps one day have accessors for lanes of various sizes but in the meantime only supports conversion back and forth between `u128`. The intention of this type is to allow platforms to perform typed between to functions that take or return `v128` wasm values. Previously this was not implemented because it's a bit tricky ABI-wise. Typed functions work by passing arguments in registers which requires the calling convention to match in both Cranelift and in Rust. This should be the case for supported platforms and the default calling convention, especially now that the wasm calling convention is separate from the platform calling convention. This does mean, however, that this feature can only be supported on x86_64 and AArch64. Currently neither s390x nor RISC-V have a means of supporting the vector calling convention since the vector types aren't available on stable in Rust itself. This means that it's now unfortunately possible to write a Wasmtime embedding that compiles on x86_64 that doesn't compile on s390x for example, but given how niche this feature is that seems like an ok tradeoff for now and by the time it's a problem Rust might have native stable support for vector types on these platforms. prtest:full * Fix compile of C API * Conditionally enable typed v128 tests * Review comments * Fix compiler warnings
* Add support for `v128` to the typed function API This commit adds a Rust type `V128` which corresponds to the wasm `v128` type. This is intended to perhaps one day have accessors for lanes of various sizes but in the meantime only supports conversion back and forth between `u128`. The intention of this type is to allow platforms to perform typed between to functions that take or return `v128` wasm values. Previously this was not implemented because it's a bit tricky ABI-wise. Typed functions work by passing arguments in registers which requires the calling convention to match in both Cranelift and in Rust. This should be the case for supported platforms and the default calling convention, especially now that the wasm calling convention is separate from the platform calling convention. This does mean, however, that this feature can only be supported on x86_64 and AArch64. Currently neither s390x nor RISC-V have a means of supporting the vector calling convention since the vector types aren't available on stable in Rust itself. This means that it's now unfortunately possible to write a Wasmtime embedding that compiles on x86_64 that doesn't compile on s390x for example, but given how niche this feature is that seems like an ok tradeoff for now and by the time it's a problem Rust might have native stable support for vector types on these platforms. prtest:full * Fix compile of C API * Conditionally enable typed v128 tests * Review comments * Fix compiler warnings
This commit adds a Rust type
V128
which corresponds to the wasmv128
type. This is intended to perhaps one day have accessors for lanes of various sizes but in the meantime only supports conversion back and forth betweenu128
. The intention of this type is to allow platforms to perform typed between to functions that take or returnv128
wasm values.Previously this was not implemented because it's a bit tricky ABI-wise. Typed functions work by passing arguments in registers which requires the calling convention to match in both Cranelift and in Rust. This should be the case for supported platforms and the default calling convention, especially now that the wasm calling convention is separate from the platform calling convention. This does mean, however, that this feature can only be supported on x86_64 and AArch64. Currently neither s390x nor RISC-V have a means of supporting the vector calling convention since the vector types aren't available on stable in Rust itself. This means that it's now unfortunately possible to write a Wasmtime embedding that compiles on x86_64 that doesn't compile on s390x for example, but given how niche this feature is that seems like an ok tradeoff for now and by the time it's a problem Rust might have native stable support for vector types on these platforms.
prtest:full