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.
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... |
calebzulawski
left a comment
There was a problem hiding this comment.
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,
unsafelibrary authors,and eventually ourselves.
This closes #244.