| OLD | NEW | 
|    1 // Copyright 2013 the V8 project authors. All rights reserved. |    1 // Copyright 2013 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_GRAPH_BUILDER_H_ |    5 #ifndef V8_COMPILER_GRAPH_BUILDER_H_ | 
|    6 #define V8_COMPILER_GRAPH_BUILDER_H_ |    6 #define V8_COMPILER_GRAPH_BUILDER_H_ | 
|    7  |    7  | 
|    8 #include "src/v8.h" |    8 #include "src/v8.h" | 
|    9  |    9  | 
|   10 #include "src/allocation.h" |   10 #include "src/allocation.h" | 
|   11 #include "src/compiler/common-operator.h" |   11 #include "src/compiler/common-operator.h" | 
|   12 #include "src/compiler/graph.h" |   12 #include "src/compiler/graph.h" | 
|   13 #include "src/compiler/node.h" |   13 #include "src/compiler/node.h" | 
|   14 #include "src/unique.h" |   14 #include "src/unique.h" | 
|   15  |   15  | 
|   16 namespace v8 { |   16 namespace v8 { | 
|   17 namespace internal { |   17 namespace internal { | 
|   18  |   18  | 
|   19 class BitVector; |   19 class BitVector; | 
|   20  |   20  | 
|   21 namespace compiler { |   21 namespace compiler { | 
|   22  |   22  | 
|   23 class Node; |   23 class Node; | 
|   24  |   24  | 
|   25 // A common base class for anything that creates nodes in a graph. |   25 // A common base class for anything that creates nodes in a graph. | 
|   26 class GraphBuilder { |   26 class GraphBuilder { | 
|   27  public: |   27  public: | 
|   28   explicit GraphBuilder(Graph* graph) : graph_(graph) {} |   28   GraphBuilder(Isolate* isolate, Graph* graph) | 
 |   29       : isolate_(isolate), graph_(graph) {} | 
|   29   virtual ~GraphBuilder() {} |   30   virtual ~GraphBuilder() {} | 
|   30  |   31  | 
|   31   Node* NewNode(const Operator* op, bool incomplete = false) { |   32   Node* NewNode(const Operator* op, bool incomplete = false) { | 
|   32     return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); |   33     return MakeNode(op, 0, static_cast<Node**>(NULL), incomplete); | 
|   33   } |   34   } | 
|   34  |   35  | 
|   35   Node* NewNode(const Operator* op, Node* n1) { |   36   Node* NewNode(const Operator* op, Node* n1) { | 
|   36     return MakeNode(op, 1, &n1, false); |   37     return MakeNode(op, 1, &n1, false); | 
|   37   } |   38   } | 
|   38  |   39  | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|   61                 Node* n5, Node* n6) { |   62                 Node* n5, Node* n6) { | 
|   62     Node* nodes[] = {n1, n2, n3, n4, n5, n6}; |   63     Node* nodes[] = {n1, n2, n3, n4, n5, n6}; | 
|   63     return MakeNode(op, arraysize(nodes), nodes, false); |   64     return MakeNode(op, arraysize(nodes), nodes, false); | 
|   64   } |   65   } | 
|   65  |   66  | 
|   66   Node* NewNode(const Operator* op, int value_input_count, Node** value_inputs, |   67   Node* NewNode(const Operator* op, int value_input_count, Node** value_inputs, | 
|   67                 bool incomplete = false) { |   68                 bool incomplete = false) { | 
|   68     return MakeNode(op, value_input_count, value_inputs, incomplete); |   69     return MakeNode(op, value_input_count, value_inputs, incomplete); | 
|   69   } |   70   } | 
|   70  |   71  | 
 |   72   Isolate* isolate() const { return isolate_; } | 
|   71   Graph* graph() const { return graph_; } |   73   Graph* graph() const { return graph_; } | 
|   72  |   74  | 
|   73  protected: |   75  protected: | 
|   74   // Base implementation used by all factory methods. |   76   // Base implementation used by all factory methods. | 
|   75   virtual Node* MakeNode(const Operator* op, int value_input_count, |   77   virtual Node* MakeNode(const Operator* op, int value_input_count, | 
|   76                          Node** value_inputs, bool incomplete) = 0; |   78                          Node** value_inputs, bool incomplete) = 0; | 
|   77  |   79  | 
|   78  private: |   80  private: | 
 |   81   Isolate* isolate_; | 
|   79   Graph* graph_; |   82   Graph* graph_; | 
|   80 }; |   83 }; | 
|   81  |   84  | 
|   82  |   85  | 
|   83 // The StructuredGraphBuilder produces a high-level IR graph. It is used as the |   86 // The StructuredGraphBuilder produces a high-level IR graph. It is used as the | 
|   84 // base class for concrete implementations (e.g the AstGraphBuilder or the |   87 // base class for concrete implementations (e.g the AstGraphBuilder or the | 
|   85 // StubGraphBuilder). |   88 // StubGraphBuilder). | 
|   86 class StructuredGraphBuilder : public GraphBuilder { |   89 class StructuredGraphBuilder : public GraphBuilder { | 
|   87  public: |   90  public: | 
|   88   StructuredGraphBuilder(Zone* zone, Graph* graph, |   91   StructuredGraphBuilder(Isolate* isolate, Zone* zone, Graph* graph, | 
|   89                          CommonOperatorBuilder* common); |   92                          CommonOperatorBuilder* common); | 
|   90   ~StructuredGraphBuilder() OVERRIDE {} |   93   ~StructuredGraphBuilder() OVERRIDE {} | 
|   91  |   94  | 
|   92   // Creates a new Phi node having {count} input values. |   95   // Creates a new Phi node having {count} input values. | 
|   93   Node* NewPhi(int count, Node* input, Node* control); |   96   Node* NewPhi(int count, Node* input, Node* control); | 
|   94   Node* NewEffectPhi(int count, Node* input, Node* control); |   97   Node* NewEffectPhi(int count, Node* input, Node* control); | 
|   95  |   98  | 
|   96   // Helpers for merging control, effect or value dependencies. |   99   // Helpers for merging control, effect or value dependencies. | 
|   97   Node* MergeControl(Node* control, Node* other); |  100   Node* MergeControl(Node* control, Node* other); | 
|   98   Node* MergeEffect(Node* value, Node* other, Node* control); |  101   Node* MergeEffect(Node* value, Node* other, Node* control); | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
|  124   Node* current_context() const { return current_context_; } |  127   Node* current_context() const { return current_context_; } | 
|  125   void set_current_context(Node* context) { current_context_ = context; } |  128   void set_current_context(Node* context) { current_context_ = context; } | 
|  126  |  129  | 
|  127   Node* exit_control() const { return exit_control_; } |  130   Node* exit_control() const { return exit_control_; } | 
|  128   void set_exit_control(Node* node) { exit_control_ = node; } |  131   void set_exit_control(Node* node) { exit_control_ = node; } | 
|  129  |  132  | 
|  130   Node* dead_control(); |  133   Node* dead_control(); | 
|  131  |  134  | 
|  132   Zone* graph_zone() const { return graph()->zone(); } |  135   Zone* graph_zone() const { return graph()->zone(); } | 
|  133   Zone* local_zone() const { return local_zone_; } |  136   Zone* local_zone() const { return local_zone_; } | 
|  134   Isolate* isolate() const { return graph_zone()->isolate(); } |  | 
|  135   CommonOperatorBuilder* common() const { return common_; } |  137   CommonOperatorBuilder* common() const { return common_; } | 
|  136  |  138  | 
|  137   // Helper to wrap a Handle<T> into a Unique<T>. |  139   // Helper to wrap a Handle<T> into a Unique<T>. | 
|  138   template <class T> |  140   template <class T> | 
|  139   Unique<T> MakeUnique(Handle<T> object) { |  141   Unique<T> MakeUnique(Handle<T> object) { | 
|  140     return Unique<T>::CreateUninitialized(object); |  142     return Unique<T>::CreateUninitialized(object); | 
|  141   } |  143   } | 
|  142  |  144  | 
|  143   // Support for control flow builders. The concrete type of the environment |  145   // Support for control flow builders. The concrete type of the environment | 
|  144   // depends on the graph builder, but environments themselves are not virtual. |  146   // depends on the graph builder, but environments themselves are not virtual. | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  240   StructuredGraphBuilder* builder_; |  242   StructuredGraphBuilder* builder_; | 
|  241   Node* control_dependency_; |  243   Node* control_dependency_; | 
|  242   Node* effect_dependency_; |  244   Node* effect_dependency_; | 
|  243   NodeVector values_; |  245   NodeVector values_; | 
|  244 }; |  246 }; | 
|  245 } |  247 } | 
|  246 } |  248 } | 
|  247 }  // namespace v8::internal::compiler |  249 }  // namespace v8::internal::compiler | 
|  248  |  250  | 
|  249 #endif  // V8_COMPILER_GRAPH_BUILDER_H__ |  251 #endif  // V8_COMPILER_GRAPH_BUILDER_H__ | 
| OLD | NEW |