Commit a67f31c4 authored by yangguo's avatar yangguo Committed by Commit bot

Speed up cctest/test-debug/DebugBreakLoop.

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/1262613002

Cr-Commit-Position: refs/heads/master@{#29918}
parent def86473
...@@ -409,10 +409,6 @@ void FullCodeGenerator::EmitProfilingCounterReset() { ...@@ -409,10 +409,6 @@ void FullCodeGenerator::EmitProfilingCounterReset() {
Label start; Label start;
__ bind(&start); __ bind(&start);
int reset_value = FLAG_interrupt_budget; int reset_value = FLAG_interrupt_budget;
if (info_->is_debug()) {
// Detect debug break requests as soon as possible.
reset_value = FLAG_interrupt_budget >> 4;
}
__ mov(r2, Operand(profiling_counter_)); __ mov(r2, Operand(profiling_counter_));
// The mov instruction above can be either 1 to 3 (for ARMv7) or 1 to 5 // The mov instruction above can be either 1 to 3 (for ARMv7) or 1 to 5
// instructions (for ARMv6) depending upon whether it is an extended constant // instructions (for ARMv6) depending upon whether it is an extended constant
......
...@@ -403,10 +403,6 @@ void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) { ...@@ -403,10 +403,6 @@ void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
void FullCodeGenerator::EmitProfilingCounterReset() { void FullCodeGenerator::EmitProfilingCounterReset() {
int reset_value = FLAG_interrupt_budget; int reset_value = FLAG_interrupt_budget;
if (info_->is_debug()) {
// Detect debug break requests as soon as possible.
reset_value = FLAG_interrupt_budget >> 4;
}
__ Mov(x2, Operand(profiling_counter_)); __ Mov(x2, Operand(profiling_counter_));
__ Mov(x3, Smi::FromInt(reset_value)); __ Mov(x3, Smi::FromInt(reset_value));
__ Str(x3, FieldMemOperand(x2, Cell::kValueOffset)); __ Str(x3, FieldMemOperand(x2, Cell::kValueOffset));
......
...@@ -108,7 +108,6 @@ ...@@ -108,7 +108,6 @@
'test-heap-profiler/ManyLocalsInSharedContext': [PASS, NO_VARIANTS], 'test-heap-profiler/ManyLocalsInSharedContext': [PASS, NO_VARIANTS],
'test-serialize/SerializeToplevelLargeCodeObject': [PASS, NO_VARIANTS], 'test-serialize/SerializeToplevelLargeCodeObject': [PASS, NO_VARIANTS],
'test-debug/ThreadedDebugging': [PASS, NO_VARIANTS], 'test-debug/ThreadedDebugging': [PASS, NO_VARIANTS],
'test-debug/DebugBreakLoop': [PASS, NO_VARIANTS],
# BUG(3742). # BUG(3742).
'test-mark-compact/MarkCompactCollector': [PASS, ['arch==arm', NO_VARIANTS]], 'test-mark-compact/MarkCompactCollector': [PASS, ['arch==arm', NO_VARIANTS]],
...@@ -133,12 +132,6 @@ ...@@ -133,12 +132,6 @@
'test-lockers/LockerUnlocker': [PASS, ['mode == debug', FLAKY]], 'test-lockers/LockerUnlocker': [PASS, ['mode == debug', FLAKY]],
}], # ALWAYS }], # ALWAYS
##############################################################################
['novfp3 == True', {
# TODO(yangguo): Got very slow after 3069c43.
'test-debug/DebugBreakLoop': [SKIP],
}], # novfp3 == True
############################################################################## ##############################################################################
['arch == arm64', { ['arch == arm64', {
...@@ -183,7 +176,6 @@ ...@@ -183,7 +176,6 @@
'test-api/ExternalFloatArray': [SKIP], 'test-api/ExternalFloatArray': [SKIP],
'test-api/Float32Array': [SKIP], 'test-api/Float32Array': [SKIP],
'test-api/Float64Array': [SKIP], 'test-api/Float64Array': [SKIP],
'test-debug/DebugBreakLoop': [SKIP],
}], # 'arch == arm64 and mode == debug and simulator_run == True' }], # 'arch == arm64 and mode == debug and simulator_run == True'
############################################################################## ##############################################################################
......
...@@ -853,7 +853,6 @@ bool terminate_after_max_break_point_hit = false; ...@@ -853,7 +853,6 @@ bool terminate_after_max_break_point_hit = false;
static void DebugEventBreakMax( static void DebugEventBreakMax(
const v8::Debug::EventDetails& event_details) { const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent(); v8::DebugEvent event = event_details.GetEvent();
v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
v8::Isolate* v8_isolate = CcTest::isolate(); v8::Isolate* v8_isolate = CcTest::isolate();
v8::internal::Isolate* isolate = CcTest::i_isolate(); v8::internal::Isolate* isolate = CcTest::i_isolate();
v8::internal::Debug* debug = isolate->debug(); v8::internal::Debug* debug = isolate->debug();
...@@ -865,17 +864,6 @@ static void DebugEventBreakMax( ...@@ -865,17 +864,6 @@ static void DebugEventBreakMax(
// Count the number of breaks. // Count the number of breaks.
break_point_hit_count++; break_point_hit_count++;
// Collect the JavsScript stack height if the function frame_count is
// compiled.
if (!frame_count.IsEmpty()) {
static const int kArgc = 1;
v8::Handle<v8::Value> argv[kArgc] = { exec_state };
// Using exec_state as receiver is just to have a receiver.
v8::Handle<v8::Value> result =
frame_count->Call(exec_state, kArgc, argv);
last_js_stack_height = result->Int32Value();
}
// Set the break flag again to come back here as soon as possible. // Set the break flag again to come back here as soon as possible.
v8::Debug::DebugBreak(v8_isolate); v8::Debug::DebugBreak(v8_isolate);
...@@ -7087,15 +7075,22 @@ TEST(DebugBreakStackInspection) { ...@@ -7087,15 +7075,22 @@ TEST(DebugBreakStackInspection) {
static void TestDebugBreakInLoop(const char* loop_head, static void TestDebugBreakInLoop(const char* loop_head,
const char** loop_bodies, const char** loop_bodies,
const char* loop_tail) { const char* loop_tail) {
// Receive 100 breaks for each test and then terminate JavaScript execution. // Receive 10 breaks for each test and then terminate JavaScript execution.
static const int kBreaksPerTest = 100; static const int kBreaksPerTest = 10;
for (int i = 0; loop_bodies[i] != NULL; i++) { for (int i = 0; loop_bodies[i] != NULL; i++) {
// Perform a lazy deoptimization after various numbers of breaks // Perform a lazy deoptimization after various numbers of breaks
// have been hit. // have been hit.
for (int j = 0; j < 7; j++) {
EmbeddedVector<char, 1024> buffer;
SNPrintF(buffer, "function f() {%s%s%s}", loop_head, loop_bodies[i],
loop_tail);
i::PrintF("%s\n", buffer.start());
for (int j = 0; j < 3; j++) {
break_point_hit_count_deoptimize = j; break_point_hit_count_deoptimize = j;
if (j == 6) { if (j == 2) {
break_point_hit_count_deoptimize = kBreaksPerTest; break_point_hit_count_deoptimize = kBreaksPerTest;
} }
...@@ -7103,11 +7098,6 @@ static void TestDebugBreakInLoop(const char* loop_head, ...@@ -7103,11 +7098,6 @@ static void TestDebugBreakInLoop(const char* loop_head,
max_break_point_hit_count = kBreaksPerTest; max_break_point_hit_count = kBreaksPerTest;
terminate_after_max_break_point_hit = true; terminate_after_max_break_point_hit = true;
EmbeddedVector<char, 1024> buffer;
SNPrintF(buffer,
"function f() {%s%s%s}",
loop_head, loop_bodies[i], loop_tail);
// Function with infinite loop. // Function with infinite loop.
CompileRun(buffer.start()); CompileRun(buffer.start());
...@@ -7124,43 +7114,38 @@ static void TestDebugBreakInLoop(const char* loop_head, ...@@ -7124,43 +7114,38 @@ static void TestDebugBreakInLoop(const char* loop_head,
} }
TEST(DebugBreakLoop) { static const char* loop_bodies_1[] = {"",
"g()",
"if (a == 0) { g() }",
"if (a == 1) { g() }",
"if (a == 0) { g() } else { h() }",
"if (a == 0) { continue }",
NULL};
static const char* loop_bodies_2[] = {
"if (a == 1) { continue }",
"switch (a) { case 1: g(); }",
"switch (a) { case 1: continue; }",
"switch (a) { case 1: g(); break; default: h() }",
"switch (a) { case 1: continue; break; default: h() }",
NULL};
void DebugBreakLoop(const char* loop_header, const char** loop_bodies,
const char* loop_footer) {
DebugLocalContext env; DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate()); v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts. // Register a debug event listener which sets the break flag and counts.
v8::Debug::SetDebugEventListener(DebugEventBreakMax); v8::Debug::SetDebugEventListener(DebugEventBreakMax);
// Create a function for getting the frame count when hitting the break. CompileRun(
frame_count = CompileFunction(&env, frame_count_source, "frame_count"); "var a = 1;\n"
"function g() { }\n"
CompileRun("var a = 1;"); "function h() { }");
CompileRun("function g() { }");
CompileRun("function h() { }");
const char* loop_bodies[] = {
"",
"g()",
"if (a == 0) { g() }",
"if (a == 1) { g() }",
"if (a == 0) { g() } else { h() }",
"if (a == 0) { continue }",
"if (a == 1) { continue }",
"switch (a) { case 1: g(); }",
"switch (a) { case 1: continue; }",
"switch (a) { case 1: g(); break; default: h() }",
"switch (a) { case 1: continue; break; default: h() }",
NULL
};
TestDebugBreakInLoop("while (true) {", loop_bodies, "}");
TestDebugBreakInLoop("while (a == 1) {", loop_bodies, "}");
TestDebugBreakInLoop("do {", loop_bodies, "} while (true)");
TestDebugBreakInLoop("do {", loop_bodies, "} while (a == 1)");
TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); TestDebugBreakInLoop(loop_header, loop_bodies, loop_footer);
TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
// Get rid of the debug event listener. // Get rid of the debug event listener.
v8::Debug::SetDebugEventListener(NULL); v8::Debug::SetDebugEventListener(NULL);
...@@ -7168,6 +7153,62 @@ TEST(DebugBreakLoop) { ...@@ -7168,6 +7153,62 @@ TEST(DebugBreakLoop) {
} }
TEST(DebugBreakInWhileTrue1) {
DebugBreakLoop("while (true) {", loop_bodies_1, "}");
}
TEST(DebugBreakInWhileTrue2) {
DebugBreakLoop("while (true) {", loop_bodies_2, "}");
}
TEST(DebugBreakInWhileCondition1) {
DebugBreakLoop("while (a == 1) {", loop_bodies_1, "}");
}
TEST(DebugBreakInWhileCondition2) {
DebugBreakLoop("while (a == 1) {", loop_bodies_2, "}");
}
TEST(DebugBreakInDoWhileTrue1) {
DebugBreakLoop("do {", loop_bodies_1, "} while (true)");
}
TEST(DebugBreakInDoWhileTrue2) {
DebugBreakLoop("do {", loop_bodies_2, "} while (true)");
}
TEST(DebugBreakInDoWhileCondition1) {
DebugBreakLoop("do {", loop_bodies_1, "} while (a == 1)");
}
TEST(DebugBreakInDoWhileCondition2) {
DebugBreakLoop("do {", loop_bodies_2, "} while (a == 1)");
}
TEST(DebugBreakInFor1) { DebugBreakLoop("for (;;) {", loop_bodies_1, "}"); }
TEST(DebugBreakInFor2) { DebugBreakLoop("for (;;) {", loop_bodies_2, "}"); }
TEST(DebugBreakInForCondition1) {
DebugBreakLoop("for (;a == 1;) {", loop_bodies_1, "}");
}
TEST(DebugBreakInForCondition2) {
DebugBreakLoop("for (;a == 1;) {", loop_bodies_2, "}");
}
v8::Local<v8::Script> inline_script; v8::Local<v8::Script> inline_script;
static void DebugBreakInlineListener( static void DebugBreakInlineListener(
......
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