From 3564b71c25d7691267f5f7d8b95f10fd5929090a Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 19 Feb 2019 10:14:59 -0800 Subject: 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 --- src/wasm/literal.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/wasm/literal.cpp') 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 -- cgit v1.2.3