diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index eb4b4a5c44..5aa5dd0bf8 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -60,12 +60,10 @@ const char* Representation::Mnemonic() const { case kDouble: return "d"; case kInteger32: return "i"; case kExternal: return "x"; - case kNumRepresentations: + default: UNREACHABLE(); return NULL; } - UNREACHABLE(); - return NULL; } @@ -402,8 +400,39 @@ void HValue::SetBlock(HBasicBlock* block) { } -void HValue::PrintTypeTo(HType type, StringStream* stream) { - stream->Add(type.ToShortString()); +void HValue::PrintTypeTo(StringStream* stream) { + if (!representation().IsTagged() || type().Equals(HType::Tagged())) return; + stream->Add(" type[%s]", type().ToString()); +} + + +void HValue::PrintRangeTo(StringStream* stream) { + if (range() == NULL || range()->IsMostGeneric()) return; + stream->Add(" range[%d,%d,m0=%d]", + range()->lower(), + range()->upper(), + static_cast(range()->CanBeMinusZero())); +} + + +void HValue::PrintChangesTo(StringStream* stream) { + int changes_flags = (flags() & HValue::ChangesFlagsMask()); + if (changes_flags == 0) return; + stream->Add(" changes["); + if (changes_flags == AllSideEffects()) { + stream->Add("*"); + } else { + bool add_comma = false; +#define PRINT_DO(type) \ + if (changes_flags & (1 << kChanges##type)) { \ + if (add_comma) stream->Add(","); \ + add_comma = true; \ + stream->Add(#type); \ + } + GVN_FLAG_LIST(PRINT_DO); +#undef PRINT_DO + } + stream->Add("]"); } @@ -465,28 +494,18 @@ void HValue::ComputeInitialRange() { void HInstruction::PrintTo(StringStream* stream) { + PrintMnemonicTo(stream); + PrintDataTo(stream); + PrintRangeTo(stream); + PrintChangesTo(stream); + PrintTypeTo(stream); +} + + +void HInstruction::PrintMnemonicTo(StringStream* stream) { stream->Add("%s", Mnemonic()); if (HasSideEffects()) stream->Add("*"); stream->Add(" "); - PrintDataTo(stream); - - if (range() != NULL && - !range()->IsMostGeneric() && - !range()->CanBeMinusZero()) { - stream->Add(" range[%d,%d,m0=%d]", - range()->lower(), - range()->upper(), - static_cast(range()->CanBeMinusZero())); - } - - int changes_flags = (flags() & HValue::ChangesFlagsMask()); - if (changes_flags != 0) { - stream->Add(" changes[0x%x]", changes_flags); - } - - if (representation().IsTagged() && !type().Equals(HType::Tagged())) { - stream->Add(" type[%s]", type().ToString()); - } } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 73c46a4403..d921b1c86a 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -628,7 +628,9 @@ class HValue: public ZoneObject { // Printing support. virtual void PrintTo(StringStream* stream) = 0; void PrintNameTo(StringStream* stream); - static void PrintTypeTo(HType type, StringStream* stream); + void PrintTypeTo(StringStream* stream); + void PrintRangeTo(StringStream* stream); + void PrintChangesTo(StringStream* stream); const char* Mnemonic() const; @@ -741,6 +743,8 @@ class HInstruction: public HValue { SetBlock(block); } + void PrintMnemonicTo(StringStream* stream); + HInstruction* next_; HInstruction* previous_; int position_; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 70db9db69b..8460472be9 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -5889,10 +5889,11 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { Tag states_tag(this, "states"); Tag locals_tag(this, "locals"); int total = current->phis()->length(); - trace_.Add("size %d\n", total); - trace_.Add("method \"None\""); + PrintIntProperty("size", current->phis()->length()); + PrintStringProperty("method", "None"); for (int j = 0; j < total; ++j) { HPhi* phi = current->phis()->at(j); + PrintIndent(); trace_.Add("%d ", phi->merged_index()); phi->PrintNameTo(&trace_); trace_.Add(" "); @@ -5907,6 +5908,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { while (instruction != NULL) { int bci = 0; int uses = instruction->UseCount(); + PrintIndent(); trace_.Add("%d %d ", bci, uses); instruction->PrintNameTo(&trace_); trace_.Add(" "); @@ -5926,6 +5928,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { for (int i = first_index; i <= last_index; ++i) { LInstruction* linstr = instructions->at(i); if (linstr != NULL) { + PrintIndent(); trace_.Add("%d ", LifetimePosition::FromInstructionIndex(i).Value()); linstr->PrintTo(&trace_); @@ -5961,6 +5964,7 @@ void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) { void HTracer::TraceLiveRange(LiveRange* range, const char* type) { if (range != NULL && !range->IsEmpty()) { + PrintIndent(); trace_.Add("%d %s", range->id(), type); if (range->HasRegisterAssigned()) { LOperand* op = range->CreateAssignedOperand();