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.
5 let p = Cc["@mozilla.org/tools/profiler;1"];
6 // Just skip the test if the profiler component isn't present.
9 p = p.getService(Ci.nsIProfiler);
13 // This test assumes that it's starting on an empty SPS stack.
14 // (Note that the other profiler tests also assume the profiler
15 // isn't already started.)
16 do_check_true(!p.IsActive());
19 p.StartProfiler(100, ms, ["js"], 1);
21 function arbitrary_name(){
22 // A frame for |arbitrary_name| has been pushed. Do a sequence of
23 // increasingly long spins until we get a sample.
26 do_print("loop: ms = " + delayMS);
27 let then = Date.now();
30 while (--n); // OSR happens here
31 // Spin in the hope of getting a sample.
32 } while (Date.now() - then < delayMS);
33 let pr = p.getProfileData().threads[0].samples;
34 if (pr.length > 0 || delayMS > 30000)
40 var profile = arbitrary_name();
42 do_check_neq(profile.length, 0);
43 let stack = profile[profile.length - 1].frames.map(f => f.location);
44 stack = stack.slice(stack.lastIndexOf("js::RunScript") + 1);
47 // This test needs to not break on platforms and configurations
48 // where IonMonkey isn't available / enabled.
49 if (stack.length < 2 || stack[1] != "EnterJIT") {
51 // Try to check what we can....
52 do_check_eq(Math.min(stack.length, 1), 1);
53 let thisInterp = stack[0];
54 do_check_eq(thisInterp.split(" ")[0], "arbitrary_name");
55 if (stack.length >= 2) {
56 let nextFrame = stack[1];
57 do_check_neq(nextFrame.split(" ")[0], "arbitrary_name");
60 do_check_eq(Math.min(stack.length, 3), 3);
61 let thisInterp = stack[0];
62 let enterJit = stack[1];
63 let thisBC = stack[2];
64 do_check_eq(thisInterp.split(" ")[0], "arbitrary_name");
65 do_check_eq(enterJit, "EnterJIT");
66 do_check_eq(thisBC.split(" ")[0], "arbitrary_name");