Debian Codegraph @

js/src/jit-test/tests/wasm/js-promise-integration/basic-profiler-2.js

raw
1 // |jit-test| skip-if: !WasmHelpers.isSingleStepProfilingEnabled
2
3 // Test profiling of JS PI non-suspending import call.
4
5 const {
6 assertEqImpreciseStacks,
7 } = WasmHelpers;
8
9 var compute_delta = (i) => i / 100;
10
11 var ins = wasmEvalText(`(module
12 (import "js" "compute_delta"
13 (func $compute_delta (param i32) (result f64)))
14
15 (global $state (mut f64) (f64.const 0))
16
17 (func (export "update_state_export") (param i32) (result f64)
18 (global.set $state (f64.add
19 (global.get $state) (call $compute_delta (local.get 0))))
20 (global.get $state)
21 )
22 )`, {
23 js: {
24 compute_delta,
25 },
26 });
27
28 var update_state = WebAssembly.promising(
29 ins.exports.update_state_export
30 );
31
32 enableGeckoProfiling();
33
34 enableSingleStepProfiling();
35
36 function wb(s) {
37 var p = s.split(",");
38 p[0] = "<";
39 var t = p.join(",");
40 return [t, s, t];
41 }
42
43 var res = update_state(4);
44 var tasks = res.then((r) => {
45 assertEq(r, .04);
46 const stacks = disableSingleStepProfiling();
47 assertEqImpreciseStacks(stacks,
48 [
49 "",
50 ">",
51 "1,>", // enter $promising.exported
52 ...wb("CreateSuspender,1,>"),
53 "1,>",
54 ...wb("CreatePromisingPromise,1,>"),
55 "1,>",
56 ...wb("#ref.func function,1,>"), // ref to $promising.trampoline
57 "1,>",
58 ...wb("#update suspender state util,1,>"),
59 "1,>",
60 "2,1,>", // enter $promising.trampoline
61 "1,2,1,>", // enter "update_state_export"
62 "<,1,2,1,>", // JS compute_delta
63 "1,2,1,>", // exiting from "update_state_export"
64 "2,1,>", // at $promising.trampoline
65 ...wb("SetPromisingPromiseResults,2,1,>"),
66 "2,1,>",
67 "1,>",
68 ...wb("#update suspender state util,1,>"),
69 "1,>", // exiting $promising.exported
70 ">",
71 ""
72 ]
73 );
74
75 disableGeckoProfiling();
76 });