Stream: git-wasmtime

Topic: wasmtime / PR #5510 Use floats for `wasmtime::component::...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 03 2023 at 19:18):

lann opened PR #5510 from component-val-use-native-floats to main:

The definitions of wasmtime::component::Val::Float{32,64} mirrored wasmtime::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 Wasm f32/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 Rust f{32,64} instead.

Closes #5480

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jan 03 2023 at 19:19):

lann edited PR #5510 from component-val-use-native-floats to main:

The definitions of wasmtime::component::Val::Float{32,64} mirrored wasmtime::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 Wasm f32/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 Rust f{32,64} instead.

Closes #5480

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jan 03 2023 at 19:20):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 03 2023 at 19:21):

alexcrichton has enabled auto merge for PR #5510.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 03 2023 at 20:23):

alexcrichton merged PR #5510.


Last updated: Dec 23 2024 at 12:05 UTC