Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Check that the EnterJIT frame, added by the JIT trampoline and |
michael@0 | 2 | // usable by a native unwinder to resume unwinding after encountering |
michael@0 | 3 | // JIT code, is pushed as expected. |
michael@0 | 4 | function run_test() { |
michael@0 | 5 | let p = Cc["@mozilla.org/tools/profiler;1"]; |
michael@0 | 6 | // Just skip the test if the profiler component isn't present. |
michael@0 | 7 | if (!p) |
michael@0 | 8 | return; |
michael@0 | 9 | p = p.getService(Ci.nsIProfiler); |
michael@0 | 10 | if (!p) |
michael@0 | 11 | return; |
michael@0 | 12 | |
michael@0 | 13 | // This test assumes that it's starting on an empty SPS stack. |
michael@0 | 14 | // (Note that the other profiler tests also assume the profiler |
michael@0 | 15 | // isn't already started.) |
michael@0 | 16 | do_check_true(!p.IsActive()); |
michael@0 | 17 | |
michael@0 | 18 | const ms = 5; |
michael@0 | 19 | p.StartProfiler(100, ms, ["js"], 1); |
michael@0 | 20 | let profile = (function arbitrary_name(){ |
michael@0 | 21 | // A frame for |arbitrary_name| has been pushed. |
michael@0 | 22 | let then = Date.now(); |
michael@0 | 23 | do { |
michael@0 | 24 | let n = 10000; |
michael@0 | 25 | while (--n); // OSR happens here |
michael@0 | 26 | // Spin until we're sure we have a sample. |
michael@0 | 27 | } while (Date.now() - then < ms * 2.5); |
michael@0 | 28 | return p.getProfileData().threads[0].samples; |
michael@0 | 29 | })(); |
michael@0 | 30 | do_check_neq(profile.length, 0); |
michael@0 | 31 | let stack = profile[profile.length - 1].frames.map(f => f.location); |
michael@0 | 32 | stack = stack.slice(stack.indexOf("js::RunScript") + 1); |
michael@0 | 33 | |
michael@0 | 34 | do_print(stack); |
michael@0 | 35 | // This test needs to not break on platforms and configurations |
michael@0 | 36 | // where IonMonkey isn't available / enabled. |
michael@0 | 37 | if (stack.length < 2 || stack[1] != "EnterJIT") { |
michael@0 | 38 | do_print("No JIT?"); |
michael@0 | 39 | // Try to check what we can.... |
michael@0 | 40 | do_check_eq(Math.min(stack.length, 1), 1); |
michael@0 | 41 | let thisInterp = stack[0]; |
michael@0 | 42 | do_check_eq(thisInterp.split(" ")[0], "arbitrary_name"); |
michael@0 | 43 | if (stack.length >= 2) { |
michael@0 | 44 | let nextFrame = stack[1]; |
michael@0 | 45 | do_check_neq(nextFrame.split(" ")[0], "arbitrary_name"); |
michael@0 | 46 | } |
michael@0 | 47 | } else { |
michael@0 | 48 | do_check_eq(Math.min(stack.length, 3), 3); |
michael@0 | 49 | let thisInterp = stack[0]; |
michael@0 | 50 | let enterJit = stack[1]; |
michael@0 | 51 | let thisBC = stack[2]; |
michael@0 | 52 | do_check_eq(thisInterp.split(" ")[0], "arbitrary_name"); |
michael@0 | 53 | do_check_eq(enterJit, "EnterJIT"); |
michael@0 | 54 | do_check_eq(thisBC.split(" ")[0], "arbitrary_name"); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | p.StopProfiler(); |
michael@0 | 58 | } |