tools/profiler/tests/test_enterjit_osr.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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     let p = Cc["@mozilla.org/tools/profiler;1"];
     6     // Just skip the test if the profiler component isn't present.
     7     if (!p)
     8 	return;
     9     p = p.getService(Ci.nsIProfiler);
    10     if (!p)
    11 	return;
    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());
    18     const ms = 5;
    19     p.StartProfiler(100, ms, ["js"], 1);
    20     let profile = (function arbitrary_name(){
    21 	// A frame for |arbitrary_name| has been pushed.
    22 	let then = Date.now();
    23 	do {
    24 	    let n = 10000;
    25 	    while (--n); // OSR happens here
    26 	    // Spin until we're sure we have a sample.
    27 	} while (Date.now() - then < ms * 2.5);
    28 	return p.getProfileData().threads[0].samples;
    29     })();
    30     do_check_neq(profile.length, 0);
    31     let stack = profile[profile.length - 1].frames.map(f => f.location);
    32     stack = stack.slice(stack.indexOf("js::RunScript") + 1);
    34     do_print(stack);
    35     // This test needs to not break on platforms and configurations
    36     // where IonMonkey isn't available / enabled.
    37     if (stack.length < 2 || stack[1] != "EnterJIT") {
    38 	do_print("No JIT?");
    39 	// Try to check what we can....
    40 	do_check_eq(Math.min(stack.length, 1), 1);
    41 	let thisInterp = stack[0];
    42 	do_check_eq(thisInterp.split(" ")[0], "arbitrary_name");
    43 	if (stack.length >= 2) {
    44 	    let nextFrame = stack[1];
    45 	    do_check_neq(nextFrame.split(" ")[0], "arbitrary_name");
    46 	}
    47     } else {
    48 	do_check_eq(Math.min(stack.length, 3), 3);
    49 	let thisInterp = stack[0];
    50 	let enterJit = stack[1];
    51 	let thisBC = stack[2];
    52 	do_check_eq(thisInterp.split(" ")[0], "arbitrary_name");
    53 	do_check_eq(enterJit, "EnterJIT");
    54 	do_check_eq(thisBC.split(" ")[0], "arbitrary_name");
    55     }
    57     p.StopProfiler();
    58 }

mercurial