Bug 1298541: Tracelogger: Part 1: Add debugging to check start and stop correspond, r=bbouvier
authorHannes Verschore <hv1989@gmail.com>
Fri, 02 Sep 2016 18:19:27 +0200
changeset 312532 9bf32cd7b3e5c9c06cf56fd65f070b318de36193
parent 312531 2ecd402d39348717259f7f6f2f07be3f947c1e30
child 312533 f352fb065d2e2d88b4201571e8fa0b764d3b5136
push id30646
push userryanvm@gmail.com
push dateSat, 03 Sep 2016 15:33:40 +0000
treeherdermozilla-central@1789229965bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1298541
milestone51.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 1298541: Tracelogger: Part 1: Add debugging to check start and stop correspond, r=bbouvier
js/src/vm/TraceLogging.cpp
js/src/vm/TraceLogging.h
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -486,16 +486,24 @@ TraceLoggerThread::startEvent(const Trac
 void
 TraceLoggerThread::startEvent(uint32_t id)
 {
     MOZ_ASSERT(TLTextIdIsTreeEvent(id) || id == TraceLogger_Error);
     MOZ_ASSERT(traceLoggerState);
     if (!traceLoggerState->isTextIdEnabled(id))
        return;
 
+#ifdef DEBUG
+    if (enabled > 0) {
+        AutoEnterOOMUnsafeRegion oomUnsafe;
+        if (!graphStack.append(id))
+            oomUnsafe.crash("Could not add item to debug stack.");
+    }
+#endif
+
     log(id);
 }
 
 void
 TraceLoggerThread::stopEvent(TraceLoggerTextId id) {
     stopEvent(uint32_t(id));
 }
 
@@ -511,16 +519,33 @@ TraceLoggerThread::stopEvent(const Trace
 void
 TraceLoggerThread::stopEvent(uint32_t id)
 {
     MOZ_ASSERT(TLTextIdIsTreeEvent(id) || id == TraceLogger_Error);
     MOZ_ASSERT(traceLoggerState);
     if (!traceLoggerState->isTextIdEnabled(id))
         return;
 
+#ifdef DEBUG
+    if (enabled > 0) {
+        uint32_t prev = graphStack.popCopy();
+        if (id == TraceLogger_Engine) {
+            MOZ_ASSERT(prev == TraceLogger_IonMonkey || prev == TraceLogger_Baseline ||
+                       prev == TraceLogger_Interpreter);
+        } else if (id == TraceLogger_Scripts) {
+            MOZ_ASSERT(prev >= TraceLogger_Last);
+        } else if (id >= TraceLogger_Last) {
+            MOZ_ASSERT(prev >= TraceLogger_Last);
+            MOZ_ASSERT_IF(prev != id, strcmp(eventText(id), eventText(prev)) == 0);
+        } else {
+            MOZ_ASSERT(id == prev);
+        }
+    }
+#endif
+
     log(TraceLogger_Stop);
 }
 
 void
 TraceLoggerThread::logTimestamp(TraceLoggerTextId id)
 {
     logTimestamp(uint32_t(id));
 }
--- a/js/src/vm/TraceLogging.h
+++ b/js/src/vm/TraceLogging.h
@@ -178,16 +178,21 @@ class TraceLoggerThread
 
     ContinuousSpace<EventEntry> events;
 
     // Every time the events get flushed, this count is increased by one.
     // Together with events.lastEntryId(), this gives an unique id for every
     // event.
     uint32_t iteration_;
 
+#ifdef DEBUG
+    typedef Vector<uint32_t, 1, js::SystemAllocPolicy > GraphStack;
+    GraphStack graphStack;
+#endif
+
   public:
     AutoTraceLog* top;
 
     TraceLoggerThread()
       : enabled(0),
         failed(false),
         graph(),
         nextTextId(TraceLogger_Last),