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

Unified Diff: src/compiler/instruction.cc

Issue 699083003: [turbofan] extend register allocator testing with control flow (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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/instruction.h ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/instruction.cc
diff --git a/src/compiler/instruction.cc b/src/compiler/instruction.cc
index ad7a5ee05c6bcf9a7324995841e1bc0f53f7330a..218130c686c585f8de4456a18522916f9c2a660b 100644
--- a/src/compiler/instruction.cc
+++ b/src/compiler/instruction.cc
@@ -338,6 +338,36 @@ std::ostream& operator<<(std::ostream& os, const Constant& constant) {
}
+InstructionBlock::InstructionBlock(Zone* zone, BasicBlock::Id id,
+ BasicBlock::RpoNumber ao_number,
+ BasicBlock::RpoNumber rpo_number,
+ BasicBlock::RpoNumber loop_header,
+ BasicBlock::RpoNumber loop_end,
+ bool deferred)
+ : successors_(zone),
+ predecessors_(zone),
+ phis_(zone),
+ id_(id),
+ ao_number_(ao_number),
+ rpo_number_(rpo_number),
+ loop_header_(loop_header),
+ loop_end_(loop_end),
+ code_start_(-1),
+ code_end_(-1),
+ deferred_(deferred) {}
+
+
+size_t InstructionBlock::PredecessorIndexOf(
+ BasicBlock::RpoNumber rpo_number) const {
+ size_t j = 0;
+ for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin();
+ i != predecessors_.end(); ++i, ++j) {
+ if (*i == rpo_number) break;
+ }
+ return j;
+}
+
+
static BasicBlock::RpoNumber GetRpo(BasicBlock* block) {
if (block == NULL) return BasicBlock::RpoNumber::Invalid();
return block->GetRpoNumber();
@@ -350,43 +380,23 @@ static BasicBlock::RpoNumber GetLoopEndRpo(const BasicBlock* block) {
}
-InstructionBlock::InstructionBlock(Zone* zone, const BasicBlock* block)
- : successors_(static_cast<int>(block->SuccessorCount()),
- BasicBlock::RpoNumber::Invalid(), zone),
- predecessors_(static_cast<int>(block->PredecessorCount()),
- BasicBlock::RpoNumber::Invalid(), zone),
- phis_(zone),
- id_(block->id()),
- ao_number_(block->GetAoNumber()),
- rpo_number_(block->GetRpoNumber()),
- loop_header_(GetRpo(block->loop_header())),
- loop_end_(GetLoopEndRpo(block)),
- code_start_(-1),
- code_end_(-1),
- deferred_(block->deferred()) {
+static InstructionBlock* InstructionBlockFor(Zone* zone,
+ const BasicBlock* block) {
+ InstructionBlock* instr_block = new (zone) InstructionBlock(
+ zone, block->id(), block->GetAoNumber(), block->GetRpoNumber(),
+ GetRpo(block->loop_header()), GetLoopEndRpo(block), block->deferred());
// Map successors and precessors
- size_t index = 0;
- for (BasicBlock::Successors::const_iterator it = block->successors_begin();
- it != block->successors_end(); ++it, ++index) {
- successors_[index] = (*it)->GetRpoNumber();
- }
- index = 0;
- for (BasicBlock::Predecessors::const_iterator
- it = block->predecessors_begin();
- it != block->predecessors_end(); ++it, ++index) {
- predecessors_[index] = (*it)->GetRpoNumber();
+ instr_block->successors().reserve(block->SuccessorCount());
+ for (auto it = block->successors_begin(); it != block->successors_end();
+ ++it) {
+ instr_block->successors().push_back((*it)->GetRpoNumber());
}
-}
-
-
-size_t InstructionBlock::PredecessorIndexOf(
- BasicBlock::RpoNumber rpo_number) const {
- size_t j = 0;
- for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin();
- i != predecessors_.end(); ++i, ++j) {
- if (*i == rpo_number) break;
+ instr_block->predecessors().reserve(block->PredecessorCount());
+ for (auto it = block->predecessors_begin(); it != block->predecessors_end();
+ ++it) {
+ instr_block->predecessors().push_back((*it)->GetRpoNumber());
}
- return j;
+ return instr_block;
}
@@ -400,7 +410,7 @@ InstructionBlocks* InstructionSequence::InstructionBlocksFor(
it != schedule->rpo_order()->end(); ++it, ++rpo_number) {
DCHECK_EQ(NULL, (*blocks)[rpo_number]);
DCHECK((*it)->GetRpoNumber().ToSize() == rpo_number);
- (*blocks)[rpo_number] = new (zone) InstructionBlock(zone, *it);
+ (*blocks)[rpo_number] = InstructionBlockFor(zone, *it);
}
return blocks;
}
@@ -436,18 +446,18 @@ BlockStartInstruction* InstructionSequence::GetBlockStart(
}
-void InstructionSequence::StartBlock(BasicBlock* basic_block) {
- InstructionBlock* block = InstructionBlockAt(basic_block->GetRpoNumber());
+void InstructionSequence::StartBlock(BasicBlock::RpoNumber rpo) {
+ InstructionBlock* block = InstructionBlockAt(rpo);
block->set_code_start(static_cast<int>(instructions_.size()));
BlockStartInstruction* block_start =
- BlockStartInstruction::New(zone(), basic_block);
+ BlockStartInstruction::New(zone(), block->id(), rpo);
AddInstruction(block_start);
}
-void InstructionSequence::EndBlock(BasicBlock* basic_block) {
+void InstructionSequence::EndBlock(BasicBlock::RpoNumber rpo) {
int end = static_cast<int>(instructions_.size());
- InstructionBlock* block = InstructionBlockAt(basic_block->GetRpoNumber());
+ InstructionBlock* block = InstructionBlockAt(rpo);
DCHECK(block->code_start() >= 0 && block->code_start() < end);
block->set_code_end(end);
}
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698