-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[embind] Reuse signature codes from em_asm. NFC #24611
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@sbc100 Would love your thoughts on this one. In other places we represent size_t aka unsigned long as number, even though it's 32 bit on wasm32 and 64 on wasm64, so it's lossy on wasm64.
Should we change EM_ASM behaviour to match that, or should we change those other places to prevent precision loss for unsigned long, or is it expected that they handle it differently?
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.
Hm maybe "most" is an exaggeration. Embind itself also encodes size_t aka unsigned long as a BigInt on wasm64 and number otherwise.
Shame that you can't distinguish between size_t and "plain" longs.
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.
(Without looking at this specific instance yet) I think the only times we want to use i53 numbers for 64-bit values is:
p
is used in signature of a JS function)__i53abi
tag on JS functions).Otherwise 64-bit values should be preserved either via bigint (or pair-of-numbers)
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.
Makes sense, but in that case sounds like we should instead remove this override from Embind, as it will currently use i53 for any
unsigned long
.Does that sound right / should I do that in the same PR?
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.
If this PR is NFC than lets keep that way,.. is 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.
Changing the behavior in another PR to be consistent sounds good to me. FWIW, I thought size_t was already a bigint on memory64, but I'm guessing we left it int32 to avoid users having to deal with BigInt.
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.
We handle size_t like we handle pointers yes. They have both have pointer-like behaviour in that they have a different size on wasm32 and wasm64.
Other types such as uint64 have the same size on both wasm32 and wasm64.
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.
But for pointers we translate them to int53 aka plain numbers in JS code, including in Embind, whereas size_t is different, as it will become bigint on wasm64.
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.
This is, I suppose, a limitation of type system. I assume its not possible to distinguish between
unsigned long
andsize_t
? If it is possible we should treat size_t like we do pointers.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.
Indeed. That's what I said above too: