diff options
Diffstat (limited to 'deps/v8/src/compiler/graph.h')
-rw-r--r-- | deps/v8/src/compiler/graph.h | 82 |
1 files changed, 24 insertions, 58 deletions
diff --git a/deps/v8/src/compiler/graph.h b/deps/v8/src/compiler/graph.h index d619da252f..882e549f8d 100644 --- a/deps/v8/src/compiler/graph.h +++ b/deps/v8/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 Decorate(Node* node, bool incomplete); + 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,46 +102,12 @@ 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 { public: virtual ~GraphDecorator() {} - virtual void Decorate(Node* node) = 0; + virtual void Decorate(Node* node, bool incomplete) = 0; }; } // namespace compiler |