Bug 895019: Cleanup and make the tracelogger work again, r=jandem

This commit is contained in:
Hannes Verschore 2013-07-19 09:31:12 -07:00
parent 0e691457b2
commit 4b678ca3d6
12 changed files with 150 additions and 48 deletions

View File

@ -24,7 +24,7 @@ using namespace js;
#if defined(__i386__)
static __inline__ uint64_t
js::rdtsc(void)
rdtsc(void)
{
uint64_t x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
@ -32,7 +32,7 @@ js::rdtsc(void)
}
#elif defined(__x86_64__)
static __inline__ uint64_t
js::rdtsc(void)
rdtsc(void)
{
unsigned hi, lo;
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
@ -40,7 +40,7 @@ js::rdtsc(void)
}
#elif defined(__powerpc__)
static __inline__ uint64_t
js::rdtsc(void)
rdtsc(void)
{
uint64_t result=0;
uint32_t upper, lower,tmp;
@ -62,26 +62,17 @@ js::rdtsc(void)
#endif
const char* const TraceLogging::type_name[] = {
"start,script",
"stop,script",
"start,ion_compile",
"stop,ion_compile",
"start,ion_cannon",
"stop,ion_cannon",
"stop,ion_cannon_bailout",
"start,ion_side_cannon",
"stop,ion_side_cannon",
"stop,ion_side_cannon_bailout",
"start,yarr_jit_execute",
"stop,yarr_jit_execute",
"start,jm_safepoint",
"stop,jm_safepoint",
"start,jm_normal",
"stop,jm_normal",
"start,jm_compile",
"stop,jm_compile",
"start,gc",
"stop,gc",
"start,interpreter",
"stop,interpreter"
"info,engine,interpreter",
"info,engine,baseline",
"info,engine,ionmonkey"
};
TraceLogging* TraceLogging::_defaultLogger = NULL;
@ -157,7 +148,7 @@ TraceLogging::log(Type type, const char* file, unsigned int lineno)
void
TraceLogging::log(Type type, JSScript* script)
{
this->log(type, script->filename, script->lineno);
this->log(type, script->filename(), script->lineno);
}
void

View File

@ -15,26 +15,17 @@ class TraceLogging
{
public:
enum Type {
SCRIPT_START,
SCRIPT_STOP,
ION_COMPILE_START,
ION_COMPILE_STOP,
ION_CANNON_START,
ION_CANNON_STOP,
ION_CANNON_BAIL,
ION_SIDE_CANNON_START,
ION_SIDE_CANNON_STOP,
ION_SIDE_CANNON_BAIL,
YARR_JIT_START,
YARR_JIT_STOP,
JM_SAFEPOINT_START,
JM_SAFEPOINT_STOP,
JM_START,
JM_STOP,
JM_COMPILE_START,
JM_COMPILE_STOP,
GC_START,
GC_STOP,
INTERPRETER_START,
INTERPRETER_STOP,
INFO_ENGINE_INTERPRETER,
INFO_ENGINE_BASELINE,
INFO_ENGINE_IONMONKEY,
INFO
};

View File

@ -1032,6 +1032,10 @@ ion::BailoutIonToBaseline(JSContext *cx, JitActivation *activation, IonBailoutIt
JS_ASSERT(bailoutInfo != NULL);
JS_ASSERT(*bailoutInfo == NULL);
#if JS_TRACE_LOGGING
TraceLogging::defaultLogger()->log(TraceLogging::INFO_ENGINE_BASELINE);
#endif
// The caller of the top frame must be one of the following:
// OptimizedJS - Ion calling into Ion.
// BaselineStub - Baseline calling into Ion.
@ -1107,6 +1111,12 @@ ion::BailoutIonToBaseline(JSContext *cx, JitActivation *activation, IonBailoutIt
RootedScript scr(cx, iter.script());
AutoValueVector startFrameFormals(cx);
while (true) {
#if JS_TRACE_LOGGING
if (frameNo > 0) {
TraceLogging::defaultLogger()->log(TraceLogging::SCRIPT_START, scr);
TraceLogging::defaultLogger()->log(TraceLogging::INFO_ENGINE_BASELINE);
}
#endif
IonSpew(IonSpew_BaselineBailouts, " FrameNo %d", frameNo);
jsbytecode *callPC = NULL;
RootedFunction nextCallee(cx, NULL);

View File

@ -84,6 +84,7 @@ BaselineCompiler::compile()
if (status != Method_Compiled)
return status;
if (!emitEpilogue())
return Method_Error;
@ -224,6 +225,11 @@ BaselineCompiler::emitPrologue()
masm.pushValue(R0);
}
#if JS_TRACE_LOGGING
masm.tracelogStart(script.get());
masm.tracelogLog(TraceLogging::INFO_ENGINE_BASELINE);
#endif
// Record the offset of the prologue, because Ion can bailout before
// the scope chain is initialized.
prologueOffset_ = masm.currentOffset();
@ -256,6 +262,10 @@ BaselineCompiler::emitEpilogue()
{
masm.bind(&return_);
#if JS_TRACE_LOGGING
masm.tracelogStop();
#endif
// Pop SPS frame if necessary
emitSPSPop();

View File

@ -185,6 +185,10 @@ ion::EnterBaselineAtBranch(JSContext *cx, StackFrame *fp, jsbytecode *pc)
data.calleeToken = CalleeToToken(fp->script());
}
#if JS_TRACE_LOGGING
TraceLogging::defaultLogger()->log(TraceLogging::INFO_ENGINE_BASELINE);
#endif
IonExecStatus status = EnterBaseline(cx, data);
if (status != IonExec_Ok)
return status;

View File

@ -897,6 +897,10 @@ CodeGenerator::visitOsrEntry(LOsrEntry *lir)
masm.flushBuffer();
setOsrEntryOffset(masm.size());
#if JS_TRACE_LOGGING
masm.tracelogLog(TraceLogging::INFO_ENGINE_IONMONKEY);
#endif
// Allocate the full frame for this function.
uint32_t size = frameSize();
if (size != 0)
@ -5421,6 +5425,11 @@ CodeGenerator::generate()
if (!safepoints_.init(graph.totalSlotCount()))
return false;
#if JS_TRACE_LOGGING
masm.tracelogStart(gen->info().script());
masm.tracelogLog(TraceLogging::INFO_ENGINE_IONMONKEY);
#endif
// Before generating any code, we generate type checks for all parameters.
// This comes before deoptTable_, because we can't use deopt tables without
// creating the actual frame.
@ -5433,10 +5442,21 @@ CodeGenerator::generate()
return false;
}
#if JS_TRACE_LOGGING
Label skip;
masm.jump(&skip);
#endif
// Remember the entry offset to skip the argument check.
masm.flushBuffer();
setSkipArgCheckEntryOffset(masm.size());
#if JS_TRACE_LOGGING
masm.tracelogStart(gen->info().script());
masm.tracelogLog(TraceLogging::INFO_ENGINE_IONMONKEY);
masm.bind(&skip);
#endif
if (!generatePrologue())
return false;
if (!generateBody())

View File

@ -1927,20 +1927,8 @@ ion::Cannon(JSContext *cx, RunState &state)
if (!SetEnterJitData(cx, data, state, vals))
return IonExec_Error;
#if JS_TRACE_LOGGING
TraceLog(TraceLogging::defaultLogger(),
TraceLogging::ION_CANNON_START,
script);
#endif
IonExecStatus status = EnterIon(cx, data);
#if JS_TRACE_LOGGING
TraceLog(TraceLogging::defaultLogger(),
TraceLogging::ION_CANNON_STOP,
script);
#endif
if (status == IonExec_Ok)
state.setReturnValue(data.result);

View File

@ -1233,6 +1233,74 @@ MacroAssembler::printf(const char *output, Register value)
PopRegsInMask(RegisterSet::Volatile());
}
#if JS_TRACE_LOGGING
void
MacroAssembler::tracelogStart(JSScript *script)
{
void (&TraceLogStart)(TraceLogging*, TraceLogging::Type, JSScript*) = TraceLog;
RegisterSet regs = RegisterSet::Volatile();
PushRegsInMask(regs);
Register temp = regs.takeGeneral();
Register logger = regs.takeGeneral();
Register type = regs.takeGeneral();
Register rscript = regs.takeGeneral();
setupUnalignedABICall(3, temp);
movePtr(ImmWord((void *)TraceLogging::defaultLogger()), logger);
passABIArg(logger);
move32(Imm32(TraceLogging::SCRIPT_START), type);
passABIArg(type);
movePtr(ImmGCPtr(script), rscript);
passABIArg(rscript);
callWithABI(JS_FUNC_TO_DATA_PTR(void *, TraceLogStart));
PopRegsInMask(RegisterSet::Volatile());
}
void
MacroAssembler::tracelogStop()
{
void (&TraceLogStop)(TraceLogging*, TraceLogging::Type) = TraceLog;
RegisterSet regs = RegisterSet::Volatile();
PushRegsInMask(regs);
Register temp = regs.takeGeneral();
Register logger = regs.takeGeneral();
Register type = regs.takeGeneral();
setupUnalignedABICall(2, temp);
movePtr(ImmWord((void *)TraceLogging::defaultLogger()), logger);
passABIArg(logger);
move32(Imm32(TraceLogging::SCRIPT_STOP), type);
passABIArg(type);
callWithABI(JS_FUNC_TO_DATA_PTR(void *, TraceLogStop));
PopRegsInMask(RegisterSet::Volatile());
}
void
MacroAssembler::tracelogLog(TraceLogging::Type type)
{
void (&TraceLogStop)(TraceLogging*, TraceLogging::Type) = TraceLog;
RegisterSet regs = RegisterSet::Volatile();
PushRegsInMask(regs);
Register temp = regs.takeGeneral();
Register logger = regs.takeGeneral();
Register rtype = regs.takeGeneral();
setupUnalignedABICall(2, temp);
movePtr(ImmWord((void *)TraceLogging::defaultLogger()), logger);
passABIArg(logger);
move32(Imm32(type), rtype);
passABIArg(rtype);
callWithABI(JS_FUNC_TO_DATA_PTR(void *, TraceLogStop));
PopRegsInMask(RegisterSet::Volatile());
}
#endif
void
MacroAssembler::convertInt32ValueToDouble(const Address &address, Register scratch, Label *done)
{

View File

@ -944,6 +944,12 @@ class MacroAssembler : public MacroAssemblerSpecific
void printf(const char *output);
void printf(const char *output, Register value);
#if JS_TRACE_LOGGING
void tracelogStart(JSScript *script);
void tracelogStop();
void tracelogLog(TraceLogging::Type type);
#endif
void convertInt32ValueToDouble(const Address &address, Register scratch, Label *done);
void convertValueToDouble(ValueOperand value, FloatRegister output, Label *fail);
void convertValueToInt32(ValueOperand value, FloatRegister temp, Register output, Label *fail);

View File

@ -55,6 +55,9 @@ bool
CodeGeneratorARM::generateEpilogue()
{
masm.bind(&returnLabel_);
#if JS_TRACE_LOGGING
masm.tracelogStop();
#endif
if (gen->compilingAsmJS()) {
// Pop the stack we allocated at the start of the function.
masm.freeStack(frameDepth_);

View File

@ -49,6 +49,10 @@ CodeGeneratorX86Shared::generateEpilogue()
{
masm.bind(&returnLabel_);
#if JS_TRACE_LOGGING
masm.tracelogStop();
#endif
// Pop the stack we allocated at the start of the function.
masm.freeStack(frameSize());
JS_ASSERT(masm.framePushed() == 0);

View File

@ -1373,10 +1373,8 @@ Interpret(JSContext *cx, RunState &state)
SET_SCRIPT(regs.fp()->script());
#if JS_TRACE_LOGGING
AutoTraceLog logger(TraceLogging::defaultLogger(),
TraceLogging::INTERPRETER_START,
TraceLogging::INTERPRETER_STOP,
script);
TraceLogging::defaultLogger()->log(TraceLogging::SCRIPT_START, script);
TraceLogging::defaultLogger()->log(TraceLogging::INFO_ENGINE_INTERPRETER);
#endif
/*
@ -1689,6 +1687,10 @@ BEGIN_CASE(JSOP_STOP)
*/
CHECK_BRANCH();
#if JS_TRACE_LOGGING
TraceLogging::defaultLogger()->log(TraceLogging::SCRIPT_STOP);
#endif
interpReturnOK = true;
if (entryFrame != regs.fp())
inline_return:
@ -2551,6 +2553,11 @@ BEGIN_CASE(JSOP_FUNCALL)
SET_SCRIPT(regs.fp()->script());
#if JS_TRACE_LOGGING
TraceLogging::defaultLogger()->log(TraceLogging::SCRIPT_START, script);
TraceLogging::defaultLogger()->log(TraceLogging::INFO_ENGINE_INTERPRETER);
#endif
if (!regs.fp()->prologue(cx))
goto error;
if (cx->compartment()->debugMode()) {