Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2254493002: [interpreter] Use VisitForTest for loop conditions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase(line) golden file Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/bytecode-loop-analysis.cc ('k') | src/interpreter/bytecode-label.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 2b5b4ef828409d8bd28717a5a9186cb4134e2d46..ba90501dbf5f78e1c8960580268f5a24efe8b705 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -1119,7 +1119,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);
@@ -1140,8 +1139,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.
@@ -1150,9 +1149,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) {
@@ -1165,7 +1162,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) {
@@ -1180,9 +1177,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(),
+ loop_builder.break_labels(), TestFallthrough::kElse);
}
loop_builder.EndLoop();
}
@@ -1197,9 +1193,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();
@@ -1220,9 +1217,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) {
« no previous file with comments | « src/compiler/bytecode-loop-analysis.cc ('k') | src/interpreter/bytecode-label.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698