Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index cb133c365eb053b713b31638e1c7d23ec6716668..34865251da57ca16fe0157836f2098214cc8599a 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -1118,7 +1118,6 @@ void BytecodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
Register tag = VisitForRegisterValue(stmt->tag()); |
// Iterate over all cases and create nodes for label comparison. |
- BytecodeLabel done_label; |
for (int i = 0; i < clauses->length(); i++) { |
CaseClause* clause = clauses->at(i); |
@@ -1139,8 +1138,8 @@ void BytecodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
switch_builder.DefaultAt(default_index); |
} else { |
// Otherwise if we have reached here none of the cases matched, so jump to |
- // done. |
- builder()->Jump(&done_label); |
+ // the end. |
+ switch_builder.Break(); |
} |
// Iterate over all cases and create the case bodies. |
@@ -1149,9 +1148,7 @@ void BytecodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
switch_builder.SetCaseTarget(i); |
VisitStatements(clause->statements()); |
} |
- builder()->Bind(&done_label); |
- |
- switch_builder.SetBreakTarget(done_label); |
+ switch_builder.BindBreakTarget(); |
} |
void BytecodeGenerator::VisitCaseClause(CaseClause* clause) { |
@@ -1164,7 +1161,7 @@ void BytecodeGenerator::VisitIterationBody(IterationStatement* stmt, |
ControlScopeForIteration execution_control(this, stmt, loop_builder); |
builder()->StackCheck(stmt->position()); |
Visit(stmt->body()); |
- loop_builder->SetContinueTarget(); |
+ loop_builder->BindContinueTarget(); |
} |
void BytecodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { |
@@ -1179,9 +1176,8 @@ void BytecodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { |
VisitIterationHeader(stmt, &loop_builder); |
VisitIterationBody(stmt, &loop_builder); |
builder()->SetExpressionAsStatementPosition(stmt->cond()); |
- // TODO(klaasb) VisitForTest for loop conditions |
- VisitForAccumulatorValue(stmt->cond()); |
- loop_builder.JumpToHeaderIfTrue(); |
+ VisitForTest(stmt->cond(), loop_builder.header_labels(), |
Michael Starzinger
2016/08/18 13:24:28
Just for posterity: I am fine with this. But this
klaasb
2016/08/18 13:50:11
True. However, when/if that's needed we could just
|
+ loop_builder.break_labels(), TestFallthrough::kElse); |
} |
loop_builder.EndLoop(); |
} |
@@ -1196,9 +1192,10 @@ void BytecodeGenerator::VisitWhileStatement(WhileStatement* stmt) { |
VisitIterationHeader(stmt, &loop_builder); |
if (!stmt->cond()->ToBooleanIsTrue()) { |
builder()->SetExpressionAsStatementPosition(stmt->cond()); |
- // TODO(klaasb) VisitForTest for loop conditions |
- VisitForAccumulatorValue(stmt->cond()); |
- loop_builder.BreakIfFalse(); |
+ BytecodeLabels loop_body(zone()); |
+ VisitForTest(stmt->cond(), &loop_body, loop_builder.break_labels(), |
+ TestFallthrough::kThen); |
+ loop_body.Bind(builder()); |
} |
VisitIterationBody(stmt, &loop_builder); |
loop_builder.JumpToHeader(); |
@@ -1219,9 +1216,10 @@ void BytecodeGenerator::VisitForStatement(ForStatement* stmt) { |
VisitIterationHeader(stmt, &loop_builder); |
if (stmt->cond() && !stmt->cond()->ToBooleanIsTrue()) { |
builder()->SetExpressionAsStatementPosition(stmt->cond()); |
- // TODO(klaasb) VisitForTest for loop conditions |
- VisitForAccumulatorValue(stmt->cond()); |
- loop_builder.BreakIfFalse(); |
+ BytecodeLabels loop_body(zone()); |
+ VisitForTest(stmt->cond(), &loop_body, loop_builder.break_labels(), |
+ TestFallthrough::kThen); |
+ loop_body.Bind(builder()); |
} |
VisitIterationBody(stmt, &loop_builder); |
if (stmt->next() != nullptr) { |