-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Automatically convert i32 pointer args to unsigned when CAN_ADDRESS_2GB is set #19740
Conversation
6ca2414
to
a84657f
Compare
I think this change might also allows us to completely remove the unsignPointers pass.. but I'm not sure. |
864860e
to
b09ddf0
Compare
8eb5546
to
1206ca2
Compare
34d58ac
to
bb88913
Compare
requestedSize = requestedSize >>> 0; | ||
#if !MEMORY64 && !CAN_ADDRESS_2GB | ||
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned. | ||
requestedSize >>>= 0; |
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.
Why do this? The code is only run if requestedSize === (requestedSize >>> 0)
.
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.
The reason for this special case is that we still want emscripten_resize_heap(MAX_INT32)
to fail here even if CAN_ADDRESS_2GB
is not set.. at least the tests expect that. So this function in particular has to force its parameter to unsigned even when CAN_ADDRESS_2GB
is not set.
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.
In fact we want to fail especially if CAN_ADDRESS_2GB
is not set.
Without this line the below assert(requestedSize > oldSize);
will fail because requestedSize would come through as -1
.
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.
Oh, right... this is for proper error handling. Higher values are not valid and we error on them.
requestedSize = requestedSize >>> 0; | ||
#if !MEMORY64 && !CAN_ADDRESS_2GB | ||
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned. | ||
requestedSize >>>= 0; |
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.
Oh, right... this is for proper error handling. Higher values are not valid and we error on them.
I split out #19752 |
bb88913
to
e221930
Compare
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 reverted the potentially problematic parts of this change in src/library_strings.js.. so hopefully what remains is more conservative.
e221930
to
3e11c0c
Compare
…GB is set This extends the use automatically-generated JS wrappers to handle conversion of incoming i32 pointer to u32 JS numbers. This is only needed when CAN_ADDRESS_2GB is set. See #19737
3e11c0c
to
96e9b41
Compare
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.
Thanks, and sorry for insisting on those assertions, maybe I'm overly cautious but I think they might help someone.
This extends the use automatically-generated JS wrappers to handle conversion of incoming i32 pointer to u32 JS numbers. This is only needed when CAN_ADDRESS_2GB is set.
See #19737