}
-void FullCodeGenerator::SetStatementPosition(int pos) {
- CodeGenerator::RecordPositions(masm_, pos);
-}
-
-
void FullCodeGenerator::SetSourcePosition(int pos) {
if (pos != RelocInfo::kNoPosition) {
masm_->positions_recorder()->RecordPosition(pos);
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());
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);
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();
}
}