Bug 996509 - TraceLogger: Make it possible to toggle TraceLogger_Engine on and off, r=bbouvier
authorHannes Verschore <hv1989@gmail.com>
Thu, 20 Nov 2014 17:43:58 +0100
changeset 247489 648947a5a4452d154ced5b535513dfdbd4310aff
parent 247488 3ccf3fac28b77259efc654663ed2808d1e6a8c2f
child 247490 16aa61577e9536dcd1c328e43c22743840c9f921
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs996509
milestone37.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/MacroAssembler.cpp
js/src/vm/Interpreter.cpp
js/src/vm/TraceLogging.cpp
js/src/vm/TraceLogging.h
--- a/js/src/jit/MacroAssembler.cpp
+++ b/js/src/jit/MacroAssembler.cpp
@@ -1721,62 +1721,41 @@ 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 *, TraceLogEvent));
 
     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 *, TraceLogEvent));
 
     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
@@ -1770,17 +1770,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:
 
@@ -3520,17 +3520,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;