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 // This AstVistor is not final, and provides the AstVisitor methods as virtual |
| 36 // methods so they can be specialized by subclasses. |
| 37 class AstGraphBuilder : public AstVisitor<AstGraphBuilder> { |
36 public: | 38 public: |
37 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, | 39 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, |
38 LoopAssignmentAnalysis* loop_assignment = nullptr, | 40 LoopAssignmentAnalysis* loop_assignment = nullptr, |
39 TypeHintAnalysis* type_hint_analysis = nullptr); | 41 TypeHintAnalysis* type_hint_analysis = nullptr); |
| 42 virtual ~AstGraphBuilder() {} |
40 | 43 |
41 // Creates a graph by visiting the entire AST. | 44 // Creates a graph by visiting the entire AST. |
42 bool CreateGraph(bool stack_check = true); | 45 bool CreateGraph(bool stack_check = true); |
43 | 46 |
44 // Helpers to create new control nodes. | 47 // Helpers to create new control nodes. |
45 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } | 48 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } |
46 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } | 49 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } |
47 Node* NewMerge() { return NewNode(common()->Merge(1), true); } | 50 Node* NewMerge() { return NewNode(common()->Merge(1), true); } |
48 Node* NewLoop() { return NewNode(common()->Loop(1), true); } | 51 Node* NewLoop() { return NewNode(common()->Loop(1), true); } |
49 Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) { | 52 Node* NewBranch(Node* condition, BranchHint hint = BranchHint::kNone) { |
50 return NewNode(common()->Branch(hint), condition); | 53 return NewNode(common()->Branch(hint), condition); |
51 } | 54 } |
52 | 55 |
53 protected: | 56 protected: |
54 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 57 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
55 // Visiting functions for AST nodes make this an AstVisitor. | 58 // Visiting functions for AST nodes make this an AstVisitor. |
56 AST_NODE_LIST(DECLARE_VISIT) | 59 AST_NODE_LIST(DECLARE_VISIT) |
57 #undef DECLARE_VISIT | 60 #undef DECLARE_VISIT |
58 | 61 |
59 // Visiting function for declarations list is overridden. | 62 // Visiting function for declarations list is overridden. |
60 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; | 63 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
61 | 64 |
62 private: | 65 private: |
63 class AstContext; | 66 class AstContext; |
64 class AstEffectContext; | 67 class AstEffectContext; |
65 class AstValueContext; | 68 class AstValueContext; |
66 class AstTestContext; | 69 class AstTestContext; |
67 class ContextScope; | 70 class ContextScope; |
68 class ControlScope; | 71 class ControlScope; |
69 class ControlScopeForBreakable; | 72 class ControlScopeForBreakable; |
70 class ControlScopeForIteration; | 73 class ControlScopeForIteration; |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 | 611 |
609 // Prepare environment to be used as loop header. | 612 // Prepare environment to be used as loop header. |
610 void PrepareForLoop(BitVector* assigned, bool is_osr = false); | 613 void PrepareForLoop(BitVector* assigned, bool is_osr = false); |
611 }; | 614 }; |
612 | 615 |
613 } // namespace compiler | 616 } // namespace compiler |
614 } // namespace internal | 617 } // namespace internal |
615 } // namespace v8 | 618 } // namespace v8 |
616 | 619 |
617 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ | 620 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ |
OLD | NEW |