Allow use of phase-local zone in GenericGraphVisit.

R=titzer@chromium.org, bmeurer@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23103 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b80e7684
......@@ -38,10 +38,9 @@ class GenericGraphVisit {
// void PostEdge(Traits::Node* from, int index, Traits::Node* to);
// }
template <class Visitor, class Traits, class RootIterator>
static void Visit(GenericGraphBase* graph, RootIterator root_begin,
RootIterator root_end, Visitor* visitor) {
// TODO(bmeurer): Pass "local" zone as parameter.
Zone* zone = graph->zone();
static void Visit(GenericGraphBase* 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;
......@@ -97,10 +96,10 @@ class GenericGraphVisit {
}
template <class Visitor, class Traits>
static void Visit(GenericGraphBase* graph, typename Traits::Node* current,
Visitor* visitor) {
static void Visit(GenericGraphBase* graph, Zone* zone,
typename Traits::Node* current, Visitor* visitor) {
typename Traits::Node* array[] = {current};
Visit<Visitor, Traits>(graph, &array[0], &array[1], visitor);
Visit<Visitor, Traits>(graph, zone, &array[0], &array[1], visitor);
}
template <class B, class S>
......
......@@ -14,8 +14,8 @@ namespace compiler {
template <class Visitor>
void Graph::VisitNodeUsesFrom(Node* node, Visitor* visitor) {
GenericGraphVisit::Visit<Visitor, NodeUseIterationTraits<Node> >(this, node,
visitor);
GenericGraphVisit::Visit<Visitor, NodeUseIterationTraits<Node> >(
this, zone(), node, visitor);
}
......@@ -28,7 +28,7 @@ void Graph::VisitNodeUsesFromStart(Visitor* visitor) {
template <class Visitor>
void Graph::VisitNodeInputsFromEnd(Visitor* visitor) {
GenericGraphVisit::Visit<Visitor, NodeInputIterationTraits<Node> >(
this, end(), visitor);
this, zone(), end(), visitor);
}
}
}
......
......@@ -24,7 +24,7 @@ namespace compiler {
class GraphVisualizer : public NullNodeVisitor {
public:
GraphVisualizer(OStream& os, const Graph* graph); // NOLINT
GraphVisualizer(OStream& os, Zone* zone, const Graph* graph); // NOLINT
void Print();
......@@ -35,6 +35,7 @@ class GraphVisualizer : public NullNodeVisitor {
void AnnotateNode(Node* node);
void PrintEdge(Node* from, int index, Node* to);
Zone* zone_;
NodeSet all_nodes_;
NodeSet white_nodes_;
bool use_to_def_;
......@@ -225,8 +226,8 @@ void GraphVisualizer::Print() {
// Visit all uses of white nodes.
use_to_def_ = false;
GenericGraphVisit::Visit<GraphVisualizer, NodeUseIterationTraits<Node> >(
const_cast<Graph*>(graph_), white_nodes_.begin(), white_nodes_.end(),
this);
const_cast<Graph*>(graph_), zone_, white_nodes_.begin(),
white_nodes_.end(), this);
os_ << " DEAD_INPUT [\n"
<< " style=\"filled\" \n"
......@@ -246,18 +247,19 @@ void GraphVisualizer::Print() {
}
GraphVisualizer::GraphVisualizer(OStream& os, const Graph* graph) // NOLINT
: all_nodes_(NodeSet::key_compare(),
NodeSet::allocator_type(graph->zone())),
white_nodes_(NodeSet::key_compare(),
NodeSet::allocator_type(graph->zone())),
GraphVisualizer::GraphVisualizer(OStream& os, Zone* zone,
const Graph* graph) // NOLINT
: zone_(zone),
all_nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)),
white_nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)),
use_to_def_(true),
os_(os),
graph_(graph) {}
OStream& operator<<(OStream& os, const AsDOT& ad) {
GraphVisualizer(os, &ad.graph).Print();
Zone tmp_zone(ad.graph.zone()->isolate());
GraphVisualizer(os, &tmp_zone, &ad.graph).Print();
return os;
}
}
......
......@@ -16,7 +16,8 @@ namespace internal {
namespace compiler {
Scheduler::Scheduler(Zone* zone, Graph* graph, Schedule* schedule)
: graph_(graph),
: zone_(zone),
graph_(graph),
schedule_(schedule),
branches_(NodeVector::allocator_type(zone)),
calls_(NodeVector::allocator_type(zone)),
......@@ -624,7 +625,7 @@ void Scheduler::ScheduleLate() {
i != schedule_root_nodes_.end(); ++i) {
GenericGraphVisit::Visit<ScheduleLateNodeVisitor,
NodeInputIterationTraits<Node> >(
graph_, *i, &schedule_late_visitor);
graph_, zone_, *i, &schedule_late_visitor);
}
// Add collected nodes for basic blocks to their blocks in the right order.
......
......@@ -29,6 +29,7 @@ class Scheduler {
static BasicBlockVector* ComputeSpecialRPO(Schedule* schedule);
private:
Zone* zone_;
Graph* graph_;
Schedule* schedule_;
NodeVector branches_;
......
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