| 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_H_ | 5 #ifndef V8_COMPILER_GRAPH_H_ |
| 6 #define V8_COMPILER_GRAPH_H_ | 6 #define V8_COMPILER_GRAPH_H_ |
| 7 | 7 |
| 8 #include "src/zone.h" | 8 #include "src/zone.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // Marks are used during traversal of the graph to distinguish states of nodes. | 21 // Marks are used during traversal of the graph to distinguish states of nodes. |
| 22 // Each node has a mark which is a monotonically increasing integer, and a | 22 // Each node has a mark which is a monotonically increasing integer, and a |
| 23 // {NodeMarker} has a range of values that indicate states of a node. | 23 // {NodeMarker} has a range of values that indicate states of a node. |
| 24 typedef uint32_t Mark; | 24 typedef uint32_t Mark; |
| 25 | 25 |
| 26 | 26 |
| 27 // NodeIds are identifying numbers for nodes that can be used to index auxiliary | 27 // NodeIds are identifying numbers for nodes that can be used to index auxiliary |
| 28 // out-of-line data associated with each node. | 28 // out-of-line data associated with each node. |
| 29 typedef uint32_t NodeId; | 29 typedef uint32_t NodeId; |
| 30 | 30 |
| 31 | 31 class Graph final : public ZoneObject { |
| 32 class Graph : public ZoneObject { | |
| 33 public: | 32 public: |
| 34 explicit Graph(Zone* zone); | 33 explicit Graph(Zone* zone); |
| 35 | 34 |
| 35 // Scope used when creating a subgraph for inlining. Automatically preserves |
| 36 // the original start and end nodes of the graph, and resets them when you |
| 37 // leave the scope. |
| 38 class SubgraphScope final { |
| 39 public: |
| 40 explicit SubgraphScope(Graph* graph) |
| 41 : graph_(graph), start_(graph->start()), end_(graph->end()) {} |
| 42 ~SubgraphScope() { |
| 43 graph_->SetStart(start_); |
| 44 graph_->SetEnd(end_); |
| 45 } |
| 46 |
| 47 private: |
| 48 Graph* const graph_; |
| 49 Node* const start_; |
| 50 Node* const end_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(SubgraphScope); |
| 53 }; |
| 54 |
| 36 // Base implementation used by all factory methods. | 55 // Base implementation used by all factory methods. |
| 37 Node* NewNodeUnchecked(const Operator* op, int input_count, | 56 Node* NewNodeUnchecked(const Operator* op, int input_count, |
| 38 Node* const* inputs, bool incomplete = false); | 57 Node* const* inputs, bool incomplete = false); |
| 39 | 58 |
| 40 // Factory that checks the input count. | 59 // Factory that checks the input count. |
| 41 Node* NewNode(const Operator* op, int input_count, Node* const* inputs, | 60 Node* NewNode(const Operator* op, int input_count, Node* const* inputs, |
| 42 bool incomplete = false); | 61 bool incomplete = false); |
| 43 | 62 |
| 44 // Factories for nodes with static input counts. | 63 // Factories for nodes with static input counts. |
| 45 Node* NewNode(const Operator* op) { | 64 Node* NewNode(const Operator* op) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 public: | 141 public: |
| 123 virtual ~GraphDecorator() {} | 142 virtual ~GraphDecorator() {} |
| 124 virtual void Decorate(Node* node) = 0; | 143 virtual void Decorate(Node* node) = 0; |
| 125 }; | 144 }; |
| 126 | 145 |
| 127 } // namespace compiler | 146 } // namespace compiler |
| 128 } // namespace internal | 147 } // namespace internal |
| 129 } // namespace v8 | 148 } // namespace v8 |
| 130 | 149 |
| 131 #endif // V8_COMPILER_GRAPH_H_ | 150 #endif // V8_COMPILER_GRAPH_H_ |
| OLD | NEW |