Debian Codegraph @

js/src/jit-test/tests/wasm/tail-calls/return-call-profiling.js

raw
1 // Tests if the profiler (frame iterator) can unwind in the middle
2 // of collapse frame instructions.
3
4 enableGeckoProfiling();
5 try {
6 enableSingleStepProfiling();
7 } catch (e) {
8 // continue anyway if single step profiling is not supported
9 }
10
11 var ins = wasmEvalText(`
12 (module
13 (func $f (param i64 i64 i64 i64 i64 i64 i64 i64 i64)
14 local.get 0
15 i64.eqz
16 br_if 0
17 local.get 0
18 return_call $g
19 )
20 (func $g (param i64)
21 local.get 0
22 i64.const 1
23 i64.sub
24 i64.const 2
25 i64.const 6
26 i64.const 3
27 i64.const 4
28 i64.const 1
29 i64.const 2
30 i64.const 6
31 i64.const 3
32 return_call $f
33 )
34 (func (export "run") (param i64)
35 local.get 0
36 call $g
37 )
38 )`);
39
40 for (var i = 0; i < 10; i++) {
41 ins.exports.run(100n);
42 }
43
44 // Also when trampoline is used.
45 var ins0 = wasmEvalText(`(module (func (export "t")))`);
46 var ins = wasmEvalText(`
47 (module
48 (import "" "t" (func $g))
49 (func $f (return_call_indirect $t (i32.const 0)))
50 (table $t 1 1 funcref)
51
52 (func (export "run") (param i64)
53 loop
54 local.get 0
55 i64.eqz
56 br_if 1
57 call $f
58 local.get 0
59 i64.const 1
60 i64.sub
61 local.set 0
62 br 0
63 end
64 )
65 (elem (i32.const 0) $g)
66 )`, {"": {t: ins0.exports.t},});
67
68 ins.exports.run(10n);