Commit c0720d28 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Test] Add PrepareForOptimization to debugger/ tests.

BUG=v8:8801

Change-Id: Id5ef6219ba2dca2be0603dd0d45e7b27136836e9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1587391Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61085}
parent 884a45a7
...@@ -34,6 +34,7 @@ Debug.setListener(listener); ...@@ -34,6 +34,7 @@ Debug.setListener(listener);
return e; return e;
} }
} }
%PrepareFunctionForOptimization(f);
assertEquals("boom1", f(1)); assertEquals("boom1", f(1));
assertEquals("boom2", f(2)); assertEquals("boom2", f(2));
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -51,6 +52,7 @@ Debug.setListener(listener); ...@@ -51,6 +52,7 @@ Debug.setListener(listener);
return a + 10; return a + 10;
} }
} }
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1)); assertEquals(11, f(1));
assertEquals(12, f(2)); assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -70,6 +72,7 @@ Debug.setListener(listener); ...@@ -70,6 +72,7 @@ Debug.setListener(listener);
// Nothing. // Nothing.
} }
} }
%PrepareFunctionForOptimization(f);
assertEquals("wosh11", f(1)); assertEquals("wosh11", f(1));
assertEquals("wosh22", f(2)); assertEquals("wosh22", f(2));
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -91,6 +94,7 @@ Debug.setListener(listener); ...@@ -91,6 +94,7 @@ Debug.setListener(listener);
return e + a; return e + a;
} }
} }
%PrepareFunctionForOptimization(f);
assertEquals("bang11", f(1)); assertEquals("bang11", f(1));
assertEquals("bang22", f(2)); assertEquals("bang22", f(2));
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -112,6 +116,7 @@ Debug.setListener(listener); ...@@ -112,6 +116,7 @@ Debug.setListener(listener);
return a + 10; return a + 10;
} }
} }
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1)); assertEquals(11, f(1));
assertEquals(12, f(2)); assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -133,6 +138,7 @@ Debug.setListener(listener); ...@@ -133,6 +138,7 @@ Debug.setListener(listener);
return a + 10; return a + 10;
} }
} }
%PrepareFunctionForOptimization(f);
assertEquals(11, f(1)); assertEquals(11, f(1));
assertEquals(12, f(2)); assertEquals(12, f(2));
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -63,6 +63,7 @@ function h() { ...@@ -63,6 +63,7 @@ function h() {
debugger; debugger;
} }
%PrepareFunctionForOptimization(f);
f();f();f(); f();f();f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
f(); f();
......
...@@ -9,6 +9,7 @@ Debug = debug.Debug; ...@@ -9,6 +9,7 @@ Debug = debug.Debug;
Debug.setListener(function() {}); Debug.setListener(function() {});
function f() {} function f() {}
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -17,6 +18,7 @@ assertOptimized(f); ...@@ -17,6 +18,7 @@ assertOptimized(f);
var bp = Debug.setBreakPoint(f); var bp = Debug.setBreakPoint(f);
assertUnoptimized(f); assertUnoptimized(f);
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -24,6 +26,7 @@ f(); ...@@ -24,6 +26,7 @@ f();
assertUnoptimized(f); assertUnoptimized(f);
Debug.clearBreakPoint(bp); Debug.clearBreakPoint(bp);
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
f(); f();
assertOptimized(f); assertOptimized(f);
......
...@@ -30,6 +30,7 @@ function foo(a) { ...@@ -30,6 +30,7 @@ function foo(a) {
} }
return bar(1,2,a); return bar(1,2,a);
} }
%PrepareFunctionForOptimization(foo);
listened = false; listened = false;
foo_expected = [3]; foo_expected = [3];
...@@ -53,6 +54,7 @@ assertTrue(listened); ...@@ -53,6 +54,7 @@ assertTrue(listened);
listened = false; listened = false;
foo_expected = [3,4,5]; foo_expected = [3,4,5];
bar_expected = [1,2,3]; bar_expected = [1,2,3];
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
assertEquals(6, foo(3,4,5)); assertEquals(6, foo(3,4,5));
assertTrue(listened); assertTrue(listened);
......
...@@ -131,6 +131,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -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); for (var i = 0; i < 4; i++) f(input.length - 1, 11.11, 12.12);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
f(input.length - 1, 11.11, 12.12); f(input.length - 1, 11.11, 12.12);
......
...@@ -122,6 +122,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -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); for (var i = 0; i < 4; i++) f(expected.length - 1, 11, 12);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
f(expected.length - 1, 11, 12); f(expected.length - 1, 11, 12);
......
...@@ -12,8 +12,9 @@ eval("var something1 = 25; " ...@@ -12,8 +12,9 @@ eval("var something1 = 25; "
function foo() { return ChooseAnimal() } function foo() { return ChooseAnimal() }
%PrepareFunctionForOptimization(foo);
assertEquals("Cat", foo()); assertEquals("Cat", foo());
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
foo(); foo();
......
...@@ -18,6 +18,8 @@ function bar() { ...@@ -18,6 +18,8 @@ function bar() {
return t.a; return t.a;
} }
%PrepareFunctionForOptimization(foo);
%PrepareFunctionForOptimization(bar);
foo(1); foo(1);
foo(1); foo(1);
bar(1); bar(1);
......
...@@ -24,6 +24,7 @@ function f4() { ...@@ -24,6 +24,7 @@ function f4() {
function optimize(f) { function optimize(f) {
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -457,6 +457,7 @@ function with_7() { ...@@ -457,6 +457,7 @@ function with_7() {
debugger; debugger;
} }
} }
%PrepareFunctionForOptimization(with_7);
listener_delegate = function(exec_state) { listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.With, CheckScopeChain([debug.ScopeType.With,
...@@ -825,6 +826,7 @@ listener_delegate = function(exec_state) { ...@@ -825,6 +826,7 @@ listener_delegate = function(exec_state) {
CheckScopeChainNames( CheckScopeChainNames(
["closure_11", "closure_10", undefined, undefined], exec_state); ["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++;
begin_test_count++; closure_10(5); end_test_count++; begin_test_count++; closure_10(5); end_test_count++;
%OptimizeFunctionOnNextCall(closure_10); %OptimizeFunctionOnNextCall(closure_10);
...@@ -1152,6 +1154,7 @@ function catch_block_7() { ...@@ -1152,6 +1154,7 @@ function catch_block_7() {
debugger; debugger;
} }
}; };
%PrepareFunctionForOptimization(catch_block_7);
listener_delegate = function(exec_state) { listener_delegate = function(exec_state) {
......
...@@ -44,6 +44,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -44,6 +44,7 @@ function listener(event, exec_state, event_data, data) {
} }
} }
%PrepareFunctionForOptimization(g);
f(0); f(0);
f(0); f(0);
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
......
...@@ -39,6 +39,8 @@ function bar(a,b) { ...@@ -39,6 +39,8 @@ function bar(a,b) {
throw new Error("uncaught"); // EXCEPTION throw new Error("uncaught"); // EXCEPTION
} }
%PrepareFunctionForOptimization(foo);
foo(); foo();
%PerformMicrotaskCheckpoint(); %PerformMicrotaskCheckpoint();
...@@ -52,6 +54,7 @@ foo(); ...@@ -52,6 +54,7 @@ foo();
%PerformMicrotaskCheckpoint(); %PerformMicrotaskCheckpoint();
%NeverOptimizeFunction(bar); %NeverOptimizeFunction(bar);
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
// bar does not get inlined into foo. // bar does not get inlined into foo.
......
...@@ -14,6 +14,8 @@ function f(o) { ...@@ -14,6 +14,8 @@ function f(o) {
return result; return result;
} }
%PrepareFunctionForOptimization(f);
assertEquals(["0"], f("a")); assertEquals(["0"], f("a"));
assertEquals(["0"], f("a")); assertEquals(["0"], f("a"));
...@@ -62,6 +64,8 @@ function check_f2() { ...@@ -62,6 +64,8 @@ function check_f2() {
property_descriptor_keys.length = 0; property_descriptor_keys.length = 0;
} }
%PrepareFunctionForOptimization(f2);
check_f2(); check_f2();
check_f2(); check_f2();
...@@ -71,6 +75,7 @@ deopt_enum = true; ...@@ -71,6 +75,7 @@ deopt_enum = true;
check_f2(); check_f2();
// Test lazy deopt after FILTER_KEY // Test lazy deopt after FILTER_KEY
%PrepareFunctionForOptimization(f2);
%OptimizeFunctionOnNextCall(f2); %OptimizeFunctionOnNextCall(f2);
deopt_property_descriptor = true; deopt_property_descriptor = true;
check_f2(); check_f2();
...@@ -81,6 +86,7 @@ function f3(o) { ...@@ -81,6 +86,7 @@ function f3(o) {
} }
} }
%PrepareFunctionForOptimization(f3);
f3({__proto__:{x:1}}); f3({__proto__:{x:1}});
f3({__proto__:{x:1}}); f3({__proto__:{x:1}});
...@@ -106,6 +112,8 @@ function check_f4() { ...@@ -106,6 +112,8 @@ function check_f4() {
property_descriptor_keys.length = 0; property_descriptor_keys.length = 0;
} }
%PrepareFunctionForOptimization(f4);
check_f4(); check_f4();
check_f4(); check_f4();
...@@ -146,6 +154,7 @@ function f5() { ...@@ -146,6 +154,7 @@ function f5() {
x = false; x = false;
%PrepareFunctionForOptimization(f5);
f5(); f5(); f5(); f5(); f5(); f5();
%OptimizeFunctionOnNextCall(f5); %OptimizeFunctionOnNextCall(f5);
x = true; x = true;
......
...@@ -678,6 +678,7 @@ function catch_block_7() { ...@@ -678,6 +678,7 @@ function catch_block_7() {
} }
}; };
%PrepareFunctionForOptimization(catch_block_7);
listener_delegate = function(exec_state) { listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Catch, CheckScopeChain([debug.ScopeType.Catch,
......
...@@ -23,6 +23,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -23,6 +23,7 @@ function listener(event, exec_state, event_data, data) {
break_count++; break_count++;
} }
%PrepareFunctionForOptimization(g);
g(); g();
g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
......
...@@ -15,6 +15,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -15,6 +15,7 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return; if (event != Debug.DebugEvent.Break) return;
// Optimize foo. // Optimize foo.
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
foo(); foo();
assertOptimized(foo); assertOptimized(foo);
......
...@@ -52,6 +52,7 @@ c(); ...@@ -52,6 +52,7 @@ c();
Debug.setListener(function () {}); Debug.setListener(function () {});
var d = create_closure(); var d = create_closure();
%PrepareFunctionForOptimization(d);
%OptimizeFunctionOnNextCall(d); %OptimizeFunctionOnNextCall(d);
// Thanks to the debugger, we recreate the full code too. We deopt and run // 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. // it, stomping on the unexpected AllocationSite in the type vector slot.
......
...@@ -25,6 +25,8 @@ function f() { ...@@ -25,6 +25,8 @@ function f() {
debugger; debugger;
} }
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
......
...@@ -22,6 +22,8 @@ function f() { ...@@ -22,6 +22,8 @@ function f() {
debugger; debugger;
} }
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
......
...@@ -27,6 +27,8 @@ function f() { ...@@ -27,6 +27,8 @@ function f() {
} }
} }
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
......
...@@ -9,6 +9,7 @@ function f() { g(); } ...@@ -9,6 +9,7 @@ function f() { g(); }
function g() { } function g() { }
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -7,6 +7,7 @@ function bar(x) { debugger; } ...@@ -7,6 +7,7 @@ function bar(x) { debugger; }
function foo() { bar(arguments[0]); } function foo() { bar(arguments[0]); }
function wrap() { return foo(1); } function wrap() { return foo(1); }
%PrepareFunctionForOptimization(wrap);
wrap(); wrap();
wrap(); wrap();
%OptimizeFunctionOnNextCall(wrap); %OptimizeFunctionOnNextCall(wrap);
......
...@@ -28,6 +28,7 @@ Debug.setListener(listener); ...@@ -28,6 +28,7 @@ Debug.setListener(listener);
} catch (e) { } catch (e) {
} }
} }
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -34,6 +34,7 @@ function g() { ...@@ -34,6 +34,7 @@ function g() {
b=2; b=2;
} }
%PrepareFunctionForOptimization(Debug.setBreakPoint);
bp = Debug.setBreakPoint(f, 0, 0); bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp); Debug.clearBreakPoint(bp);
%OptimizeFunctionOnNextCall(Debug.setBreakPoint); %OptimizeFunctionOnNextCall(Debug.setBreakPoint);
...@@ -41,6 +42,7 @@ bp = Debug.setBreakPoint(f, 0, 0); ...@@ -41,6 +42,7 @@ bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp); Debug.clearBreakPoint(bp);
bp = Debug.setBreakPoint(f, 0, 0); bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp); Debug.clearBreakPoint(bp);
%PrepareFunctionForOptimization(Debug.setBreakPoint);
%OptimizeFunctionOnNextCall(Debug.setBreakPoint); %OptimizeFunctionOnNextCall(Debug.setBreakPoint);
bp = Debug.setBreakPoint(f, 0, 0); bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp); Debug.clearBreakPoint(bp);
......
...@@ -45,13 +45,16 @@ var f = function() { ...@@ -45,13 +45,16 @@ var f = function() {
var bar = "foo"; var bar = "foo";
var baz = bar; // Break point should be here. var baz = bar; // Break point should be here.
return bar; return bar;
} };
var g = function() { var g = function() {
var bar = "foo"; var bar = "foo";
var baz = bar; // Break point should be here. var baz = bar; // Break point should be here.
return bar; return bar;
} };
%PrepareFunctionForOptimization(f);
%PrepareFunctionForOptimization(g);
f(); f();
f(); f();
......
...@@ -53,8 +53,9 @@ var f = function() { ...@@ -53,8 +53,9 @@ var f = function() {
var b = a.substring("1"); var b = a.substring("1");
[a, b].sort(); [a, b].sort();
return a; return a;
} };
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
%OptimizeFunctionOnNextCall(f, "concurrent"); // Mark with builtin. %OptimizeFunctionOnNextCall(f, "concurrent"); // Mark with builtin.
......
...@@ -45,6 +45,7 @@ function bar() { ...@@ -45,6 +45,7 @@ function bar() {
return x; return x;
} }
%PrepareFunctionForOptimization(foo);
foo(); foo();
foo(); foo();
// Mark and kick off recompilation. // Mark and kick off recompilation.
......
...@@ -18,6 +18,7 @@ function h() { ...@@ -18,6 +18,7 @@ function h() {
return g(); return g();
} }
%PrepareFunctionForOptimization(h);
h(); h();
h(); h();
......
...@@ -15,6 +15,7 @@ function h() { ...@@ -15,6 +15,7 @@ function h() {
return g(); return g();
} }
%PrepareFunctionForOptimization(h);
h(); h();
h(); h();
......
...@@ -15,6 +15,7 @@ function h() { ...@@ -15,6 +15,7 @@ function h() {
return g(); return g();
} }
%PrepareFunctionForOptimization(h);
h(); h();
h(); h();
......
...@@ -16,8 +16,9 @@ var f = function() { ...@@ -16,8 +16,9 @@ var f = function() {
} catch (e) { } catch (e) {
} }
}); });
} };
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -47,14 +47,17 @@ function listener(event, exec_state, event_data, data) { ...@@ -47,14 +47,17 @@ function listener(event, exec_state, event_data, data) {
wrapper1(); wrapper1();
fail("wrapper1()"); fail("wrapper1()");
%PrepareFunctionForOptimization(wrapper2);
wrapper2(true); wrapper2(true);
wrapper2(false); wrapper2(false);
wrapper2(true); wrapper2(true);
%OptimizeFunctionOnNextCall(wrapper2); %OptimizeFunctionOnNextCall(wrapper2);
wrapper2(false); wrapper2(false);
fail("wrapper2(true)"); fail("wrapper2(true)");
fail("%OptimizeFunctionOnNextCall(wrapper2); wrapper2(true)"); fail("%PrepareFunctionForOptimization(wrapper2); "+
"%OptimizeFunctionOnNextCall(wrapper2); wrapper2(true)");
%PrepareFunctionForOptimization(wrapper2);
%OptimizeFunctionOnNextCall(wrapper2, "concurrent"); %OptimizeFunctionOnNextCall(wrapper2, "concurrent");
wrapper2(false); wrapper2(false);
fail("%UnblockConcurrentRecompilation();" + fail("%UnblockConcurrentRecompilation();" +
......
...@@ -8,6 +8,7 @@ function listener() {} ...@@ -8,6 +8,7 @@ function listener() {}
function f() { [1,2,3].forEach(g) } function f() { [1,2,3].forEach(g) }
function g() { debugger } function g() { debugger }
%PrepareFunctionForOptimization(f);
f(); f();
f(); f();
Debug.setListener(listener); Debug.setListener(listener);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment