-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Use floats for wasmtime::component::Val::Float*
#5510
Use floats for wasmtime::component::Val::Float*
#5510
Conversation
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 bytecodealliance#5480
I failed to mention: this removes the |
Yeah that's ok and I think it makes sense as well due to the usage of floats it shouldn't be applicable for |
Subscribe to Label Actioncc @fitzgen, @peterhuene
This issue or pull request has been labeled: "fuzzing", "wasmtime:api"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
It looks like this broke fuzzing here because nan is no longer equal to nan. @lann would you be up for helping to fix this? I think the way to fix it would be to write a custom equality function which considers two NaN values to be equal. |
Would it make sense to change the test code? e.g. match (expected, actual) {
// NaNs never compare equal
(Val::Float32(expected), Val::Float32(actual)) if expected.is_nan() => assert!(actual.is_nan()),
(Val::Float64(expected), Val::Float64(actual)) if expected.is_nan() => assert!(actual.is_nan()),
(expected, actual) => assert_eq!(expected, actual),
}; |
More-or-less that's what needs to happen, but floats can appear recursively as well so the equality change there would need to be applied deeply through types like lists and recors too |
In bytecodealliance#5510 we changed the value types of these variants from u{32,64} to f{32,64}. One side effect of this change was that two NaN values would no longer compare equal. While this is behavior complies with IEEE-754 floating point operations, it broke equality assumptions in fuzzing. This commit changes equality for Val to make NaNs compare equal. Since the component model requires NaN canonicalization, all NaN bit representations compare equal, which is different from the original behavior. This also gives Vals the semantics of Eq again, so that has been reintroduced to related types as well.
In bytecodealliance#5510 we changed the value types of these variants from u{32,64} to f{32,64}. One side effect of this change was that two NaN values would no longer compare equal. While this is behavior complies with IEEE-754 floating point operations, it broke equality assumptions in fuzzing. This commit changes equality for Val to make NaNs compare equal. Since the component model requires NaN canonicalization, all NaN bit representations compare equal, which is different from the original behavior. This also gives Vals the semantics of Eq again, so that trait impl has been reintroduced to related types as well.
In bytecodealliance#5510 we changed the value types of these variants from u{32,64} to f{32,64}. One side effect of this change was that two NaN values would no longer compare equal. While this is behavior complies with IEEE-754 floating point operations, it broke equality assumptions in fuzzing. This commit changes equality for Val to make NaNs compare equal. Since the component model requires NaN canonicalization, all NaN bit representations compare equal, which is different from the original behavior. This also gives Vals the semantics of Eq again, so that trait impl has been reintroduced to related types as well.
In bytecodealliance#5510 we changed the value types of these variants from u{32,64} to f{32,64}. One side effect of this change was that two NaN values would no longer compare equal. While this is behavior complies with IEEE-754 floating point operations, it broke equality assumptions in fuzzing. This commit changes equality for Val to make NaNs compare equal. Since the component model requires NaN canonicalization, all NaN bit representations compare equal, which is different from the original behavior. This also gives Vals the semantics of Eq again, so that trait impl has been reintroduced to related types as well.
In bytecodealliance#5510 we changed the value types of these variants from u{32,64} to f{32,64}. One side effect of this change was that two NaN values would no longer compare equal. While this is behavior complies with IEEE-754 floating point operations, it broke equality assumptions in fuzzing. This commit changes equality for Val to make NaNs compare equal. Since the component model requires NaN canonicalization, all NaN bit representations compare equal, which is different from the original behavior. This also gives Vals the semantics of Eq again, so that trait impl has been reintroduced to related types as well.
In #5510 we changed the value types of these variants from u{32,64} to f{32,64}. One side effect of this change was that two NaN values would no longer compare equal. While this is behavior complies with IEEE-754 floating point operations, it broke equality assumptions in fuzzing. This commit changes equality for Val to make NaNs compare equal. Since the component model requires NaN canonicalization, all NaN bit representations compare equal, which is different from the original behavior. This also gives Vals the semantics of Eq again, so that trait impl has been reintroduced to related types as well.
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