| Index: src/compiler/scheduler.cc
|
| diff --git a/src/compiler/scheduler.cc b/src/compiler/scheduler.cc
|
| index a0ab947eab6f7fdf2db7aec95473f05e3daa9445..cccbc841985089146d78c5515ea0075bcfc1b7dd 100644
|
| --- a/src/compiler/scheduler.cc
|
| +++ b/src/compiler/scheduler.cc
|
| @@ -19,15 +19,10 @@ namespace v8 {
|
| namespace internal {
|
| namespace compiler {
|
|
|
| -static inline void Trace(const char* msg, ...) {
|
| - if (FLAG_trace_turbo_scheduler) {
|
| - va_list arguments;
|
| - va_start(arguments, msg);
|
| - base::OS::VPrint(msg, arguments);
|
| - va_end(arguments);
|
| - }
|
| -}
|
| -
|
| +#define TRACE(...) \
|
| + do { \
|
| + if (FLAG_trace_turbo_scheduler) PrintF(__VA_ARGS__); \
|
| + } while (false)
|
|
|
| Scheduler::Scheduler(Zone* zone, Graph* graph, Schedule* schedule, Flags flags)
|
| : zone_(zone),
|
| @@ -173,7 +168,7 @@ void Scheduler::IncrementUnscheduledUseCount(Node* node, int index,
|
|
|
| ++(GetData(node)->unscheduled_count_);
|
| 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(),
|
| node->op()->mnemonic(), from->id(), from->op()->mnemonic(),
|
| GetData(node)->unscheduled_count_);
|
| }
|
| @@ -197,12 +192,12 @@ void Scheduler::DecrementUnscheduledUseCount(Node* node, int index,
|
| DCHECK(GetData(node)->unscheduled_count_ > 0);
|
| --(GetData(node)->unscheduled_count_);
|
| 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(),
|
| node->op()->mnemonic(), from->id(), from->op()->mnemonic(),
|
| GetData(node)->unscheduled_count_);
|
| }
|
| if (GetData(node)->unscheduled_count_ == 0) {
|
| - Trace(" newly eligible #%d:%s\n", node->id(), node->op()->mnemonic());
|
| + TRACE(" newly eligible #%d:%s\n", node->id(), node->op()->mnemonic());
|
| schedule_queue_.push(node);
|
| }
|
| }
|
| @@ -268,7 +263,7 @@ class CFGBuilder : public ZoneObject {
|
| // Use control dependence equivalence to find a canonical single-entry
|
| // single-exit region that makes up a minimal component to be scheduled.
|
| if (IsSingleEntrySingleExitRegion(node, exit)) {
|
| - Trace("Found SESE at #%d:%s\n", node->id(), node->op()->mnemonic());
|
| + TRACE("Found SESE at #%d:%s\n", node->id(), node->op()->mnemonic());
|
| DCHECK(!component_entry_);
|
| component_entry_ = node;
|
| continue;
|
| @@ -372,7 +367,7 @@ class CFGBuilder : public ZoneObject {
|
| BasicBlock* block = schedule_->block(node);
|
| if (block == NULL) {
|
| block = schedule_->NewBasicBlock();
|
| - Trace("Create block id:%d for #%d:%s\n", block->id().ToInt(), node->id(),
|
| + TRACE("Create block id:%d for #%d:%s\n", block->id().ToInt(), node->id(),
|
| node->op()->mnemonic());
|
| FixNode(block, node);
|
| }
|
| @@ -515,10 +510,10 @@ class CFGBuilder : public ZoneObject {
|
| void TraceConnect(Node* node, BasicBlock* block, BasicBlock* succ) {
|
| DCHECK_NOT_NULL(block);
|
| if (succ == NULL) {
|
| - Trace("Connect #%d:%s, id:%d -> end\n", node->id(),
|
| + TRACE("Connect #%d:%s, id:%d -> end\n", node->id(),
|
| node->op()->mnemonic(), block->id().ToInt());
|
| } else {
|
| - Trace("Connect #%d:%s, id:%d -> id:%d\n", node->id(),
|
| + TRACE("Connect #%d:%s, id:%d -> id:%d\n", node->id(),
|
| node->op()->mnemonic(), block->id().ToInt(), succ->id().ToInt());
|
| }
|
| }
|
| @@ -560,7 +555,7 @@ class CFGBuilder : public ZoneObject {
|
|
|
|
|
| void Scheduler::BuildCFG() {
|
| - Trace("--- CREATING CFG -------------------------------------------\n");
|
| + TRACE("--- CREATING CFG -------------------------------------------\n");
|
|
|
| // Instantiate a new control equivalence algorithm for the graph.
|
| equivalence_ = new (zone_) ControlEquivalence(zone_, graph_);
|
| @@ -888,17 +883,17 @@ class SpecialRPONumberer : public ZoneObject {
|
| BasicBlock* end = current_loop->end;
|
| current->set_loop_end(end == NULL ? BeyondEndSentinel() : end);
|
| current_header = current_loop->header;
|
| - Trace("id:%d is a loop header, increment loop depth to %d\n",
|
| + TRACE("id:%d is a loop header, increment loop depth to %d\n",
|
| current->id().ToInt(), loop_depth);
|
| }
|
|
|
| current->set_loop_depth(loop_depth);
|
|
|
| if (current->loop_header() == NULL) {
|
| - Trace("id:%d is not in a loop (depth == %d)\n", current->id().ToInt(),
|
| + TRACE("id:%d is not in a loop (depth == %d)\n", current->id().ToInt(),
|
| current->loop_depth());
|
| } else {
|
| - Trace("id:%d has loop header id:%d, (depth == %d)\n",
|
| + TRACE("id:%d has loop header id:%d, (depth == %d)\n",
|
| current->id().ToInt(), current->loop_header()->id().ToInt(),
|
| current->loop_depth());
|
| }
|
| @@ -1080,7 +1075,7 @@ BasicBlockVector* Scheduler::ComputeSpecialRPO(Zone* zone, Schedule* schedule) {
|
|
|
|
|
| void Scheduler::ComputeSpecialRPONumbering() {
|
| - Trace("--- COMPUTING SPECIAL RPO ----------------------------------\n");
|
| + TRACE("--- COMPUTING SPECIAL RPO ----------------------------------\n");
|
|
|
| // Compute the special reverse-post-order for basic blocks.
|
| special_rpo_ = new (zone_) SpecialRPONumberer(zone_, schedule_);
|
| @@ -1107,14 +1102,14 @@ void Scheduler::PropagateImmediateDominators(BasicBlock* block) {
|
| block->set_dominator(dominator);
|
| block->set_dominator_depth(dominator->dominator_depth() + 1);
|
| block->set_deferred(deferred | block->deferred());
|
| - Trace("Block id:%d's idom is id:%d, depth = %d\n", block->id().ToInt(),
|
| + TRACE("Block id:%d's idom is id:%d, depth = %d\n", block->id().ToInt(),
|
| dominator->id().ToInt(), block->dominator_depth());
|
| }
|
| }
|
|
|
|
|
| void Scheduler::GenerateImmediateDominatorTree() {
|
| - Trace("--- IMMEDIATE BLOCK DOMINATORS -----------------------------\n");
|
| + TRACE("--- IMMEDIATE BLOCK DOMINATORS -----------------------------\n");
|
|
|
| // Seed start block to be the first dominator.
|
| schedule_->start()->set_dominator_depth(0);
|
| @@ -1139,7 +1134,7 @@ class PrepareUsesVisitor {
|
| scheduler_->schedule_root_nodes_.push_back(node);
|
| if (!schedule_->IsScheduled(node)) {
|
| // Make sure root nodes are scheduled in their respective blocks.
|
| - Trace("Scheduling fixed position node #%d:%s\n", node->id(),
|
| + TRACE("Scheduling fixed position node #%d:%s\n", node->id(),
|
| node->op()->mnemonic());
|
| IrOpcode::Value opcode = node->opcode();
|
| BasicBlock* block =
|
| @@ -1169,7 +1164,7 @@ class PrepareUsesVisitor {
|
|
|
|
|
| void Scheduler::PrepareUses() {
|
| - Trace("--- PREPARE USES -------------------------------------------\n");
|
| + TRACE("--- PREPARE USES -------------------------------------------\n");
|
|
|
| // Count the uses of every node, which is used to ensure that all of a
|
| // node's uses are scheduled before the node itself.
|
| @@ -1226,7 +1221,7 @@ class ScheduleEarlyNodeVisitor {
|
| // Fixed nodes already know their schedule early position.
|
| if (scheduler_->GetPlacement(node) == Scheduler::kFixed) {
|
| data->minimum_block_ = schedule_->block(node);
|
| - Trace("Fixing #%d:%s minimum_block = id:%d, dominator_depth = %d\n",
|
| + TRACE("Fixing #%d:%s minimum_block = id:%d, dominator_depth = %d\n",
|
| node->id(), node->op()->mnemonic(),
|
| data->minimum_block_->id().ToInt(),
|
| data->minimum_block_->dominator_depth());
|
| @@ -1264,7 +1259,7 @@ class ScheduleEarlyNodeVisitor {
|
| if (block->dominator_depth() > data->minimum_block_->dominator_depth()) {
|
| data->minimum_block_ = block;
|
| queue_.push(node);
|
| - Trace("Propagating #%d:%s minimum_block = id:%d, dominator_depth = %d\n",
|
| + TRACE("Propagating #%d:%s minimum_block = id:%d, dominator_depth = %d\n",
|
| node->id(), node->op()->mnemonic(),
|
| data->minimum_block_->id().ToInt(),
|
| data->minimum_block_->dominator_depth());
|
| @@ -1285,13 +1280,13 @@ class ScheduleEarlyNodeVisitor {
|
|
|
|
|
| void Scheduler::ScheduleEarly() {
|
| - Trace("--- SCHEDULE EARLY -----------------------------------------\n");
|
| + TRACE("--- SCHEDULE EARLY -----------------------------------------\n");
|
| if (FLAG_trace_turbo_scheduler) {
|
| - Trace("roots: ");
|
| + TRACE("roots: ");
|
| for (Node* node : schedule_root_nodes_) {
|
| - Trace("#%d:%s ", node->id(), node->op()->mnemonic());
|
| + TRACE("#%d:%s ", node->id(), node->op()->mnemonic());
|
| }
|
| - Trace("\n");
|
| + TRACE("\n");
|
| }
|
|
|
| // Compute the minimum block for each node thereby determining the earliest
|
| @@ -1353,14 +1348,14 @@ class ScheduleLateNodeVisitor {
|
|
|
| // Determine the dominating block for all of the uses of this node. It is
|
| // the latest block that this node can be scheduled in.
|
| - Trace("Scheduling #%d:%s\n", node->id(), node->op()->mnemonic());
|
| + TRACE("Scheduling #%d:%s\n", node->id(), node->op()->mnemonic());
|
| BasicBlock* block = GetCommonDominatorOfUses(node);
|
| DCHECK_NOT_NULL(block);
|
|
|
| // The schedule early block dominates the schedule late block.
|
| BasicBlock* min_block = scheduler_->GetData(node)->minimum_block_;
|
| DCHECK_EQ(min_block, BasicBlock::GetCommonDominator(block, min_block));
|
| - Trace(
|
| + TRACE(
|
| "Schedule late of #%d:%s is id:%d at loop depth %d, minimum = id:%d\n",
|
| node->id(), node->op()->mnemonic(), block->id().ToInt(),
|
| block->loop_depth(), min_block->id().ToInt());
|
| @@ -1372,7 +1367,7 @@ class ScheduleLateNodeVisitor {
|
| if (hoist_block &&
|
| hoist_block->dominator_depth() >= min_block->dominator_depth()) {
|
| do {
|
| - Trace(" hoisting #%d:%s to block id:%d\n", node->id(),
|
| + TRACE(" hoisting #%d:%s to block id:%d\n", node->id(),
|
| node->op()->mnemonic(), hoist_block->id().ToInt());
|
| DCHECK_LT(hoist_block->loop_depth(), block->loop_depth());
|
| block = hoist_block;
|
| @@ -1422,7 +1417,7 @@ class ScheduleLateNodeVisitor {
|
| BasicBlock* use_block = GetBlockForUse(edge);
|
| if (use_block == nullptr || marked_[use_block->id().ToSize()]) continue;
|
| if (use_block == block) {
|
| - Trace(" not splitting #%d:%s, it is used in id:%d\n", node->id(),
|
| + TRACE(" not splitting #%d:%s, it is used in id:%d\n", node->id(),
|
| node->op()->mnemonic(), block->id().ToInt());
|
| marking_queue_.clear();
|
| return block;
|
| @@ -1450,7 +1445,7 @@ class ScheduleLateNodeVisitor {
|
| // {block} to the end contain at least one use of {node}, and hence there's
|
| // no point in splitting the {node} in this case.
|
| if (marked_[block->id().ToSize()]) {
|
| - Trace(" not splitting #%d:%s, its common dominator id:%d is perfect\n",
|
| + TRACE(" not splitting #%d:%s, its common dominator id:%d is perfect\n",
|
| node->id(), node->op()->mnemonic(), block->id().ToInt());
|
| return block;
|
| }
|
| @@ -1472,12 +1467,12 @@ class ScheduleLateNodeVisitor {
|
| // Place the {node} at {use_block}.
|
| block = use_block;
|
| use_node = node;
|
| - Trace(" pushing #%d:%s down to id:%d\n", node->id(),
|
| + TRACE(" pushing #%d:%s down to id:%d\n", node->id(),
|
| node->op()->mnemonic(), block->id().ToInt());
|
| } else {
|
| // Place a copy of {node} at {use_block}.
|
| use_node = CloneNode(node);
|
| - Trace(" cloning #%d:%s for id:%d\n", use_node->id(),
|
| + TRACE(" cloning #%d:%s for id:%d\n", use_node->id(),
|
| use_node->op()->mnemonic(), use_block->id().ToInt());
|
| scheduler_->schedule_queue_.push(use_node);
|
| }
|
| @@ -1528,7 +1523,7 @@ class ScheduleLateNodeVisitor {
|
| // If the use is from a coupled (i.e. floating) phi, compute the common
|
| // dominator of its uses. This will not recurse more than one level.
|
| if (scheduler_->GetPlacement(use) == Scheduler::kCoupled) {
|
| - Trace(" inspecting uses of coupled #%d:%s\n", use->id(),
|
| + TRACE(" inspecting uses of coupled #%d:%s\n", use->id(),
|
| use->op()->mnemonic());
|
| DCHECK_EQ(edge.to(), NodeProperties::GetControlInput(use));
|
| return GetCommonDominatorOfUses(use);
|
| @@ -1536,7 +1531,7 @@ class ScheduleLateNodeVisitor {
|
| // If the use is from a fixed (i.e. non-floating) phi, we use the
|
| // predecessor block of the corresponding control input to the merge.
|
| if (scheduler_->GetPlacement(use) == Scheduler::kFixed) {
|
| - Trace(" input@%d into a fixed phi #%d:%s\n", edge.index(), use->id(),
|
| + TRACE(" input@%d into a fixed phi #%d:%s\n", edge.index(), use->id(),
|
| use->op()->mnemonic());
|
| Node* merge = NodeProperties::GetControlInput(use, 0);
|
| DCHECK(IrOpcode::IsMergeOpcode(merge->opcode()));
|
| @@ -1547,14 +1542,14 @@ class ScheduleLateNodeVisitor {
|
| // If the use is from a fixed (i.e. non-floating) merge, we use the
|
| // predecessor block of the current input to the merge.
|
| if (scheduler_->GetPlacement(use) == Scheduler::kFixed) {
|
| - Trace(" input@%d into a fixed merge #%d:%s\n", edge.index(), use->id(),
|
| + TRACE(" input@%d into a fixed merge #%d:%s\n", edge.index(), use->id(),
|
| use->op()->mnemonic());
|
| return FindPredecessorBlock(edge.to());
|
| }
|
| }
|
| BasicBlock* result = schedule_->block(use);
|
| if (result == NULL) return NULL;
|
| - Trace(" must dominate use #%d:%s in id:%d\n", use->id(),
|
| + TRACE(" must dominate use #%d:%s in id:%d\n", use->id(),
|
| use->op()->mnemonic(), result->id().ToInt());
|
| return result;
|
| }
|
| @@ -1592,13 +1587,13 @@ class ScheduleLateNodeVisitor {
|
|
|
|
|
| void Scheduler::ScheduleLate() {
|
| - Trace("--- SCHEDULE LATE ------------------------------------------\n");
|
| + TRACE("--- SCHEDULE LATE ------------------------------------------\n");
|
| if (FLAG_trace_turbo_scheduler) {
|
| - Trace("roots: ");
|
| + TRACE("roots: ");
|
| for (Node* node : schedule_root_nodes_) {
|
| - Trace("#%d:%s ", node->id(), node->op()->mnemonic());
|
| + TRACE("#%d:%s ", node->id(), node->op()->mnemonic());
|
| }
|
| - Trace("\n");
|
| + TRACE("\n");
|
| }
|
|
|
| // Schedule: Places nodes in dominator block of all their uses.
|
| @@ -1612,7 +1607,7 @@ void Scheduler::ScheduleLate() {
|
|
|
|
|
| void Scheduler::SealFinalSchedule() {
|
| - Trace("--- SEAL FINAL SCHEDULE ------------------------------------\n");
|
| + TRACE("--- SEAL FINAL SCHEDULE ------------------------------------\n");
|
|
|
| // Serialize the assembly order and reverse-post-order numbering.
|
| special_rpo_->SerializeRPOIntoSchedule();
|
| @@ -1634,7 +1629,7 @@ void Scheduler::SealFinalSchedule() {
|
|
|
|
|
| void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) {
|
| - Trace("--- FUSE FLOATING CONTROL ----------------------------------\n");
|
| + TRACE("--- FUSE FLOATING CONTROL ----------------------------------\n");
|
| if (FLAG_trace_turbo_scheduler) {
|
| OFStream os(stdout);
|
| os << "Schedule before control flow fusion:\n" << *schedule_;
|
| @@ -1663,11 +1658,11 @@ void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) {
|
| }
|
| }
|
| if (FLAG_trace_turbo_scheduler) {
|
| - Trace("propagation roots: ");
|
| + TRACE("propagation roots: ");
|
| for (Node* node : propagation_roots) {
|
| - Trace("#%d:%s ", node->id(), node->op()->mnemonic());
|
| + TRACE("#%d:%s ", node->id(), node->op()->mnemonic());
|
| }
|
| - Trace("\n");
|
| + TRACE("\n");
|
| }
|
| ScheduleEarlyNodeVisitor schedule_early_visitor(zone_, this);
|
| schedule_early_visitor.Run(&propagation_roots);
|
| @@ -1685,7 +1680,7 @@ void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) {
|
|
|
|
|
| void Scheduler::MovePlannedNodes(BasicBlock* from, BasicBlock* to) {
|
| - Trace("Move planned nodes from id:%d to id:%d\n", from->id().ToInt(),
|
| + TRACE("Move planned nodes from id:%d to id:%d\n", from->id().ToInt(),
|
| to->id().ToInt());
|
| NodeVector* nodes = &(scheduled_nodes_[from->id().ToSize()]);
|
| for (Node* const node : *nodes) {
|
|
|