[Test] Add PrepareForOptimization to debugger/ tests.

BUG=v8:8801

Change-Id: Id5ef6219ba2dca2be0603dd0d45e7b27136836e9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1587391
Reviewed-by: Mythri Alle <mythria@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61085}
This commit is contained in:
Ross McIlroy 2019-04-29 14:14:40 +01:00 committed by Commit Bot
parent 884a45a72d
commit c0720d28db
33 changed files with 68 additions and 6 deletions

View File

@ -34,6 +34,7 @@ Debug.setListener(listener);
return e;
}
}
%PrepareFunctionForOptimization(f);
assertEquals("boom1", f(1));
assertEquals("boom2", f(2));
%OptimizeFunctionOnNextCall(f);
@ -51,6 +52,7 @@ Debug.setListener(listener);
return a + 10;
}
}
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1));
assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f);
@ -70,6 +72,7 @@ Debug.setListener(listener);
// Nothing.
}
}
%PrepareFunctionForOptimization(f);
assertEquals("wosh11", f(1));
assertEquals("wosh22", f(2));
%OptimizeFunctionOnNextCall(f);
@ -91,6 +94,7 @@ Debug.setListener(listener);
return e + a;
}
}
%PrepareFunctionForOptimization(f);
assertEquals("bang11", f(1));
assertEquals("bang22", f(2));
%OptimizeFunctionOnNextCall(f);
@ -112,6 +116,7 @@ Debug.setListener(listener);
return a + 10;
}
}
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1));
assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f);
@ -133,6 +138,7 @@ Debug.setListener(listener);
return a + 10;
}
}
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1));
assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f);

View File

@ -63,6 +63,7 @@ function h() {
debugger;
}
%PrepareFunctionForOptimization(f);
f();f();f();
%OptimizeFunctionOnNextCall(f);
f();

View File

@ -9,6 +9,7 @@ Debug = debug.Debug;
Debug.setListener(function() {});
function f() {}
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
@ -17,6 +18,7 @@ assertOptimized(f);
var bp = Debug.setBreakPoint(f);
assertUnoptimized(f);
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
@ -24,6 +26,7 @@ f();
assertUnoptimized(f);
Debug.clearBreakPoint(bp);
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f);
f();
assertOptimized(f);

View File

@ -30,6 +30,7 @@ function foo(a) {
}
return bar(1,2,a);
}
%PrepareFunctionForOptimization(foo);
listened = false;
foo_expected = [3];
@ -53,6 +54,7 @@ assertTrue(listened);
listened = false;
foo_expected = [3,4,5];
bar_expected = [1,2,3];
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
assertEquals(6, foo(3,4,5));
assertTrue(listened);

View File

@ -131,6 +131,7 @@ function listener(event, exec_state, event_data, data) {
};
};
%PrepareFunctionForOptimization(f);
for (var i = 0; i < 4; i++) f(input.length - 1, 11.11, 12.12);
%OptimizeFunctionOnNextCall(f);
f(input.length - 1, 11.11, 12.12);

View File

@ -122,6 +122,7 @@ function listener(event, exec_state, event_data, data) {
};
};
%PrepareFunctionForOptimization(f);
for (var i = 0; i < 4; i++) f(expected.length - 1, 11, 12);
%OptimizeFunctionOnNextCall(f);
f(expected.length - 1, 11, 12);

View File

@ -12,8 +12,9 @@ eval("var something1 = 25; "
function foo() { return ChooseAnimal() }
%PrepareFunctionForOptimization(foo);
assertEquals("Cat", foo());
%OptimizeFunctionOnNextCall(foo);
%OptimizeFunctionOnNextCall(foo);
foo();

View File

@ -18,6 +18,8 @@ function bar() {
return t.a;
}
%PrepareFunctionForOptimization(foo);
%PrepareFunctionForOptimization(bar);
foo(1);
foo(1);
bar(1);

View File

@ -24,6 +24,7 @@ function f4() {
function optimize(f) {
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);

View File

@ -457,6 +457,7 @@ function with_7() {
debugger;
}
}
%PrepareFunctionForOptimization(with_7);
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.With,
@ -825,6 +826,7 @@ listener_delegate = function(exec_state) {
CheckScopeChainNames(
["closure_11", "closure_10", undefined, undefined], exec_state);
};
%PrepareFunctionForOptimization(closure_10);
begin_test_count++; closure_10(5); end_test_count++;
begin_test_count++; closure_10(5); end_test_count++;
%OptimizeFunctionOnNextCall(closure_10);
@ -1152,6 +1154,7 @@ function catch_block_7() {
debugger;
}
};
%PrepareFunctionForOptimization(catch_block_7);
listener_delegate = function(exec_state) {

View File

@ -44,6 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
}
%PrepareFunctionForOptimization(g);
f(0);
f(0);
%OptimizeFunctionOnNextCall(g);

View File

@ -39,6 +39,8 @@ function bar(a,b) {
throw new Error("uncaught"); // EXCEPTION
}
%PrepareFunctionForOptimization(foo);
foo();
%PerformMicrotaskCheckpoint();
@ -52,6 +54,7 @@ foo();
%PerformMicrotaskCheckpoint();
%NeverOptimizeFunction(bar);
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
// bar does not get inlined into foo.

View File

@ -14,6 +14,8 @@ function f(o) {
return result;
}
%PrepareFunctionForOptimization(f);
assertEquals(["0"], f("a"));
assertEquals(["0"], f("a"));
@ -62,6 +64,8 @@ function check_f2() {
property_descriptor_keys.length = 0;
}
%PrepareFunctionForOptimization(f2);
check_f2();
check_f2();
@ -71,6 +75,7 @@ deopt_enum = true;
check_f2();
// Test lazy deopt after FILTER_KEY
%PrepareFunctionForOptimization(f2);
%OptimizeFunctionOnNextCall(f2);
deopt_property_descriptor = true;
check_f2();
@ -81,6 +86,7 @@ function f3(o) {
}
}
%PrepareFunctionForOptimization(f3);
f3({__proto__:{x:1}});
f3({__proto__:{x:1}});
@ -106,6 +112,8 @@ function check_f4() {
property_descriptor_keys.length = 0;
}
%PrepareFunctionForOptimization(f4);
check_f4();
check_f4();
@ -146,6 +154,7 @@ function f5() {
x = false;
%PrepareFunctionForOptimization(f5);
f5(); f5(); f5();
%OptimizeFunctionOnNextCall(f5);
x = true;

View File

@ -678,6 +678,7 @@ function catch_block_7() {
}
};
%PrepareFunctionForOptimization(catch_block_7);
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Catch,

View File

@ -23,6 +23,7 @@ function listener(event, exec_state, event_data, data) {
break_count++;
}
%PrepareFunctionForOptimization(g);
g();
g();
%OptimizeFunctionOnNextCall(g);

View File

@ -15,6 +15,7 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
// Optimize foo.
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
foo();
assertOptimized(foo);

View File

@ -52,6 +52,7 @@ c();
Debug.setListener(function () {});
var d = create_closure();
%PrepareFunctionForOptimization(d);
%OptimizeFunctionOnNextCall(d);
// Thanks to the debugger, we recreate the full code too. We deopt and run
// it, stomping on the unexpected AllocationSite in the type vector slot.

View File

@ -25,6 +25,8 @@ function f() {
debugger;
}
%PrepareFunctionForOptimization(f);
f();
f();

View File

@ -22,6 +22,8 @@ function f() {
debugger;
}
%PrepareFunctionForOptimization(f);
f();
f();

View File

@ -27,6 +27,8 @@ function f() {
}
}
%PrepareFunctionForOptimization(f);
f();
f();

View File

@ -9,6 +9,7 @@ function f() { g(); }
function g() { }
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);

View File

@ -7,6 +7,7 @@ function bar(x) { debugger; }
function foo() { bar(arguments[0]); }
function wrap() { return foo(1); }
%PrepareFunctionForOptimization(wrap);
wrap();
wrap();
%OptimizeFunctionOnNextCall(wrap);

View File

@ -28,6 +28,7 @@ Debug.setListener(listener);
} catch (e) {
}
}
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);

View File

@ -34,6 +34,7 @@ function g() {
b=2;
}
%PrepareFunctionForOptimization(Debug.setBreakPoint);
bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp);
%OptimizeFunctionOnNextCall(Debug.setBreakPoint);
@ -41,6 +42,7 @@ bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp);
bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp);
%PrepareFunctionForOptimization(Debug.setBreakPoint);
%OptimizeFunctionOnNextCall(Debug.setBreakPoint);
bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp);

View File

@ -45,13 +45,16 @@ var f = function() {
var bar = "foo";
var baz = bar; // Break point should be here.
return bar;
}
};
var g = function() {
var bar = "foo";
var baz = bar; // Break point should be here.
return bar;
}
};
%PrepareFunctionForOptimization(f);
%PrepareFunctionForOptimization(g);
f();
f();

View File

@ -53,8 +53,9 @@ var f = function() {
var b = a.substring("1");
[a, b].sort();
return a;
}
};
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f, "concurrent"); // Mark with builtin.

View File

@ -45,6 +45,7 @@ function bar() {
return x;
}
%PrepareFunctionForOptimization(foo);
foo();
foo();
// Mark and kick off recompilation.

View File

@ -18,6 +18,7 @@ function h() {
return g();
}
%PrepareFunctionForOptimization(h);
h();
h();

View File

@ -15,6 +15,7 @@ function h() {
return g();
}
%PrepareFunctionForOptimization(h);
h();
h();

View File

@ -15,6 +15,7 @@ function h() {
return g();
}
%PrepareFunctionForOptimization(h);
h();
h();

View File

@ -16,8 +16,9 @@ var f = function() {
} catch (e) {
}
});
}
};
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);

View File

@ -47,14 +47,17 @@ function listener(event, exec_state, event_data, data) {
wrapper1();
fail("wrapper1()");
%PrepareFunctionForOptimization(wrapper2);
wrapper2(true);
wrapper2(false);
wrapper2(true);
%OptimizeFunctionOnNextCall(wrapper2);
wrapper2(false);
fail("wrapper2(true)");
fail("%OptimizeFunctionOnNextCall(wrapper2); wrapper2(true)");
fail("%PrepareFunctionForOptimization(wrapper2); "+
"%OptimizeFunctionOnNextCall(wrapper2); wrapper2(true)");
%PrepareFunctionForOptimization(wrapper2);
%OptimizeFunctionOnNextCall(wrapper2, "concurrent");
wrapper2(false);
fail("%UnblockConcurrentRecompilation();" +

View File

@ -8,6 +8,7 @@ function listener() {}
function f() { [1,2,3].forEach(g) }
function g() { debugger }
%PrepareFunctionForOptimization(f);
f();
f();
Debug.setListener(listener);