From 4b678ca3d6753a0a99bf97ed3ce1777e958dfa30 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Fri, 19 Jul 2013 09:31:12 -0700 Subject: [PATCH] Bug 895019: Cleanup and make the tracelogger work again, r=jandem --- js/src/TraceLogging.cpp | 27 +++----- js/src/TraceLogging.h | 19 ++---- js/src/ion/BaselineBailouts.cpp | 10 +++ js/src/ion/BaselineCompiler.cpp | 10 +++ js/src/ion/BaselineJIT.cpp | 4 ++ js/src/ion/CodeGenerator.cpp | 20 ++++++ js/src/ion/Ion.cpp | 12 ---- js/src/ion/IonMacroAssembler.cpp | 68 +++++++++++++++++++ js/src/ion/IonMacroAssembler.h | 6 ++ js/src/ion/arm/CodeGenerator-arm.cpp | 3 + .../ion/shared/CodeGenerator-x86-shared.cpp | 4 ++ js/src/vm/Interpreter.cpp | 15 ++-- 12 files changed, 150 insertions(+), 48 deletions(-) diff --git a/js/src/TraceLogging.cpp b/js/src/TraceLogging.cpp index 7d6f8b09dd1..5c0e3a68eee 100644 --- a/js/src/TraceLogging.cpp +++ b/js/src/TraceLogging.cpp @@ -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 diff --git a/js/src/TraceLogging.h b/js/src/TraceLogging.h index 99c6685a140..63052777a0d 100644 --- a/js/src/TraceLogging.h +++ b/js/src/TraceLogging.h @@ -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 }; diff --git a/js/src/ion/BaselineBailouts.cpp b/js/src/ion/BaselineBailouts.cpp index 7c9ac00b575..c65b38b9a3a 100644 --- a/js/src/ion/BaselineBailouts.cpp +++ b/js/src/ion/BaselineBailouts.cpp @@ -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); diff --git a/js/src/ion/BaselineCompiler.cpp b/js/src/ion/BaselineCompiler.cpp index e821d7641fb..bc883c79191 100644 --- a/js/src/ion/BaselineCompiler.cpp +++ b/js/src/ion/BaselineCompiler.cpp @@ -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(); diff --git a/js/src/ion/BaselineJIT.cpp b/js/src/ion/BaselineJIT.cpp index d17d41583fa..42468ca98c2 100644 --- a/js/src/ion/BaselineJIT.cpp +++ b/js/src/ion/BaselineJIT.cpp @@ -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; diff --git a/js/src/ion/CodeGenerator.cpp b/js/src/ion/CodeGenerator.cpp index 1b6b5a9ef55..6fd0ead9f76 100644 --- a/js/src/ion/CodeGenerator.cpp +++ b/js/src/ion/CodeGenerator.cpp @@ -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()) diff --git a/js/src/ion/Ion.cpp b/js/src/ion/Ion.cpp index d93afcaba1e..35f3cb849fa 100644 --- a/js/src/ion/Ion.cpp +++ b/js/src/ion/Ion.cpp @@ -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); diff --git a/js/src/ion/IonMacroAssembler.cpp b/js/src/ion/IonMacroAssembler.cpp index f8ce5309b69..050a4236332 100644 --- a/js/src/ion/IonMacroAssembler.cpp +++ b/js/src/ion/IonMacroAssembler.cpp @@ -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) { diff --git a/js/src/ion/IonMacroAssembler.h b/js/src/ion/IonMacroAssembler.h index cf6fca613f1..69024507d84 100644 --- a/js/src/ion/IonMacroAssembler.h +++ b/js/src/ion/IonMacroAssembler.h @@ -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); diff --git a/js/src/ion/arm/CodeGenerator-arm.cpp b/js/src/ion/arm/CodeGenerator-arm.cpp index bacf2e23ff7..f299bc2ee1e 100644 --- a/js/src/ion/arm/CodeGenerator-arm.cpp +++ b/js/src/ion/arm/CodeGenerator-arm.cpp @@ -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_); diff --git a/js/src/ion/shared/CodeGenerator-x86-shared.cpp b/js/src/ion/shared/CodeGenerator-x86-shared.cpp index d161d820e33..41fb2cbce2b 100644 --- a/js/src/ion/shared/CodeGenerator-x86-shared.cpp +++ b/js/src/ion/shared/CodeGenerator-x86-shared.cpp @@ -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); diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 0b83f5a0dad..30657738410 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -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()) {