-
Notifications
You must be signed in to change notification settings - Fork 280
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
Stabilize wasm32 memory-related intrinsics #613
Conversation
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.
LGTM.
coresimd/wasm32/memory.rs
Outdated
@@ -47,9 +48,10 @@ pub unsafe fn size(mem: i32) -> i32 { | |||
#[inline] | |||
#[cfg_attr(test, assert_instr("memory.grow", mem = 0))] | |||
#[rustc_args_required_const(0)] | |||
pub unsafe fn grow(mem: i32, delta: i32) -> i32 { | |||
#[stable(feature = "simd_wasm32", since = "1.33.0")] | |||
pub unsafe fn memory_grow(mem: u32, delta: usize) -> 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.
memory.grow
conceptually returns the value that memory.size
would return after the resize, which suggests that it should be usize rather than isize (with the error value being usize::MAX
rather than -1
). However, I don't think it'll make a big difference in practice, so I don't feel strongly about it.
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.
Good point. User programs can use as
to go either way anyways, and to me it feels that both approaches have downsides - using isize
might mean that negative values might indicate success, while using usize
will confuse those trying to use -1
here to catch errors like the spec suggests =/
Using usize
here and updating the docs to suggest using usize::MAX
feels like the lesser evil.
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.
That sounds reasonable to me! I've switched to usize
and documented the return value on failure. Thanks for the suggestions @sunfishcode!
This commit stabilizes the wasm32 memory-related intrinsics, as specified in rust-lang/rust#56292. The old intrinsics were removed and the current intrinsics were updated in place, but it's the last breaking change!
a4f9689
to
30da169
Compare
This commit stabilizes the wasm32 memory-related intrinsics, as
specified in rust-lang/rust#56292. The old intrinsics were removed and
the current intrinsics were updated in place, but it's the last breaking
change!