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

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: 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-reducer.h » ('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 9b0d234818a46abe79ab9b275f49fc96e47c7914..9e4cb70ea5d7f45f3e93b8e3a37ba3317964f5c0 100644
--- a/src/compiler/graph.h
+++ b/src/compiler/graph.h
@@ -19,6 +19,35 @@ namespace compiler {
class GraphDecorator;
+template <typename LocalState>
Michael Starzinger 2014/11/28 11:27:27 nit: Can we use s/LocalState/State/ here for reada
+class GraphTraversal : public ZoneObject {
Michael Starzinger 2014/11/28 11:27:27 As discussed offline: Since this is not really a "
+ public:
+ LocalState GetState(Node* node) {
+ TraversalState state = node->traversal_state();
+ if (state < traversal_state_min_) {
+ state = traversal_state_min_;
+ node->set_traversal_state(traversal_state_min_);
+ }
+ DCHECK_LT(state, traversal_state_max_);
+ return static_cast<LocalState>(state - traversal_state_min_);
+ }
+
+ void SetState(Node* node, LocalState state) {
+ TraversalState local = static_cast<TraversalState>(state);
+ DCHECK(local >= 0 && local < (traversal_state_max_ - traversal_state_min_));
+ DCHECK_LT(node->traversal_state(), traversal_state_max_);
+ node->set_traversal_state(local + traversal_state_min_);
+ }
+
+ private:
+ GraphTraversal(TraversalState min, TraversalState max)
+ : traversal_state_min_(min), traversal_state_max_(max) {}
+
+ TraversalState traversal_state_min_;
+ TraversalState traversal_state_max_;
+
+ friend class Graph;
+};
class Graph : public GenericGraph<Node> {
public:
@@ -83,7 +112,16 @@ class Graph : public GenericGraph<Node> {
decorators_.erase(it, it + 1);
}
+ template <typename LocalState>
Michael Starzinger 2014/11/28 11:27:27 nit: Can we use s/LocalState/State/ here for reada
+ GraphTraversal<LocalState>* NewTraversal(Zone* local_zone,
+ uint32_t num_states) {
+ TraversalState min = traversal_state_max_;
+ TraversalState max = (traversal_state_max_ += num_states);
+ return new (local_zone) GraphTraversal<LocalState>(min, max);
+ }
+
private:
+ TraversalState traversal_state_max_;
ZoneVector<GraphDecorator*> decorators_;
};
« no previous file with comments | « no previous file | src/compiler/graph-reducer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698