frame-offset-stack-arg.js (1455B)
1 // We have some register args and the rest are on the stack in the wasm->js 2 // call. This tests a case where the wrong frame offset was used (on ARM64, 3 // which is weird in this regard) to read the stack arg in an optimized callout 4 // stub. 5 6 var loop_counter = 0; 7 8 function f(a,b,c,d,e,f,g,h,i,j) { 9 assertEq(a, loop_counter); 10 assertEq(b, a+1); 11 assertEq(c, b+1); 12 assertEq(d, c+1); 13 assertEq(e, d+1); 14 assertEq(f, e+1); 15 assertEq(g, f+1); 16 assertEq(h, g+1); 17 assertEq(i, h+1); 18 assertEq(j, i+1); 19 } 20 21 var bin = wasmTextToBinary( 22 `(module 23 (import "m" "f" (func $f (param i32) (param i32) (param i32) (param i32) (param i32) 24 (param i32) (param i32) (param i32) (param i32) (param i32))) 25 (func (export "test") (param $a i32) (param $b i32) (param $c i32) (param $d i32) (param $e i32) 26 (param $f i32) (param $g i32) (param $h i32) (param $i i32) (param $j i32) 27 (call $f (local.get $a) (local.get $b) (local.get $c) (local.get $d) (local.get $e) 28 (local.get $f) (local.get $g) (local.get $h) (local.get $i) (local.get $j))))`); 29 30 var mod = new WebAssembly.Module(bin); 31 var ins = new WebAssembly.Instance(mod, {m:{f}}); 32 33 // Enough iterations for the jit to kick in and the stub to become optimized. 34 35 for ( let i=0; i < 100; i++ ) { 36 loop_counter = i; 37 ins.exports.test(i, i+1, i+2, i+3, i+4, i+5, i+6, i+7, i+8, i+9); 38 }