-
Notifications
You must be signed in to change notification settings - Fork 113
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
Clarify sign/size of ABI types #279
Conversation
@tiziano88 Any thoughts? |
docs/abi.md
Outdated
In this document, integer types are written as `u32` or `u64` to indicate that | ||
the corresponding values will be treated as unsigned values. (There are | ||
currently no uses of signed values in the ABI). |
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.
Maybe this should say that we use a more precise description for the types in the API, referring to the interpretation of those values as either signed or unsigned in the target language. I guess this relies on C++, Rust and other languages to perform conversions between those types in a compatible way (which hopefully is the case, but I have not checked). In fact, if you know of any such reference, it would be good to include a link here, so we know what we can safely rely on for each language.
I think my preferred approach would be to keep using i32 / i64 in the API function signatures, and explain how to interpret those values in the description of each method. But I'll leave that to you to decide anyways.
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 still prefer the u32
/ u64
approach, not least to save boilerplate – every single parameter description in the ABI definition would need to have the same "This value is treated as an unsigned integer" / "This value is treated as an unsigned integer of size equivalent to Wasm linear memory size (currently always 32 bits)" text.
docs/abi.md
Outdated
|
||
are written as the `usize` type, which is an alias for the `u32` type in the | ||
current WebAssembly implementation(s). However, in any future | ||
[64-bit ](https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#linear-memory-bigger-than-4-gib) |
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.
[64-bit ](https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#linear-memory-bigger-than-4-gib) | |
[64-bit](https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#linear-memory-bigger-than-4-gib) |
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.
Done.
Use u32/u64/usize everywhere (all ABI values are treated as unsigned), with usize specifically indicating a linear memory address or size (so any future Wasm64 port would map usize->u64 instead of u32).
Use u32/u64/usize everywhere (all ABI values are treated as unsigned),
with usize specifically indicating a linear memory address or size
(so any future Wasm64 port would map usize->u64 instead of u32).