diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /js/src/jit-test/tests/wasm/exceptions/example.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/wasm/exceptions/example.js')
-rw-r--r-- | js/src/jit-test/tests/wasm/exceptions/example.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/exceptions/example.js b/js/src/jit-test/tests/wasm/exceptions/example.js new file mode 100644 index 0000000000..f1c9f144b9 --- /dev/null +++ b/js/src/jit-test/tests/wasm/exceptions/example.js @@ -0,0 +1,28 @@ +// A diagram depicting the control flow graph of the function g below can be +// found in "js/src/wasm/WasmIonCompile.cpp". If you make any changes to this +// test file be sure to adjust the SMDOC documentation there as well. + +let g = wasmEvalText( + `(module + (tag $exn (param f64)) + (func $f) + (func (export "g") (param $arg i32) (result f64) + (local.get $arg) + (try (param i32) (result f64) + (do + (if (result f64) + (then + (f64.const 3)) + (else + (throw $exn (f64.const 6)))) + (call $f) + (f64.sub (f64.const 2))) ;; If $arg is 0 we end here, subtracting 3. + ;; If $arg is not 0 then the else-block throws $exn, caught below. + (catch $exn + (f64.add (f64.const 4))) ;; Adds 4 to the value in the $exn (6). + (catch_all ;; This shouldn't occur. + (f64.const 5)))))` +).exports.g; + +assertEq(g(0), 10); +assertEq(g(1), 1); |