exceptions.js (1140B)
1 // Simple test with return_call. 2 var ins = wasmEvalText(`(module 3 (tag $exn) 4 (func $f0 (result i32) 5 throw $exn 6 ) 7 (func $f1 (result i32) 8 try 9 return_call $f0 10 catch $exn 11 i32.const 3 12 return 13 end 14 i32.const 4 15 ) 16 (func (export "main") (result i32) 17 call $f1 18 ) 19 )`); 20 assertErrorMessage(() => ins.exports.main(), WebAssembly.Exception, /.*/); 21 22 // Test if return stub, created by introducing the slow path, 23 // not interfering with exception propagation. 24 var ins0 = wasmEvalText(`(module 25 (tag $exn) 26 (func $f0 (result i32) 27 throw $exn 28 ) 29 (func (export "f") (result i32) 30 call $f0 31 ) 32 (export "t" (tag $exn)) 33 )`); 34 var ins = wasmEvalText(`(module 35 (import "" "t" (tag $exn)) 36 (import "" "f" (func $f0 (result i32))) 37 (func $f1 (result i32) 38 try 39 return_call $f0 40 catch $exn 41 i32.const 3 42 return 43 end 44 i32.const 4 45 ) 46 (func (export "main") (result i32) 47 call $f1 48 ) 49 )`, {"":ins0.exports,}); 50 51 assertErrorMessage(() => ins.exports.main(), WebAssembly.Exception, /.*/); 52