| 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 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ | 5 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ | 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| 7 | 7 |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // The AstGraphBuilder produces a high-level IR graph, based on an | 24 // The AstGraphBuilder produces a high-level IR graph, based on an |
| 25 // underlying AST. The produced graph can either be compiled into a | 25 // underlying AST. The produced graph can either be compiled into a |
| 26 // stand-alone function or be wired into another graph for the purposes | 26 // stand-alone function or be wired into another graph for the purposes |
| 27 // of function inlining. | 27 // of function inlining. |
| 28 class AstGraphBuilder : public AstVisitor { | 28 class AstGraphBuilder : public AstVisitor { |
| 29 public: | 29 public: |
| 30 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, | 30 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, |
| 31 LoopAssignmentAnalysis* loop_assignment = NULL); | 31 LoopAssignmentAnalysis* loop_assignment = NULL); |
| 32 | 32 |
| 33 // Creates a graph by visiting the entire AST. | 33 // Creates a graph by visiting the entire AST. |
| 34 bool CreateGraph(bool constant_context); | 34 bool CreateGraph(bool constant_context, bool stack_check = true); |
| 35 | 35 |
| 36 // Helpers to create new control nodes. | 36 // Helpers to create new control nodes. |
| 37 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } | 37 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } |
| 38 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } | 38 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } |
| 39 Node* NewMerge() { return NewNode(common()->Merge(1), true); } | 39 Node* NewMerge() { return NewNode(common()->Merge(1), true); } |
| 40 Node* NewLoop() { return NewNode(common()->Loop(1), true); } | 40 Node* NewLoop() { return NewNode(common()->Loop(1), true); } |
| 41 Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) { | 41 Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) { |
| 42 return NewNode(common()->Branch(hint), condition); | 42 return NewNode(common()->Branch(hint), condition); |
| 43 } | 43 } |
| 44 | 44 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 Node* current_context() const; | 118 Node* current_context() const; |
| 119 Node* exit_control() const { return exit_control_; } | 119 Node* exit_control() const { return exit_control_; } |
| 120 | 120 |
| 121 void set_environment(Environment* env) { environment_ = env; } | 121 void set_environment(Environment* env) { environment_ = env; } |
| 122 void set_ast_context(AstContext* ctx) { ast_context_ = ctx; } | 122 void set_ast_context(AstContext* ctx) { ast_context_ = ctx; } |
| 123 void set_execution_control(ControlScope* ctrl) { execution_control_ = ctrl; } | 123 void set_execution_control(ControlScope* ctrl) { execution_control_ = ctrl; } |
| 124 void set_execution_context(ContextScope* ctx) { execution_context_ = ctx; } | 124 void set_execution_context(ContextScope* ctx) { execution_context_ = ctx; } |
| 125 void set_exit_control(Node* exit) { exit_control_ = exit; } | 125 void set_exit_control(Node* exit) { exit_control_ = exit; } |
| 126 | 126 |
| 127 // Create the main graph body by visiting the AST. | 127 // Create the main graph body by visiting the AST. |
| 128 void CreateGraphBody(); | 128 void CreateGraphBody(bool stack_check); |
| 129 | 129 |
| 130 // Create the node that represents the outer context of the function. | 130 // Create the node that represents the outer context of the function. |
| 131 void CreateFunctionContext(bool constant_context); | 131 void CreateFunctionContext(bool constant_context); |
| 132 | 132 |
| 133 // Get or create the node that represents the outer function closure. | 133 // Get or create the node that represents the outer function closure. |
| 134 Node* GetFunctionClosure(); | 134 Node* GetFunctionClosure(); |
| 135 | 135 |
| 136 // Node creation helpers. | 136 // Node creation helpers. |
| 137 Node* NewNode(const Operator* op, bool incomplete = false) { | 137 Node* NewNode(const Operator* op, bool incomplete = false) { |
| 138 return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); | 138 return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 477 |
| 478 // Prepare environment to be used as loop header. | 478 // Prepare environment to be used as loop header. |
| 479 void PrepareForLoop(BitVector* assigned, bool is_osr = false); | 479 void PrepareForLoop(BitVector* assigned, bool is_osr = false); |
| 480 }; | 480 }; |
| 481 | 481 |
| 482 } // namespace compiler | 482 } // namespace compiler |
| 483 } // namespace internal | 483 } // namespace internal |
| 484 } // namespace v8 | 484 } // namespace v8 |
| 485 | 485 |
| 486 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 486 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
| OLD | NEW |