-
Notifications
You must be signed in to change notification settings - Fork 82
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
Explain unsafe contracts of core::simd #245
Conversation
This permeate the module with remarks on safety for pub methods, layout of the Simd type, correct use of intrinsics, et cetera. This is mostly to help others curious about how core::simd works, including other Rust contributors, `unsafe` library authors, and eventually ourselves.
My memory says this happens for wasm too. We did attempt to undo it for wasm but then had to revert that at some point to the memory-passing behavior due to it uncovering another bug. |
/// It is thus sound to [`transmute`] `Simd<T, N>` to `[T; N]`, and will typically optimize to zero cost, | ||
/// but the reverse transmutation is more likely to require a copy the compiler cannot simply elide. | ||
/// | ||
/// # ABI "Features" |
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.
I might change this to "ABI Limitations" and "pass by reference" instead of "pass by memory", though both of these are correct too
There was a bug passing u128 by value in wasm, too, so maybe it's not the best example... |
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.
Left one more comment, but lgtm
Ah, I want to avoid the term "pass by reference", because it risks conflating this behavior with the behavior of "proper" references and borrows. |
This permeates the module with remarks on safety for pub methods,
layout of the Simd type, correct use of intrinsics, et cetera.
This is mostly to help others curious about how core::simd works,
including other Rust contributors,
unsafe
library authors,and eventually ourselves.
This closes #244.