Bug 1083694 - TraceLogger: Part 2: Split meaning of Script into AnnotateScript and Script (called), r=till
☠☠ backed out by 95e10b3f1765 ☠ ☠
authorHannes Verschore <hv1989@gmail.com>
Thu, 20 Nov 2014 17:44:03 +0100
changeset 240990 4ba3f3e635fc04c81954ff49b93f082a6f0e5fbf
parent 240989 aa78b751e325dff76e9238280809d3c612b9e8cc
child 240991 59f15435d8deb46f043b017c70622c9a81fe88ca
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 2: Split meaning of Script into AnnotateScript and Script (called), r=till
js/src/frontend/BytecodeCompiler.cpp
js/src/jit/BaselineBailouts.cpp
js/src/jit/BaselineCompiler.cpp
js/src/jit/BaselineJIT.cpp
js/src/jit/CodeGenerator.cpp
js/src/jit/Ion.cpp
js/src/vm/Debugger.cpp
js/src/vm/HelperThreads.cpp
js/src/vm/Interpreter.cpp
js/src/vm/TraceLogging.cpp
js/src/vm/TraceLogging.h
js/src/vm/TraceLoggingTypes.h
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -220,17 +220,17 @@ frontend::CompileScript(ExclusiveContext
 
     RootedString source(cx, source_);
 
     js::TraceLoggerThread *logger = nullptr;
     if (cx->isJSContext())
         logger = TraceLoggerForMainThread(cx->asJSContext()->runtime());
     else
         logger = TraceLoggerForCurrentThread();
-    uint32_t logId = js::TraceLogCreateTextId(logger, options);
+    uint32_t logId = js::TraceLogCreateTextId(logger, TraceLogger_AnnotateScripts, options);
     js::AutoTraceLog scriptLogger(logger, logId);
     js::AutoTraceLog typeLogger(logger, TraceLogger_ParserCompileScript);
 
     /*
      * The scripted callerFrame can only be given for compile-and-go scripts
      * and non-zero static level requires callerFrame.
      */
     MOZ_ASSERT_IF(evalCaller, options.compileAndGo);
@@ -471,17 +471,17 @@ frontend::CompileLazyFunction(JSContext 
     options.setMutedErrors(lazy->mutedErrors())
            .setFileAndLine(lazy->source()->filename(), lazy->lineno())
            .setColumn(lazy->column())
            .setCompileAndGo(true)
            .setNoScriptRval(false)
            .setSelfHostingMode(false);
 
     js::TraceLoggerThread *logger = js::TraceLoggerForMainThread(cx->runtime());
-    uint32_t logId = js::TraceLogCreateTextId(logger, options);
+    uint32_t logId = js::TraceLogCreateTextId(logger, TraceLogger_AnnotateScripts, options);
     js::AutoTraceLog scriptLogger(logger, logId);
     js::AutoTraceLog typeLogger(logger, TraceLogger_ParserCompileLazy);
 
     Parser<FullParseHandler> parser(cx, &cx->tempLifoAlloc(), options, chars, length,
                                     /* foldConstants = */ true, nullptr, lazy);
     if (!parser.checkOptions())
         return false;
 
@@ -529,17 +529,17 @@ frontend::CompileLazyFunction(JSContext 
 // Compile a JS function body, which might appear as the value of an event
 // handler attribute in an HTML <INPUT> tag, or in a Function() constructor.
 static bool
 CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, const ReadOnlyCompileOptions &options,
                     const AutoNameVector &formals, SourceBufferHolder &srcBuf,
                     HandleObject enclosingScope, GeneratorKind generatorKind)
 {
     js::TraceLoggerThread *logger = js::TraceLoggerForMainThread(cx->runtime());
-    uint32_t logId = js::TraceLogCreateTextId(logger, options);
+    uint32_t logId = js::TraceLogCreateTextId(logger, TraceLogger_AnnotateScripts, options);
     js::AutoTraceLog scriptLogger(logger, logId);
     js::AutoTraceLog typeLogger(logger, TraceLogger_ParserCompileFunction);
 
     // FIXME: make Function pass in two strings and parse them as arguments and
     // ProgramElements respectively.
 
     if (!CheckLength(cx, srcBuf))
         return false;
--- a/js/src/jit/BaselineBailouts.cpp
+++ b/js/src/jit/BaselineBailouts.cpp
@@ -1455,17 +1455,20 @@ jit::BailoutIonToBaseline(JSContext *cx,
 
     gc::AutoSuppressGC suppress(cx);
 
     while (true) {
         // Skip recover instructions as they are already recovered by |initInstructionResults|.
         snapIter.settleOnFrame();
 
         if (frameNo > 0) {
-            TraceLogStartEvent(logger, TraceLogCreateTextId(logger, scr));
+            // TraceLogger doesn't create entries for inlined frames. But we
+            // see them in Baseline. Here we create the start events of those
+            // entries. So they correspond to what we will see in Baseline.
+            TraceLogStartEvent(logger, TraceLogCreateTextId(logger, TraceLogger_Scripts, scr));
             TraceLogStartEvent(logger, TraceLogger_Baseline);
         }
 
         JitSpew(JitSpew_BaselineBailouts, "    FrameNo %d", frameNo);
 
         // If we are bailing out to a catch or finally block in this frame,
         // pass excInfo to InitFromBailout and don't unpack any other frames.
         bool handleException = (catchingException && excInfo->frameNo() == frameNo);
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -77,17 +77,17 @@ BaselineCompiler::compile()
 {
     JitSpew(JitSpew_BaselineScripts, "Baseline compiling script %s:%d (%p)",
             script->filename(), script->lineno(), script);
 
     JitSpew(JitSpew_Codegen, "# Emitting baseline code for script %s:%d",
             script->filename(), script->lineno());
 
     TraceLoggerThread *logger = TraceLoggerForMainThread(cx->runtime());
-    AutoTraceLog logScript(logger, TraceLogCreateTextId(logger, script));
+    AutoTraceLog logScript(logger, TraceLogCreateTextId(logger, TraceLogger_AnnotateScripts, script));
     AutoTraceLog logCompile(logger, TraceLogger_BaselineCompilation);
 
     if (!script->ensureHasTypes(cx) || !script->ensureHasAnalyzedArgsUsage(cx))
         return Method_Error;
 
     // Pin analysis info during compilation.
     types::AutoEnterAnalysis autoEnterAnalysis(cx);
 
--- a/js/src/jit/BaselineJIT.cpp
+++ b/js/src/jit/BaselineJIT.cpp
@@ -854,17 +854,17 @@ BaselineScript::toggleTraceLoggerScripts
     bool engineEnabled = TraceLogTextIdEnabled(TraceLogger_Engine);
 
     MOZ_ASSERT(enable == !traceLoggerScriptsEnabled_);
     MOZ_ASSERT(engineEnabled == traceLoggerEngineEnabled_);
 
     // Patch the logging script textId to be correct.
     // When logging log the specific textId else the global Scripts textId.
     TraceLoggerThread *logger = TraceLoggerForMainThread(runtime);
-    uint32_t textId = TraceLogCreateTextId(logger, script);
+    uint32_t textId = TraceLogCreateTextId(logger, TraceLogger_Scripts, script);
     CodeLocationLabel patchLocation(method()->raw() + traceLoggerScriptTextIdOffset_);
     if (enable) {
         Assembler::PatchDataWithValueCheck(patchLocation,
                                            PatchedImmPtr((void *)textId),
                                            PatchedImmPtr((void *)TraceLogger_Scripts));
     } else {
         Assembler::PatchDataWithValueCheck(patchLocation,
                                            PatchedImmPtr((void *)TraceLogger_Scripts),
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -7930,17 +7930,17 @@ CodeGenerator::link(JSContext *cx, types
 #ifdef JS_TRACE_LOGGING
     TraceLoggerThread *logger = TraceLoggerForMainThread(cx->runtime());
     for (uint32_t i = 0; i < patchableTraceLoggers_.length(); i++) {
         patchableTraceLoggers_[i].fixup(&masm);
         Assembler::PatchDataWithValueCheck(CodeLocationLabel(code, patchableTraceLoggers_[i]),
                                            ImmPtr(logger),
                                            ImmPtr(nullptr));
     }
-    uint32_t scriptId = TraceLogCreateTextId(logger, script);
+    uint32_t scriptId = TraceLogCreateTextId(logger, TraceLogger_Scripts, script);
     for (uint32_t i = 0; i < patchableTLScripts_.length(); i++) {
         patchableTLScripts_[i].fixup(&masm);
         Assembler::PatchDataWithValueCheck(CodeLocationLabel(code, patchableTLScripts_[i]),
                                            ImmPtr((void *) uintptr_t(scriptId)),
                                            ImmPtr((void *)0));
     }
 #endif
 
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -535,17 +535,18 @@ jit::LazyLinkTopActivation(JSContext *cx
     types::AutoEnterAnalysis enterTypes(cx);
     RootedScript script(cx, builder->script());
 
     // Remove from pending.
     builder->remove();
 
     if (CodeGenerator *codegen = builder->backgroundCodegen()) {
         js::TraceLoggerThread *logger = TraceLoggerForMainThread(cx->runtime());
-        AutoTraceLog logScript(logger, TraceLogCreateTextId(logger, script));
+        uint32_t textId = TraceLogCreateTextId(logger, TraceLogger_AnnotateScripts, script);
+        AutoTraceLog logScript(logger, textId);
         AutoTraceLog logLink(logger, TraceLogger_IonLinking);
 
         IonContext ictx(cx, &builder->alloc());
 
         // Root the assembler until the builder is finished below. As it
         // was constructed off thread, the assembler has not been rooted
         // previously, though any GC activity would discard the builder.
         codegen->masm.constructRoot(cx);
@@ -1798,17 +1799,18 @@ AttachFinishedCompilations(JSContext *cx
                 HelperThreadState().ionLazyLinkList().insertFront(builder);
                 continue;
             }
         }
 
         if (CodeGenerator *codegen = builder->backgroundCodegen()) {
             RootedScript script(cx, builder->script());
             IonContext ictx(cx, &builder->alloc());
-            AutoTraceLog logScript(logger, TraceLogCreateTextId(logger, script));
+            uint32_t textId = TraceLogCreateTextId(logger, TraceLogger_AnnotateScripts, script);
+            AutoTraceLog logScript(logger, textId);
             AutoTraceLog logLink(logger, TraceLogger_IonLinking);
 
             // Root the assembler until the builder is finished below. As it
             // was constructed off thread, the assembler has not been rooted
             // previously, though any GC activity would discard the builder.
             codegen->masm.constructRoot(cx);
 
             bool success;
@@ -1878,17 +1880,18 @@ TrackPropertiesForSingletonScopes(JSCont
 
 static AbortReason
 IonCompile(JSContext *cx, JSScript *script,
            BaselineFrame *baselineFrame, jsbytecode *osrPc, bool constructing,
            ExecutionMode executionMode, bool recompile,
            OptimizationLevel optimizationLevel)
 {
     TraceLoggerThread *logger = TraceLoggerForMainThread(cx->runtime());
-    AutoTraceLog logScript(logger, TraceLogCreateTextId(logger, script));
+    uint32_t textId = TraceLogCreateTextId(logger, TraceLogger_AnnotateScripts, script);
+    AutoTraceLog logScript(logger, textId);
     AutoTraceLog logCompile(logger, TraceLogger_IonCompilation);
 
     MOZ_ASSERT(optimizationLevel > Optimization_DontCompile);
 
     // Make sure the script's canonical function isn't lazy. We can't de-lazify
     // it in a helper thread.
     script->ensureNonLazyCanonicalFunction(cx);
 
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -3907,16 +3907,17 @@ Debugger::drainTraceLogger(JSContext *cx
 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;
 
     TraceLogEnableTextId(cx, TraceLogger_Scripts);
+    TraceLogDisableTextId(cx, TraceLogger_AnnotateScripts);
 
     args.rval().setBoolean(true);
 
     return true;
 }
 
 bool
 Debugger::startTraceLogger(JSContext *cx, unsigned argc, Value *vp)
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -1043,17 +1043,18 @@ HelperThread::handleIonWorkload()
         MOZ_ASSERT(other->ionBuilder && !other->pause);
         other->pause = true;
     }
 
     ionBuilder = builder;
     ionBuilder->setPauseFlag(&pause);
 
     TraceLoggerThread *logger = TraceLoggerForCurrentThread();
-    AutoTraceLog logScript(logger, TraceLogCreateTextId(logger, ionBuilder->script()));
+    uint32_t textId = TraceLogCreateTextId(logger, TraceLogger_AnnotateScripts, ionBuilder->script());
+    AutoTraceLog logScript(logger, textId);
     AutoTraceLog logCompile(logger, TraceLogger_IonCompilation);
 
     JSRuntime *rt = ionBuilder->script()->compartment()->runtimeFromAnyThread();
 
     {
         AutoUnlockHelperThreadState unlock;
         PerThreadData::AutoEnterRuntime enter(threadData.ptr(),
                                               ionBuilder->script()->runtimeFromAnyThread());
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -1458,17 +1458,17 @@ Interpret(JSContext *cx, RunState &state
 
     InterpreterActivation activation(state, cx, entryFrame);
 
     /* The script is used frequently, so keep a local copy. */
     RootedScript script(cx);
     SET_SCRIPT(REGS.fp()->script());
 
     TraceLoggerThread *logger = TraceLoggerForMainThread(cx->runtime());
-    uint32_t scriptLogId = TraceLogCreateTextId(logger, script);
+    uint32_t scriptLogId = TraceLogCreateTextId(logger, TraceLogger_Scripts, script);
     TraceLogStartEvent(logger, scriptLogId);
     TraceLogStartEvent(logger, TraceLogger_Interpreter);
 
     /*
      * Pool of rooters for use in this interpreter frame. References to these
      * are used for local variables within interpreter cases. This avoids
      * creating new rooters each time an interpreter case is entered, and also
      * correctness pitfalls due to incorrect compilation of destructor calls
@@ -2572,17 +2572,17 @@ CASE(JSOP_FUNCALL)
     if (!activation.pushInlineFrame(args, funScript, initial))
         goto error;
 
     if (newType)
         REGS.fp()->setUseNewType();
 
     SET_SCRIPT(REGS.fp()->script());
 
-    uint32_t scriptLogId = TraceLogCreateTextId(logger, script);
+    uint32_t scriptLogId = TraceLogCreateTextId(logger, TraceLogger_Scripts, script);
     TraceLogStartEvent(logger, scriptLogId);
     TraceLogStartEvent(logger, TraceLogger_Interpreter);
 
     if (!REGS.fp()->prologue(cx))
         goto error;
 
     switch (Debugger::onEnterFrame(cx, REGS.fp())) {
       case JSTRAP_CONTINUE:
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -220,17 +220,17 @@ TraceLoggerThread::enable(JSContext *cx)
             engine = TraceLogger_Interpreter;
             if (script->compartment() != cx->compartment()) {
                 failed = true;
                 enabled = 0;
                 return false;
             }
         }
 
-        startEvent(createTextId(script));
+        startEvent(createTextId(TraceLogger_Scripts, script));
         startEvent(engine);
     }
 
     return true;
 }
 
 bool
 TraceLoggerThread::disable()
@@ -333,27 +333,30 @@ TraceLoggerThread::createTextId(const ch
 
     if (graph.get())
         graph->addTextId(textId, text);
 
     return textId;
 }
 
 uint32_t
-TraceLoggerThread::createTextId(const char *filename, size_t lineno, size_t colno, const void *ptr)
+TraceLoggerThread::createTextId(TraceLoggerTextId type, const char *filename, size_t lineno,
+                                size_t colno, const void *ptr)
 {
+    MOZ_ASSERT(type == TraceLogger_Scripts || type == TraceLogger_AnnotateScripts);
+
     if (!filename)
         filename = "<unknown>";
 
     assertNoQuotes(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;
+    if (!traceLoggers.isTextIdEnabled(type))
+        return type;
 
     PointerHashMap::AddPtr p = pointerMap.lookupForAdd(ptr);
     if (p)
         return p->value();
 
     // Compute the length of the string to create.
     size_t lenFilename = strlen(filename);
     size_t lenLineno = 1;
@@ -380,25 +383,25 @@ TraceLoggerThread::createTextId(const ch
 
     if (graph.get())
         graph->addTextId(textId, str);
 
     return textId;
 }
 
 uint32_t
-TraceLoggerThread::createTextId(JSScript *script)
+TraceLoggerThread::createTextId(TraceLoggerTextId type, JSScript *script)
 {
-    return createTextId(script->filename(), script->lineno(), script->column(), script);
+    return createTextId(type, script->filename(), script->lineno(), script->column(), script);
 }
 
 uint32_t
-TraceLoggerThread::createTextId(const JS::ReadOnlyCompileOptions &script)
+TraceLoggerThread::createTextId(TraceLoggerTextId type, const JS::ReadOnlyCompileOptions &script)
 {
-    return createTextId(script.filename(), script.lineno, script.column, &script);
+    return createTextId(type, script.filename(), script.lineno, script.column, &script);
 }
 
 void
 TraceLoggerThread::startEvent(uint32_t id)
 {
     MOZ_ASSERT(TLTextIdIsTreeEvent(id));
     if (!traceLoggers.isTextIdEnabled(id))
        return;
@@ -544,16 +547,17 @@ TraceLoggerThreadState::lazyInit()
         TraceLoggerTextId id = TraceLoggerTextId(i);
         if (TLTextIdIsToggable(id))
             enabledTextIds[i] = ContainsFlag(env, TLTextIdString(id));
         else
             enabledTextIds[i] = true;
     }
 
     if (ContainsFlag(env, "Default")) {
+        enabledTextIds[TraceLogger_AnnotateScripts] = true;
         enabledTextIds[TraceLogger_Bailout] = true;
         enabledTextIds[TraceLogger_Baseline] = true;
         enabledTextIds[TraceLogger_BaselineCompilation] = true;
         enabledTextIds[TraceLogger_GC] = true;
         enabledTextIds[TraceLogger_GCAllocation] = true;
         enabledTextIds[TraceLogger_GCSweeping] = true;
         enabledTextIds[TraceLogger_Interpreter] = true;
         enabledTextIds[TraceLogger_IonCompilation] = true;
--- a/js/src/vm/TraceLogging.h
+++ b/js/src/vm/TraceLogging.h
@@ -146,20 +146,21 @@ class TraceLoggerThread
     const char *eventText(uint32_t id);
     bool textIdIsScriptEvent(uint32_t id);
 
     // The createTextId functions map a unique input to a logger ID.
     // This can be used to give start and stop events. Calls to these functions should be
     // limited if possible, because of the overhead.
     // Note: it is not allowed to use them in logTimestamp.
     uint32_t createTextId(const char *text);
-    uint32_t createTextId(JSScript *script);
-    uint32_t createTextId(const JS::ReadOnlyCompileOptions &script);
+    uint32_t createTextId(TraceLoggerTextId type, JSScript *script);
+    uint32_t createTextId(TraceLoggerTextId type, const JS::ReadOnlyCompileOptions &script);
   private:
-    uint32_t createTextId(const char *filename, size_t lineno, size_t colno, const void *p);
+    uint32_t createTextId(TraceLoggerTextId type, const char *filename, size_t lineno,
+                          size_t colno, const void *p);
 
   public:
     // 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.
     void startEvent(uint32_t id);
     void stopEvent(uint32_t id);
@@ -259,29 +260,31 @@ inline bool TraceLoggerEnable(TraceLogge
 inline bool TraceLoggerDisable(TraceLoggerThread *logger) {
 #ifdef JS_TRACE_LOGGING
     if (logger)
         return logger->disable();
 #endif
     return false;
 }
 
-inline uint32_t TraceLogCreateTextId(TraceLoggerThread *logger, JSScript *script) {
+inline uint32_t TraceLogCreateTextId(TraceLoggerThread *logger, TraceLoggerTextId type,
+                                     JSScript *script)
+{
 #ifdef JS_TRACE_LOGGING
     if (logger)
-        return logger->createTextId(script);
+        return logger->createTextId(type, script);
 #endif
     return TraceLogger_Error;
 }
-inline uint32_t TraceLogCreateTextId(TraceLoggerThread *logger,
+inline uint32_t TraceLogCreateTextId(TraceLoggerThread *logger, TraceLoggerTextId type,
                                      const JS::ReadOnlyCompileOptions &compileOptions)
 {
 #ifdef JS_TRACE_LOGGING
     if (logger)
-        return logger->createTextId(compileOptions);
+        return logger->createTextId(type, compileOptions);
 #endif
     return TraceLogger_Error;
 }
 inline uint32_t TraceLogCreateTextId(TraceLoggerThread *logger, const char *text) {
 #ifdef JS_TRACE_LOGGING
     if (logger)
         return logger->createTextId(text);
 #endif
--- a/js/src/vm/TraceLoggingTypes.h
+++ b/js/src/vm/TraceLoggingTypes.h
@@ -6,16 +6,17 @@
 
 #ifndef TraceLoggingTypes_h
 #define TraceLoggingTypes_h
 
 #include "jsalloc.h"
 #include "jsstr.h"
 
 #define TRACELOGGER_TREE_ITEMS(_)                     \
+    _(AnnotateScripts)                                \
     _(Baseline)                                       \
     _(BaselineCompilation)                            \
     _(Engine)                                         \
     _(GC)                                             \
     _(GCAllocation)                                   \
     _(GCSweeping)                                     \
     _(Internal)                                       \
     _(Interpreter)                                    \