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() {
Label start;
__ bind(&start);
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_));
// 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
......
......@@ -403,10 +403,6 @@ void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
void FullCodeGenerator::EmitProfilingCounterReset() {
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(x3, Smi::FromInt(reset_value));
__ Str(x3, FieldMemOperand(x2, Cell::kValueOffset));
......
......@@ -108,7 +108,6 @@
'test-heap-profiler/ManyLocalsInSharedContext': [PASS, NO_VARIANTS],
'test-serialize/SerializeToplevelLargeCodeObject': [PASS, NO_VARIANTS],
'test-debug/ThreadedDebugging': [PASS, NO_VARIANTS],
'test-debug/DebugBreakLoop': [PASS, NO_VARIANTS],
# BUG(3742).
'test-mark-compact/MarkCompactCollector': [PASS, ['arch==arm', NO_VARIANTS]],
......@@ -133,12 +132,6 @@
'test-lockers/LockerUnlocker': [PASS, ['mode == debug', FLAKY]],
}], # ALWAYS
##############################################################################
['novfp3 == True', {
# TODO(yangguo): Got very slow after 3069c43.
'test-debug/DebugBreakLoop': [SKIP],
}], # novfp3 == True
##############################################################################
['arch == arm64', {
......@@ -183,7 +176,6 @@
'test-api/ExternalFloatArray': [SKIP],
'test-api/Float32Array': [SKIP],
'test-api/Float64Array': [SKIP],
'test-debug/DebugBreakLoop': [SKIP],
}], # 'arch == arm64 and mode == debug and simulator_run == True'
##############################################################################
......
......@@ -853,7 +853,6 @@ bool terminate_after_max_break_point_hit = false;
static void DebugEventBreakMax(
const v8::Debug::EventDetails& event_details) {
v8::DebugEvent event = event_details.GetEvent();
v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
v8::Isolate* v8_isolate = CcTest::isolate();
v8::internal::Isolate* isolate = CcTest::i_isolate();
v8::internal::Debug* debug = isolate->debug();
......@@ -865,17 +864,6 @@ static void DebugEventBreakMax(
// Count the number of breaks.
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.
v8::Debug::DebugBreak(v8_isolate);
......@@ -7087,15 +7075,22 @@ TEST(DebugBreakStackInspection) {
static void TestDebugBreakInLoop(const char* loop_head,
const char** loop_bodies,
const char* loop_tail) {
// Receive 100 breaks for each test and then terminate JavaScript execution.
static const int kBreaksPerTest = 100;
// Receive 10 breaks for each test and then terminate JavaScript execution.
static const int kBreaksPerTest = 10;
for (int i = 0; loop_bodies[i] != NULL; i++) {
// Perform a lazy deoptimization after various numbers of breaks
// 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;
if (j == 6) {
if (j == 2) {
break_point_hit_count_deoptimize = kBreaksPerTest;
}
......@@ -7103,11 +7098,6 @@ static void TestDebugBreakInLoop(const char* loop_head,
max_break_point_hit_count = kBreaksPerTest;
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.
CompileRun(buffer.start());
......@@ -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;
v8::HandleScope scope(env->GetIsolate());
// Register a debug event listener which sets the break flag and counts.
v8::Debug::SetDebugEventListener(DebugEventBreakMax);
// Create a function for getting the frame count when hitting the break.
frame_count = CompileFunction(&env, frame_count_source, "frame_count");
CompileRun("var a = 1;");
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)");
CompileRun(
"var a = 1;\n"
"function g() { }\n"
"function h() { }");
TestDebugBreakInLoop("for (;;) {", loop_bodies, "}");
TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
TestDebugBreakInLoop(loop_header, loop_bodies, loop_footer);
// Get rid of the debug event listener.
v8::Debug::SetDebugEventListener(NULL);
......@@ -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;
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