Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: src/compiler/graph.h

Issue 768763002: [turbofan] Add TraversalState and GraphTraversal and use them in GraphReducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: base embedded. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/graph.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/graph.h
diff --git a/src/compiler/graph.h b/src/compiler/graph.h
index 5cb7702175d11396b2785bc2c37f6ea11947b815..71fa3e73ed03b4979994ea395923a830992ee20d 100644
--- a/src/compiler/graph.h
+++ b/src/compiler/graph.h
@@ -19,7 +19,6 @@ namespace compiler {
class GraphDecorator;
-
class Graph : public GenericGraph<Node> {
public:
explicit Graph(Zone* zone);
@@ -78,10 +77,50 @@ class Graph : public GenericGraph<Node> {
}
private:
+ template <typename State>
+ friend class NodeMarker;
+
+ Mark mark_max_;
ZoneVector<GraphDecorator*> decorators_;
};
+// A NodeMarker uses monotonically increasing marks to assign local "states"
+// to nodes. Only one NodeMarker per graph is valid at a given time.
+template <typename State>
+class NodeMarker BASE_EMBEDDED {
+ public:
+ NodeMarker(Graph* graph, uint32_t num_states)
+ : mark_min_(graph->mark_max_), mark_max_(graph->mark_max_ += num_states) {
+ DCHECK(num_states > 0); // user error!
+ DCHECK(mark_max_ > mark_min_); // check for wraparound.
+ }
+
+ State Get(Node* node) {
+ Mark mark = node->mark();
+ if (mark < mark_min_) {
+ mark = mark_min_;
+ node->set_mark(mark_min_);
+ }
+ DCHECK_LT(mark, mark_max_);
+ return static_cast<State>(mark - mark_min_);
+ }
+
+ void Set(Node* node, State state) {
+ Mark local = static_cast<Mark>(state);
+ DCHECK(local < (mark_max_ - mark_min_));
+ DCHECK_LT(node->mark(), mark_max_);
+ node->set_mark(local + mark_min_);
+ }
+
+ private:
+ Mark mark_min_;
+ Mark mark_max_;
+};
+
+
+// A graph decorator can be used to add behavior to the creation of nodes
+// in a graph.
class GraphDecorator : public ZoneObject {
public:
virtual ~GraphDecorator() {}
« no previous file with comments | « no previous file | src/compiler/graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698