Commit 02210179 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

De-generify the GenericGraph.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/767733002

Cr-Commit-Position: refs/heads/master@{#25569}
parent 1d42a9db
......@@ -499,7 +499,6 @@ source_set("v8_base") {
"src/compiler/gap-resolver.h",
"src/compiler/generic-algorithm-inl.h",
"src/compiler/generic-algorithm.h",
"src/compiler/generic-graph.h",
"src/compiler/generic-node-inl.h",
"src/compiler/generic-node.h",
"src/compiler/graph-builder.cc",
......
......@@ -8,9 +8,9 @@
#include <vector>
#include "src/compiler/generic-algorithm.h"
#include "src/compiler/generic-graph.h"
#include "src/compiler/generic-node.h"
#include "src/compiler/generic-node-inl.h"
#include "src/compiler/graph.h"
namespace v8 {
namespace internal {
......@@ -24,7 +24,7 @@ class NodeInputIterationTraits {
static Iterator begin(Node* node) { return node->inputs().begin(); }
static Iterator end(Node* node) { return node->inputs().end(); }
static int max_id(GenericGraphBase* graph) { return graph->NodeCount(); }
static int max_id(Graph* graph) { return graph->NodeCount(); }
static Node* to(Iterator iterator) { return *iterator; }
static Node* from(Iterator iterator) { return iterator.edge().from(); }
};
......
......@@ -7,7 +7,6 @@
#include <stack>
#include "src/compiler/generic-graph.h"
#include "src/compiler/generic-node.h"
#include "src/zone-containers.h"
......@@ -30,9 +29,8 @@ class GenericGraphVisit {
// void PostEdge(Traits::Node* from, int index, Traits::Node* to);
// }
template <class Visitor, class Traits, class RootIterator>
static void Visit(GenericGraphBase* graph, Zone* zone,
RootIterator root_begin, RootIterator root_end,
Visitor* visitor) {
static void Visit(Graph* graph, Zone* zone, RootIterator root_begin,
RootIterator root_end, Visitor* visitor) {
typedef typename Traits::Node Node;
typedef typename Traits::Iterator Iterator;
typedef std::pair<Iterator, Iterator> NodeState;
......@@ -84,8 +82,8 @@ class GenericGraphVisit {
}
template <class Visitor, class Traits>
static void Visit(GenericGraphBase* graph, Zone* zone,
typename Traits::Node* current, Visitor* visitor) {
static void Visit(Graph* graph, Zone* zone, typename Traits::Node* current,
Visitor* visitor) {
typename Traits::Node* array[] = {current};
Visit<Visitor, Traits>(graph, zone, &array[0], &array[1], visitor);
}
......
// Copyright 2013 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_COMPILER_GENERIC_GRAPH_H_
#define V8_COMPILER_GENERIC_GRAPH_H_
#include "src/compiler/generic-node.h"
namespace v8 {
namespace internal {
class Zone;
namespace compiler {
class GenericGraphBase : public ZoneObject {
public:
explicit GenericGraphBase(Zone* zone) : zone_(zone), next_node_id_(0) {}
Zone* zone() const { return zone_; }
NodeId NextNodeID() { return next_node_id_++; }
NodeId NodeCount() const { return next_node_id_; }
private:
Zone* zone_;
NodeId next_node_id_;
};
template <class V>
class GenericGraph : public GenericGraphBase {
public:
explicit GenericGraph(Zone* zone)
: GenericGraphBase(zone), start_(NULL), end_(NULL) {}
V* start() const { return start_; }
V* end() const { return end_; }
void SetStart(V* start) { start_ = start; }
void SetEnd(V* end) { end_ = end; }
private:
V* start_;
V* end_;
DISALLOW_COPY_AND_ASSIGN(GenericGraph);
};
}
}
} // namespace v8::internal::compiler
#endif // V8_COMPILER_GENERIC_GRAPH_H_
......@@ -7,8 +7,8 @@
#include "src/v8.h"
#include "src/compiler/generic-graph.h"
#include "src/compiler/generic-node.h"
#include "src/compiler/graph.h"
#include "src/zone.h"
namespace v8 {
......@@ -16,7 +16,7 @@ namespace internal {
namespace compiler {
template <class B, class S>
GenericNode<B, S>::GenericNode(GenericGraphBase* graph, int input_count,
GenericNode<B, S>::GenericNode(Graph* graph, int input_count,
int reserve_input_count)
: BaseClass(graph->zone()),
input_count_(input_count),
......@@ -31,7 +31,7 @@ GenericNode<B, S>::GenericNode(GenericGraphBase* graph, int input_count,
}
template <class B, class S>
inline void GenericNode<B, S>::AssignUniqueID(GenericGraphBase* graph) {
inline void GenericNode<B, S>::AssignUniqueID(Graph* graph) {
id_ = graph->NextNodeID();
}
......@@ -233,7 +233,7 @@ inline bool GenericNode<B, S>::OwnedBy(GenericNode* owner) const {
}
template <class B, class S>
S* GenericNode<B, S>::New(GenericGraphBase* graph, int input_count, S** inputs,
S* GenericNode<B, S>::New(Graph* graph, int input_count, S** inputs,
bool has_extensible_inputs) {
size_t node_size = sizeof(GenericNode);
int reserve_input_count = has_extensible_inputs ? kDefaultReservedInputs : 0;
......
......@@ -13,7 +13,7 @@ namespace v8 {
namespace internal {
namespace compiler {
class GenericGraphBase;
class Graph;
typedef int NodeId;
......@@ -92,11 +92,11 @@ class GenericNode : public B {
bool OwnedBy(GenericNode* owner) const;
static S* New(GenericGraphBase* graph, int input_count, S** inputs,
static S* New(Graph* graph, int input_count, S** inputs,
bool has_extensible_inputs);
protected:
friend class GenericGraphBase;
friend class Graph;
class Use : public ZoneObject {
public:
......@@ -129,11 +129,10 @@ class GenericNode : public B {
void* operator new(size_t, void* location) { return location; }
GenericNode(GenericGraphBase* graph, int input_count,
int reserved_input_count);
GenericNode(Graph* graph, int input_count, int reserved_input_count);
private:
void AssignUniqueID(GenericGraphBase* graph);
void AssignUniqueID(Graph* graph);
typedef ZoneDeque<Input> InputDeque;
......
......@@ -5,7 +5,6 @@
#include "src/compiler/graph-builder.h"
#include "src/compiler.h"
#include "src/compiler/generic-graph.h"
#include "src/compiler/generic-node.h"
#include "src/compiler/generic-node-inl.h"
#include "src/compiler/graph-visualizer.h"
......
......@@ -20,7 +20,12 @@ namespace internal {
namespace compiler {
Graph::Graph(Zone* zone)
: GenericGraph<Node>(zone), mark_max_(0), decorators_(zone) {}
: zone_(zone),
start_(NULL),
end_(NULL),
mark_max_(0),
next_node_id_(0),
decorators_(zone) {}
void Graph::Decorate(Node* node) {
......
......@@ -19,7 +19,7 @@ namespace compiler {
class GraphDecorator;
class Graph : public GenericGraph<Node> {
class Graph : public ZoneObject {
public:
explicit Graph(Zone* zone);
......@@ -63,6 +63,16 @@ class Graph : public GenericGraph<Node> {
template <class Visitor>
void VisitNodeInputsFromEnd(Visitor* visitor);
Zone* zone() const { return zone_; }
Node* start() const { return start_; }
Node* end() const { return end_; }
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_; }
void Decorate(Node* node);
void AddDecorator(GraphDecorator* decorator) {
......@@ -80,8 +90,14 @@ class Graph : public GenericGraph<Node> {
template <typename State>
friend class NodeMarker;
Zone* zone_;
Node* start_;
Node* end_;
Mark mark_max_;
NodeId next_node_id_;
ZoneVector<GraphDecorator*> decorators_;
DISALLOW_COPY_AND_ASSIGN(Graph);
};
......
......@@ -61,7 +61,7 @@ class NodeData {
// out-of-line indexed by the Node's id.
class Node FINAL : public GenericNode<NodeData, Node> {
public:
Node(GenericGraphBase* graph, int input_count, int reserve_input_count)
Node(Graph* graph, int input_count, int reserve_input_count)
: GenericNode<NodeData, Node>(graph, input_count, reserve_input_count) {}
void Initialize(const Operator* op) {
......
......@@ -431,7 +431,6 @@
'../../src/compiler/gap-resolver.h',
'../../src/compiler/generic-algorithm-inl.h',
'../../src/compiler/generic-algorithm.h',
'../../src/compiler/generic-graph.h',
'../../src/compiler/generic-node-inl.h',
'../../src/compiler/generic-node.h',
'../../src/compiler/graph-builder.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment