summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/tail-calls/exceptions.js
blob: c4c774a4f352f16647099deb8a3c9440198b25a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Simple test with return_call.
var ins = wasmEvalText(`(module
    (tag $exn)
    (func $f0 (result i32)
       throw $exn
    )
    (func $f1 (result i32)
      try
        return_call $f0
      catch $exn
        i32.const 3
        return
      end
      i32.const 4
    )
    (func (export "main") (result i32)
      call $f1
    )
)`);
assertErrorMessage(() => ins.exports.main(), WebAssembly.Exception, /.*/);

// Test if return stub, created by introducing the slow path,
// not interfering with exception propagation.
var ins0 = wasmEvalText(`(module
    (tag $exn)
    (func $f0 (result i32)
       throw $exn
    )
    (func (export "f") (result i32)
      call $f0
    )
    (export "t" (tag $exn))
)`);
var ins = wasmEvalText(`(module
    (import "" "t" (tag $exn))
    (import "" "f" (func $f0 (result i32)))
    (func $f1 (result i32)
      try
        return_call $f0
      catch $exn
        i32.const 3
        return
      end
      i32.const 4
    )
    (func (export "main") (result i32)
      call $f1
    )
  )`, {"":ins0.exports,});
  
assertErrorMessage(() => ins.exports.main(), WebAssembly.Exception, /.*/);