Index: test/cctest/test-debug.cc |
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc |
index 7bdf08730211bee7cdb700144a6384f2a7720376..7bf35f530070ab55995bf65ecdb71399cebe94ba 100644 |
--- a/test/cctest/test-debug.cc |
+++ b/test/cctest/test-debug.cc |
@@ -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( |