ion-error-throw.js (1209B)
1 // |jit-test| skip-if: !getJitCompilerOptions()['baseline.enable'] 2 // These tests need at least baseline to make sense. 3 4 const { assertStackTrace, startProfiling, endProfiling, assertEqPreciseStacks } = WasmHelpers; 5 6 enableGeckoProfiling(); 7 8 let { add } = wasmEvalText(`(module 9 (func (export "add") (param i32) (param i32) (result i32) 10 local.get 0 11 i32.const 42 12 i32.eq 13 if 14 unreachable 15 end 16 17 local.get 0 18 local.get 1 19 i32.add 20 ) 21 )`).exports; 22 23 const SLOW_ENTRY_STACK = ['', '!>', '0,!>', '!>', '']; 24 const FAST_ENTRY_STACK = ['', '>', '0,>', '>', '']; 25 const FAST_ENTRY_STACK_THROW = ['', '>', '0,>', '>', '', '>', '']; 26 const INLINED_CALL_STACK = ['', '0', '']; 27 28 function main() { 29 for (let i = 0; i < 50; i++) { 30 startProfiling(); 31 try { 32 assertEq(add(i, i+1), 2*i+1); 33 } catch (e) { 34 assertEq(i, 42); 35 assertEq(e.message.includes("unreachable"), true); 36 assertStackTrace(e, ['wasm-function[0]', 'main', '']); 37 } 38 let stack = endProfiling(); 39 assertEqPreciseStacks(stack, [INLINED_CALL_STACK, FAST_ENTRY_STACK, FAST_ENTRY_STACK_THROW, SLOW_ENTRY_STACK]); 40 } 41 } 42 43 main();