Chromium Code Reviews| Index: src/compiler/ast-graph-builder.cc |
| diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc |
| index b97260111ea45ffb0ea1683b4347183bb90be733..a4deb5324918ea9d2fcbfa350f1ea10601438a3d 100644 |
| --- a/src/compiler/ast-graph-builder.cc |
| +++ b/src/compiler/ast-graph-builder.cc |
| @@ -5,10 +5,11 @@ |
| #include "src/compiler/ast-graph-builder.h" |
| #include "src/compiler.h" |
| +#include "src/compiler/ast-loop-assignment-analyzer.h" |
| #include "src/compiler/control-builders.h" |
| #include "src/compiler/machine-operator.h" |
| -#include "src/compiler/node-properties.h" |
| #include "src/compiler/node-properties-inl.h" |
| +#include "src/compiler/node-properties.h" |
| #include "src/full-codegen.h" |
| #include "src/parser.h" |
| #include "src/scopes.h" |
| @@ -24,7 +25,8 @@ AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info, |
| jsgraph_(jsgraph), |
| globals_(0, info->zone()), |
| breakable_(NULL), |
| - execution_context_(NULL) { |
| + execution_context_(NULL), |
| + loop_assignment_analysis_(NULL) { |
| InitializeAstVisitor(info->zone()); |
| } |
| @@ -59,6 +61,12 @@ bool AstGraphBuilder::CreateGraph() { |
| int parameter_count = info()->num_parameters(); |
| graph()->SetStart(graph()->NewNode(common()->Start(parameter_count))); |
| + if (FLAG_loop_assignment_analysis) { |
| + // TODO(turbofan): use a temporary zone for the loop assignment analysis. |
| + AstLoopAssignmentAnalyzer analyzer(zone(), info()); |
| + loop_assignment_analysis_ = analyzer.Analyze(); |
| + } |
| + |
| // Initialize the top-level environment. |
| Environment env(this, scope, graph()->start()); |
| set_environment(&env); |
| @@ -579,9 +587,16 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { |
| } |
| +BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( |
| + IterationStatement* stmt) { |
| + if (loop_assignment_analysis_ == NULL) return NULL; |
|
danno
2014/10/28 14:23:29
This seems a bit weird. Why is it OK to call this
titzer
2014/10/28 17:16:03
It's so that there's one place where we make the d
|
| + return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); |
| +} |
| + |
| + |
| void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| LoopBuilder while_loop(this); |
| - while_loop.BeginLoop(); |
| + while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt)); |
| VisitIterationBody(stmt, &while_loop, 0); |
| while_loop.EndBody(); |
| VisitForTest(stmt->cond()); |
| @@ -593,7 +608,7 @@ void AstGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
| LoopBuilder while_loop(this); |
| - while_loop.BeginLoop(); |
| + while_loop.BeginLoop(GetVariablesAssignedInLoop(stmt)); |
| VisitForTest(stmt->cond()); |
| Node* condition = environment()->Pop(); |
| while_loop.BreakUnless(condition); |
| @@ -606,7 +621,7 @@ void AstGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
| void AstGraphBuilder::VisitForStatement(ForStatement* stmt) { |
| LoopBuilder for_loop(this); |
| VisitIfNotNull(stmt->init()); |
| - for_loop.BeginLoop(); |
| + for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt)); |
| if (stmt->cond() != NULL) { |
| VisitForTest(stmt->cond()); |
| Node* condition = environment()->Pop(); |
| @@ -682,7 +697,7 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) { |
| environment()->Push(jsgraph()->ZeroConstant()); |
| // PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
| LoopBuilder for_loop(this); |
| - for_loop.BeginLoop(); |
| + for_loop.BeginLoop(GetVariablesAssignedInLoop(stmt)); |
| // Check loop termination condition. |
| Node* index = environment()->Peek(0); |
| Node* exit_cond = |