-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[wasm64] convert BigInt<->Number based on library function __sig attributes
#16877
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
Conversation
|
This is just the initial change that introduces this concept. More widespread usage, and increased test coverage is coming in a followup. |
d5cb46c to
32a18ed
Compare
Do we assume |
Yup that's already been hard-coded in since the start. |
|
Nice, this seems a more solid way to do it! |
Great, thanks! |
32a18ed to
5525cf8
Compare
__sig attributes__sig attributes
12d3cfd to
c298297
Compare
c298297 to
f058030
Compare
…tributes This change introduces and type to the `__sig` scheme that we using for library functions: 'p'. This letter signifies that the parameter or return value is the width of a pointer which means it will differ between wasm32 and wasm64. We use this whenever a JS function receives or returns pointer type or a size_t type. For wasm32, we don't need to do anything since the incoming value is and i32. For wasm64 we convert the incoming BigInt value to an int53/double at the JS/Wasm boundary. At the moment no checking is done on the values, which means values that don't precisely convert to JS double can be corrupted/truncated. As a followup, we could consider using the checking conversion functions, or asserting in debug builds if the values don't fit within this range.
f058030 to
fcfa6b5
Compare
This change introduces and type to the
__sigscheme that we using forlibrary functions: 'p'. This letter signifies that the paramater or
return value is the width of a pointer which means it will differ
between wasm32 and wasm64.
We use this whenever a JS function receives or returns pointer type or a
size_t type.
For wasm32, we don't need to do anything since the incoming value is and
i32. For wasm64 we covert the incoming BigInt value to an int53/double
at the JS/Wasm boundary. At the moment no checking is done on the
values, which means values that don't pricely convert to JS double can
be currupted/truncated. As a followup, we could consider using the
checking coversion functions, or asserting in debug builds if the values
don't fit within this range.