diff options
author | Alon Zakai <azakai@google.com> | 2021-04-06 10:08:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 10:08:35 -0700 |
commit | cc0439224cfc2eabe8f8c28d782ab6b44a0f24f9 (patch) | |
tree | d44f639f2eb835ed7839e82885e8ebba212cfd84 | |
parent | b900ed95deda68dad12b3aac7d1283f642e7a545 (diff) | |
download | binaryen-cc0439224cfc2eabe8f8c28d782ab6b44a0f24f9.tar.gz binaryen-cc0439224cfc2eabe8f8c28d782ab6b44a0f24f9.tar.bz2 binaryen-cc0439224cfc2eabe8f8c28d782ab6b44a0f24f9.zip |
Fuzzing in JS VMs: Print types when we have nothing better (#3773)
This matches #3747 which makes us not log out reference values, instead
we print just their types.
This also prints a type for non-reference things, replacing a previous
exception, which affects things like SIMD and BigInts, but those trap
anyhow at the JS boundary I believe (or did that change for SIMD?).
Anyhow, printing the type won't give a false "ok" when comparing wasm2js
output to the interpreter, assuming the interpreter prints out a value and
not just a type (which is the case). We could try to do better, but this
code is on the JS side, where we don't have the type - just a string
representation of it, which we'd need to parse etc.
-rw-r--r-- | src/tools/js-wrapper.h | 3 | ||||
-rw-r--r-- | test/passes/emit-js-wrapper=a.js.wast.js | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/tools/js-wrapper.h b/src/tools/js-wrapper.h index 3a1a1aa4a..9568bccc0 100644 --- a/src/tools/js-wrapper.h +++ b/src/tools/js-wrapper.h @@ -60,7 +60,8 @@ static std::string generateJSWrapper(Module& wasm) { " ret += Number(x).toString();\n" " break;\n" " }\n" - " default: throw 'what?';\n" + " // For anything else, just print the type.\n" + " default: ret += type; break;\n" " }\n" " return ret;\n" "}\n" diff --git a/test/passes/emit-js-wrapper=a.js.wast.js b/test/passes/emit-js-wrapper=a.js.wast.js index 60f2449b0..a3c0a22ee 100644 --- a/test/passes/emit-js-wrapper=a.js.wast.js +++ b/test/passes/emit-js-wrapper=a.js.wast.js @@ -30,7 +30,8 @@ function literal(x, type) { ret += Number(x).toString(); break; } - default: throw 'what?'; + // For anything else, just print the type. + default: ret += type; break; } return ret; } |