Bug 943449 - IonMonkey: Introduce a new idiom for dumping routines: dump(). r=nbp

This commit is contained in:
Dan Gohman 2013-11-26 11:22:58 -08:00
parent a4ec8efa54
commit d2dea693c7
15 changed files with 114 additions and 41 deletions

View File

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "jit/BacktrackingAllocator.h"
#include "jsprf.h"
#include "jit/BitSet.h"
using namespace js;
@ -76,33 +75,6 @@ BacktrackingAllocator::init()
return true;
}
static inline const char *
IntervalString(const LiveInterval *interval)
{
#ifdef DEBUG
if (!interval->numRanges())
return " empty";
// Not reentrant!
static char buf[1000];
char *cursor = buf;
char *end = cursor + sizeof(buf);
for (size_t i = 0; i < interval->numRanges(); i++) {
const LiveInterval::Range *range = interval->getRange(i);
int n = JS_snprintf(cursor, end - cursor, " [%u,%u>", range->from.pos(), range->to.pos());
if (n < 0)
return " ???";
cursor += n;
}
return buf;
#else
return " ???";
#endif
}
bool
BacktrackingAllocator::go()
{
@ -423,7 +395,7 @@ BacktrackingAllocator::processInterval(LiveInterval *interval)
if (IonSpewEnabled(IonSpew_RegAlloc)) {
IonSpew(IonSpew_RegAlloc, "Allocating v%u [priority %lu] [weight %lu]: %s",
interval->vreg(), computePriority(interval), computeSpillWeight(interval),
IntervalString(interval));
interval->rangesToString());
}
// An interval can be processed by doing any of the following:
@ -741,7 +713,7 @@ BacktrackingAllocator::evictInterval(LiveInterval *interval)
{
if (IonSpewEnabled(IonSpew_RegAlloc)) {
IonSpew(IonSpew_RegAlloc, "Evicting interval v%u: %s",
interval->vreg(), IntervalString(interval));
interval->vreg(), interval->rangesToString());
}
JS_ASSERT(interval->getAllocation()->isRegister());
@ -794,9 +766,9 @@ BacktrackingAllocator::split(LiveInterval *interval,
{
if (IonSpewEnabled(IonSpew_RegAlloc)) {
IonSpew(IonSpew_RegAlloc, "splitting interval v%u %s into:",
interval->vreg(), IntervalString(interval));
interval->vreg(), interval->rangesToString());
for (size_t i = 0; i < newIntervals.length(); i++)
IonSpew(IonSpew_RegAlloc, " %s", IntervalString(newIntervals[i]));
IonSpew(IonSpew_RegAlloc, " %s", newIntervals[i]->rangesToString());
}
JS_ASSERT(newIntervals.length() >= 2);
@ -1244,7 +1216,7 @@ BacktrackingAllocator::dumpLiveness()
for (size_t i = 0; i < AnyRegister::Total; i++)
if (registers[i].allocatable)
fprintf(stderr, "reg %s: %s\n", AnyRegister::FromCode(i).name(), IntervalString(fixedIntervals[i]));
fprintf(stderr, "reg %s: %s\n", AnyRegister::FromCode(i).name(), fixedIntervals[i]->rangesToString());
// Virtual register number 0 is unused.
JS_ASSERT(vregs[0u].numIntervals() == 0);
@ -1254,7 +1226,7 @@ BacktrackingAllocator::dumpLiveness()
for (size_t j = 0; j < vreg.numIntervals(); j++) {
if (j)
fprintf(stderr, " *");
fprintf(stderr, "%s", IntervalString(vreg.getInterval(j)));
fprintf(stderr, "%s", vreg.getInterval(j)->rangesToString());
}
fprintf(stderr, "\n");
}
@ -1272,10 +1244,10 @@ struct BacktrackingAllocator::PrintLiveIntervalRange
if (item.interval->hasVreg())
fprintf(stderr, " v%u: %s\n",
item.interval->vreg(),
IntervalString(item.interval));
item.interval->rangesToString());
else
fprintf(stderr, " fixed: %s\n",
IntervalString(item.interval));
item.interval->rangesToString());
}
}
};
@ -1296,7 +1268,7 @@ BacktrackingAllocator::dumpAllocations()
if (j)
fprintf(stderr, " *");
LiveInterval *interval = vreg.getInterval(j);
fprintf(stderr, "%s :: %s", IntervalString(interval), interval->getAllocation()->toString());
fprintf(stderr, "%s :: %s", interval->rangesToString(), interval->getAllocation()->toString());
}
fprintf(stderr, "\n");
}

View File

@ -106,7 +106,7 @@ DumpLIR(FILE *fp, LInstruction *ins)
{
fprintf(fp, " ");
fprintf(fp, "%d ", ins->id());
ins->print(fp);
ins->dump(fp);
fprintf(fp, " <|@\n");
}

View File

@ -1921,6 +1921,12 @@ LinearSum::dump(FILE *fp) const
fprintf(fp, "%s\n", sp.string());
}
void
LinearSum::dump() const
{
dump(stderr);
}
static bool
AnalyzePoppedThis(JSContext *cx, types::TypeObject *type,
MDefinition *thisValue, MInstruction *ins, bool definitelyExecuted,

View File

@ -121,6 +121,7 @@ class LinearSum
void print(Sprinter &sp) const;
void dump(FILE *) const;
void dump() const;
private:
Vector<LinearTerm, 2, IonAllocPolicy> terms_;

View File

@ -344,7 +344,7 @@ JSONSpewer::spewLIns(LInstruction *ins)
property("opcode");
fprintf(fp_, "\"");
ins->print(fp_);
ins->dump(fp_);
fprintf(fp_, "\"");
beginListProperty("defs");

View File

@ -287,6 +287,12 @@ LAllocation::toString() const
}
#endif // DEBUG
void
LAllocation::dump() const
{
fprintf(stderr, "%s\n", toString());
}
void
LInstruction::printOperands(FILE *fp)
{
@ -315,7 +321,7 @@ LInstruction::assignSnapshot(LSnapshot *snapshot)
}
void
LInstruction::print(FILE *fp)
LInstruction::dump(FILE *fp)
{
fprintf(fp, "{");
for (size_t i = 0; i < numDefs(); i++) {
@ -341,6 +347,12 @@ LInstruction::print(FILE *fp)
}
}
void
LInstruction::dump()
{
return dump(stderr);
}
void
LInstruction::initSafepoint(TempAllocator &alloc)
{

View File

@ -203,6 +203,8 @@ class LAllocation : public TempObject
#else
const char *toString() const { return "???"; }
#endif
void dump() const;
};
class LUse : public LAllocation
@ -675,7 +677,8 @@ class LInstruction
return false;
}
virtual void print(FILE *fp);
virtual void dump(FILE *fp);
void dump();
static void printName(FILE *fp, Opcode op);
virtual void printName(FILE *fp);
virtual void printOperands(FILE *fp);

View File

@ -9,6 +9,7 @@
#include "jit/BacktrackingAllocator.h"
#include "jit/BitSet.h"
#include "jit/LinearScan.h"
#include "jsprf.h"
using namespace js;
using namespace js::jit;
@ -859,3 +860,37 @@ LiveInterval::validateRanges()
}
#endif // DEBUG
const char *
LiveInterval::rangesToString() const
{
#ifdef DEBUG
if (!numRanges())
return " empty";
// Not reentrant!
static char buf[1000];
char *cursor = buf;
char *end = cursor + sizeof(buf);
for (size_t i = 0; i < numRanges(); i++) {
const LiveInterval::Range *range = getRange(i);
int n = JS_snprintf(cursor, end - cursor, " [%u,%u>", range->from.pos(), range->to.pos());
if (n < 0)
return " ???";
cursor += n;
}
return buf;
#else
return " ???";
#endif
}
void
LiveInterval::dump()
{
fprintf(stderr, "v%u: index=%u allocation=%s %s\n",
vreg(), index(), getAllocation()->toString(), rangesToString());
}

View File

@ -380,6 +380,12 @@ class LiveInterval
#ifdef DEBUG
void validateRanges();
#endif
// Return a string describing the ranges in this LiveInterval. This is
// not re-entrant!
const char *rangesToString() const;
void dump();
};
/*

View File

@ -281,6 +281,12 @@ MDefinition::dump(FILE *fp) const
fprintf(fp, "\n");
}
void
MDefinition::dump() const
{
dump(stderr);
}
size_t
MDefinition::useCount() const
{

View File

@ -337,6 +337,7 @@ class MDefinition : public MNode
static void PrintOpcodeName(FILE *fp, Opcode op);
virtual void printOpcode(FILE *fp) const;
void dump(FILE *fp) const;
void dump() const;
// For LICM.
virtual bool neverHoist() const { return false; }

View File

@ -1202,6 +1202,12 @@ MIRGraph::dump(FILE *fp)
#endif
}
void
MIRGraph::dump()
{
dump(stderr);
}
void
MBasicBlock::dump(FILE *fp)
{
@ -1214,3 +1220,9 @@ MBasicBlock::dump(FILE *fp)
}
#endif
}
void
MBasicBlock::dump()
{
dump(stderr);
}

View File

@ -474,6 +474,7 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
void dumpStack(FILE *fp);
void dump(FILE *fp);
void dump();
// Track bailouts by storing the current pc in MIR instruction added at this
// cycle. This is also used for tracking calls when profiling.
@ -683,6 +684,7 @@ class MIRGraph
MDefinition *forkJoinSlice();
void dump(FILE *fp);
void dump();
};
class MDefinitionIterator

View File

@ -291,6 +291,15 @@ SymbolicBound::print(Sprinter &sp) const
sum.print(sp);
}
void
SymbolicBound::dump() const
{
Sprinter sp(GetIonContext()->cx);
sp.init();
print(sp);
fprintf(stderr, "%s\n", sp.string());
}
// Test whether the given range's exponent tells us anything that its lower
// and upper bound values don't.
static bool
@ -365,6 +374,12 @@ Range::dump(FILE *fp) const
fprintf(fp, "%s\n", sp.string());
}
void
Range::dump() const
{
dump(stderr);
}
Range *
Range::intersect(const Range *lhs, const Range *rhs, bool *emptyRange)
{

View File

@ -63,6 +63,7 @@ struct SymbolicBound : public TempObject
}
void print(Sprinter &sp) const;
void dump() const;
};
class RangeAnalysis
@ -372,6 +373,7 @@ class Range : public TempObject {
void print(Sprinter &sp) const;
void dump(FILE *fp) const;
void dump() const;
bool update(const Range *other);
// Unlike the other operations, unionWith is an in-place