Cleanup unscheduled use count for controls of coupled nodes.

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

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

Cr-Commit-Position: refs/heads/master@{#24991}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24991 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 234ffb76
...@@ -122,10 +122,6 @@ void Scheduler::UpdatePlacement(Node* node, Placement placement) { ...@@ -122,10 +122,6 @@ void Scheduler::UpdatePlacement(Node* node, Placement placement) {
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
BasicBlock* block = schedule_->block(control); BasicBlock* block = schedule_->block(control);
schedule_->AddNode(block, node); schedule_->AddNode(block, node);
// TODO(mstarzinger): Cheap hack to make sure unscheduled use count of
// control does not drop below zero. This might cause the control to be
// queued for scheduling more than once, which makes this ugly!
++(GetData(control)->unscheduled_count_);
break; break;
} }
#define DEFINE_FLOATING_CONTROL_CASE(V) case IrOpcode::k##V: #define DEFINE_FLOATING_CONTROL_CASE(V) case IrOpcode::k##V:
...@@ -153,19 +149,30 @@ void Scheduler::UpdatePlacement(Node* node, Placement placement) { ...@@ -153,19 +149,30 @@ void Scheduler::UpdatePlacement(Node* node, Placement placement) {
for (InputIter i = node->inputs().begin(); i != node->inputs().end(); ++i) { for (InputIter i = node->inputs().begin(); i != node->inputs().end(); ++i) {
// TODO(mstarzinger): Another cheap hack for use counts. // TODO(mstarzinger): Another cheap hack for use counts.
if (GetData(*i)->placement_ == kFixed) continue; if (GetData(*i)->placement_ == kFixed) continue;
DecrementUnscheduledUseCount(*i, i.edge().from()); DecrementUnscheduledUseCount(*i, i.index(), i.edge().from());
} }
} }
data->placement_ = placement; data->placement_ = placement;
} }
void Scheduler::IncrementUnscheduledUseCount(Node* node, Node* from) { bool Scheduler::IsCoupledControlEdge(Node* node, int index) {
return GetPlacement(node) == kCoupled &&
NodeProperties::FirstControlIndex(node) == index;
}
void Scheduler::IncrementUnscheduledUseCount(Node* node, int index,
Node* from) {
// Make sure that control edges from coupled nodes are not counted.
if (IsCoupledControlEdge(from, index)) return;
// Use count for coupled nodes is summed up on their control.
if (GetPlacement(node) == kCoupled) { if (GetPlacement(node) == kCoupled) {
// Use count for coupled nodes is summed up on their control.
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
return IncrementUnscheduledUseCount(control, from); return IncrementUnscheduledUseCount(control, index, from);
} }
++(GetData(node)->unscheduled_count_); ++(GetData(node)->unscheduled_count_);
if (FLAG_trace_turbo_scheduler) { if (FLAG_trace_turbo_scheduler) {
Trace(" Use count of #%d:%s (used by #%d:%s)++ = %d\n", node->id(), Trace(" Use count of #%d:%s (used by #%d:%s)++ = %d\n", node->id(),
...@@ -175,12 +182,17 @@ void Scheduler::IncrementUnscheduledUseCount(Node* node, Node* from) { ...@@ -175,12 +182,17 @@ void Scheduler::IncrementUnscheduledUseCount(Node* node, Node* from) {
} }
void Scheduler::DecrementUnscheduledUseCount(Node* node, Node* from) { void Scheduler::DecrementUnscheduledUseCount(Node* node, int index,
Node* from) {
// Make sure that control edges from coupled nodes are not counted.
if (IsCoupledControlEdge(from, index)) return;
// Use count for coupled nodes is summed up on their control.
if (GetPlacement(node) == kCoupled) { if (GetPlacement(node) == kCoupled) {
// Use count for coupled nodes is summed up on their control.
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
return DecrementUnscheduledUseCount(control, from); return DecrementUnscheduledUseCount(control, index, from);
} }
DCHECK(GetData(node)->unscheduled_count_ > 0); DCHECK(GetData(node)->unscheduled_count_ > 0);
--(GetData(node)->unscheduled_count_); --(GetData(node)->unscheduled_count_);
if (FLAG_trace_turbo_scheduler) { if (FLAG_trace_turbo_scheduler) {
...@@ -1019,20 +1031,14 @@ class PrepareUsesVisitor : public NullNodeVisitor { ...@@ -1019,20 +1031,14 @@ class PrepareUsesVisitor : public NullNodeVisitor {
void PostEdge(Node* from, int index, Node* to) { void PostEdge(Node* from, int index, Node* to) {
// If the edge is from an unscheduled node, then tally it in the use count // If the edge is from an unscheduled node, then tally it in the use count
// for all of its inputs. Also make sure that control edges from coupled // for all of its inputs. The same criterion will be used in ScheduleLate
// nodes are not counted. The same criterion will be used in ScheduleLate
// for decrementing use counts. // for decrementing use counts.
if (!schedule_->IsScheduled(from) && !IsCoupledControlEdge(from, index)) { if (!schedule_->IsScheduled(from)) {
DCHECK_NE(Scheduler::kFixed, scheduler_->GetPlacement(from)); DCHECK_NE(Scheduler::kFixed, scheduler_->GetPlacement(from));
scheduler_->IncrementUnscheduledUseCount(to, from); scheduler_->IncrementUnscheduledUseCount(to, index, from);
} }
} }
bool IsCoupledControlEdge(Node* node, int index) {
return scheduler_->GetPlacement(node) == Scheduler::kCoupled &&
NodeProperties::FirstControlIndex(node) == index;
}
private: private:
Scheduler* scheduler_; Scheduler* scheduler_;
Schedule* schedule_; Schedule* schedule_;
......
...@@ -69,8 +69,9 @@ class Scheduler { ...@@ -69,8 +69,9 @@ class Scheduler {
Placement GetPlacement(Node* node); Placement GetPlacement(Node* node);
void UpdatePlacement(Node* node, Placement placement); void UpdatePlacement(Node* node, Placement placement);
void IncrementUnscheduledUseCount(Node* node, Node* from); inline bool IsCoupledControlEdge(Node* node, int index);
void DecrementUnscheduledUseCount(Node* node, Node* from); void IncrementUnscheduledUseCount(Node* node, int index, Node* from);
void DecrementUnscheduledUseCount(Node* node, int index, Node* from);
inline int GetRPONumber(BasicBlock* block); inline int GetRPONumber(BasicBlock* block);
BasicBlock* GetCommonDominator(BasicBlock* b1, BasicBlock* b2); BasicBlock* GetCommonDominator(BasicBlock* b1, BasicBlock* b2);
......
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