OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_COMPILER_NODE_MARKER_H_ |
| 6 #define V8_COMPILER_NODE_MARKER_H_ |
| 7 |
| 8 #include "src/base/macros.h" |
| 9 |
| 10 namespace v8 { |
| 11 namespace internal { |
| 12 namespace compiler { |
| 13 |
| 14 // Forward declarations. |
| 15 class Graph; |
| 16 class Node; |
| 17 |
| 18 |
| 19 // Marks are used during traversal of the graph to distinguish states of nodes. |
| 20 // Each node has a mark which is a monotonically increasing integer, and a |
| 21 // {NodeMarker} has a range of values that indicate states of a node. |
| 22 typedef uint32_t Mark; |
| 23 |
| 24 |
| 25 // Base class for templatized NodeMarkers. |
| 26 class NodeMarkerBase { |
| 27 public: |
| 28 NodeMarkerBase(Graph* graph, uint32_t num_states); |
| 29 |
| 30 Mark Get(Node* node); |
| 31 void Set(Node* node, Mark mark); |
| 32 |
| 33 private: |
| 34 Mark mark_min_; |
| 35 Mark mark_max_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(NodeMarkerBase); |
| 38 }; |
| 39 |
| 40 |
| 41 // A NodeMarker uses monotonically increasing marks to assign local "states" |
| 42 // to nodes. Only one NodeMarker per graph is valid at a given time. |
| 43 template <typename State> |
| 44 class NodeMarker : public NodeMarkerBase { |
| 45 public: |
| 46 NodeMarker(Graph* graph, uint32_t num_states) |
| 47 : NodeMarkerBase(graph, num_states) {} |
| 48 |
| 49 State Get(Node* node) { |
| 50 return static_cast<State>(NodeMarkerBase::Get(node)); |
| 51 } |
| 52 |
| 53 void Set(Node* node, State state) { |
| 54 NodeMarkerBase::Set(node, static_cast<Mark>(state)); |
| 55 } |
| 56 }; |
| 57 |
| 58 } // namespace compiler |
| 59 } // namespace internal |
| 60 } // namespace v8 |
| 61 |
| 62 #endif // V8_COMPILER_NODE_MARKER_H_ |
OLD | NEW |