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/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/liveness-analyzer.h" | 10 #include "src/compiler/liveness-analyzer.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 class LoopAssignmentAnalysis; | 25 class LoopAssignmentAnalysis; |
26 class LoopBuilder; | 26 class LoopBuilder; |
27 class Node; | 27 class Node; |
28 class TypeHintAnalysis; | 28 class TypeHintAnalysis; |
29 | 29 |
30 | 30 |
31 // The AstGraphBuilder produces a high-level IR graph, based on an | 31 // The AstGraphBuilder produces a high-level IR graph, based on an |
32 // underlying AST. The produced graph can either be compiled into a | 32 // underlying AST. The produced graph can either be compiled into a |
33 // stand-alone function or be wired into another graph for the purposes | 33 // stand-alone function or be wired into another graph for the purposes |
34 // of function inlining. | 34 // of function inlining. |
35 class AstGraphBuilder : public AstVisitor { | 35 class AstGraphBuilder : public AstVisitor<AstGraphBuilder> { |
Igor Sheludko
2016/07/14 16:39:54
Same comment as in HOptimizedGraphBuilder is reque
Toon Verwaest
2016/07/15 07:07:20
Done.
| |
36 public: | 36 public: |
37 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, | 37 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, |
38 LoopAssignmentAnalysis* loop_assignment = nullptr, | 38 LoopAssignmentAnalysis* loop_assignment = nullptr, |
39 TypeHintAnalysis* type_hint_analysis = nullptr); | 39 TypeHintAnalysis* type_hint_analysis = nullptr); |
40 virtual ~AstGraphBuilder() {} | |
40 | 41 |
41 // Creates a graph by visiting the entire AST. | 42 // Creates a graph by visiting the entire AST. |
42 bool CreateGraph(bool stack_check = true); | 43 bool CreateGraph(bool stack_check = true); |
43 | 44 |
44 // Helpers to create new control nodes. | 45 // Helpers to create new control nodes. |
45 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } | 46 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } |
46 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } | 47 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } |
47 Node* NewMerge() { return NewNode(common()->Merge(1), true); } | 48 Node* NewMerge() { return NewNode(common()->Merge(1), true); } |
48 Node* NewLoop() { return NewNode(common()->Loop(1), true); } | 49 Node* NewLoop() { return NewNode(common()->Loop(1), true); } |
49 Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) { | 50 Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) { |
50 return NewNode(common()->Branch(hint), condition); | 51 return NewNode(common()->Branch(hint), condition); |
51 } | 52 } |
52 | 53 |
53 protected: | 54 protected: |
54 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 55 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
55 // Visiting functions for AST nodes make this an AstVisitor. | 56 // Visiting functions for AST nodes make this an AstVisitor. |
56 AST_NODE_LIST(DECLARE_VISIT) | 57 AST_NODE_LIST(DECLARE_VISIT) |
57 #undef DECLARE_VISIT | 58 #undef DECLARE_VISIT |
58 | 59 |
59 // Visiting function for declarations list is overridden. | 60 // Visiting function for declarations list is overridden. |
60 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; | 61 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
61 | 62 |
62 private: | 63 private: |
63 class AstContext; | 64 class AstContext; |
64 class AstEffectContext; | 65 class AstEffectContext; |
65 class AstValueContext; | 66 class AstValueContext; |
66 class AstTestContext; | 67 class AstTestContext; |
67 class ContextScope; | 68 class ContextScope; |
68 class ControlScope; | 69 class ControlScope; |
69 class ControlScopeForBreakable; | 70 class ControlScopeForBreakable; |
70 class ControlScopeForIteration; | 71 class ControlScopeForIteration; |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 | 603 |
603 // Prepare environment to be used as loop header. | 604 // Prepare environment to be used as loop header. |
604 void PrepareForLoop(BitVector* assigned, bool is_osr = false); | 605 void PrepareForLoop(BitVector* assigned, bool is_osr = false); |
605 }; | 606 }; |
606 | 607 |
607 } // namespace compiler | 608 } // namespace compiler |
608 } // namespace internal | 609 } // namespace internal |
609 } // namespace v8 | 610 } // namespace v8 |
610 | 611 |
611 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 612 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
OLD | NEW |