Refactoring such that loop builders only call into the HOsrBuilder if

compiling for OSR.

BUG=
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/25039003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16990 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mvstanton@chromium.org 2013-09-27 13:38:04 +00:00
parent dbdcf5b671
commit 807cdd492b
4 changed files with 37 additions and 22 deletions

View File

@ -37,19 +37,8 @@ bool HOsrBuilder::HasOsrEntryAt(IterationStatement* statement) {
}
// Build a new loop header block and set it as the current block.
HBasicBlock *HOsrBuilder::BuildLoopEntry() {
HBasicBlock* loop_entry = builder_->CreateLoopHeaderBlock();
builder_->current_block()->Goto(loop_entry);
builder_->set_current_block(loop_entry);
return loop_entry;
}
HBasicBlock* HOsrBuilder::BuildPossibleOsrLoopEntry(
IterationStatement* statement) {
// Check if there is an OSR here first.
if (!HasOsrEntryAt(statement)) return BuildLoopEntry();
HBasicBlock* HOsrBuilder::BuildOsrLoopEntry(IterationStatement* statement) {
ASSERT(HasOsrEntryAt(statement));
Zone* zone = builder_->zone();
HGraph* graph = builder_->graph();
@ -113,7 +102,7 @@ HBasicBlock* HOsrBuilder::BuildPossibleOsrLoopEntry(
builder_->set_current_block(loop_predecessor);
// Create the final loop entry
osr_loop_entry_ = BuildLoopEntry();
osr_loop_entry_ = builder_->BuildLoopEntry();
return osr_loop_entry_;
}

View File

@ -45,9 +45,10 @@ class HOsrBuilder : public ZoneObject {
osr_entry_(NULL),
osr_loop_entry_(NULL),
osr_values_(NULL) { }
// Creates the loop entry block for the given statement, setting up OSR
// entries as necessary, and sets the current block to the new block.
HBasicBlock* BuildPossibleOsrLoopEntry(IterationStatement* statement);
HBasicBlock* BuildOsrLoopEntry(IterationStatement* statement);
// Process the hydrogen graph after it has been completed, performing
// any OSR-specific cleanups or changes.
@ -61,10 +62,9 @@ class HOsrBuilder : public ZoneObject {
return unoptimized_frame_slots_;
}
private:
HBasicBlock* BuildLoopEntry();
bool HasOsrEntryAt(IterationStatement* statement);
private:
int unoptimized_frame_slots_;
HOptimizedGraphBuilder* builder_;
HBasicBlock* osr_entry_;

View File

@ -2246,6 +2246,24 @@ HBasicBlock* HOptimizedGraphBuilder::CreateLoop(IterationStatement* statement,
}
// Build a new loop header block and set it as the current block.
HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry() {
HBasicBlock* loop_entry = CreateLoopHeaderBlock();
current_block()->Goto(loop_entry);
set_current_block(loop_entry);
return loop_entry;
}
HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry(
IterationStatement* statement) {
HBasicBlock* loop_entry = osr()->HasOsrEntryAt(statement)
? osr()->BuildOsrLoopEntry(statement)
: BuildLoopEntry();
return loop_entry;
}
void HBasicBlock::FinishExit(HControlInstruction* instruction) {
Finish(instruction);
ClearEnvironment();
@ -3087,7 +3105,7 @@ bool HOptimizedGraphBuilder::BuildGraph() {
type_info->set_inlined_type_change_checksum(composite_checksum);
// Perform any necessary OSR-specific cleanups or changes to the graph.
osr_->FinishGraph();
osr()->FinishGraph();
return true;
}
@ -3670,7 +3688,7 @@ void HOptimizedGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) {
ASSERT(current_block() != NULL);
ASSERT(current_block()->HasPredecessor());
ASSERT(current_block() != NULL);
HBasicBlock* loop_entry = osr_->BuildPossibleOsrLoopEntry(stmt);
HBasicBlock* loop_entry = BuildLoopEntry(stmt);
BreakAndContinueInfo break_info(stmt);
CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info));
@ -3709,7 +3727,7 @@ void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) {
ASSERT(current_block() != NULL);
ASSERT(current_block()->HasPredecessor());
ASSERT(current_block() != NULL);
HBasicBlock* loop_entry = osr_->BuildPossibleOsrLoopEntry(stmt);
HBasicBlock* loop_entry = BuildLoopEntry(stmt);
// If the condition is constant true, do not generate a branch.
HBasicBlock* loop_successor = NULL;
@ -3751,7 +3769,7 @@ void HOptimizedGraphBuilder::VisitForStatement(ForStatement* stmt) {
CHECK_ALIVE(Visit(stmt->init()));
}
ASSERT(current_block() != NULL);
HBasicBlock* loop_entry = osr_->BuildPossibleOsrLoopEntry(stmt);
HBasicBlock* loop_entry = BuildLoopEntry(stmt);
HBasicBlock* loop_successor = NULL;
if (stmt->cond() != NULL) {
@ -3834,7 +3852,7 @@ void HOptimizedGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
HForInCacheArray::cast(array)->set_index_cache(
HForInCacheArray::cast(index_cache));
HBasicBlock* loop_entry = osr_->BuildPossibleOsrLoopEntry(stmt);
HBasicBlock* loop_entry = BuildLoopEntry(stmt);
HValue* index = environment()->ExpressionStackAt(0);
HValue* limit = environment()->ExpressionStackAt(1);

View File

@ -1781,6 +1781,8 @@ class HOptimizedGraphBuilder V8_FINAL
HValue* context() { return environment()->context(); }
HOsrBuilder* osr() const { return osr_; }
void Bailout(BailoutReason reason);
HBasicBlock* CreateJoin(HBasicBlock* first,
@ -1886,6 +1888,12 @@ class HOptimizedGraphBuilder V8_FINAL
HBasicBlock* loop_successor,
HBasicBlock* break_block);
// Build a loop entry
HBasicBlock* BuildLoopEntry();
// Builds a loop entry respectful of OSR requirements
HBasicBlock* BuildLoopEntry(IterationStatement* statement);
HBasicBlock* JoinContinue(IterationStatement* statement,
HBasicBlock* exit_block,
HBasicBlock* continue_block);