bug1871951.js (1711B)
1 // |jit-test| skip-variant-if: --setpref=wasm_test_serialization=true, true 2 3 gczeal(18) 4 function a(str, imports) { 5 b = wasmTextToBinary(str) 6 try { 7 c = new WebAssembly.Module(b) 8 } catch {} 9 return new WebAssembly.Instance(c, imports) 10 } 11 gczeal(10) 12 base = a(`(module 13 (global (export "rngState") 14 (mut i32) i32.const 1 15 ) 16 (global $ttl (mut i32) (i32.const 100000)) 17 18 (type $d (array (mut i32))) 19 (type $e (array (mut (ref null $d)))) 20 21 (func $f 22 (param $arr (ref $d)) 23 (result (ref $d)) 24 25 (global.set $ttl (i32.sub (global.get $ttl) (i32.const 1))) 26 (if (i32.eqz (global.get $ttl)) 27 (then 28 unreachable 29 ) 30 ) 31 32 local.get $arr 33 ) 34 (func $createSecondaryArray (result (ref $d)) 35 (return_call $f 36 (array.new $d (i32.const 0) (i32.const 1)) 37 ) 38 ) 39 (func $g (export "createPrimaryArrayLoop") 40 (param i32) (param $arrarr (ref $e)) 41 (result (ref $e)) 42 43 (call $createSecondaryArray (local.get $arrarr)) 44 (return_call $g 45 (i32.const 1) 46 local.get $arrarr 47 ) 48 ) 49 )`) 50 t58 = `(module 51 (type $d (array (mut i32))) 52 (type $e (array (mut (ref null $d)))) 53 54 (import "" "rngState" (global $h (mut i32))) 55 (import "" "createPrimaryArrayLoop" (func $g (param i32 (ref $e)) (result (ref $e)))) 56 57 (func $createPrimaryArray (result (ref $e)) 58 (return_call $g 59 i32.const 0 60 (array.new $e (ref.null $d) (i32.const 500)) 61 ) 62 ) 63 (func (export "churn") (result i32) 64 (local $arrarr (ref $e)) 65 (local.set $arrarr (call $createPrimaryArray)) 66 67 (global.get $h) 68 ) 69 )` 70 j = a(t58, {"": base.exports}) 71 fns = j.exports; 72 73 assertErrorMessage(() => { 74 fns.churn(); 75 }, WebAssembly.RuntimeError, /unreachable executed/);