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

Unified Diff: src/interpreter/control-flow-builders.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/interpreter/control-flow-builders.h ('k') | test/cctest/compiler/test-run-bytecode-graph-builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/control-flow-builders.cc
diff --git a/src/interpreter/control-flow-builders.cc b/src/interpreter/control-flow-builders.cc
index 1624712425392f6addf140473ede669b059f6760..56cd481f9cdd50c36e3cc2045a4aaa78ecf309e1 100644
--- a/src/interpreter/control-flow-builders.cc
+++ b/src/interpreter/control-flow-builders.cc
@@ -10,95 +10,53 @@ namespace interpreter {
BreakableControlFlowBuilder::~BreakableControlFlowBuilder() {
- DCHECK(break_sites_.empty());
+ DCHECK(break_labels_.empty() || break_labels_.is_bound());
}
-
-void BreakableControlFlowBuilder::SetBreakTarget(const BytecodeLabel& target) {
- BindLabels(target, &break_sites_);
-}
-
-
-void BreakableControlFlowBuilder::EmitJump(ZoneVector<BytecodeLabel>* sites) {
- sites->push_back(BytecodeLabel());
- builder()->Jump(&sites->back());
-}
-
-
-void BreakableControlFlowBuilder::EmitJumpIfTrue(
- ZoneVector<BytecodeLabel>* sites) {
- sites->push_back(BytecodeLabel());
- builder()->JumpIfTrue(&sites->back());
+void BreakableControlFlowBuilder::BindBreakTarget() {
+ break_labels_.Bind(builder());
}
-
-void BreakableControlFlowBuilder::EmitJumpIfFalse(
- ZoneVector<BytecodeLabel>* sites) {
- sites->push_back(BytecodeLabel());
- builder()->JumpIfFalse(&sites->back());
-}
-
-
-void BreakableControlFlowBuilder::EmitJumpIfUndefined(
- ZoneVector<BytecodeLabel>* sites) {
- sites->push_back(BytecodeLabel());
- builder()->JumpIfUndefined(&sites->back());
-}
-
-
-void BreakableControlFlowBuilder::EmitJumpIfNull(
- ZoneVector<BytecodeLabel>* sites) {
- sites->push_back(BytecodeLabel());
- builder()->JumpIfNull(&sites->back());
+void BreakableControlFlowBuilder::EmitJump(BytecodeLabels* sites) {
+ builder()->Jump(sites->New());
}
-
-void BreakableControlFlowBuilder::EmitJump(ZoneVector<BytecodeLabel>* sites,
- int index) {
- builder()->Jump(&sites->at(index));
+void BreakableControlFlowBuilder::EmitJumpIfTrue(BytecodeLabels* sites) {
+ builder()->JumpIfTrue(sites->New());
}
-
-void BreakableControlFlowBuilder::EmitJumpIfTrue(
- ZoneVector<BytecodeLabel>* sites, int index) {
- builder()->JumpIfTrue(&sites->at(index));
+void BreakableControlFlowBuilder::EmitJumpIfFalse(BytecodeLabels* sites) {
+ builder()->JumpIfFalse(sites->New());
}
-
-void BreakableControlFlowBuilder::EmitJumpIfFalse(
- ZoneVector<BytecodeLabel>* sites, int index) {
- builder()->JumpIfFalse(&sites->at(index));
+void BreakableControlFlowBuilder::EmitJumpIfUndefined(BytecodeLabels* sites) {
+ builder()->JumpIfUndefined(sites->New());
}
-
-void BreakableControlFlowBuilder::BindLabels(const BytecodeLabel& target,
- ZoneVector<BytecodeLabel>* sites) {
- for (size_t i = 0; i < sites->size(); i++) {
- BytecodeLabel& site = sites->at(i);
- builder()->Bind(target, &site);
- }
- sites->clear();
+void BreakableControlFlowBuilder::EmitJumpIfNull(BytecodeLabels* sites) {
+ builder()->JumpIfNull(sites->New());
}
void BlockBuilder::EndBlock() {
builder()->Bind(&block_end_);
- SetBreakTarget(block_end_);
+ BindBreakTarget();
}
-
-LoopBuilder::~LoopBuilder() { DCHECK(continue_sites_.empty()); }
-
+LoopBuilder::~LoopBuilder() {
+ DCHECK(continue_labels_.empty() || continue_labels_.is_bound());
+ DCHECK(header_labels_.empty() || header_labels_.is_bound());
+}
void LoopBuilder::LoopHeader(ZoneVector<BytecodeLabel>* additional_labels) {
// Jumps from before the loop header into the loop violate ordering
// requirements of bytecode basic blocks. The only entry into a loop
// must be the loop header. Surely breaks is okay? Not if nested
// and misplaced between the headers.
- DCHECK(break_sites_.empty() && continue_sites_.empty());
+ DCHECK(break_labels_.empty() && continue_labels_.empty());
builder()->Bind(&loop_header_);
for (auto& label : *additional_labels) {
- builder()->Bind(loop_header_, &label);
+ builder()->Bind(&label);
}
}
@@ -117,16 +75,11 @@ void LoopBuilder::JumpToHeaderIfTrue() {
}
void LoopBuilder::EndLoop() {
- builder()->Bind(&loop_end_);
- SetBreakTarget(loop_end_);
-}
-
-void LoopBuilder::SetContinueTarget() {
- BytecodeLabel target;
- builder()->Bind(&target);
- BindLabels(target, &continue_sites_);
+ BindBreakTarget();
+ header_labels_.BindToLabel(builder(), loop_header_);
}
+void LoopBuilder::BindContinueTarget() { continue_labels_.Bind(builder()); }
SwitchBuilder::~SwitchBuilder() {
#ifdef DEBUG
@@ -165,8 +118,7 @@ void TryFinallyBuilder::BeginTry(Register context) {
void TryFinallyBuilder::LeaveTry() {
- finalization_sites_.push_back(BytecodeLabel());
- builder()->Jump(&finalization_sites_.back());
+ builder()->Jump(finalization_sites_.New());
}
@@ -180,14 +132,7 @@ void TryFinallyBuilder::BeginHandler() {
builder()->MarkHandler(handler_id_, catch_prediction_);
}
-
-void TryFinallyBuilder::BeginFinally() {
- for (size_t i = 0; i < finalization_sites_.size(); i++) {
- BytecodeLabel& site = finalization_sites_.at(i);
- builder()->Bind(&site);
- }
-}
-
+void TryFinallyBuilder::BeginFinally() { finalization_sites_.Bind(builder()); }
void TryFinallyBuilder::EndFinally() {
// Nothing to be done here.
« no previous file with comments | « src/interpreter/control-flow-builders.h ('k') | test/cctest/compiler/test-run-bytecode-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698