lann opened PR #5510 from component-val-use-native-floats
to main
:
The definitions of
wasmtime::component::Val::Float{32,64}
mirroredwasmtime::Val::F{32,64}
by using integers as their wrapped types, storing the bit representation of their floating point values. This was necessary for the core Wasmf32
/f64
types because Rust floats don't have guaranteed NaN bit representations.The component model
float32
/float64
types require NaN canonicalization, so we can use normal Rustf{32,64}
instead.Closes #5480
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
lann edited PR #5510 from component-val-use-native-floats
to main
:
The definitions of
wasmtime::component::Val::Float{32,64}
mirroredwasmtime::Val::F{32,64}
by using integers as their wrapped types, storing the bit representation of their floating point values. This was necessary for the core Wasmf32
/f64
types because Rust floats don't have guaranteed NaN bit representations.https://github.com/bytecodealliance/wasmtime/issues/5480#issuecomment-1359712605 @jameysharp:
We do this in Cranelift too. I don't know if it's for the same reason that Wasmtime's API works this way, but Cranelift's reason was discussed in https://github.com/bytecodealliance/wasmtime/pull/2251#discussion_r498508646. In short, Rust doesn't make any guarantees about the bit-representation of NaN values being preserved in floating-point types. So if you care about that, you need to keep the raw bits in an integer type until the time when you want to do actual floating-point operations on them.The component model
float32
/float64
types require NaN canonicalization, so we can use normal Rustf{32,64}
instead.Closes #5480
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton submitted PR review.
alexcrichton has enabled auto merge for PR #5510.
alexcrichton merged PR #5510.
Last updated: Dec 23 2024 at 12:05 UTC