-
Notifications
You must be signed in to change notification settings - Fork 287
add wasm64 support #974
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 wasm64 support #974
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
#[doc(cfg(any(target_arch = "wasm32", target_arch = "wasm64")))] | ||
#[stable(feature = "", since = "0.0.0")] | ||
pub mod wasm { | ||
#[stable(feature = "", since = "0.0.0")] |
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.
This should probably be private. Even x86
and x86_64
are only available on the respective targets despite the fact that x86_64
re-exports everything in x86
.
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.
What i was trying to do here was avoid people having to write
#[cfg(target_os = "wasm32")]
use core::arch::wasm32 as wasm;
#[cfg(target_os = "wasm64")]
use core::arch::wasm64 as wasm;
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.
This doesn't match what we do for x86
/x86_64
right now, however, where you only get one or the other. I think that we'll want to stick to a wasm32
and a wasm64
module for now to mirror that. The core::arch
module isn't optimized for ergonomic usage, but rather optimized for developers (us) to add intrinsics in a known location.
This looks good to me, thanks! I do think though that there shouldn't be a |
☔ The latest upstream changes (presumably 8724eb4) made this pull request unmergeable. Please resolve the merge conflicts. |
b025da3
to
1e8e134
Compare
I feel very strongly that we should encourage the abstraction of wasm32 and wasm64, both in rust internals and to users of rust. They are not really different targets, and code that specializes on one of them just makes developing for wasm more difficult. |
My thinking here is that wasm should follow established precedent primarily and not try to be that different compared to other platforms. It seems like all the issues for wasm32/wasm64 would be the same in Rust's x86 and x86_64 land as well. Given that hasn't been a huge issue leading to trying to have a unified module I'm not sure that it's worth trying to blaze the trail here with wasm. |
@alexcrichton what if we also include wasm64 here? so we'd have three. I'm open to other approaches but I'm not interested in landing this with no solution. |
If we can actually have the same intrinsics on all targets (using |
IIRC the I would definitely want to ensure that, where possible, we use the exact same types across the wasm32/wasm64 modules to enable reexporting. It'd be a bummer if something took an |
From my perspective the more important bit is usage of this. I have to go through and make all the core and std code work with both wasm32 and wasm64, which should (imo) be as simple as |
AFAIK core/std only very lightly use this module, so adding some |
☔ The latest upstream changes (presumably 768b238) made this pull request unmergeable. Please resolve the merge conflicts. |
updated to use bad pattern, pls review. also needs something for the |
@@ -41,7 +41,7 @@ | |||
bench_black_box | |||
)] | |||
#![cfg_attr(test, feature(test, abi_vectorcall))] | |||
#![cfg_attr(all(test, target_arch = "wasm32"), feature(wasm_simd))] | |||
#![cfg_attr(all(test, target_arch = "wasm32", target_arch = "wasm64"), feature(wasm_simd))] |
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.
#![cfg_attr(all(test, target_arch = "wasm32", target_arch = "wasm64"), feature(wasm_simd))] | |
#![cfg_attr(all(test, any(target_arch = "wasm32", target_arch = "wasm64")), feature(wasm_simd))] |
Otherwise this condition will always be false. But then again tests still seem to pass so maybe it isn't needed?
#[link_name = "llvm.wasm.memory.grow"] | ||
fn llvm_memory_grow(mem: u32, pages: isize) -> isize; | ||
#[link_name = "llvm.wasm.memory.size"] | ||
fn llvm_memory_size(mem: u32) -> isize; |
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.
Does LLVM still accept these intrinsics without the .i32
at the end? I've noticed that we don't actually have any tests for this.
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.
FWIW the assert_instr
on each intrinsic at least asserts that the codegen is correct, but you're right in that I don't think there's any runtime tests for these intrinsics.
/// See the [module documentation](../index.html) for more details. | ||
#[cfg(any(target_arch = "wasm64", doc))] | ||
#[doc(cfg(target_arch = "wasm64"))] | ||
#[stable(feature = "", since = "0.0.0")] |
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.
This should be unstable under simd_wasm64
for now.
/// generated in your program. This means to generate a binary without SIMD | ||
/// you'll need to avoid both options above plus calling into any intrinsics | ||
/// in this module. | ||
/// See the [module documentation](../index.html) for more details. |
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.
This point back to the docs for the arch
module, not the wasm
module.
//! enable SIMD via either of these mechanisms, you'll still have SIMD | ||
//! generated in your program. This means to generate a binary without SIMD | ||
//! you'll need to avoid both options above plus calling into any intrinsics | ||
//! in this module. |
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.
This module is private so these docs are not actually visible in the documentation.
☔ The latest upstream changes (presumably c313294) made this pull request unmergeable. Please resolve the merge conflicts. |
seems to be replaced by #1240 |
rust-lang/rust#80525
I took the approach of adding a new
arch::wasm
module which covers both wasm32 and wasm64.