summaryrefslogtreecommitdiff
path: root/src/tools/wasm-opt.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/tools/wasm-opt.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/tools/wasm-opt.cpp')
-rw-r--r--src/tools/wasm-opt.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index 61e554276..d2f3d718c 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -71,6 +71,7 @@ int main(int argc, const char* argv[]) {
std::string extraFuzzCommand;
bool translateToFuzz = false;
bool fuzzPasses = false;
+ bool fuzzNaNs = true;
std::string emitJSWrapper;
std::string emitSpecWrapper;
std::string inputSourceMapFilename;
@@ -112,6 +113,9 @@ int main(int argc, const char* argv[]) {
.add("--fuzz-passes", "-fp", "Pick a random set of passes to run, useful for fuzzing. this depends on translate-to-fuzz (it picks the passes from the input)",
Options::Arguments::Zero,
[&](Options *o, const std::string& arguments) { fuzzPasses = true; })
+ .add("--no-fuzz-nans", "", "don't emit NaNs when fuzzing, and remove them at runtime as well (helps avoid nondeterminism between VMs)",
+ Options::Arguments::Zero,
+ [&](Options *o, const std::string& arguments) { fuzzNaNs = false; })
.add("--emit-js-wrapper", "-ejw", "Emit a JavaScript wrapper file that can run the wasm with some test values, useful for fuzzing",
Options::Arguments::One,
[&](Options *o, const std::string& arguments) { emitJSWrapper = arguments; })
@@ -166,7 +170,9 @@ int main(int argc, const char* argv[]) {
if (fuzzPasses) {
reader.pickPasses(options);
}
- reader.build(options.getFeatures());
+ reader.setFeatures(options.getFeatures());
+ reader.setAllowNaNs(fuzzNaNs);
+ reader.build();
if (options.passOptions.validate) {
if (!WasmValidator().validate(wasm, options.getFeatures())) {
WasmPrinter::printModule(&wasm);