| 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/unique.h" | 13 #include "src/unique.h" | 
| 14 | 14 | 
| 15 namespace v8 { | 15 namespace v8 { | 
| 16 namespace internal { | 16 namespace internal { | 
| 17 namespace compiler { | 17 namespace compiler { | 
| 18 | 18 | 
| 19 class Node; | 19 class Node; | 
| 20 | 20 | 
| 21 // A common base class for anything that creates nodes in a graph. | 21 // A common base class for anything that creates nodes in a graph. | 
| 22 class GraphBuilder { | 22 class GraphBuilder { | 
| 23  public: | 23  public: | 
| 24   explicit GraphBuilder(Graph* graph) : graph_(graph) {} | 24   explicit GraphBuilder(Graph* graph) : graph_(graph) {} | 
| 25   virtual ~GraphBuilder() {} | 25   virtual ~GraphBuilder() {} | 
| 26 | 26 | 
| 27   Node* NewNode(Operator* op) { | 27   Node* NewNode(const Operator* op) { | 
| 28     return MakeNode(op, 0, static_cast<Node**>(NULL)); | 28     return MakeNode(op, 0, static_cast<Node**>(NULL)); | 
| 29   } | 29   } | 
| 30 | 30 | 
| 31   Node* NewNode(Operator* op, Node* n1) { return MakeNode(op, 1, &n1); } | 31   Node* NewNode(const Operator* op, Node* n1) { return MakeNode(op, 1, &n1); } | 
| 32 | 32 | 
| 33   Node* NewNode(Operator* op, Node* n1, Node* n2) { | 33   Node* NewNode(const Operator* op, Node* n1, Node* n2) { | 
| 34     Node* buffer[] = {n1, n2}; | 34     Node* buffer[] = {n1, n2}; | 
| 35     return MakeNode(op, arraysize(buffer), buffer); | 35     return MakeNode(op, arraysize(buffer), buffer); | 
| 36   } | 36   } | 
| 37 | 37 | 
| 38   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3) { | 38   Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) { | 
| 39     Node* buffer[] = {n1, n2, n3}; | 39     Node* buffer[] = {n1, n2, n3}; | 
| 40     return MakeNode(op, arraysize(buffer), buffer); | 40     return MakeNode(op, arraysize(buffer), buffer); | 
| 41   } | 41   } | 
| 42 | 42 | 
| 43   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) { | 43   Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) { | 
| 44     Node* buffer[] = {n1, n2, n3, n4}; | 44     Node* buffer[] = {n1, n2, n3, n4}; | 
| 45     return MakeNode(op, arraysize(buffer), buffer); | 45     return MakeNode(op, arraysize(buffer), buffer); | 
| 46   } | 46   } | 
| 47 | 47 | 
| 48   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | 48   Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | 
| 49                 Node* n5) { | 49                 Node* n5) { | 
| 50     Node* buffer[] = {n1, n2, n3, n4, n5}; | 50     Node* buffer[] = {n1, n2, n3, n4, n5}; | 
| 51     return MakeNode(op, arraysize(buffer), buffer); | 51     return MakeNode(op, arraysize(buffer), buffer); | 
| 52   } | 52   } | 
| 53 | 53 | 
| 54   Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, | 54   Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, | 
| 55                 Node* n6) { | 55                 Node* n5, Node* n6) { | 
| 56     Node* nodes[] = {n1, n2, n3, n4, n5, n6}; | 56     Node* nodes[] = {n1, n2, n3, n4, n5, n6}; | 
| 57     return MakeNode(op, arraysize(nodes), nodes); | 57     return MakeNode(op, arraysize(nodes), nodes); | 
| 58   } | 58   } | 
| 59 | 59 | 
| 60   Node* NewNode(Operator* op, int value_input_count, Node** value_inputs) { | 60   Node* NewNode(const Operator* op, int value_input_count, | 
|  | 61                 Node** value_inputs) { | 
| 61     return MakeNode(op, value_input_count, value_inputs); | 62     return MakeNode(op, value_input_count, value_inputs); | 
| 62   } | 63   } | 
| 63 | 64 | 
| 64   Graph* graph() const { return graph_; } | 65   Graph* graph() const { return graph_; } | 
| 65 | 66 | 
| 66  protected: | 67  protected: | 
| 67   // Base implementation used by all factory methods. | 68   // Base implementation used by all factory methods. | 
| 68   virtual Node* MakeNode(Operator* op, int value_input_count, | 69   virtual Node* MakeNode(const Operator* op, int value_input_count, | 
| 69                          Node** value_inputs) = 0; | 70                          Node** value_inputs) = 0; | 
| 70 | 71 | 
| 71  private: | 72  private: | 
| 72   Graph* graph_; | 73   Graph* graph_; | 
| 73 }; | 74 }; | 
| 74 | 75 | 
| 75 | 76 | 
| 76 // The StructuredGraphBuilder produces a high-level IR graph. It is used as the | 77 // The StructuredGraphBuilder produces a high-level IR graph. It is used as the | 
| 77 // base class for concrete implementations (e.g the AstGraphBuilder or the | 78 // base class for concrete implementations (e.g the AstGraphBuilder or the | 
| 78 // StubGraphBuilder). | 79 // StubGraphBuilder). | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 100   } | 101   } | 
| 101 | 102 | 
| 102  protected: | 103  protected: | 
| 103   class Environment; | 104   class Environment; | 
| 104   friend class Environment; | 105   friend class Environment; | 
| 105   friend class ControlBuilder; | 106   friend class ControlBuilder; | 
| 106 | 107 | 
| 107   // The following method creates a new node having the specified operator and | 108   // The following method creates a new node having the specified operator and | 
| 108   // ensures effect and control dependencies are wired up. The dependencies | 109   // ensures effect and control dependencies are wired up. The dependencies | 
| 109   // tracked by the environment might be mutated. | 110   // tracked by the environment might be mutated. | 
| 110   virtual Node* MakeNode(Operator* op, int value_input_count, | 111   virtual Node* MakeNode(const Operator* op, int value_input_count, | 
| 111                          Node** value_inputs); | 112                          Node** value_inputs) FINAL; | 
| 112 | 113 | 
| 113   Environment* environment() const { return environment_; } | 114   Environment* environment() const { return environment_; } | 
| 114   void set_environment(Environment* env) { environment_ = env; } | 115   void set_environment(Environment* env) { environment_ = env; } | 
| 115 | 116 | 
| 116   Node* current_context() const { return current_context_; } | 117   Node* current_context() const { return current_context_; } | 
| 117   void set_current_context(Node* context) { current_context_ = context; } | 118   void set_current_context(Node* context) { current_context_ = context; } | 
| 118 | 119 | 
| 119   Node* exit_control() const { return exit_control_; } | 120   Node* exit_control() const { return exit_control_; } | 
| 120   void set_exit_control(Node* node) { exit_control_ = node; } | 121   void set_exit_control(Node* node) { exit_control_ = node; } | 
| 121 | 122 | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 220   StructuredGraphBuilder* builder_; | 221   StructuredGraphBuilder* builder_; | 
| 221   Node* control_dependency_; | 222   Node* control_dependency_; | 
| 222   Node* effect_dependency_; | 223   Node* effect_dependency_; | 
| 223   NodeVector values_; | 224   NodeVector values_; | 
| 224 }; | 225 }; | 
| 225 } | 226 } | 
| 226 } | 227 } | 
| 227 }  // namespace v8::internal::compiler | 228 }  // namespace v8::internal::compiler | 
| 228 | 229 | 
| 229 #endif  // V8_COMPILER_GRAPH_BUILDER_H__ | 230 #endif  // V8_COMPILER_GRAPH_BUILDER_H__ | 
| OLD | NEW | 
|---|