Index: src/compiler/ast-graph-builder.cc |
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc |
index cde5e7182df0cba24ed1147a4b503d62a9b0a9e9..5c91b95153d6448fda9816f1340546aac6952186 100644 |
--- a/src/compiler/ast-graph-builder.cc |
+++ b/src/compiler/ast-graph-builder.cc |
@@ -62,10 +62,17 @@ bool AstGraphBuilder::CreateGraph() { |
int parameter_count = info()->num_parameters(); |
graph()->SetStart(graph()->NewNode(common()->Start(parameter_count))); |
+ Node* start = graph()->start(); |
// Initialize the top-level environment. |
- Environment env(this, scope, graph()->start()); |
+ Environment env(this, scope, start); |
set_environment(&env); |
+ if (info()->is_osr()) { |
+ // Use OSR normal entry as the start of the top-level environment. |
+ // It will be replaced with {Dead} after typing and optimizations. |
+ NewNode(common()->OsrNormalEntry()); |
+ } |
+ |
// Initialize the incoming context. |
Node* outer_context = GetFunctionContext(); |
set_current_context(outer_context); |
@@ -589,7 +596,7 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { |
void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
LoopBuilder while_loop(this); |
- while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt)); |
+ while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), IsOsrLoopEntry(stmt)); |
VisitIterationBody(stmt, &while_loop, 0); |
while_loop.EndBody(); |
VisitForTest(stmt->cond()); |
@@ -601,7 +608,7 @@ void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
LoopBuilder while_loop(this); |
- while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt)); |
+ while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), IsOsrLoopEntry(stmt)); |
VisitForTest(stmt->cond()); |
Node* condition = environment()->Pop(); |
while_loop.BreakUnless(condition); |
@@ -614,7 +621,7 @@ void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { |
LoopBuilder for_loop(this); |
VisitIfNotNull(stmt->init()); |
- for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt)); |
+ for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), IsOsrLoopEntry(stmt)); |
if (stmt->cond() != NULL) { |
VisitForTest(stmt->cond()); |
Node* condition = environment()->Pop(); |
@@ -690,7 +697,8 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) { |
environment()->Push(jsgraph()->ZeroConstant()); |
// PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
LoopBuilder for_loop(this); |
- for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt)); |
+ for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt), |
+ IsOsrLoopEntry(stmt)); |
// Check loop termination condition. |
Node* index = environment()->Peek(0); |
Node* exit_cond = |
@@ -2209,6 +2217,11 @@ Node* AstGraphBuilder::BuildStackCheck() { |
} |
+bool AstGraphBuilder::IsOsrLoopEntry(IterationStatement* stmt) { |
+ return info()->osr_ast_id() == stmt->OsrEntryId(); |
+} |
+ |
+ |
void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, |
OutputFrameStateCombine combine) { |
if (OperatorProperties::HasFrameStateInput(node->op())) { |