diff --git a/scripts/fuzz_shell.js b/scripts/fuzz_shell.js index 718692498d1..de1ef135202 100644 --- a/scripts/fuzz_shell.js +++ b/scripts/fuzz_shell.js @@ -270,8 +270,10 @@ var imports = { // Throw an exception from JS. 'throw': (which) => { if (!which) { - throw 'some JS error'; + // Throw a JS exception. + throw 0; } else { + // Throw a wasm exception. throw new WebAssembly.Exception(wasmTag, [which]); } }, diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index c6cb7ecc571..9ef409a385d 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -182,7 +182,8 @@ struct LoggingExternalInterface : public ShellExternalInterface { void throwJSException() { // JS exceptions contain an externref, which wasm can't read (so the actual - // value here does not matter). + // value here does not matter, but it does need to match what the 'throw' + // import does in fuzz_shell.js, as the fuzzer will do comparisons). Literal externref = Literal::makeI31(0, Unshared).externalize(); Literals arguments = {externref}; auto payload = std::make_shared(jsTag, arguments); diff --git a/test/lit/d8/fuzz_shell_exceptions.wast b/test/lit/d8/fuzz_shell_exceptions.wast index 6b46ee2adfa..da1e7fbe0aa 100644 --- a/test/lit/d8/fuzz_shell_exceptions.wast +++ b/test/lit/d8/fuzz_shell_exceptions.wast @@ -31,7 +31,7 @@ ;; RUN: v8 %S/../../../scripts/fuzz_shell.js -- %t.wasm | filecheck %s ;; ;; CHECK: [fuzz-exec] calling throwing-js -;; CHECK: exception thrown: some JS error +;; CHECK: exception thrown: 0 ;; CHECK: [fuzz-exec] calling throwing-tag ;; CHECK: exception thrown: [object WebAssembly.Exception]