Bug 996509 - TraceLogger: Make it possible to toggle TraceLogger_Script on and off, r=bbouvier
☠☠ backed out by d2f30e292c15 ☠ ☠
authorHannes Verschore <hv1989@gmail.com>
Thu, 20 Nov 2014 17:43:58 +0100
changeset 216662 2b29d8a0077494fd25559bdc209b2be3481ebaba
parent 216661 44c68f942d20027ef281bc14401e520d86dc9012
child 216663 5c168f5722527ba41882f316220a6206549ecb8e
push id27858
push userkwierso@gmail.com
push dateFri, 21 Nov 2014 01:35:46 +0000
treeherdermozilla-central@6309710dd71d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs996509
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 996509 - TraceLogger: Make it possible to toggle TraceLogger_Script on and off, r=bbouvier
js/src/jit/BaselineCompiler.cpp
js/src/jit/IonFrames.cpp
js/src/jit/IonMacroAssembler.cpp
js/src/jit/IonMacroAssembler.h
js/src/jit/VMFunctions.cpp
js/src/jit/shared/CodeGenerator-shared.cpp
js/src/vm/Interpreter.cpp
js/src/vm/TraceLogging.cpp
js/src/vm/TraceLogging.h
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -419,19 +419,17 @@ BaselineCompiler::emitEpilogue()
     masm.bind(&return_);
 
 #ifdef JS_TRACE_LOGGING
     TraceLogger *logger = TraceLoggerForMainThread(cx->runtime());
     Register loggerReg = RegisterSet::Volatile().takeGeneral();
     masm.Push(loggerReg);
     masm.movePtr(ImmPtr(logger), loggerReg);
     masm.tracelogStop(loggerReg, TraceLogger::Baseline);
-    // Stop the script. Using a stop without checking the textId, since we
-    // we didn't save the textId for the script.
-    masm.tracelogStop(loggerReg);
+    masm.tracelogStop(loggerReg, TraceLogger::Scripts);
     masm.Pop(loggerReg);
 #endif
 
     // Pop SPS frame if necessary
     emitSPSPop();
 
     masm.mov(BaselineFrameReg, BaselineStackReg);
     masm.pop(BaselineFrameReg);
--- a/js/src/jit/IonFrames.cpp
+++ b/js/src/jit/IonFrames.cpp
@@ -752,17 +752,17 @@ HandleException(ResumeFromException *rfe
                 // When profiling, each frame popped needs a notification that
                 // the function has exited, so invoke the probe that a function
                 // is exiting.
 
                 JSScript *script = frames.script();
                 probes::ExitScript(cx, script, script->functionNonDelazifying(), popSPSFrame);
                 if (!frames.more()) {
                     TraceLogStopEvent(logger, TraceLogger::IonMonkey);
-                    TraceLogStopEvent(logger);
+                    TraceLogStopEvent(logger, TraceLogger::Scripts);
                     break;
                 }
                 ++frames;
             }
 
             if (invalidated)
                 ionScript->decrementInvalidationCount(cx->runtime()->defaultFreeOp());
 
@@ -783,17 +783,17 @@ HandleException(ResumeFromException *rfe
             // We cannot delete it immediately because of the call to
             // iter.baselineScriptAndPc below.
             AutoDeleteDebugModeOSRInfo deleteDebugModeOSRInfo(iter.baselineFrame());
 
             if (rfe->kind != ResumeFromException::RESUME_ENTRY_FRAME)
                 return;
 
             TraceLogStopEvent(logger, TraceLogger::Baseline);
-            TraceLogStopEvent(logger);
+            TraceLogStopEvent(logger, TraceLogger::Scripts);
 
             // Unwind profiler pseudo-stack
             JSScript *script = iter.script();
             probes::ExitScript(cx, script, script->functionNonDelazifying(),
                                iter.baselineFrame()->hasPushedSPSFrame());
             // After this point, any pushed SPS frame would have been popped if it needed
             // to be.  Unset the flag here so that if we call DebugEpilogue below,
             // it doesn't try to pop the SPS frame again.
--- a/js/src/jit/IonMacroAssembler.cpp
+++ b/js/src/jit/IonMacroAssembler.cpp
@@ -1665,16 +1665,19 @@ MacroAssembler::printf(const char *outpu
 
     PopRegsInMask(RegisterSet::Volatile());
 }
 
 #ifdef JS_TRACE_LOGGING
 void
 MacroAssembler::tracelogStart(Register logger, uint32_t textId)
 {
+    if (!TraceLogTextIdEnabled(textId))
+        return;
+
     void (&TraceLogFunc)(TraceLogger*, uint32_t) = TraceLogStartEvent;
 
     PushRegsInMask(RegisterSet::Volatile());
 
     RegisterSet regs = RegisterSet::Volatile();
     regs.takeUnchecked(logger);
 
     Register temp = regs.takeGeneral();
@@ -1701,88 +1704,78 @@ MacroAssembler::tracelogStart(Register l
 
     Register temp = regs.takeGeneral();
 
     setupUnalignedABICall(2, temp);
     passABIArg(logger);
     passABIArg(textId);
     callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogFunc));
 
-    regs.add(temp);
-
     PopRegsInMask(RegisterSet::Volatile());
 }
 
 void
 MacroAssembler::tracelogStop(Register logger, uint32_t textId)
 {
-    void (&TraceLogFunc)(TraceLogger*, uint32_t) = TraceLogStopEvent;
+    if (!TraceLogTextIdEnabled(textId))
+        return;
 
     PushRegsInMask(RegisterSet::Volatile());
 
     RegisterSet regs = RegisterSet::Volatile();
     regs.takeUnchecked(logger);
 
     Register temp = regs.takeGeneral();
 
+#ifdef DEBUG
+    void (&TraceLogFunc)(TraceLogger*, uint32_t) = TraceLogStopEvent;
+
     setupUnalignedABICall(2, temp);
     passABIArg(logger);
     move32(Imm32(textId), temp);
     passABIArg(temp);
-    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogFunc));
+#else
+    void (&TraceLogFunc)(TraceLogger*) = TraceLogStopEvent;
 
-    regs.add(temp);
+    setupUnalignedABICall(1, temp);
+    passABIArg(logger);
+#endif
+
+    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogFunc));
 
     PopRegsInMask(RegisterSet::Volatile());
 }
 
 void
 MacroAssembler::tracelogStop(Register logger, Register textId)
 {
+    PushRegsInMask(RegisterSet::Volatile());
+    RegisterSet regs = RegisterSet::Volatile();
+    regs.takeUnchecked(logger);
+
 #ifdef DEBUG
     void (&TraceLogFunc)(TraceLogger*, uint32_t) = TraceLogStopEvent;
 
-    PushRegsInMask(RegisterSet::Volatile());
-
-    RegisterSet regs = RegisterSet::Volatile();
-    regs.takeUnchecked(logger);
     regs.takeUnchecked(textId);
 
     Register temp = regs.takeGeneral();
 
     setupUnalignedABICall(2, temp);
     passABIArg(logger);
     passABIArg(textId);
-    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogFunc));
-
-    regs.add(temp);
-
-    PopRegsInMask(RegisterSet::Volatile());
 #else
-    tracelogStop(logger);
-#endif
-}
-
-void
-MacroAssembler::tracelogStop(Register logger)
-{
     void (&TraceLogFunc)(TraceLogger*) = TraceLogStopEvent;
 
-    PushRegsInMask(RegisterSet::Volatile());
-
-    RegisterSet regs = RegisterSet::Volatile();
-    regs.takeUnchecked(logger);
-
     Register temp = regs.takeGeneral();
 
     setupUnalignedABICall(1, temp);
     passABIArg(logger);
-    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogFunc));
+#endif
 
-    regs.add(temp);
+    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogFunc));
 
     PopRegsInMask(RegisterSet::Volatile());
 }
 #endif
 
 void
 MacroAssembler::convertInt32ValueToDouble(const Address &address, Register scratch, Label *done)
 {
--- a/js/src/jit/IonMacroAssembler.h
+++ b/js/src/jit/IonMacroAssembler.h
@@ -1206,17 +1206,16 @@ class MacroAssembler : public MacroAssem
     void printf(const char *output);
     void printf(const char *output, Register value);
 
 #ifdef JS_TRACE_LOGGING
     void tracelogStart(Register logger, uint32_t textId);
     void tracelogStart(Register logger, Register textId);
     void tracelogStop(Register logger, uint32_t textId);
     void tracelogStop(Register logger, Register textId);
-    void tracelogStop(Register logger);
 #endif
 
 #define DISPATCH_FLOATING_POINT_OP(method, type, arg1d, arg1f, arg2)    \
     MOZ_ASSERT(IsFloatingPointType(type));                              \
     if (type == MIRType_Double)                                         \
         method##Double(arg1d, arg2);                                    \
     else                                                                \
         method##Float32(arg1f, arg2);                                   \
--- a/js/src/jit/VMFunctions.cpp
+++ b/js/src/jit/VMFunctions.cpp
@@ -775,17 +775,17 @@ DebugPrologue(JSContext *cx, BaselineFra
 bool
 DebugEpilogueOnBaselineReturn(JSContext *cx, BaselineFrame *frame, jsbytecode *pc)
 {
     if (!DebugEpilogue(cx, frame, pc, true)) {
         // DebugEpilogue popped the frame by updating jitTop, so run the stop event
         // here before we enter the exception handler.
         TraceLogger *logger = TraceLoggerForMainThread(cx->runtime());
         TraceLogStopEvent(logger, TraceLogger::Baseline);
-        TraceLogStopEvent(logger); // Leave script.
+        TraceLogStopEvent(logger, TraceLogger::Scripts);
         return false;
     }
 
     return true;
 }
 
 bool
 DebugEpilogue(JSContext *cx, BaselineFrame *frame, jsbytecode *pc, bool ok)
--- a/js/src/jit/shared/CodeGenerator-shared.cpp
+++ b/js/src/jit/shared/CodeGenerator-shared.cpp
@@ -1397,16 +1397,19 @@ CodeGeneratorShared::computeDivisionCons
 }
 
 
 #ifdef JS_TRACE_LOGGING
 
 bool
 CodeGeneratorShared::emitTracelogScript(bool isStart)
 {
+    if (!TraceLogTextIdEnabled(TraceLogger::Scripts))
+        return true;
+
     Label done;
 
     RegisterSet regs = RegisterSet::Volatile();
     Register logger = regs.takeGeneral();
     Register script = regs.takeGeneral();
 
     masm.Push(logger);
 
@@ -1450,25 +1453,20 @@ CodeGeneratorShared::emitTracelogTree(bo
 
     CodeOffsetLabel patchLocation = masm.movWithPatch(ImmPtr(nullptr), logger);
     if (!patchableTraceLoggers_.append(patchLocation))
         return false;
 
     Address enabledAddress(logger, TraceLogger::offsetOfEnabled());
     masm.branch32(Assembler::Equal, enabledAddress, Imm32(0), &done);
 
-    if (isStart) {
+    if (isStart)
         masm.tracelogStart(logger, textId);
-    } else {
-#ifdef DEBUG
+    else
         masm.tracelogStop(logger, textId);
-#else
-        masm.tracelogStop(logger);
-#endif
-    }
 
     masm.bind(&done);
 
     masm.Pop(logger);
     return true;
 }
 #endif
 
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -1759,18 +1759,17 @@ CASE(JSOP_RETRVAL)
 
   successful_return_continuation:
     interpReturnOK = true;
   return_continuation:
     if (activation.entryFrame() != REGS.fp()) {
         // Stop the engine. (No details about which engine exactly, could be
         // interpreter, Baseline or IonMonkey.)
         TraceLogStopEvent(logger);
-        // Stop the script. (Again no details about which script exactly.)
-        TraceLogStopEvent(logger);
+        TraceLogStopEvent(logger, TraceLogger::Scripts);
 
         interpReturnOK = Debugger::onLeaveFrame(cx, REGS.fp(), interpReturnOK);
 
         REGS.fp()->epilogue(cx);
 
   jit_return_pop_frame:
 
         activation.popInlineFrame(REGS.fp());
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -373,16 +373,21 @@ TraceLogger::createTextId(const char *te
 uint32_t
 TraceLogger::createTextId(JSScript *script)
 {
     if (!script->filename())
         return createTextId("");
 
     assertNoQuotes(script->filename());
 
+    // Only log scripts when enabled otherwise return the global Scripts textId,
+    // which will get filtered out.
+    if (!traceLoggers.isTextIdEnabled(TraceLogger::Scripts))
+        return TraceLogger::Scripts;
+
     PointerHashMap::AddPtr p = pointerMap.lookupForAdd(script);
     if (p)
         return p->value();
 
     uint32_t textId = nextTextId++;
     if (!pointerMap.add(p, script, textId))
         return TraceLogger::TL_Error;
 
@@ -404,16 +409,21 @@ TraceLogger::createTextId(JSScript *scri
 uint32_t
 TraceLogger::createTextId(const JS::ReadOnlyCompileOptions &compileOptions)
 {
     if (!compileOptions.filename())
         return createTextId("");
 
     assertNoQuotes(compileOptions.filename());
 
+    // Only log scripts when enabled. Else return the global Scripts textId,
+    // which will get filtered out.
+    if (!traceLoggers.isTextIdEnabled(TraceLogger::Scripts))
+        return TraceLogger::Scripts;
+
     PointerHashMap::AddPtr p = pointerMap.lookupForAdd(&compileOptions);
     if (p)
         return p->value();
 
     uint32_t textId = nextTextId++;
     if (!pointerMap.add(p, &compileOptions, textId))
         return TraceLogger::TL_Error;
 
@@ -666,20 +676,20 @@ TraceLogger::startEvent(uint32_t id, uin
 
     return true;
 }
 
 void
 TraceLogger::stopEvent(uint32_t id)
 {
 #ifdef DEBUG
-    if (stack.size() > 1) {
+    if (stack.size() > 1 && id != TraceLogger::Scripts && stack.lastEntry().active()) {
         TreeEntry entry;
-        MOZ_ASSERT_IF(stack.lastEntry().active(), getTreeEntry(stack.lastEntry().treeId(), &entry));
-        MOZ_ASSERT_IF(stack.lastEntry().active(), entry.textId() == id);
+        MOZ_ASSERT(getTreeEntry(stack.lastEntry().treeId(), &entry));
+        MOZ_ASSERT(entry.textId() == id);
     }
 #endif
     stopEvent();
 }
 
 void
 TraceLogger::stopEvent()
 {
@@ -816,16 +826,17 @@ TraceLogging::lazyInit()
         enabledTextIds[TraceLogger::IonLinking] = true;
         enabledTextIds[TraceLogger::IonMonkey] = true;
         enabledTextIds[TraceLogger::MinorGC] = true;
         enabledTextIds[TraceLogger::ParserCompileFunction] = true;
         enabledTextIds[TraceLogger::ParserCompileLazy] = true;
         enabledTextIds[TraceLogger::ParserCompileScript] = true;
         enabledTextIds[TraceLogger::IrregexpCompile] = true;
         enabledTextIds[TraceLogger::IrregexpExecute] = true;
+        enabledTextIds[TraceLogger::Scripts] = true;
     }
 
     if (ContainsFlag(env, "IonCompiler")) {
         enabledTextIds[TraceLogger::IonCompilation] = true;
         enabledTextIds[TraceLogger::IonLinking] = true;
         enabledTextIds[TraceLogger::FoldTests] = true;
         enabledTextIds[TraceLogger::SplitCriticalEdges] = true;
         enabledTextIds[TraceLogger::RenumberBlocks] = true;
@@ -840,16 +851,17 @@ TraceLogging::lazyInit()
         enabledTextIds[TraceLogger::LoopUnrolling] = true;
         enabledTextIds[TraceLogger::EffectiveAddressAnalysis] = true;
         enabledTextIds[TraceLogger::EliminateDeadCode] = true;
         enabledTextIds[TraceLogger::EdgeCaseAnalysis] = true;
         enabledTextIds[TraceLogger::EliminateRedundantChecks] = true;
         enabledTextIds[TraceLogger::GenerateLIR] = true;
         enabledTextIds[TraceLogger::RegisterAllocation] = true;
         enabledTextIds[TraceLogger::GenerateCode] = true;
+        enabledTextIds[TraceLogger::Scripts] = true;
     }
 
     const char *options = getenv("TLOPTIONS");
     if (options) {
         if (strstr(options, "help")) {
             fflush(nullptr);
             printf(
                 "\n"
--- a/js/src/vm/TraceLogging.h
+++ b/js/src/vm/TraceLogging.h
@@ -114,23 +114,24 @@ namespace jit {
     _(GCAllocation)                                   \
     _(GCSweeping)                                     \
     _(Interpreter)                                    \
     _(Invalidation)                                   \
     _(IonCompilation)                                 \
     _(IonCompilationPaused)                           \
     _(IonLinking)                                     \
     _(IonMonkey)                                      \
+    _(IrregexpCompile)                                \
+    _(IrregexpExecute)                                \
     _(MinorGC)                                        \
     _(ParserCompileFunction)                          \
     _(ParserCompileLazy)                              \
     _(ParserCompileScript)                            \
+    _(Scripts)                                        \
     _(TL)                                             \
-    _(IrregexpCompile)                                \
-    _(IrregexpExecute)                                \
     _(VM)                                             \
                                                       \
     /* Specific passes during ion compilation */      \
     _(FoldTests)                                      \
     _(SplitCriticalEdges)                             \
     _(RenumberBlocks)                                 \
     _(ScalarReplacement)                              \
     _(DominatorTree)                                  \