Index: src/compiler/scheduler.cc |
diff --git a/src/compiler/scheduler.cc b/src/compiler/scheduler.cc |
index 6a84591fc1b548ae865bbe58ea176854df315724..cccd7fefe3ded0a55954f1fdf857a8364abf4c59 100644 |
--- a/src/compiler/scheduler.cc |
+++ b/src/compiler/scheduler.cc |
@@ -34,7 +34,7 @@ Scheduler::Scheduler(Zone* zone, Graph* graph, Schedule* schedule) |
schedule_(schedule), |
scheduled_nodes_(zone), |
schedule_root_nodes_(zone), |
- node_data_(graph_->NodeCount(), DefaultSchedulerData(), zone), |
+ node_data_(graph_->NodeCount(), DefaultSchedulerData(zone), zone), |
has_floating_control_(false) {} |
@@ -62,8 +62,8 @@ Schedule* Scheduler::ComputeSchedule(Graph* graph) { |
} |
-Scheduler::SchedulerData Scheduler::DefaultSchedulerData() { |
- SchedulerData def = {0, -1, false, false, kUnknown}; |
+Scheduler::SchedulerData Scheduler::DefaultSchedulerData(Zone* zone) { |
+ SchedulerData def = {0, -1, false, false, kUnknown, NodeVector(zone)}; |
return def; |
} |
@@ -182,6 +182,7 @@ class CFGBuilder { |
} |
} |
+ |
void BuildBlocks(Node* node) { |
switch (node->opcode()) { |
case IrOpcode::kLoop: |
@@ -395,6 +396,26 @@ class PrepareUsesVisitor : public NullNodeVisitor { |
Trace(" Use count of #%d:%s (used by #%d:%s)++ = %d\n", to->id(), |
to->op()->mnemonic(), from->id(), from->op()->mnemonic(), |
scheduler_->GetData(to)->unscheduled_count_); |
+ if (OperatorProperties::IsBasicBlockBegin(to->op()) && |
+ (from->opcode() == IrOpcode::kEffectPhi || |
+ from->opcode() == IrOpcode::kPhi) && |
+ scheduler_->GetData(to)->is_floating_control_ && |
+ !scheduler_->GetData(to)->is_connected_control_) { |
+ for (InputIter i = from->inputs().begin(); i != from->inputs().end(); |
+ ++i) { |
+ if (!NodeProperties::IsControlEdge(i.edge())) { |
+ Scheduler::SchedulerData* data = scheduler_->GetData(to); |
+ data->additional_dependencies.push_back(*i); |
+ ++(scheduler_->GetData(*i)->unscheduled_count_); |
+ Trace( |
+ " Use count of #%d:%s (additional dependency of #%d:%s)++ = " |
+ "%d\n", |
+ (*i)->id(), (*i)->op()->mnemonic(), to->id(), |
+ to->op()->mnemonic(), |
+ scheduler_->GetData(*i)->unscheduled_count_); |
+ } |
+ } |
+ } |
} |
} |
@@ -509,6 +530,7 @@ class ScheduleLateNodeVisitor : public NullNodeVisitor { |
if (schedule_->IsScheduled(node)) { |
return GenericGraphVisit::CONTINUE; |
} |
+ |
Scheduler::SchedulerData* data = scheduler_->GetData(node); |
DCHECK_EQ(Scheduler::kSchedulable, data->placement_); |
@@ -611,6 +633,24 @@ class ScheduleLateNodeVisitor : public NullNodeVisitor { |
} |
} |
} |
+ |
+ Scheduler::SchedulerData* data = scheduler_->GetData(node); |
+ for (NodeVectorIter i = data->additional_dependencies.begin(); |
+ i != data->additional_dependencies.end(); ++i) { |
+ Scheduler::SchedulerData* data = scheduler_->GetData(*i); |
+ DCHECK(data->unscheduled_count_ > 0); |
+ --data->unscheduled_count_; |
+ if (FLAG_trace_turbo_scheduler) { |
+ Trace( |
+ " Use count for #%d:%s (additional dependency of #%d:%s)-- = %d\n", |
+ (*i)->id(), (*i)->op()->mnemonic(), node->id(), |
+ node->op()->mnemonic(), data->unscheduled_count_); |
+ if (data->unscheduled_count_ == 0) { |
+ Trace(" newly eligible #%d:%s\n", (*i)->id(), |
+ (*i)->op()->mnemonic()); |
+ } |
+ } |
+ } |
} |
Scheduler* scheduler_; |
@@ -669,16 +709,14 @@ bool Scheduler::ConnectFloatingControl() { |
// TODO(titzer): we place at most one floating control structure per |
// basic block because scheduling currently can interleave phis from |
// one subgraph with the merges from another subgraph. |
- bool one_placed = false; |
for (size_t j = 0; j < block->NodeCount(); j++) { |
Node* node = block->NodeAt(block->NodeCount() - 1 - j); |
SchedulerData* data = GetData(node); |
- if (data->is_floating_control_ && !data->is_connected_control_ && |
- !one_placed) { |
+ if (data->is_floating_control_ && !data->is_connected_control_) { |
Trace(" Floating control #%d:%s was scheduled in B%d\n", node->id(), |
node->op()->mnemonic(), block->id().ToInt()); |
ConnectFloatingControlSubgraph(block, node); |
- one_placed = true; |
+ return true; |
} |
} |
} |