-
-
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
feat(stdlib): Add Conv.wasmI32ToNumber function #978
Conversation
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.
Beautiful! Thank you!
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
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.
Thank you!
// the same. This may sound counter intuitive, but for numbers that fit into | ||
// the range it is faster than performing the check with WasmI32.geS and | ||
// WasmI32.leS by about 20%. An additional ~33% is gained by avoiding a | ||
// call to tagSimpleNumber and instead doing it inline. For the case of |
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've got some branches in the works that makes Binaryen inlining of these calls work, so no worries about that in the future 🙂
This PR adds a function to convert WasmI32 to Number. This differs from
tagSimpleNumber
in runtime/dataStructures in that it's safe to use for any value of WasmI32, not just the range allowed in Simple numbers.Btw there's also
tagSimple
in runtime/numbes that duplicates exactly the code fromtagSimpleNumber
, or the other way around. Maybe one can become reexport of the other.I tried to optimize it so that we can possibly just replace most uses of
tagSimpleNumber
/tagSimple
without fearing performance regressions.