wasm-get-return.js (1868B)
1 // |jit-test| test-also=--wasm-compiler=optimizing; skip-if: !wasmDebuggingEnabled() 2 // Tests that wasm frame opPop event can access function resumption value. 3 4 load(libdir + "wasm.js"); 5 load(libdir + 'eqArrayHelper.js'); 6 7 function monitorFrameOnPopReturns(wast, expected) { 8 var values = []; 9 wasmRunWithDebugger( 10 wast, 11 undefined, 12 function ({dbg}) { 13 dbg.onEnterFrame = function (frame) { 14 if (frame.type != 'wasmcall') return; 15 frame.onPop = function (value) { 16 values.push(value.return); 17 }; 18 }; 19 }, 20 function ({error}) { 21 assertEq(error, undefined); 22 } 23 ); 24 assertEqArray(values, expected); 25 } 26 27 monitorFrameOnPopReturns( 28 `(module (func (export "test")))`, 29 [undefined]); 30 monitorFrameOnPopReturns( 31 `(module (func (export "test") (result i32) (i32.const 42)))`, 32 [42]); 33 monitorFrameOnPopReturns( 34 `(module (func (export "test") (result f32) (f32.const 0.5)))`, 35 [0.5]); 36 monitorFrameOnPopReturns( 37 `(module (func (export "test") (result f64) (f64.const -42.75)))`, 38 [-42.75]); 39 monitorFrameOnPopReturns( 40 `(module (func (result i64) (i64.const 2)) (func (export "test") (call 0) (drop)))`, 41 [2, undefined]); 42 43 // Checking if throwing frame has right resumption value. 44 var throwCount = 0; 45 wasmRunWithDebugger( 46 '(module (func (unreachable)) (func (export "test") (result i32) (call 0) (i32.const 1)))', 47 undefined, 48 function ({dbg, g}) { 49 dbg.onEnterFrame = function (frame) { 50 if (frame.type != 'wasmcall') return; 51 frame.onPop = function (value) { 52 if ('throw' in value) 53 throwCount++; 54 }; 55 }; 56 }, 57 function ({error}) { 58 assertEq(error != undefined, true); 59 assertEq(throwCount, 2); 60 } 61 );