Revision: 22013
Author: [email protected]
Date: Wed Jun 25 12:42:28 2014 UTC
Log: Reorder full code for while loops to better reflect statement
positions.
[email protected]
BUG=v8:2047
LOG=N
Review URL: https://codereview.chromium.org/353823002
http://code.google.com/p/v8/source/detail?r=22013
Modified:
/branches/bleeding_edge/src/full-codegen.cc
/branches/bleeding_edge/src/full-codegen.h
/branches/bleeding_edge/test/cctest/test-debug.cc
=======================================
--- /branches/bleeding_edge/src/full-codegen.cc Tue Jun 24 09:31:30 2014 UTC
+++ /branches/bleeding_edge/src/full-codegen.cc Wed Jun 25 12:42:28 2014 UTC
@@ -852,11 +852,6 @@
}
}
}
-
-
-void FullCodeGenerator::SetStatementPosition(int pos) {
- CodeGenerator::RecordPositions(masm_, pos);
-}
void FullCodeGenerator::SetSourcePosition(int pos) {
@@ -1283,31 +1278,28 @@
void FullCodeGenerator::VisitWhileStatement(WhileStatement* stmt) {
Comment cmnt(masm_, "[ WhileStatement");
- Label test, body;
+ Label loop, body;
Iteration loop_statement(this, stmt);
increment_loop_depth();
- // Emit the test at the bottom of the loop.
- __ jmp(&test);
+ __ bind(&loop);
+
+ SetExpressionPosition(stmt->cond());
+ VisitForControl(stmt->cond(),
+ &body,
+ loop_statement.break_label(),
+ &body);
PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS);
__ bind(&body);
Visit(stmt->body());
- // Emit the statement position here as this is where the while
- // statement code starts.
__ bind(loop_statement.continue_label());
- SetStatementPosition(stmt);
// Check stack before looping.
- EmitBackEdgeBookkeeping(stmt, &body);
-
- __ bind(&test);
- VisitForControl(stmt->cond(),
- &body,
- loop_statement.break_label(),
- loop_statement.break_label());
+ EmitBackEdgeBookkeeping(stmt, &loop);
+ __ jmp(&loop);
PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
__ bind(loop_statement.break_label());
=======================================
--- /branches/bleeding_edge/src/full-codegen.h Tue Jun 24 09:31:30 2014 UTC
+++ /branches/bleeding_edge/src/full-codegen.h Wed Jun 25 12:42:28 2014 UTC
@@ -562,7 +562,6 @@
void SetReturnPosition(FunctionLiteral* fun);
void SetStatementPosition(Statement* stmt);
void SetExpressionPosition(Expression* expr);
- void SetStatementPosition(int pos);
void SetSourcePosition(int pos);
// Non-local control flow support.
=======================================
--- /branches/bleeding_edge/test/cctest/test-debug.cc Fri Jun 13 16:43:27
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-debug.cc Wed Jun 25 12:42:28
2014 UTC
@@ -3193,19 +3193,26 @@
v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
SetBreakPoint(foo, 8); // "var a = 0;"
+ // Looping 0 times. We still should break at the while-condition once.
+ step_action = StepIn;
+ break_point_hit_count = 0;
+ v8::Handle<v8::Value> argv_0[argc] = { v8::Number::New(isolate, 0) };
+ foo->Call(env->Global(), argc, argv_0);
+ CHECK_EQ(3, break_point_hit_count);
+
// Looping 10 times.
step_action = StepIn;
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_10[argc] = { v8::Number::New(isolate, 10) };
foo->Call(env->Global(), argc, argv_10);
- CHECK_EQ(22, break_point_hit_count);
+ CHECK_EQ(23, break_point_hit_count);
// Looping 100 times.
step_action = StepIn;
break_point_hit_count = 0;
v8::Handle<v8::Value> argv_100[argc] = { v8::Number::New(isolate, 100) };
foo->Call(env->Global(), argc, argv_100);
- CHECK_EQ(202, break_point_hit_count);
+ CHECK_EQ(203, break_point_hit_count);
// Get rid of the debug event listener.
v8::Debug::SetDebugEventListener(NULL);
@@ -5123,10 +5130,7 @@
if (IsBreakEventMessage(print_buffer)) {
// Check that we are inside the while loop.
int source_line = GetSourceLineFromBreakEventMessage(print_buffer);
- // TODO(2047): This should really be 8 <= source_line <= 13; but we
- // currently have an off-by-one error when calculating the source
- // position corresponding to the program counter at the debug break.
- CHECK(7 <= source_line && source_line <= 13);
+ CHECK(8 <= source_line && source_line <= 13);
threaded_debugging_barriers.barrier_2.Wait();
}
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.