}
+bool Scheduler::IsBasicBlockBegin(Node* node) {
+ return OperatorProperties::IsBasicBlockBegin(node->op());
+}
+
+
+bool Scheduler::CanBeScheduled(Node* node) { return true; }
+
+
+bool Scheduler::HasFixedSchedulePosition(Node* node) {
+ IrOpcode::Value opcode = node->opcode();
+ return (IrOpcode::IsControlOpcode(opcode)) ||
+ opcode == IrOpcode::kParameter || opcode == IrOpcode::kEffectPhi ||
+ opcode == IrOpcode::kPhi;
+}
+
+
+bool Scheduler::IsScheduleRoot(Node* node) {
+ IrOpcode::Value opcode = node->opcode();
+ return opcode == IrOpcode::kEnd || opcode == IrOpcode::kEffectPhi ||
+ opcode == IrOpcode::kPhi;
+}
+
+
class CreateBlockVisitor : public NullNodeVisitor {
public:
explicit CreateBlockVisitor(Scheduler* scheduler) : scheduler_(scheduler) {}
// For all of the merge's control inputs, add a goto at the end to the
// merge's basic block.
for (InputIter j = (*i)->inputs().begin(); j != (*i)->inputs().end(); ++j) {
- if (OperatorProperties::IsBasicBlockBegin((*i)->op())) {
+ if (IsBasicBlockBegin((*i))) {
BasicBlock* predecessor_block = schedule_->block(*j);
if ((*j)->opcode() != IrOpcode::kReturn &&
(*j)->opcode() != IrOpcode::kDeoptimize) {
int max_rpo = 0;
// Otherwise, the minimum rpo for the node is the max of all of the inputs.
if (!IsFixedNode(node)) {
- DCHECK(!OperatorProperties::IsBasicBlockBegin(node->op()));
+ DCHECK(!scheduler_->IsBasicBlockBegin(node));
for (InputIter i = node->inputs().begin(); i != node->inputs().end();
++i) {
int control_rpo = scheduler_->schedule_early_rpo_index_[(*i)->id()];
return GenericGraphVisit::CONTINUE;
}
- static bool IsFixedNode(Node* node) {
- return OperatorProperties::HasFixedSchedulePosition(node->op()) ||
- !OperatorProperties::CanBeScheduled(node->op());
+ bool IsFixedNode(Node* node) {
+ return scheduler_->HasFixedSchedulePosition(node) ||
+ !scheduler_->CanBeScheduled(node);
}
// TODO(mstarzinger): Dirty hack to unblock others, schedule early should be
// right place; it's a convenient place during the preparation of use counts
// to schedule them.
if (!schedule_->IsScheduled(node) &&
- OperatorProperties::HasFixedSchedulePosition(node->op())) {
+ scheduler_->HasFixedSchedulePosition(node)) {
if (FLAG_trace_turbo_scheduler) {
PrintF("Fixed position node %d is unscheduled, scheduling now\n",
node->id());
schedule_->AddNode(block, node);
}
- if (OperatorProperties::IsScheduleRoot(node->op())) {
+ if (scheduler_->IsScheduleRoot(node)) {
scheduler_->schedule_root_nodes_.push_back(node);
}
// If the edge is from an unscheduled node, then tally it in the use count
// for all of its inputs. The same criterion will be used in ScheduleLate
// for decrementing use counts.
- if (!schedule_->IsScheduled(from) &&
- OperatorProperties::CanBeScheduled(from->op())) {
- DCHECK(!OperatorProperties::HasFixedSchedulePosition(from->op()));
+ if (!schedule_->IsScheduled(from) && scheduler_->CanBeScheduled(from)) {
+ DCHECK(!scheduler_->HasFixedSchedulePosition(from));
++scheduler_->unscheduled_uses_[to->id()];
if (FLAG_trace_turbo_scheduler) {
PrintF("Incrementing uses of node %d from %d to %d\n", to->id(),
GenericGraphVisit::Control Pre(Node* node) {
// Don't schedule nodes that cannot be scheduled or are already scheduled.
- if (!OperatorProperties::CanBeScheduled(node->op()) ||
- schedule_->IsScheduled(node)) {
+ if (!scheduler_->CanBeScheduled(node) || schedule_->IsScheduled(node)) {
return GenericGraphVisit::CONTINUE;
}
- DCHECK(!OperatorProperties::HasFixedSchedulePosition(node->op()));
+ DCHECK(!scheduler_->HasFixedSchedulePosition(node));
// If all the uses of a node have been scheduled, then the node itself can
// be scheduled.
BasicBlock* GetBlockForUse(Node::Edge edge) {
Node* use = edge.from();
IrOpcode::Value opcode = use->opcode();
- // If the use is a phi, forward through the the phi to the basic block
+ // If the use is a phi, forward through the phi to the basic block
// corresponding to the phi's input.
if (opcode == IrOpcode::kPhi || opcode == IrOpcode::kEffectPhi) {
int index = edge.index();
return result;
}
- bool IsNodeEligible(Node* node) {
- bool eligible = scheduler_->unscheduled_uses_[node->id()] == 0;
- return eligible;
- }
-
void ScheduleNode(BasicBlock* block, Node* node) {
schedule_->PlanNode(block, node);
scheduler_->scheduled_nodes_[block->id()].push_back(node);