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

Unified Diff: src/compiler/graph.h

Issue 838783002: [turbofan] Cleanup Graph and related classes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Parameter pack causes compile errors. Created 5 years, 11 months 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 | « src/compiler/control-reducer.cc ('k') | 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 d619da252fa3fea0dc52122ec5106db4cfd3a8ff..e825b7e9a110fe292b938764811680dc9223fd7a 100644
--- a/src/compiler/graph.h
+++ b/src/compiler/graph.h
@@ -5,12 +5,8 @@
#ifndef V8_COMPILER_GRAPH_H_
#define V8_COMPILER_GRAPH_H_
-#include <map>
-#include <set>
-
-#include "src/compiler/node.h"
-#include "src/compiler/node-aux-data.h"
-#include "src/compiler/source-position.h"
+#include "src/zone.h"
+#include "src/zone-containers.h"
namespace v8 {
namespace internal {
@@ -18,6 +14,19 @@ namespace compiler {
// Forward declarations.
class GraphDecorator;
+class Node;
+class Operator;
+
+
+// Marks are used during traversal of the graph to distinguish states of nodes.
+// Each node has a mark which is a monotonically increasing integer, and a
+// {NodeMarker} has a range of values that indicate states of a node.
+typedef uint32_t Mark;
+
+
+// NodeIds are identifying numbers for nodes that can be used to index auxiliary
+// out-of-line data associated with each node.
+typedef int32_t NodeId;
class Graph : public ZoneObject {
@@ -71,27 +80,18 @@ class Graph : public ZoneObject {
void SetStart(Node* start) { start_ = start; }
void SetEnd(Node* end) { end_ = end; }
- NodeId NextNodeID() { return next_node_id_++; }
- NodeId NodeCount() const { return next_node_id_; }
+ int NodeCount() const { return next_node_id_; }
void Decorate(Node* node);
-
- void AddDecorator(GraphDecorator* decorator) {
- decorators_.push_back(decorator);
- }
-
- void RemoveDecorator(GraphDecorator* decorator) {
- ZoneVector<GraphDecorator*>::iterator it =
- std::find(decorators_.begin(), decorators_.end(), decorator);
- DCHECK(it != decorators_.end());
- decorators_.erase(it, it + 1);
- }
+ void AddDecorator(GraphDecorator* decorator);
+ void RemoveDecorator(GraphDecorator* decorator);
private:
- template <typename State>
- friend class NodeMarker;
+ friend class NodeMarkerBase;
- Zone* zone_;
+ inline NodeId NextNodeId();
+
+ Zone* const zone_;
Node* start_;
Node* end_;
Mark mark_max_;
@@ -102,40 +102,6 @@ class Graph : public ZoneObject {
};
-// 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 {
« no previous file with comments | « src/compiler/control-reducer.cc ('k') | src/compiler/graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698