Backed out changeset 8661c6e4fa51 (bug 1072903)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 21 Nov 2014 08:04:11 +0100
changeset 241094 e25ba08621ea4a681575b4db5c304506122d474a
parent 241093 e76a40473b811c782a6d1ada94dc5a6c07d13d89
child 241095 b09069fd05ef35359fbf8ecaf5397de1f5af1fa6
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)
bugs1072903
milestone36.0a1
backs out8661c6e4fa51801b2fdca7ed6914df421f858a00
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
Backed out changeset 8661c6e4fa51 (bug 1072903)
js/src/vm/TraceLogging.cpp
js/src/vm/TraceLoggingGraph.cpp
js/src/vm/TraceLoggingGraph.h
js/src/vm/TraceLoggingTypes.h
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -125,17 +125,17 @@ TraceLoggerThread::init()
 
     graph.addTextId(TraceLogger_LastTreeItem, "TraceLogger internal");
     for (uint32_t i = TraceLogger_LastTreeItem + 1; i < TraceLogger_Last; i++) {
         TraceLoggerTextId id = TraceLoggerTextId(i);
         graph.addTextId(i, TLTextIdString(id));
     }
 
     enabled = 1;
-    logTimestamp(TraceLogger_Enable);
+    graph.enable();
 
     return true;
 }
 
 TraceLoggerThread::~TraceLoggerThread()
 {
     if (!failed)
         graph.log(events);
@@ -152,18 +152,22 @@ TraceLoggerThread::enable()
     if (enabled > 0) {
         enabled++;
         return true;
     }
 
     if (failed)
         return false;
 
+    // TODO: Remove this. This is so the refactor works with mimimal changes,
+    // It is the intention to remove this by logging TraceLogger_Enable/TraceLogger_Disable.
+    events.clear();
+
     enabled = 1;
-    logTimestamp(TraceLogger_Enable);
+    graph.enable();
 
     return true;
 }
 
 bool
 TraceLoggerThread::enable(JSContext *cx)
 {
     if (!enable())
@@ -224,17 +228,22 @@ TraceLoggerThread::disable()
     if (enabled == 0)
         return true;
 
     if (enabled > 1) {
         enabled--;
         return true;
     }
 
-    logTimestamp(TraceLogger_Disable);
+    graph.log(events);
+    events.clear();
+
+    uint64_t time = rdtsc() - traceLoggers.startupTime;
+    graph.disable(time);
+
     enabled = 0;
 
     return true;
 }
 
 const char *
 TraceLoggerThread::eventText(uint32_t id) {
     if (id < TraceLogger_Last)
--- a/js/src/vm/TraceLoggingGraph.cpp
+++ b/js/src/vm/TraceLoggingGraph.cpp
@@ -372,40 +372,34 @@ TraceLoggerGraph::stopEvent(uint64_t tim
             return;
         }
     }
     if (stack.size() == 1) {
         if (!enabled)
             return;
 
         // Forcefully disable logging. We have no stack information anymore.
-        logTimestamp(TraceLogger_Disable, timestamp);
+        disable(timestamp);
         return;
     }
     stack.pop();
 }
 
 void
 TraceLoggerGraph::logTimestamp(uint32_t id, uint64_t timestamp)
 {
-    if (id == TraceLogger_Enable)
-        enabled = true;
-
     if (!enabled)
         return;
 
     if (!events.ensureSpaceBeforeAdd()) {
         fprintf(stderr, "TraceLogging: Disabled a tracelogger due to OOM.\n");
         enabled = 0;
         return;
     }
 
-    if (id == TraceLogger_Disable)
-        disable(timestamp);
-
     EventEntry &entry = events.pushUninitialized();
     entry.time = timestamp;
     entry.textId = id;
 }
 
 bool
 TraceLoggerGraph::getTreeEntry(uint32_t treeId, TreeEntry *entry)
 {
@@ -490,16 +484,22 @@ TraceLoggerGraph::updateStop(uint32_t tr
         return true;
     }
 
     tree[treeId - treeOffset].setStop(timestamp);
     return true;
 }
 
 void
+TraceLoggerGraph::enable()
+{
+    enabled = true;
+}
+
+void
 TraceLoggerGraph::disable(uint64_t timestamp)
 {
     MOZ_ASSERT(enabled);
     while (stack.size() > 1)
         stopEvent(timestamp);
 
     enabled = false;
 }
--- a/js/src/vm/TraceLoggingGraph.h
+++ b/js/src/vm/TraceLoggingGraph.h
@@ -194,16 +194,20 @@ class TraceLoggerGraph
     bool init(uint64_t timestamp);
 
     // Link a textId with a particular text.
     void addTextId(uint32_t id, const char *text);
 
     // Create a tree out of all the given events.
     void log(ContinuousSpace<EventEntry> &events);
 
+    // Disable/enable the logger.
+    void disable(uint64_t timestamp);
+    void enable();
+
   private:
     bool failed;
     bool enabled;
     mozilla::DebugOnly<uint32_t> nextTextId;
 
     FILE *dictFile;
     FILE *treeFile;
     FILE *eventFile;
@@ -241,15 +245,11 @@ class TraceLoggerGraph
     bool flush();
 
     // Stop a tree event.
     void stopEvent(uint32_t id, uint64_t timestamp);
     void stopEvent(uint64_t timestamp);
 
     // Log an (non-tree) event.
     void logTimestamp(uint32_t id, uint64_t timestamp);
-
-    // Disable logging and forcefully report all not yet stopped tree events
-    // as stopped.
-    void disable(uint64_t timestamp);
 };
 
 #endif /* TraceLoggingGraph_h */
--- a/js/src/vm/TraceLoggingTypes.h
+++ b/js/src/vm/TraceLoggingTypes.h
@@ -52,18 +52,16 @@
     _(EdgeCaseAnalysis)                               \
     _(EliminateRedundantChecks)                       \
     _(GenerateLIR)                                    \
     _(RegisterAllocation)                             \
     _(GenerateCode)
 
 #define TRACELOGGER_LOG_ITEMS(_)                      \
     _(Bailout)                                        \
-    _(Disable)                                        \
-    _(Enable)                                         \
     _(Stop)
 
 // Predefined IDs for common operations. These IDs can be used
 // without using TraceLogCreateTextId, because there are already created.
 enum TraceLoggerTextId {
     TraceLogger_Error = 0,
 #define DEFINE_TEXT_ID(textId) TraceLogger_ ## textId,
     TRACELOGGER_TREE_ITEMS(DEFINE_TEXT_ID)