summaryrefslogtreecommitdiff
path: root/src/wasm/literal.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2019-02-19 10:14:59 -0800
committerGitHub <noreply@github.com>2019-02-19 10:14:59 -0800
commit3564b71c25d7691267f5f7d8b95f10fd5929090a (patch)
treeca81e10e93bc10b8ade61f96ff642152540f9e8f /src/wasm/literal.cpp
parent8b820ed0021ab1a6ad5dad3972cfbf2cecb77e45 (diff)
downloadbinaryen-3564b71c25d7691267f5f7d8b95f10fd5929090a.tar.gz
binaryen-3564b71c25d7691267f5f7d8b95f10fd5929090a.tar.bz2
binaryen-3564b71c25d7691267f5f7d8b95f10fd5929090a.zip
NaN fuzzing improvements (#1913)
* make DE_NAN avoid creating nan literals in the first place * add a reducer option `--denan` to not introduce nans in destructive reduction * add a `Literal::isNaN()` method * also remove the default exception logging from the fuzzer js glue, which is a source of non-useful VM differences (like nan nondeterminism) * added an option `--no-fuzz-nans` to make it easy to avoid nans when fuzzing (without hacking the source and recompiling). Background: trying to get fuzzing on jsc working despite this open issue: https://bugs.webkit.org/show_bug.cgi?id=175691
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r--src/wasm/literal.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index 5f358fa6b..4ec256aae 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -144,6 +144,17 @@ bool Literal::operator!=(const Literal& other) const {
return !(*this == other);
}
+bool Literal::isNaN() {
+ if (type == Type::f32 && std::isnan(getf32())) {
+ return true;
+ }
+ if (type == Type::f64 && std::isnan(getf64())) {
+ return true;
+ }
+ // TODO: SIMD?
+ return false;
+}
+
uint32_t Literal::NaNPayload(float f) {
assert(std::isnan(f) && "expected a NaN");
// SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF