Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / tools / profiler / tests / xpcshell / test_enterjit_osr.js
blob86845ddc76ecf1e3815c9f44f43e6ac294ab5d68
1 // Check that the EnterJIT frame, added by the JIT trampoline and
2 // usable by a native unwinder to resume unwinding after encountering
3 // JIT code, is pushed as expected.
4 function run_test() {
5 // This test assumes that it's starting on an empty profiler stack.
6 // (Note that the other profiler tests also assume the profiler
7 // isn't already started.)
8 Assert.ok(!Services.profiler.IsActive());
10 const ms = 5;
11 Services.profiler.StartProfiler(10000, ms, ["js"]);
13 function has_arbitrary_name_in_stack() {
14 // A frame for |arbitrary_name| has been pushed. Do a sequence of
15 // increasingly long spins until we get a sample.
16 var delayMS = 5;
17 while (1) {
18 info("loop: ms = " + delayMS);
19 const then = Date.now();
20 do {
21 let n = 10000;
22 // eslint-disable-next-line no-empty
23 while (--n) {} // OSR happens here
24 // Spin in the hope of getting a sample.
25 } while (Date.now() - then < delayMS);
26 let profile = Services.profiler.getProfileData().threads[0];
28 // Go through all of the stacks, and search for this function name.
29 for (const sample of profile.samples.data) {
30 const stack = getInflatedStackLocations(profile, sample);
31 info(`The following stack was found: ${stack}`);
32 for (var i = 0; i < stack.length; i++) {
33 if (stack[i].match(/arbitrary_name/)) {
34 // This JS sample was correctly found.
35 return true;
40 // Continue running this function with an increasingly long delay.
41 delayMS *= 2;
42 if (delayMS > 30000) {
43 return false;
47 Assert.ok(
48 has_arbitrary_name_in_stack(),
49 "A JS frame was found before the test timeout."
51 Services.profiler.StopProfiler();