Bug 996509 - TraceLogger: Make it possible to toggle TraceLogger_Engine on and off, r=bbouvier
☠☠ backed out by f460adc36fb6 ☠ ☠
authorHannes Verschore <hv1989@gmail.com>
Thu, 20 Nov 2014 17:43:58 +0100
changeset 216663 5c168f5722527ba41882f316220a6206549ecb8e
parent 216662 2b29d8a0077494fd25559bdc209b2be3481ebaba
child 216664 8d040e2b9affffcc42f722e6eaf3f2d848b0ee96
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_Engine on and off, r=bbouvier
js/src/jit/IonMacroAssembler.cpp
js/src/vm/Interpreter.cpp
js/src/vm/TraceLogging.cpp
js/src/vm/TraceLogging.h
--- a/js/src/jit/IonMacroAssembler.cpp
+++ b/js/src/jit/IonMacroAssembler.cpp
@@ -1720,62 +1720,42 @@ MacroAssembler::tracelogStop(Register lo
 
     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);
-#else
-    void (&TraceLogFunc)(TraceLogger*) = TraceLogStopEvent;
 
-    setupUnalignedABICall(1, temp);
-    passABIArg(logger);
-#endif
-
-    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogFunc));
+    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogStopEvent));
 
     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;
-
     regs.takeUnchecked(textId);
 
     Register temp = regs.takeGeneral();
 
     setupUnalignedABICall(2, temp);
     passABIArg(logger);
     passABIArg(textId);
-#else
-    void (&TraceLogFunc)(TraceLogger*) = TraceLogStopEvent;
 
-    Register temp = regs.takeGeneral();
-
-    setupUnalignedABICall(1, temp);
-    passABIArg(logger);
-#endif
-
-    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogFunc));
+    callWithABINoProfiling(JS_FUNC_TO_DATA_PTR(void *, TraceLogStopEvent));
 
     PopRegsInMask(RegisterSet::Volatile());
 }
 #endif
 
 void
 MacroAssembler::convertInt32ValueToDouble(const Address &address, Register scratch, Label *done)
 {
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -1758,17 +1758,17 @@ CASE(JSOP_RETRVAL)
     CHECK_BRANCH();
 
   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);
+        TraceLogStopEvent(logger, TraceLogger::Engine);
         TraceLogStopEvent(logger, TraceLogger::Scripts);
 
         interpReturnOK = Debugger::onLeaveFrame(cx, REGS.fp(), interpReturnOK);
 
         REGS.fp()->epilogue(cx);
 
   jit_return_pop_frame:
 
@@ -3486,17 +3486,17 @@ DEFAULT()
 
   exit:
     interpReturnOK = Debugger::onLeaveFrame(cx, REGS.fp(), interpReturnOK);
 
     REGS.fp()->epilogue(cx);
 
     gc::MaybeVerifyBarriers(cx, true);
 
-    TraceLogStopEvent(logger);
+    TraceLogStopEvent(logger, TraceLogger::Engine);
     TraceLogStopEvent(logger, scriptLogId);
 
     /*
      * This path is used when it's guaranteed the method can be finished
      * inside the JIT.
      */
   leave_on_safe_point:
 
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -676,17 +676,19 @@ TraceLogger::startEvent(uint32_t id, uin
 
     return true;
 }
 
 void
 TraceLogger::stopEvent(uint32_t id)
 {
 #ifdef DEBUG
-    if (stack.size() > 1 && id != TraceLogger::Scripts && stack.lastEntry().active()) {
+    if (id != TraceLogger::Scripts && id != TraceLogger::Engine &&
+        stack.size() > 1 && stack.lastEntry().active())
+    {
         TreeEntry entry;
         MOZ_ASSERT(getTreeEntry(stack.lastEntry().treeId(), &entry));
         MOZ_ASSERT(entry.textId() == id);
     }
 #endif
     stopEvent();
 }
 
@@ -796,28 +798,31 @@ TraceLogging::lazyInit()
             "\n"
             "Collections:\n"
             "  Default        Output all default\n"
             "  IonCompiler    Output all information about compilation\n"
             "\n"
             "Specific log items:\n"
         );
         for (uint32_t i = 1; i < TraceLogger::LAST; i++) {
+            if (!TraceLogger::textIdIsToggable(i))
+                continue;
             printf("  %s\n", text[i]);
         }
         printf("\n");
         exit(0);
         /*NOTREACHED*/
     }
 
-    for (uint32_t i = 1; i < TraceLogger::LAST; i++)
-        enabledTextIds[i] = ContainsFlag(env, text[i]);
-
-    enabledTextIds[TraceLogger::TL_Error] = true;
-    enabledTextIds[TraceLogger::TL] = true;
+    for (uint32_t i = 1; i < TraceLogger::LAST; i++) {
+        if (TraceLogger::textIdIsToggable(i))
+            enabledTextIds[i] = ContainsFlag(env, text[i]);
+        else
+            enabledTextIds[i] = true;
+    }
 
     if (ContainsFlag(env, "Default")) {
         enabledTextIds[TraceLogger::Bailout] = true;
         enabledTextIds[TraceLogger::Baseline] = true;
         enabledTextIds[TraceLogger::BaselineCompilation] = true;
         enabledTextIds[TraceLogger::GC] = true;
         enabledTextIds[TraceLogger::GCAllocation] = true;
         enabledTextIds[TraceLogger::GCSweeping] = true;
@@ -827,16 +832,17 @@ TraceLogging::lazyInit()
         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;
+        enabledTextIds[TraceLogger::Engine] = 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;
@@ -854,16 +860,20 @@ TraceLogging::lazyInit()
         enabledTextIds[TraceLogger::EdgeCaseAnalysis] = true;
         enabledTextIds[TraceLogger::EliminateRedundantChecks] = true;
         enabledTextIds[TraceLogger::GenerateLIR] = true;
         enabledTextIds[TraceLogger::RegisterAllocation] = true;
         enabledTextIds[TraceLogger::GenerateCode] = true;
         enabledTextIds[TraceLogger::Scripts] = true;
     }
 
+    enabledTextIds[TraceLogger::Interpreter] = enabledTextIds[TraceLogger::Engine];
+    enabledTextIds[TraceLogger::Baseline] = enabledTextIds[TraceLogger::Engine];
+    enabledTextIds[TraceLogger::IonMonkey] = enabledTextIds[TraceLogger::Engine];
+
     const char *options = getenv("TLOPTIONS");
     if (options) {
         if (strstr(options, "help")) {
             fflush(nullptr);
             printf(
                 "\n"
                 "usage: TLOPTIONS=option,option,option,... where options can be:\n"
                 "\n"
--- a/js/src/vm/TraceLogging.h
+++ b/js/src/vm/TraceLogging.h
@@ -105,16 +105,17 @@ namespace jit {
  *    or the duration with a RAII class:
  *    - AutoTraceLog logger(logger, textId);
  */
 
 #define TRACELOGGER_TEXT_ID_LIST(_)                   \
     _(Bailout)                                        \
     _(Baseline)                                       \
     _(BaselineCompilation)                            \
+    _(Engine)                                         \
     _(GC)                                             \
     _(GCAllocation)                                   \
     _(GCSweeping)                                     \
     _(Interpreter)                                    \
     _(Invalidation)                                   \
     _(IonCompilation)                                 \
     _(IonCompilationPaused)                           \
     _(IonLinking)                                     \
@@ -426,16 +427,28 @@ class TraceLogger
     bool flush();
 
   public:
     TraceLogger();
     ~TraceLogger();
 
     bool init(uint32_t loggerId);
 
+    static bool textIdIsToggable(uint32_t id) {
+        if (id == TL_Error)
+            return false;
+        if (id == TL)
+            return false;
+        // Cannot toggle the logging of one engine on/off, because at the stop
+        // event it is sometimes unknown which engine was running.
+        if (id == IonMonkey || id == Baseline || id == Interpreter)
+            return false;
+        return true;
+    }
+
     bool enable();
     bool enable(JSContext *cx);
     bool disable();
 
     // The createTextId functions map a unique input to a logger ID.
     // This ID can be used to log something. Calls to these functions should be
     // limited if possible, because of the overhead.
     uint32_t createTextId(const char *text);
@@ -445,18 +458,20 @@ class TraceLogger
     // Log an event (no start/stop, only the timestamp is recorded).
     void logTimestamp(uint32_t id);
 
     // Record timestamps for start and stop of an event.
     // In the stop method, the ID is only used in debug builds to test
     // correctness.
     void startEvent(uint32_t id);
     void stopEvent(uint32_t id);
+  private:
     void stopEvent();
 
+  public:
     static unsigned offsetOfEnabled() {
         return offsetof(TraceLogger, enabled);
     }
 
   private:
     void assertNoQuotes(const char *text) {
 #ifdef DEBUG
         const char *quote = strchr(text, '"');
@@ -590,22 +605,16 @@ inline void TraceLogStartEvent(TraceLogg
 #endif
 }
 inline void TraceLogStopEvent(TraceLogger *logger, uint32_t textId) {
 #ifdef JS_TRACE_LOGGING
     if (logger)
         logger->stopEvent(textId);
 #endif
 }
-inline void TraceLogStopEvent(TraceLogger *logger) {
-#ifdef JS_TRACE_LOGGING
-    if (logger)
-        logger->stopEvent();
-#endif
-}
 
 // Automatic logging at the start and end of function call.
 class AutoTraceLog {
 #ifdef JS_TRACE_LOGGING
     TraceLogger *logger;
     uint32_t textId;
     bool executed;
     AutoTraceLog *prev;