Skip to content
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

Merged
merged 1 commit into from
Oct 22, 2019
Merged

Clarify sign/size of ABI types #279

merged 1 commit into from
Oct 22, 2019

Conversation

daviddrysdale
Copy link
Contributor

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).

@daviddrysdale
Copy link
Contributor Author

@tiziano88 Any thoughts?

docs/abi.md Outdated
Comment on lines 28 to 30
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).
Copy link
Collaborator

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.

Copy link
Contributor Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[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)

Copy link
Contributor Author

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).
@daviddrysdale daviddrysdale merged commit 4467abb into project-oak:master Oct 22, 2019
@daviddrysdale daviddrysdale deleted the abitypes branch October 22, 2019 16:01
daviddrysdale added a commit that referenced this pull request Oct 22, 2019
Auto-generated from commit 4467abb ("Clarify sign/size of ABI types (#279)").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants