Improved c1visualizer output a bit: Emit a human-readable description for

changes instead of a bit-pattern. Fixed logic when ranges are emitted. Improved
indentation in hydrogen.cfg (aesthetical change only). Some minor additional
cleanup.
Review URL: http://codereview.chromium.org/6995024

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7849 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2011-05-11 09:19:28 +00:00
parent e90d16953c
commit 9f3f90ddc0
3 changed files with 54 additions and 27 deletions

View File

@ -60,12 +60,10 @@ const char* Representation::Mnemonic() const {
case kDouble: return "d"; case kDouble: return "d";
case kInteger32: return "i"; case kInteger32: return "i";
case kExternal: return "x"; case kExternal: return "x";
case kNumRepresentations: default:
UNREACHABLE(); UNREACHABLE();
return NULL; return NULL;
} }
UNREACHABLE();
return NULL;
} }
@ -402,8 +400,39 @@ void HValue::SetBlock(HBasicBlock* block) {
} }
void HValue::PrintTypeTo(HType type, StringStream* stream) { void HValue::PrintTypeTo(StringStream* stream) {
stream->Add(type.ToShortString()); 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<int>(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) { void HInstruction::PrintTo(StringStream* stream) {
PrintMnemonicTo(stream);
PrintDataTo(stream);
PrintRangeTo(stream);
PrintChangesTo(stream);
PrintTypeTo(stream);
}
void HInstruction::PrintMnemonicTo(StringStream* stream) {
stream->Add("%s", Mnemonic()); stream->Add("%s", Mnemonic());
if (HasSideEffects()) stream->Add("*"); if (HasSideEffects()) stream->Add("*");
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<int>(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());
}
} }

View File

@ -628,7 +628,9 @@ class HValue: public ZoneObject {
// Printing support. // Printing support.
virtual void PrintTo(StringStream* stream) = 0; virtual void PrintTo(StringStream* stream) = 0;
void PrintNameTo(StringStream* stream); 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; const char* Mnemonic() const;
@ -741,6 +743,8 @@ class HInstruction: public HValue {
SetBlock(block); SetBlock(block);
} }
void PrintMnemonicTo(StringStream* stream);
HInstruction* next_; HInstruction* next_;
HInstruction* previous_; HInstruction* previous_;
int position_; int position_;

View File

@ -5889,10 +5889,11 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) {
Tag states_tag(this, "states"); Tag states_tag(this, "states");
Tag locals_tag(this, "locals"); Tag locals_tag(this, "locals");
int total = current->phis()->length(); int total = current->phis()->length();
trace_.Add("size %d\n", total); PrintIntProperty("size", current->phis()->length());
trace_.Add("method \"None\""); PrintStringProperty("method", "None");
for (int j = 0; j < total; ++j) { for (int j = 0; j < total; ++j) {
HPhi* phi = current->phis()->at(j); HPhi* phi = current->phis()->at(j);
PrintIndent();
trace_.Add("%d ", phi->merged_index()); trace_.Add("%d ", phi->merged_index());
phi->PrintNameTo(&trace_); phi->PrintNameTo(&trace_);
trace_.Add(" "); trace_.Add(" ");
@ -5907,6 +5908,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) {
while (instruction != NULL) { while (instruction != NULL) {
int bci = 0; int bci = 0;
int uses = instruction->UseCount(); int uses = instruction->UseCount();
PrintIndent();
trace_.Add("%d %d ", bci, uses); trace_.Add("%d %d ", bci, uses);
instruction->PrintNameTo(&trace_); instruction->PrintNameTo(&trace_);
trace_.Add(" "); 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) { for (int i = first_index; i <= last_index; ++i) {
LInstruction* linstr = instructions->at(i); LInstruction* linstr = instructions->at(i);
if (linstr != NULL) { if (linstr != NULL) {
PrintIndent();
trace_.Add("%d ", trace_.Add("%d ",
LifetimePosition::FromInstructionIndex(i).Value()); LifetimePosition::FromInstructionIndex(i).Value());
linstr->PrintTo(&trace_); linstr->PrintTo(&trace_);
@ -5961,6 +5964,7 @@ void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) {
void HTracer::TraceLiveRange(LiveRange* range, const char* type) { void HTracer::TraceLiveRange(LiveRange* range, const char* type) {
if (range != NULL && !range->IsEmpty()) { if (range != NULL && !range->IsEmpty()) {
PrintIndent();
trace_.Add("%d %s", range->id(), type); trace_.Add("%d %s", range->id(), type);
if (range->HasRegisterAssigned()) { if (range->HasRegisterAssigned()) {
LOperand* op = range->CreateAssignedOperand(); LOperand* op = range->CreateAssignedOperand();