summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/profiler/bug1782003.js
blob: 34219a71792ffc37a0692d17a8b73862efe06875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function getStack() {
    enableGeckoProfiling();
    let stack = readGeckoProfilingStack();
    // The number of frames depends on JIT flags, but there must be at least
    // one frame for the caller and at most 3 total (the global script, 'testFun'
    // and 'getStack').
    assertEq(stack.length > 0, true);
    assertEq(stack.length <= 3, true);
    assertEq(JSON.stringify(stack).includes('"testFun ('), true);
    disableGeckoProfiling();
}
function testFun() {
    // Loop until this is a JIT frame.
    while (true) {
        let isJitFrame = inJit();
        if (typeof isJitFrame === "string") {
            return; // JIT disabled.
        }
        if (isJitFrame) {
            break;
        }
    }

    // Now call getStack to check this frame is on the profiler's JIT stack.
    getStack();
    getStack();
}
testFun();