Bug 531687 - Duplicate node names in TMFLAGS=aftersf printout (TM-specific part). r=jseward.
--- a/js/src/jsregexp.cpp
+++ b/js/src/jsregexp.cpp
@@ -3093,17 +3093,17 @@ class RegExpNativeCompiler {
return !outOfMemory();
}
inline LIns*
addName(LirBuffer* lirbuf, LIns* ins, const char* name)
{
#ifdef NJ_VERBOSE
- debug_only_stmt(lirbuf->names->addName(ins, name);)
+ debug_only_stmt(lirbuf->printer->lirNameMap->addName(ins, name);)
#endif
return ins;
}
/*
* Insert the side exit and guard record for a compiled regexp. Most
* of the fields are not used. The important part is the regexp source
* and flags, which we use as the fragment lookup key.
@@ -3140,18 +3140,17 @@ class RegExpNativeCompiler {
public:
RegExpNativeCompiler(JSContext* cx, JSRegExp* re, CompilerState* cs, Fragment* fragment)
: tempAlloc(*JS_TRACE_MONITOR(cx).reTempAlloc), cx(cx),
re(re), cs(cs), fragment(fragment), lir(NULL), lirBufWriter(NULL),
lirbuf(new (tempAlloc) LirBuffer(tempAlloc))
{
fragment->lirbuf = lirbuf;
#ifdef DEBUG
- LabelMap* labels = new (tempAlloc) LabelMap(tempAlloc, &LogController);
- lirbuf->names = new (tempAlloc) LirNameMap(tempAlloc, labels);
+ lirbuf->printer = new (tempAlloc) LInsPrinter(tempAlloc);
#endif
}
~RegExpNativeCompiler() {
/* Purge the tempAlloc used during recording. */
tempAlloc.reset();
}
@@ -3183,17 +3182,17 @@ class RegExpNativeCompiler {
goto fail;
/* FIXME Use bug 463260 smart pointer when available. */
lir = lirBufWriter = new LirBufWriter(lirbuf, nanojit::AvmCore::config);
/* FIXME Use bug 463260 smart pointer when available. */
#ifdef NJ_VERBOSE
debug_only_stmt(
if (LogController.lcbits & LC_TMRegexp) {
- lir = verbose_filter = new VerboseWriter(tempAlloc, lir, lirbuf->names,
+ lir = verbose_filter = new VerboseWriter(tempAlloc, lir, lirbuf->printer,
&LogController);
}
)
#endif
#ifdef DEBUG
lir = validate_writer = new ValidateWriter(lir, "regexp writer pipeline");
#endif
@@ -3243,18 +3242,17 @@ class RegExpNativeCompiler {
/*
* Deep in the nanojit compiler, the StackFilter is trying to throw
* away stores above the VM interpreter/native stacks. We have no such
* stacks, so rely on the fact that lirbuf->sp and lirbuf->rp are null
* to ensure our stores are ignored.
*/
JS_ASSERT(!lirbuf->sp && !lirbuf->rp);
- assm->compile(fragment, tempAlloc, /*optimize*/true
- verbose_only(, lirbuf->names->labels));
+ assm->compile(fragment, tempAlloc, /*optimize*/true verbose_only(, lirbuf->printer));
if (assm->error() != nanojit::None)
goto fail;
delete lirBufWriter;
#ifdef DEBUG
delete validate_writer;
#endif
#ifdef NJ_VERBOSE
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -135,50 +135,48 @@ int
StackFilter::getTop(LIns* guard)
{
VMSideExit* e = (VMSideExit*)guard->record()->exit;
return e->sp_adj;
}
#if defined NJ_VERBOSE
void
-LirNameMap::formatGuard(LIns *i, char *out)
-{
- VMSideExit *x;
-
- x = (VMSideExit *)i->record()->exit;
- sprintf(out,
+LInsPrinter::formatGuard(InsBuf *buf, LIns *ins)
+{
+ RefBuf b1, b2;
+ VMSideExit *x = (VMSideExit *)ins->record()->exit;
+ VMPI_snprintf(buf->buf, buf->len,
"%s: %s %s -> pc=%p imacpc=%p sp%+ld rp%+ld (GuardID=%03d)",
- formatRef(i),
- lirNames[i->opcode()],
- i->oprnd1() ? formatRef(i->oprnd1()) : "",
+ formatRef(&b1, ins),
+ lirNames[ins->opcode()],
+ ins->oprnd1() ? formatRef(&b2, ins->oprnd1()) : "",
(void *)x->pc,
(void *)x->imacpc,
(long int)x->sp_adj,
(long int)x->rp_adj,
- i->record()->profGuardID);
+ ins->record()->profGuardID);
}
void
-LirNameMap::formatGuardXov(LIns *i, char *out)
-{
- VMSideExit *x;
-
- x = (VMSideExit *)i->record()->exit;
- sprintf(out,
+LInsPrinter::formatGuardXov(InsBuf *buf, LIns *ins)
+{
+ RefBuf b1, b2, b3;
+ VMSideExit *x = (VMSideExit *)ins->record()->exit;
+ VMPI_snprintf(buf->buf, buf->len,
"%s = %s %s, %s -> pc=%p imacpc=%p sp%+ld rp%+ld (GuardID=%03d)",
- formatRef(i),
- lirNames[i->opcode()],
- formatRef(i->oprnd1()),
- formatRef(i->oprnd2()),
+ formatRef(&b1, ins),
+ lirNames[ins->opcode()],
+ formatRef(&b2, ins->oprnd1()),
+ formatRef(&b3, ins->oprnd2()),
(void *)x->pc,
(void *)x->imacpc,
(long int)x->sp_adj,
(long int)x->rp_adj,
- i->record()->profGuardID);
+ ins->record()->profGuardID);
}
#endif
} /* namespace nanojit */
namespace js {
using namespace nanojit;
@@ -2170,18 +2168,17 @@ TraceRecorder::TraceRecorder(JSContext*
generatedSpecializedNative(),
tempTypeMap(cx)
{
JS_ASSERT(globalObj == JS_GetGlobalForObject(cx, cx->fp->scopeChain));
JS_ASSERT(cx->fp->regs->pc == (jsbytecode*)fragment->ip);
fragment->lirbuf = lirbuf;
#ifdef DEBUG
- LabelMap* labels = new (tempAlloc()) LabelMap(tempAlloc(), &LogController);
- lirbuf->names = new (tempAlloc()) LirNameMap(tempAlloc(), labels);
+ lirbuf->printer = new (tempAlloc()) LInsPrinter(tempAlloc());
#endif
/*
* Reset the fragment state we care about in case we got a recycled
* fragment. This includes resetting any profiling data we might have
* accumulated.
*/
fragment->lastIns = NULL;
@@ -2217,17 +2214,17 @@ TraceRecorder::TraceRecorder(JSContext*
nanojit::LirWriter*& lir = InitConst(this->lir);
lir = new (tempAlloc()) LirBufWriter(lirbuf, nanojit::AvmCore::config);
#ifdef DEBUG
lir = new (tempAlloc()) ValidateWriter(lir, "end of writer pipeline");
#endif
debug_only_stmt(
if (LogController.lcbits & LC_TMRecorder) {
- lir = new (tempAlloc()) VerboseWriter(tempAlloc(), lir, lirbuf->names,
+ lir = new (tempAlloc()) VerboseWriter(tempAlloc(), lir, lirbuf->printer,
&LogController);
}
)
// CseFilter must be downstream of SoftFloatFilter (see bug 527754 for why).
if (avmplus::AvmCore::config.cseopt)
lir = new (tempAlloc()) CseFilter(lir, tempAlloc());
#if NJ_SOFTFLOAT_SUPPORTED
if (nanojit::AvmCore::config.soft_float)
@@ -2412,17 +2409,17 @@ inline LIns*
TraceRecorder::addName(LIns* ins, const char* name)
{
#ifdef JS_JIT_SPEW
/*
* We'll only ask for verbose Nanojit when .lcbits > 0, so there's no point
* in adding names otherwise.
*/
if (LogController.lcbits > 0)
- lirbuf->names->addName(ins, name);
+ lirbuf->printer->lirNameMap->addName(ins, name);
#endif
return ins;
}
inline LIns*
TraceRecorder::insImmVal(jsval val)
{
if (JSVAL_IS_TRACEABLE(val))
@@ -4209,24 +4206,23 @@ TraceRecorder::compile()
/* :TODO: windows support */
#if defined DEBUG && !defined WIN32
/* Associate a filename and line number with the fragment. */
const char* filename = cx->fp->script->filename;
char* label = (char*)js_malloc((filename ? strlen(filename) : 7) + 16);
sprintf(label, "%s:%u", filename ? filename : "<stdin>",
js_FramePCToLineNumber(cx, cx->fp));
- lirbuf->names->labels->add(fragment, sizeof(Fragment), 0, label);
+ lirbuf->printer->addrNameMap->addAddrRange(fragment, sizeof(Fragment), 0, label);
js_free(label);
#endif
Assembler *assm = traceMonitor->assembler;
JS_ASSERT(assm->error() == nanojit::None);
- assm->compile(fragment, tempAlloc(), /*optimize*/true
- verbose_only(, lirbuf->names->labels));
+ assm->compile(fragment, tempAlloc(), /*optimize*/true verbose_only(, lirbuf->printer));
if (assm->error() != nanojit::None) {
assm->setError(nanojit::None);
debug_only_print0(LC_TMTracer, "Blacklisted: error during compilation\n");
Blacklist((jsbytecode*)tree->ip);
return ARECORD_STOP;
}