OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
11 #include "src/compiler/node-matchers.h" | 11 #include "src/compiler/node-matchers.h" |
12 #include "src/compiler/node-properties-inl.h" | 12 #include "src/compiler/node-properties-inl.h" |
13 #include "src/compiler/node-properties.h" | 13 #include "src/compiler/node-properties.h" |
14 #include "src/full-codegen.h" | 14 #include "src/full-codegen.h" |
15 #include "src/parser.h" | 15 #include "src/parser.h" |
16 #include "src/scopes.h" | 16 #include "src/scopes.h" |
17 | 17 |
18 namespace v8 { | 18 namespace v8 { |
19 namespace internal { | 19 namespace internal { |
20 namespace compiler { | 20 namespace compiler { |
21 | 21 |
22 AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info, | 22 AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info, |
23 JSGraph* jsgraph) | 23 JSGraph* jsgraph, LoopAssignmentAnalysis* loop) |
24 : StructuredGraphBuilder(local_zone, jsgraph->graph(), jsgraph->common()), | 24 : StructuredGraphBuilder(local_zone, jsgraph->graph(), jsgraph->common()), |
25 info_(info), | 25 info_(info), |
26 jsgraph_(jsgraph), | 26 jsgraph_(jsgraph), |
27 globals_(0, local_zone), | 27 globals_(0, local_zone), |
28 breakable_(NULL), | 28 breakable_(NULL), |
29 execution_context_(NULL), | 29 execution_context_(NULL), |
30 loop_assignment_analysis_(NULL) { | 30 loop_assignment_analysis_(loop) { |
31 InitializeAstVisitor(local_zone); | 31 InitializeAstVisitor(local_zone); |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 Node* AstGraphBuilder::GetFunctionClosure() { | 35 Node* AstGraphBuilder::GetFunctionClosure() { |
36 if (!function_closure_.is_set()) { | 36 if (!function_closure_.is_set()) { |
37 // Parameter -1 is special for the function closure | 37 // Parameter -1 is special for the function closure |
38 const Operator* op = common()->Parameter(-1); | 38 const Operator* op = common()->Parameter(-1); |
39 Node* node = NewNode(op, graph()->start()); | 39 Node* node = NewNode(op, graph()->start()); |
40 function_closure_.set(node); | 40 function_closure_.set(node); |
(...skipping 14 matching lines...) Expand all Loading... |
55 | 55 |
56 | 56 |
57 bool AstGraphBuilder::CreateGraph() { | 57 bool AstGraphBuilder::CreateGraph() { |
58 Scope* scope = info()->scope(); | 58 Scope* scope = info()->scope(); |
59 DCHECK(graph() != NULL); | 59 DCHECK(graph() != NULL); |
60 | 60 |
61 // Set up the basic structure of the graph. | 61 // Set up the basic structure of the graph. |
62 int parameter_count = info()->num_parameters(); | 62 int parameter_count = info()->num_parameters(); |
63 graph()->SetStart(graph()->NewNode(common()->Start(parameter_count))); | 63 graph()->SetStart(graph()->NewNode(common()->Start(parameter_count))); |
64 | 64 |
65 if (FLAG_loop_assignment_analysis) { | |
66 // TODO(turbofan): use a temporary zone for the loop assignment analysis. | |
67 AstLoopAssignmentAnalyzer analyzer(zone(), info()); | |
68 loop_assignment_analysis_ = analyzer.Analyze(); | |
69 } | |
70 | |
71 // Initialize the top-level environment. | 65 // Initialize the top-level environment. |
72 Environment env(this, scope, graph()->start()); | 66 Environment env(this, scope, graph()->start()); |
73 set_environment(&env); | 67 set_environment(&env); |
74 | 68 |
75 // Initialize the incoming context. | 69 // Initialize the incoming context. |
76 Node* outer_context = GetFunctionContext(); | 70 Node* outer_context = GetFunctionContext(); |
77 set_current_context(outer_context); | 71 set_current_context(outer_context); |
78 | 72 |
79 // Build receiver check for sloppy mode if necessary. | 73 // Build receiver check for sloppy mode if necessary. |
80 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? | 74 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? |
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 | 2222 |
2229 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( | 2223 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( |
2230 IterationStatement* stmt) { | 2224 IterationStatement* stmt) { |
2231 if (loop_assignment_analysis_ == NULL) return NULL; | 2225 if (loop_assignment_analysis_ == NULL) return NULL; |
2232 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); | 2226 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); |
2233 } | 2227 } |
2234 | 2228 |
2235 } // namespace compiler | 2229 } // namespace compiler |
2236 } // namespace internal | 2230 } // namespace internal |
2237 } // namespace v8 | 2231 } // namespace v8 |
OLD | NEW |