Bug 1083694 - TraceLogger: Part 6: Fix --disable-trace-logging, r=till
☠☠ backed out by c7540260b62c ☠ ☠
authorHannes Verschore <hv1989@gmail.com>
Thu, 20 Nov 2014 17:44:04 +0100
changeset 240994 7f5dc516518d5127289eb6c495b02f6533fa58e1
parent 240993 aafd058bcab19ced5082a53d1e8462dd745b0339
child 240995 05ca63f6ffe39f95d4348bde043e9ae1b9069112
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1083694
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 1083694 - TraceLogger: Part 6: Fix --disable-trace-logging, r=till
js/src/jit/BaselineCompiler.cpp
js/src/jit/BaselineJIT.cpp
js/src/jit/BaselineJIT.h
js/src/vm/Debugger.cpp
js/src/vm/TraceLogging.h
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -243,18 +243,20 @@ BaselineCompiler::compile()
     // All barriers are emitted off-by-default, toggle them on if needed.
     if (cx->zone()->needsIncrementalBarrier())
         baselineScript->toggleBarriers(true);
 
     // All SPS instrumentation is emitted toggled off.  Toggle them on if needed.
     if (cx->runtime()->spsProfiler.enabled())
         baselineScript->toggleSPS(true);
 
+#ifdef JS_TRACE_LOGGING
     // Initialize the tracelogger instrumentation.
     baselineScript->initTraceLogger(cx->runtime(), script);
+#endif
 
     uint32_t *bytecodeMap = baselineScript->bytecodeTypeMap();
     types::FillBytecodeTypeMap(script, bytecodeMap);
 
     // The last entry in the last index found, and is used to avoid binary
     // searches for the sought entry when queries are in linear order.
     bytecodeMap[script->nTypeSets()] = 0;
 
@@ -377,18 +379,20 @@ BaselineCompiler::emitPrologue()
     if (frame.nvars() > 0)
         emitInitializeLocals(frame.nvars(), UndefinedValue());
     if (frame.nlexicals() > 0)
         emitInitializeLocals(frame.nlexicals(), MagicValue(JS_UNINITIALIZED_LEXICAL));
 
     if (needsEarlyStackCheck())
         masm.bind(&earlyStackCheckFailed);
 
+#ifdef JS_TRACE_LOGGING
     if (!emitTraceLoggerEnter())
         return false;
+#endif
 
     // Record the offset of the prologue, because Ion can bailout before
     // the scope chain is initialized.
     prologueOffset_ = CodeOffsetLabel(masm.currentOffset());
 
     // Initialize the scope chain before any operation that may
     // call into the VM and trigger a GC.
     if (!initScopeChain())
@@ -758,16 +762,17 @@ BaselineCompiler::emitDebugTrap()
     ICEntry icEntry(script->pcToOffset(pc), ICEntry::Kind_DebugTrap);
     icEntry.setReturnOffset(CodeOffsetLabel(masm.currentOffset()));
     if (!icEntries_.append(icEntry))
         return false;
 
     return true;
 }
 
+#ifdef JS_TRACE_LOGGING
 bool
 BaselineCompiler::emitTraceLoggerEnter()
 {
     TraceLoggerThread *logger = TraceLoggerForMainThread(cx->runtime());
     RegisterSet regs = RegisterSet::Volatile();
     Register loggerReg = regs.takeGeneral();
     Register scriptReg = regs.takeGeneral();
 
@@ -813,16 +818,17 @@ BaselineCompiler::emitTraceLoggerExit()
     masm.tracelogStopId(loggerReg, TraceLogger_Scripts, /* force = */ true);
 
     masm.Pop(loggerReg);
 
     masm.bind(&noTraceLogger);
 
     return true;
 }
+#endif
 
 bool
 BaselineCompiler::emitSPSPush()
 {
     // Enter the IC, guarded by a toggled jump (initially disabled).
     Label noPush;
     CodeOffsetLabel toggleOffset = masm.toggledJump(&noPush);
     MOZ_ASSERT(frame.numUnsyncedSlots() == 0);
--- a/js/src/jit/BaselineJIT.cpp
+++ b/js/src/jit/BaselineJIT.cpp
@@ -48,23 +48,25 @@ BaselineScript::BaselineScript(uint32_t 
     templateScope_(nullptr),
     fallbackStubSpace_(),
     prologueOffset_(prologueOffset),
     epilogueOffset_(epilogueOffset),
 #ifdef DEBUG
     spsOn_(false),
 #endif
     spsPushToggleOffset_(spsPushToggleOffset),
-#ifdef DEBUG
+#ifdef JS_TRACE_LOGGING
+# ifdef DEBUG
     traceLoggerScriptsEnabled_(false),
     traceLoggerEngineEnabled_(false),
-#endif
+# endif
     traceLoggerEnterToggleOffset_(traceLoggerEnterToggleOffset),
     traceLoggerExitToggleOffset_(traceLoggerExitToggleOffset),
     traceLoggerScriptEvent_(),
+#endif
     postDebugPrologueOffset_(postDebugPrologueOffset),
     flags_(0)
 { }
 
 static const unsigned BASELINE_MAX_ARGS_LENGTH = 20000;
 
 static bool
 CheckFrame(InterpreterFrame *fp)
@@ -840,16 +842,17 @@ BaselineScript::toggleSPS(bool enable)
         Assembler::ToggleToCmp(pushToggleLocation);
     else
         Assembler::ToggleToJmp(pushToggleLocation);
 #ifdef DEBUG
     spsOn_ = enable;
 #endif
 }
 
+#ifdef JS_TRACE_LOGGING
 void
 BaselineScript::initTraceLogger(JSRuntime *runtime, JSScript *script)
 {
 #ifdef DEBUG
     traceLoggerScriptsEnabled_ = TraceLogTextIdEnabled(TraceLogger_Scripts);
     traceLoggerEngineEnabled_ = TraceLogTextIdEnabled(TraceLogger_Engine);
 #endif
 
@@ -921,16 +924,17 @@ BaselineScript::toggleTraceLoggerEngine(
             Assembler::ToggleToJmp(exit);
         }
     }
 
 #if DEBUG
     traceLoggerEngineEnabled_ = enable;
 #endif
 }
+#endif
 
 void
 BaselineScript::purgeOptimizedStubs(Zone *zone)
 {
     JitSpew(JitSpew_BaselineIC, "Purging optimized stubs");
 
     for (size_t i = 0; i < numICEntries(); i++) {
         ICEntry &entry = icEntry(i);
@@ -1029,16 +1033,17 @@ jit::ToggleBaselineSPS(JSRuntime *runtim
             JSScript *script = i.get<JSScript>();
             if (!script->hasBaselineScript())
                 continue;
             script->baselineScript()->toggleSPS(enable);
         }
     }
 }
 
+#ifdef JS_TRACE_LOGGING
 void
 jit::ToggleBaselineTraceLoggerScripts(JSRuntime *runtime, bool enable)
 {
     for (ZonesIter zone(runtime, SkipAtoms); !zone.done(); zone.next()) {
         for (gc::ZoneCellIter i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
             JSScript *script = i.get<JSScript>();
             if (!script->hasBaselineScript())
                 continue;
@@ -1054,16 +1059,17 @@ jit::ToggleBaselineTraceLoggerEngine(JSR
         for (gc::ZoneCellIter i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
             JSScript *script = i.get<JSScript>();
             if (!script->hasBaselineScript())
                 continue;
             script->baselineScript()->toggleTraceLoggerEngine(enable);
         }
     }
 }
+#endif
 
 static void
 MarkActiveBaselineScripts(JSRuntime *rt, const JitActivationIterator &activation)
 {
     for (jit::JitFrameIterator iter(activation); !iter.done(); ++iter) {
         switch (iter.type()) {
           case JitFrame_BaselineJS:
             iter.script()->baselineScript()->setActive();
--- a/js/src/jit/BaselineJIT.h
+++ b/js/src/jit/BaselineJIT.h
@@ -123,16 +123,17 @@ struct BaselineScript
     uint32_t epilogueOffset_;
 
     // The offsets for the toggledJump instructions for SPS update ICs.
 #ifdef DEBUG
     mozilla::DebugOnly<bool> spsOn_;
 #endif
     uint32_t spsPushToggleOffset_;
 
+    // The offsets and event used for Tracelogger toggling.
 #ifdef JS_TRACE_LOGGING
 # ifdef DEBUG
     bool traceLoggerScriptsEnabled_;
     bool traceLoggerEngineEnabled_;
 # endif
     uint32_t traceLoggerEnterToggleOffset_;
     uint32_t traceLoggerExitToggleOffset_;
     TraceLoggerEvent traceLoggerScriptEvent_;
@@ -366,32 +367,35 @@ struct BaselineScript
   public:
     // Toggle debug traps (used for breakpoints and step mode) in the script.
     // If |pc| is nullptr, toggle traps for all ops in the script. Else, only
     // toggle traps at |pc|.
     void toggleDebugTraps(JSScript *script, jsbytecode *pc);
 
     void toggleSPS(bool enable);
 
+#ifdef JS_TRACE_LOGGING
     void initTraceLogger(JSRuntime *runtime, JSScript *script);
     void toggleTraceLoggerScripts(JSRuntime *runtime, JSScript *script, bool enable);
     void toggleTraceLoggerEngine(bool enable);
 
+    static size_t offsetOfTraceLoggerScriptEvent() {
+        return offsetof(BaselineScript, traceLoggerScriptEvent_);
+    }
+#endif
+
     void noteAccessedGetter(uint32_t pcOffset);
     void noteArrayWriteHole(uint32_t pcOffset);
 
     static size_t offsetOfFlags() {
         return offsetof(BaselineScript, flags_);
     }
     static size_t offsetOfYieldEntriesOffset() {
         return offsetof(BaselineScript, yieldEntriesOffset_);
     }
-    static size_t offsetOfTraceLoggerScriptEvent() {
-        return offsetof(BaselineScript, traceLoggerScriptEvent_);
-    }
 
     static void writeBarrierPre(Zone *zone, BaselineScript *script);
 
     uint32_t *bytecodeTypeMap() {
         MOZ_ASSERT(bytecodeTypeMapOffset_);
         return reinterpret_cast<uint32_t *>(reinterpret_cast<uint8_t *>(this) + bytecodeTypeMapOffset_);
     }
 };
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -3782,17 +3782,18 @@ DefineProperty(JSContext *cx, HandleObje
     JSString *text = JS_NewStringCopyN(cx, value, n);
     if (!text)
         return false;
 
     RootedValue str(cx, StringValue(text));
     return JS_DefinePropertyById(cx, obj, id, str, JSPROP_ENUMERATE);
 }
 
-#ifdef NIGHTLY_BUILD
+#ifdef JS_TRACE_LOGGING
+# ifdef NIGHTLY_BUILD
 bool
 Debugger::setupTraceLogger(JSContext *cx, unsigned argc, Value *vp)
 {
     THIS_DEBUGGER(cx, argc, vp, "setupTraceLogger", args, dbg);
     if (!args.requireAtLeast(cx, "Debugger.setupTraceLogger", 1))
         return false;
 
     RootedObject obj(cx, ToObject(cx, args[0]));
@@ -3897,17 +3898,17 @@ Debugger::drainTraceLogger(JSContext *cx
     RootedValue lost(cx, BooleanValue(lostEvents));
     if (!JS_DefineProperty(cx, array, "lostEvents", lost, JSPROP_ENUMERATE))
         return false;
 
     args.rval().setObject(*array);
 
     return true;
 }
-#endif
+# endif // NIGHTLY_BUILD
 
 bool
 Debugger::setupTraceLoggerScriptCalls(JSContext *cx, unsigned argc, Value *vp)
 {
     THIS_DEBUGGER(cx, argc, vp, "setupTraceLoggerScriptCalls", args, dbg);
     if (!args.requireAtLeast(cx, "Debugger.setupTraceLoggerScriptCalls", 0))
         return false;
 
@@ -4015,16 +4016,17 @@ Debugger::drainTraceLoggerScriptCalls(JS
     RootedValue lost(cx, BooleanValue(lostEvents));
     if (!JS_DefineProperty(cx, array, "lostEvents", lost, JSPROP_ENUMERATE))
         return false;
 
     args.rval().setObject(*array);
 
     return true;
 }
+#endif
 
 const JSPropertySpec Debugger::properties[] = {
     JS_PSGS("enabled", Debugger::getEnabled, Debugger::setEnabled, 0),
     JS_PSGS("onDebuggerStatement", Debugger::getOnDebuggerStatement,
             Debugger::setOnDebuggerStatement, 0),
     JS_PSGS("onExceptionUnwind", Debugger::getOnExceptionUnwind,
             Debugger::setOnExceptionUnwind, 0),
     JS_PSGS("onNewScript", Debugger::getOnNewScript, Debugger::setOnNewScript, 0),
@@ -4045,23 +4047,25 @@ const JSFunctionSpec Debugger::methods[]
     JS_FN("hasDebuggee", Debugger::hasDebuggee, 1, 0),
     JS_FN("getDebuggees", Debugger::getDebuggees, 0, 0),
     JS_FN("getNewestFrame", Debugger::getNewestFrame, 0, 0),
     JS_FN("clearAllBreakpoints", Debugger::clearAllBreakpoints, 0, 0),
     JS_FN("findScripts", Debugger::findScripts, 1, 0),
     JS_FN("findObjects", Debugger::findObjects, 1, 0),
     JS_FN("findAllGlobals", Debugger::findAllGlobals, 0, 0),
     JS_FN("makeGlobalObjectReference", Debugger::makeGlobalObjectReference, 1, 0),
+#ifdef JS_TRACE_LOGGING
     JS_FN("setupTraceLoggerScriptCalls", Debugger::setupTraceLoggerScriptCalls, 0, 0),
     JS_FN("drainTraceLoggerScriptCalls", Debugger::drainTraceLoggerScriptCalls, 0, 0),
     JS_FN("startTraceLogger", Debugger::startTraceLogger, 0, 0),
     JS_FN("endTraceLogger", Debugger::endTraceLogger, 0, 0),
-#ifdef NIGHTLY_BUILD
+# ifdef NIGHTLY_BUILD
     JS_FN("setupTraceLogger", Debugger::setupTraceLogger, 1, 0),
     JS_FN("drainTraceLogger", Debugger::drainTraceLogger, 0, 0),
+# endif
 #endif
     JS_FS_END
 };
 
 
 /*** Debugger.Script *****************************************************************************/
 
 static inline JSScript *
--- a/js/src/vm/TraceLogging.h
+++ b/js/src/vm/TraceLogging.h
@@ -81,23 +81,32 @@ class TraceLoggerThread;
  * unique id). It also increases the useCount of this payload, so it cannot
  * get removed.
  */
 class TraceLoggerEvent {
   private:
     TraceLoggerEventPayload *payload_;
 
   public:
+    TraceLoggerEvent() { payload_ = nullptr; };
+#ifdef JS_TRACE_LOGGING
     TraceLoggerEvent(TraceLoggerThread *logger, TraceLoggerTextId textId);
     TraceLoggerEvent(TraceLoggerThread *logger, TraceLoggerTextId type, JSScript *script);
     TraceLoggerEvent(TraceLoggerThread *logger, TraceLoggerTextId type,
                      const JS::ReadOnlyCompileOptions &compileOptions);
     TraceLoggerEvent(TraceLoggerThread *logger, const char *text);
-    TraceLoggerEvent() { payload_ = nullptr; };
     ~TraceLoggerEvent();
+#else
+    TraceLoggerEvent (TraceLoggerThread *logger, TraceLoggerTextId textId) {}
+    TraceLoggerEvent (TraceLoggerThread *logger, TraceLoggerTextId type, JSScript *script) {}
+    TraceLoggerEvent (TraceLoggerThread *logger, TraceLoggerTextId type,
+                      const JS::ReadOnlyCompileOptions &compileOptions) {}
+    TraceLoggerEvent (TraceLoggerThread *logger, const char *text) {}
+    ~TraceLoggerEvent() {}
+#endif
 
     TraceLoggerEventPayload *payload() const {
         MOZ_ASSERT(hasPayload());
         return payload_;
     }
     bool hasPayload() const {
         return !!payload_;
     }
@@ -479,16 +488,21 @@ class AutoTraceLog
             logger->top = prev;
     }
 #else
   public:
     AutoTraceLog(TraceLoggerThread *logger, uint32_t textId MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
+    AutoTraceLog(TraceLoggerThread *logger,
+                 const TraceLoggerEvent &event MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+    {
+        MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+    }
 #endif
 
   private:
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 }  /* namedata js */