Commit c6004a32 authored by titzer's avatar titzer Committed by Commit bot

[turbofan] Clean up TRACE macros and use variadic macros.

R=mstarzinger@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#27248}
parent 33514ec2
...@@ -14,6 +14,11 @@ namespace v8 { ...@@ -14,6 +14,11 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
#define TRACE(...) \
do { \
if (FLAG_trace_turbo_scheduler) PrintF(__VA_ARGS__); \
} while (false)
// Determines control dependence equivalence classes for control nodes. Any two // Determines control dependence equivalence classes for control nodes. Any two
// nodes having the same set of control dependences land in one class. These // nodes having the same set of control dependences land in one class. These
// classes can in turn be used to: // classes can in turn be used to:
...@@ -96,16 +101,16 @@ class ControlEquivalence : public ZoneObject { ...@@ -96,16 +101,16 @@ class ControlEquivalence : public ZoneObject {
// Called at pre-visit during DFS walk. // Called at pre-visit during DFS walk.
void VisitPre(Node* node) { void VisitPre(Node* node) {
Trace("CEQ: Pre-visit of #%d:%s\n", node->id(), node->op()->mnemonic()); TRACE("CEQ: Pre-visit of #%d:%s\n", node->id(), node->op()->mnemonic());
// Dispense a new pre-order number. // Dispense a new pre-order number.
SetNumber(node, NewDFSNumber()); SetNumber(node, NewDFSNumber());
Trace(" Assigned DFS number is %d\n", GetNumber(node)); TRACE(" Assigned DFS number is %zu\n", GetNumber(node));
} }
// Called at mid-visit during DFS walk. // Called at mid-visit during DFS walk.
void VisitMid(Node* node, DFSDirection direction) { void VisitMid(Node* node, DFSDirection direction) {
Trace("CEQ: Mid-visit of #%d:%s\n", node->id(), node->op()->mnemonic()); TRACE("CEQ: Mid-visit of #%d:%s\n", node->id(), node->op()->mnemonic());
BracketList& blist = GetBracketList(node); BracketList& blist = GetBracketList(node);
// Remove brackets pointing to this node [line:19]. // Remove brackets pointing to this node [line:19].
...@@ -118,7 +123,7 @@ class ControlEquivalence : public ZoneObject { ...@@ -118,7 +123,7 @@ class ControlEquivalence : public ZoneObject {
} }
// Potentially start a new equivalence class [line:37]. // Potentially start a new equivalence class [line:37].
BracketListTrace(blist); BracketListTRACE(blist);
Bracket* recent = &blist.back(); Bracket* recent = &blist.back();
if (recent->recent_size != blist.size()) { if (recent->recent_size != blist.size()) {
recent->recent_size = blist.size(); recent->recent_size = blist.size();
...@@ -127,12 +132,12 @@ class ControlEquivalence : public ZoneObject { ...@@ -127,12 +132,12 @@ class ControlEquivalence : public ZoneObject {
// Assign equivalence class to node. // Assign equivalence class to node.
SetClass(node, recent->recent_class); SetClass(node, recent->recent_class);
Trace(" Assigned class number is %d\n", GetClass(node)); TRACE(" Assigned class number is %zu\n", GetClass(node));
} }
// Called at post-visit during DFS walk. // Called at post-visit during DFS walk.
void VisitPost(Node* node, Node* parent_node, DFSDirection direction) { void VisitPost(Node* node, Node* parent_node, DFSDirection direction) {
Trace("CEQ: Post-visit of #%d:%s\n", node->id(), node->op()->mnemonic()); TRACE("CEQ: Post-visit of #%d:%s\n", node->id(), node->op()->mnemonic());
BracketList& blist = GetBracketList(node); BracketList& blist = GetBracketList(node);
// Remove brackets pointing to this node [line:19]. // Remove brackets pointing to this node [line:19].
...@@ -147,7 +152,7 @@ class ControlEquivalence : public ZoneObject { ...@@ -147,7 +152,7 @@ class ControlEquivalence : public ZoneObject {
// Called when hitting a back edge in the DFS walk. // Called when hitting a back edge in the DFS walk.
void VisitBackedge(Node* from, Node* to, DFSDirection direction) { void VisitBackedge(Node* from, Node* to, DFSDirection direction) {
Trace("CEQ: Backedge from #%d:%s to #%d:%s\n", from->id(), TRACE("CEQ: Backedge from #%d:%s to #%d:%s\n", from->id(),
from->op()->mnemonic(), to->id(), to->op()->mnemonic()); from->op()->mnemonic(), to->id(), to->op()->mnemonic());
// Push backedge onto the bracket list [line:25]. // Push backedge onto the bracket list [line:25].
...@@ -316,7 +321,7 @@ class ControlEquivalence : public ZoneObject { ...@@ -316,7 +321,7 @@ class ControlEquivalence : public ZoneObject {
void BracketListDelete(BracketList& blist, Node* to, DFSDirection direction) { void BracketListDelete(BracketList& blist, Node* to, DFSDirection direction) {
for (BracketList::iterator i = blist.begin(); i != blist.end(); /*nop*/) { for (BracketList::iterator i = blist.begin(); i != blist.end(); /*nop*/) {
if (i->to == to && i->direction != direction) { if (i->to == to && i->direction != direction) {
Trace(" BList erased: {%d->%d}\n", i->from->id(), i->to->id()); TRACE(" BList erased: {%d->%d}\n", i->from->id(), i->to->id());
i = blist.erase(i); i = blist.erase(i);
} else { } else {
++i; ++i;
...@@ -324,22 +329,13 @@ class ControlEquivalence : public ZoneObject { ...@@ -324,22 +329,13 @@ class ControlEquivalence : public ZoneObject {
} }
} }
void BracketListTrace(BracketList& blist) { void BracketListTRACE(BracketList& blist) {
if (FLAG_trace_turbo_scheduler) { if (FLAG_trace_turbo_scheduler) {
Trace(" BList: "); TRACE(" BList: ");
for (Bracket bracket : blist) { for (Bracket bracket : blist) {
Trace("{%d->%d} ", bracket.from->id(), bracket.to->id()); TRACE("{%d->%d} ", bracket.from->id(), bracket.to->id());
} }
Trace("\n"); TRACE("\n");
}
}
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);
} }
} }
...@@ -350,6 +346,8 @@ class ControlEquivalence : public ZoneObject { ...@@ -350,6 +346,8 @@ class ControlEquivalence : public ZoneObject {
Data node_data_; // Per-node data stored as a side-table. Data node_data_; // Per-node data stored as a side-table.
}; };
#undef TRACE
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -15,6 +15,11 @@ namespace v8 { ...@@ -15,6 +15,11 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
#define TRACE(...) \
do { \
if (FLAG_trace_turbo_reduction) PrintF(__VA_ARGS__); \
} while (false)
enum VisitState { kUnvisited = 0, kOnStack = 1, kRevisit = 2, kVisited = 3 }; enum VisitState { kUnvisited = 0, kOnStack = 1, kRevisit = 2, kVisited = 3 };
enum Decision { kFalse, kUnknown, kTrue }; enum Decision { kFalse, kUnknown, kTrue };
...@@ -42,9 +47,6 @@ class ReachabilityMarker : public NodeMarker<uint8_t> { ...@@ -42,9 +47,6 @@ class ReachabilityMarker : public NodeMarker<uint8_t> {
}; };
#define TRACE(x) \
if (FLAG_trace_turbo_reduction) PrintF x
class ControlReducerImpl { class ControlReducerImpl {
public: public:
ControlReducerImpl(Zone* zone, JSGraph* jsgraph, ControlReducerImpl(Zone* zone, JSGraph* jsgraph,
...@@ -112,7 +114,7 @@ class ControlReducerImpl { ...@@ -112,7 +114,7 @@ class ControlReducerImpl {
while (!fw_stack.empty()) { while (!fw_stack.empty()) {
Node* node = fw_stack.back().first; Node* node = fw_stack.back().first;
TRACE(("ControlFw: #%d:%s\n", node->id(), node->op()->mnemonic())); TRACE("ControlFw: #%d:%s\n", node->id(), node->op()->mnemonic());
bool pop = true; bool pop = true;
while (fw_stack.back().second != node->uses().end()) { while (fw_stack.back().second != node->uses().end()) {
Node* succ = *(fw_stack.back().second); Node* succ = *(fw_stack.back().second);
...@@ -165,7 +167,7 @@ class ControlReducerImpl { ...@@ -165,7 +167,7 @@ class ControlReducerImpl {
// Connect {loop}, the header of a non-terminating loop, to the end node. // Connect {loop}, the header of a non-terminating loop, to the end node.
Node* ConnectNTL(Node* loop) { Node* ConnectNTL(Node* loop) {
TRACE(("ConnectNTL: #%d:%s\n", loop->id(), loop->op()->mnemonic())); TRACE("ConnectNTL: #%d:%s\n", loop->id(), loop->op()->mnemonic());
Node* always = graph()->NewNode(common_->Always()); Node* always = graph()->NewNode(common_->Always());
// Mark the node as visited so that we can revisit later. // Mark the node as visited so that we can revisit later.
...@@ -280,9 +282,9 @@ class ControlReducerImpl { ...@@ -280,9 +282,9 @@ class ControlReducerImpl {
for (Edge edge : node->use_edges()) { for (Edge edge : node->use_edges()) {
Node* use = edge.from(); Node* use = edge.from();
if (!marked.IsReachableFromEnd(use)) { if (!marked.IsReachableFromEnd(use)) {
TRACE(("DeadLink: #%d:%s(%d) -> #%d:%s\n", use->id(), TRACE("DeadLink: #%d:%s(%d) -> #%d:%s\n", use->id(),
use->op()->mnemonic(), edge.index(), node->id(), use->op()->mnemonic(), edge.index(), node->id(),
node->op()->mnemonic())); node->op()->mnemonic());
edge.UpdateTo(NULL); edge.UpdateTo(NULL);
} }
} }
...@@ -322,7 +324,7 @@ class ControlReducerImpl { ...@@ -322,7 +324,7 @@ class ControlReducerImpl {
if (node->IsDead()) return Pop(); // Node was killed while on stack. if (node->IsDead()) return Pop(); // Node was killed while on stack.
TRACE(("ControlReduce: #%d:%s\n", node->id(), node->op()->mnemonic())); TRACE("ControlReduce: #%d:%s\n", node->id(), node->op()->mnemonic());
// Recurse on an input if necessary. // Recurse on an input if necessary.
for (Node* const input : node->inputs()) { for (Node* const input : node->inputs()) {
...@@ -374,7 +376,7 @@ class ControlReducerImpl { ...@@ -374,7 +376,7 @@ class ControlReducerImpl {
void Revisit(Node* node) { void Revisit(Node* node) {
size_t id = static_cast<size_t>(node->id()); size_t id = static_cast<size_t>(node->id());
if (id < state_.size() && state_[id] == kVisited) { if (id < state_.size() && state_[id] == kVisited) {
TRACE((" Revisit #%d:%s\n", node->id(), node->op()->mnemonic())); TRACE(" Revisit #%d:%s\n", node->id(), node->op()->mnemonic());
state_[id] = kRevisit; state_[id] = kRevisit;
revisit_.push_back(node); revisit_.push_back(node);
} }
...@@ -398,7 +400,7 @@ class ControlReducerImpl { ...@@ -398,7 +400,7 @@ class ControlReducerImpl {
// If a node has only one control input and it is dead, replace with dead. // If a node has only one control input and it is dead, replace with dead.
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
if (control->opcode() == IrOpcode::kDead) { if (control->opcode() == IrOpcode::kDead) {
TRACE(("ControlDead: #%d:%s\n", node->id(), node->op()->mnemonic())); TRACE("ControlDead: #%d:%s\n", node->id(), node->op()->mnemonic());
return control; return control;
} }
} }
...@@ -507,8 +509,8 @@ class ControlReducerImpl { ...@@ -507,8 +509,8 @@ class ControlReducerImpl {
index++; index++;
} }
TRACE(("ReduceMerge: #%d:%s (%d live)\n", node->id(), TRACE("ReduceMerge: #%d:%s (%d live)\n", node->id(), node->op()->mnemonic(),
node->op()->mnemonic(), live)); live);
if (live == 0) return dead(); // no remaining inputs. if (live == 0) return dead(); // no remaining inputs.
...@@ -530,8 +532,8 @@ class ControlReducerImpl { ...@@ -530,8 +532,8 @@ class ControlReducerImpl {
if (live < node->InputCount()) { if (live < node->InputCount()) {
// Edit phis in place, removing dead inputs and revisiting them. // Edit phis in place, removing dead inputs and revisiting them.
for (Node* const phi : phis) { for (Node* const phi : phis) {
TRACE((" PhiInMerge: #%d:%s (%d live)\n", phi->id(), TRACE(" PhiInMerge: #%d:%s (%d live)\n", phi->id(),
phi->op()->mnemonic(), live)); phi->op()->mnemonic(), live);
RemoveDeadInputs(node, phi); RemoveDeadInputs(node, phi);
Revisit(phi); Revisit(phi);
} }
...@@ -557,9 +559,9 @@ class ControlReducerImpl { ...@@ -557,9 +559,9 @@ class ControlReducerImpl {
// have users except for the Merge and the Merge has no Phi or // have users except for the Merge and the Merge has no Phi or
// EffectPhi uses, so replace the Merge with the control input of the // EffectPhi uses, so replace the Merge with the control input of the
// diamond. // diamond.
TRACE((" DeadDiamond: #%d:%s #%d:%s #%d:%s\n", node0->id(), TRACE(" DeadDiamond: #%d:%s #%d:%s #%d:%s\n", node0->id(),
node0->op()->mnemonic(), node1->id(), node1->op()->mnemonic(), node0->op()->mnemonic(), node1->id(), node1->op()->mnemonic(),
branch0->id(), branch0->op()->mnemonic())); branch0->id(), branch0->op()->mnemonic());
return NodeProperties::GetControlInput(branch0); return NodeProperties::GetControlInput(branch0);
} }
} }
...@@ -575,8 +577,8 @@ class ControlReducerImpl { ...@@ -575,8 +577,8 @@ class ControlReducerImpl {
Decision result = DecideCondition(branch->InputAt(0)); Decision result = DecideCondition(branch->InputAt(0));
if (result == kTrue) { if (result == kTrue) {
// fold a true branch by replacing IfTrue with the branch control. // fold a true branch by replacing IfTrue with the branch control.
TRACE(("BranchReduce: #%d:%s => #%d:%s\n", branch->id(), TRACE("BranchReduce: #%d:%s => #%d:%s\n", branch->id(),
branch->op()->mnemonic(), node->id(), node->op()->mnemonic())); branch->op()->mnemonic(), node->id(), node->op()->mnemonic());
return branch->InputAt(1); return branch->InputAt(1);
} }
return result == kUnknown ? node : dead(); return result == kUnknown ? node : dead();
...@@ -589,8 +591,8 @@ class ControlReducerImpl { ...@@ -589,8 +591,8 @@ class ControlReducerImpl {
Decision result = DecideCondition(branch->InputAt(0)); Decision result = DecideCondition(branch->InputAt(0));
if (result == kFalse) { if (result == kFalse) {
// fold a false branch by replacing IfFalse with the branch control. // fold a false branch by replacing IfFalse with the branch control.
TRACE(("BranchReduce: #%d:%s => #%d:%s\n", branch->id(), TRACE("BranchReduce: #%d:%s => #%d:%s\n", branch->id(),
branch->op()->mnemonic(), node->id(), node->op()->mnemonic())); branch->op()->mnemonic(), node->id(), node->op()->mnemonic());
return branch->InputAt(1); return branch->InputAt(1);
} }
return result == kUnknown ? node : dead(); return result == kUnknown ? node : dead();
...@@ -622,9 +624,8 @@ class ControlReducerImpl { ...@@ -622,9 +624,8 @@ class ControlReducerImpl {
// Replace uses of {node} with {replacement} and revisit the uses. // Replace uses of {node} with {replacement} and revisit the uses.
void ReplaceNode(Node* node, Node* replacement) { void ReplaceNode(Node* node, Node* replacement) {
if (node == replacement) return; if (node == replacement) return;
TRACE((" Replace: #%d:%s with #%d:%s\n", node->id(), TRACE(" Replace: #%d:%s with #%d:%s\n", node->id(), node->op()->mnemonic(),
node->op()->mnemonic(), replacement->id(), replacement->id(), replacement->op()->mnemonic());
replacement->op()->mnemonic()));
for (Node* const use : node->uses()) { for (Node* const use : node->uses()) {
// Don't revisit this node if it refers to itself. // Don't revisit this node if it refers to itself.
if (use != node) Revisit(use); if (use != node) Revisit(use);
......
...@@ -23,6 +23,11 @@ namespace v8 { ...@@ -23,6 +23,11 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
#define TRACE(...) \
do { \
if (FLAG_trace_turbo_inlining) PrintF(__VA_ARGS__); \
} while (false)
// Provides convenience accessors for calls to JS functions. // Provides convenience accessors for calls to JS functions.
class JSCallFunctionAccessor { class JSCallFunctionAccessor {
...@@ -322,21 +327,15 @@ Reduction JSInliner::Reduce(Node* node) { ...@@ -322,21 +327,15 @@ Reduction JSInliner::Reduce(Node* node) {
if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) { if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) {
// For now do not inline functions that use their arguments array. // For now do not inline functions that use their arguments array.
SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); TRACE("Not Inlining %s into %s because inlinee uses arguments array\n",
if (FLAG_trace_turbo_inlining) { function->shared()->DebugName()->ToCString().get(),
PrintF( info_->shared_info()->DebugName()->ToCString().get());
"Not Inlining %s into %s because inlinee uses arguments "
"array\n",
name.get(), info_->shared_info()->DebugName()->ToCString().get());
}
return NoChange(); return NoChange();
} }
if (FLAG_trace_turbo_inlining) { TRACE("Inlining %s into %s\n",
SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); function->shared()->DebugName()->ToCString().get(),
PrintF("Inlining %s into %s\n", name.get(), info_->shared_info()->DebugName()->ToCString().get());
info_->shared_info()->DebugName()->ToCString().get());
}
Graph graph(info.zone()); Graph graph(info.zone());
JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(),
......
...@@ -9,8 +9,10 @@ namespace v8 { ...@@ -9,8 +9,10 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
#define TRACE(x) \ #define TRACE(...) \
if (FLAG_trace_turbo_jt) PrintF x do { \
if (FLAG_trace_turbo_jt) PrintF(__VA_ARGS__); \
} while (false)
struct JumpThreadingState { struct JumpThreadingState {
bool forwarded; bool forwarded;
...@@ -29,19 +31,19 @@ struct JumpThreadingState { ...@@ -29,19 +31,19 @@ struct JumpThreadingState {
RpoNumber to_to = result[to.ToInt()]; RpoNumber to_to = result[to.ToInt()];
bool pop = true; bool pop = true;
if (to == from) { if (to == from) {
TRACE((" xx %d\n", from.ToInt())); TRACE(" xx %d\n", from.ToInt());
result[from.ToInt()] = from; result[from.ToInt()] = from;
} else if (to_to == unvisited()) { } else if (to_to == unvisited()) {
TRACE((" fw %d -> %d (recurse)\n", from.ToInt(), to.ToInt())); TRACE(" fw %d -> %d (recurse)\n", from.ToInt(), to.ToInt());
stack.push(to); stack.push(to);
result[to.ToInt()] = onstack(); result[to.ToInt()] = onstack();
pop = false; // recurse. pop = false; // recurse.
} else if (to_to == onstack()) { } else if (to_to == onstack()) {
TRACE((" fw %d -> %d (cycle)\n", from.ToInt(), to.ToInt())); TRACE(" fw %d -> %d (cycle)\n", from.ToInt(), to.ToInt());
result[from.ToInt()] = to; // break the cycle. result[from.ToInt()] = to; // break the cycle.
forwarded = true; forwarded = true;
} else { } else {
TRACE((" fw %d -> %d (forward)\n", from.ToInt(), to.ToInt())); TRACE(" fw %d -> %d (forward)\n", from.ToInt(), to.ToInt());
result[from.ToInt()] = to_to; // forward the block. result[from.ToInt()] = to_to; // forward the block.
forwarded = true; forwarded = true;
} }
...@@ -68,36 +70,36 @@ bool JumpThreading::ComputeForwarding(Zone* local_zone, ...@@ -68,36 +70,36 @@ bool JumpThreading::ComputeForwarding(Zone* local_zone,
while (!state.stack.empty()) { while (!state.stack.empty()) {
InstructionBlock* block = code->InstructionBlockAt(state.stack.top()); InstructionBlock* block = code->InstructionBlockAt(state.stack.top());
// Process the instructions in a block up to a non-empty instruction. // Process the instructions in a block up to a non-empty instruction.
TRACE(("jt [%d] B%d\n", static_cast<int>(stack.size()), TRACE("jt [%d] B%d\n", static_cast<int>(stack.size()),
block->rpo_number().ToInt())); block->rpo_number().ToInt());
bool fallthru = true; bool fallthru = true;
RpoNumber fw = block->rpo_number(); RpoNumber fw = block->rpo_number();
for (int i = block->code_start(); i < block->code_end(); ++i) { for (int i = block->code_start(); i < block->code_end(); ++i) {
Instruction* instr = code->InstructionAt(i); Instruction* instr = code->InstructionAt(i);
if (instr->IsGapMoves() && GapInstruction::cast(instr)->IsRedundant()) { if (instr->IsGapMoves() && GapInstruction::cast(instr)->IsRedundant()) {
// skip redundant gap moves. // skip redundant gap moves.
TRACE((" nop gap\n")); TRACE(" nop gap\n");
continue; continue;
} else if (instr->IsSourcePosition()) { } else if (instr->IsSourcePosition()) {
// skip source positions. // skip source positions.
TRACE((" src pos\n")); TRACE(" src pos\n");
continue; continue;
} else if (FlagsModeField::decode(instr->opcode()) != kFlags_none) { } else if (FlagsModeField::decode(instr->opcode()) != kFlags_none) {
// can't skip instructions with flags continuations. // can't skip instructions with flags continuations.
TRACE((" flags\n")); TRACE(" flags\n");
fallthru = false; fallthru = false;
} else if (instr->IsNop()) { } else if (instr->IsNop()) {
// skip nops. // skip nops.
TRACE((" nop\n")); TRACE(" nop\n");
continue; continue;
} else if (instr->arch_opcode() == kArchJmp) { } else if (instr->arch_opcode() == kArchJmp) {
// try to forward the jump instruction. // try to forward the jump instruction.
TRACE((" jmp\n")); TRACE(" jmp\n");
fw = code->InputRpo(instr, 0); fw = code->InputRpo(instr, 0);
fallthru = false; fallthru = false;
} else { } else {
// can't skip other instructions. // can't skip other instructions.
TRACE((" other\n")); TRACE(" other\n");
fallthru = false; fallthru = false;
} }
break; break;
...@@ -118,12 +120,12 @@ bool JumpThreading::ComputeForwarding(Zone* local_zone, ...@@ -118,12 +120,12 @@ bool JumpThreading::ComputeForwarding(Zone* local_zone,
if (FLAG_trace_turbo_jt) { if (FLAG_trace_turbo_jt) {
for (int i = 0; i < static_cast<int>(result.size()); i++) { for (int i = 0; i < static_cast<int>(result.size()); i++) {
TRACE(("B%d ", i)); TRACE("B%d ", i);
int to = result[i].ToInt(); int to = result[i].ToInt();
if (i != to) { if (i != to) {
TRACE(("-> B%d\n", to)); TRACE("-> B%d\n", to);
} else { } else {
TRACE(("\n")); TRACE("\n");
} }
} }
} }
...@@ -153,7 +155,7 @@ void JumpThreading::ApplyForwarding(ZoneVector<RpoNumber>& result, ...@@ -153,7 +155,7 @@ void JumpThreading::ApplyForwarding(ZoneVector<RpoNumber>& result,
} else if (instr->arch_opcode() == kArchJmp) { } else if (instr->arch_opcode() == kArchJmp) {
if (skip[block_num]) { if (skip[block_num]) {
// Overwrite a redundant jump with a nop. // Overwrite a redundant jump with a nop.
TRACE(("jt-fw nop @%d\n", i)); TRACE("jt-fw nop @%d\n", i);
instr->OverwriteWithNop(); instr->OverwriteWithNop();
} }
fallthru = false; // jumps don't fall through to the next block. fallthru = false; // jumps don't fall through to the next block.
......
This diff is collapsed.
...@@ -25,8 +25,10 @@ namespace internal { ...@@ -25,8 +25,10 @@ namespace internal {
namespace compiler { namespace compiler {
// Macro for outputting trace information from representation inference. // Macro for outputting trace information from representation inference.
#define TRACE(x) \ #define TRACE(...) \
if (FLAG_trace_representation) PrintF x do { \
if (FLAG_trace_representation) PrintF(__VA_ARGS__); \
} while (false)
// Representation selection and lowering of {Simplified} operators to machine // Representation selection and lowering of {Simplified} operators to machine
// operators are interwined. We use a fixpoint calculation to compute both the // operators are interwined. We use a fixpoint calculation to compute both the
...@@ -85,7 +87,7 @@ class RepresentationSelector { ...@@ -85,7 +87,7 @@ class RepresentationSelector {
void Run(SimplifiedLowering* lowering) { void Run(SimplifiedLowering* lowering) {
// Run propagation phase to a fixpoint. // Run propagation phase to a fixpoint.
TRACE(("--{Propagation phase}--\n")); TRACE("--{Propagation phase}--\n");
phase_ = PROPAGATE; phase_ = PROPAGATE;
Enqueue(jsgraph_->graph()->end()); Enqueue(jsgraph_->graph()->end());
// Process nodes from the queue until it is empty. // Process nodes from the queue until it is empty.
...@@ -94,20 +96,20 @@ class RepresentationSelector { ...@@ -94,20 +96,20 @@ class RepresentationSelector {
NodeInfo* info = GetInfo(node); NodeInfo* info = GetInfo(node);
queue_.pop(); queue_.pop();
info->queued = false; info->queued = false;
TRACE((" visit #%d: %s\n", node->id(), node->op()->mnemonic())); TRACE(" visit #%d: %s\n", node->id(), node->op()->mnemonic());
VisitNode(node, info->use, NULL); VisitNode(node, info->use, NULL);
TRACE((" ==> output ")); TRACE(" ==> output ");
PrintInfo(info->output); PrintInfo(info->output);
TRACE(("\n")); TRACE("\n");
} }
// Run lowering and change insertion phase. // Run lowering and change insertion phase.
TRACE(("--{Simplified lowering phase}--\n")); TRACE("--{Simplified lowering phase}--\n");
phase_ = LOWER; phase_ = LOWER;
// Process nodes from the collected {nodes_} vector. // Process nodes from the collected {nodes_} vector.
for (NodeVector::iterator i = nodes_.begin(); i != nodes_.end(); ++i) { for (NodeVector::iterator i = nodes_.begin(); i != nodes_.end(); ++i) {
Node* node = *i; Node* node = *i;
TRACE((" visit #%d: %s\n", node->id(), node->op()->mnemonic())); TRACE(" visit #%d: %s\n", node->id(), node->op()->mnemonic());
// Reuse {VisitNode()} so the representation rules are in one place. // Reuse {VisitNode()} so the representation rules are in one place.
if (FLAG_turbo_source_positions) { if (FLAG_turbo_source_positions) {
SourcePositionTable::Scope scope( SourcePositionTable::Scope scope(
...@@ -143,21 +145,21 @@ class RepresentationSelector { ...@@ -143,21 +145,21 @@ class RepresentationSelector {
info->queued = true; info->queued = true;
nodes_.push_back(node); nodes_.push_back(node);
queue_.push(node); queue_.push(node);
TRACE((" initial: ")); TRACE(" initial: ");
info->use |= use; info->use |= use;
PrintUseInfo(node); PrintUseInfo(node);
return; return;
} }
TRACE((" queue?: ")); TRACE(" queue?: ");
PrintUseInfo(node); PrintUseInfo(node);
if ((info->use & use) != use) { if ((info->use & use) != use) {
// New usage information for the node is available. // New usage information for the node is available.
if (!info->queued) { if (!info->queued) {
queue_.push(node); queue_.push(node);
info->queued = true; info->queued = true;
TRACE((" added: ")); TRACE(" added: ");
} else { } else {
TRACE((" inqueue: ")); TRACE(" inqueue: ");
} }
info->use |= use; info->use |= use;
PrintUseInfo(node); PrintUseInfo(node);
...@@ -195,14 +197,14 @@ class RepresentationSelector { ...@@ -195,14 +197,14 @@ class RepresentationSelector {
MachineTypeUnion output = GetInfo(input)->output; MachineTypeUnion output = GetInfo(input)->output;
if ((output & (kRepBit | kRepWord8 | kRepWord16 | kRepWord32)) == 0) { if ((output & (kRepBit | kRepWord8 | kRepWord16 | kRepWord32)) == 0) {
// Output representation doesn't match usage. // Output representation doesn't match usage.
TRACE((" truncate-to-int32: #%d:%s(@%d #%d:%s) ", node->id(), TRACE(" truncate-to-int32: #%d:%s(@%d #%d:%s) ", node->id(),
node->op()->mnemonic(), index, input->id(), node->op()->mnemonic(), index, input->id(),
input->op()->mnemonic())); input->op()->mnemonic());
TRACE((" from ")); TRACE(" from ");
PrintInfo(output); PrintInfo(output);
TRACE((" to ")); TRACE(" to ");
PrintInfo(use); PrintInfo(use);
TRACE(("\n")); TRACE("\n");
Node* n = changer_->GetTruncatedWord32For(input, output); Node* n = changer_->GetTruncatedWord32For(input, output);
node->ReplaceInput(index, n); node->ReplaceInput(index, n);
} }
...@@ -220,14 +222,14 @@ class RepresentationSelector { ...@@ -220,14 +222,14 @@ class RepresentationSelector {
MachineTypeUnion output = GetInfo(input)->output; MachineTypeUnion output = GetInfo(input)->output;
if ((output & kRepMask & use) == 0) { if ((output & kRepMask & use) == 0) {
// Output representation doesn't match usage. // Output representation doesn't match usage.
TRACE((" change: #%d:%s(@%d #%d:%s) ", node->id(), TRACE(" change: #%d:%s(@%d #%d:%s) ", node->id(),
node->op()->mnemonic(), index, input->id(), node->op()->mnemonic(), index, input->id(),
input->op()->mnemonic())); input->op()->mnemonic());
TRACE((" from ")); TRACE(" from ");
PrintInfo(output); PrintInfo(output);
TRACE((" to ")); TRACE(" to ");
PrintInfo(use); PrintInfo(use);
TRACE(("\n")); TRACE("\n");
Node* n = changer_->GetRepresentationFor(input, output, use); Node* n = changer_->GetRepresentationFor(input, output, use);
node->ReplaceInput(index, n); node->ReplaceInput(index, n);
} }
...@@ -1049,11 +1051,10 @@ class RepresentationSelector { ...@@ -1049,11 +1051,10 @@ class RepresentationSelector {
} }
void DeferReplacement(Node* node, Node* replacement) { void DeferReplacement(Node* node, Node* replacement) {
if (FLAG_trace_representation) { TRACE("defer replacement #%d:%s with #%d:%s\n", node->id(),
TRACE(("defer replacement #%d:%s with #%d:%s\n", node->id(), node->op()->mnemonic(), replacement->id(),
node->op()->mnemonic(), replacement->id(), replacement->op()->mnemonic());
replacement->op()->mnemonic()));
}
if (replacement->id() < count_ && if (replacement->id() < count_ &&
GetInfo(replacement)->output == GetInfo(node)->output) { GetInfo(replacement)->output == GetInfo(node)->output) {
// Replace with a previously existing node eagerly only if the type is the // Replace with a previously existing node eagerly only if the type is the
...@@ -1071,9 +1072,9 @@ class RepresentationSelector { ...@@ -1071,9 +1072,9 @@ class RepresentationSelector {
} }
void PrintUseInfo(Node* node) { void PrintUseInfo(Node* node) {
TRACE(("#%d:%-20s ", node->id(), node->op()->mnemonic())); TRACE("#%d:%-20s ", node->id(), node->op()->mnemonic());
PrintInfo(GetUseInfo(node)); PrintInfo(GetUseInfo(node));
TRACE(("\n")); TRACE("\n");
} }
void PrintInfo(MachineTypeUnion info) { void PrintInfo(MachineTypeUnion info) {
......
...@@ -17,7 +17,7 @@ namespace compiler { ...@@ -17,7 +17,7 @@ namespace compiler {
do { \ do { \
Node* __n[] = {__VA_ARGS__}; \ Node* __n[] = {__VA_ARGS__}; \
ASSERT_TRUE(IsEquivalenceClass(arraysize(__n), __n)); \ ASSERT_TRUE(IsEquivalenceClass(arraysize(__n), __n)); \
} while (false); } while (false)
class ControlEquivalenceTest : public GraphTest { class ControlEquivalenceTest : public GraphTest {
public: public:
......
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