ion-gc.js (1466B)
1 // |jit-test| skip-if: !getJitCompilerOptions()['baseline.enable'] 2 // These tests need at least baseline to make sense. 3 4 const options = getJitCompilerOptions(); 5 const TRIGGER = options['baseline.warmup.trigger'] + 10; 6 const ITER = 2 * TRIGGER; 7 const EXCEPTION_ITER = TRIGGER + 5; 8 9 for (let type of ['i32', 'f32', 'f64']) { 10 var instance = wasmEvalText(`(module 11 (func $add (export "add") (param ${type}) (param ${type}) (result ${type}) 12 local.get 0 13 local.get 1 14 ${type}.add 15 ) 16 )`).exports; 17 18 function loopBody(a, b) { 19 var caught = null; 20 try { 21 instance.add(a, b); 22 } catch(e) { 23 caught = e; 24 } 25 assertEq(!!caught, b === EXCEPTION_ITER); 26 } 27 28 var x = 0; 29 function main() { 30 for (var i = 0; i <= EXCEPTION_ITER; i++) { 31 loopBody(i + 1, i + EXCEPTION_ITER + 1); 32 33 let otherArg = { valueOf() { return i|0; } }; 34 35 if (i === EXCEPTION_ITER) { 36 x = { valueOf: function innerValueOf() { 37 // Supress callee. 38 instance = null; 39 // Suppress other arguments. 40 otherArg = null; 41 gc(); 42 return 42; 43 }}; 44 } else { 45 x = i; 46 } 47 48 loopBody({valueOf: function outerValueOf() { return x|0; }}, otherArg); 49 } 50 } 51 52 main(); 53 }