Bug 1259403 - Tracelogger: Always make sure there are 3 free slots for events, r=bbouvier
authorHannes Verschore <hv1989@gmail.com>
Fri, 08 Apr 2016 05:47:30 -0400
changeset 316194 63f538a4fbce77dd0ac9c1dd115bb3c2cfc72ae1
parent 316193 f12e5d7ee596136dfc274d523c0c36236eb91013
child 316195 f4c7add07dc60592f5d6a77ccc54f92bb3684e6c
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1259403
milestone48.0a1
Bug 1259403 - Tracelogger: Always make sure there are 3 free slots for events, r=bbouvier
js/src/vm/TraceLogging.cpp
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -530,20 +530,24 @@ TraceLoggerThread::logTimestamp(uint32_t
 
 void
 TraceLoggerThread::log(uint32_t id)
 {
     if (enabled == 0)
         return;
 
     MOZ_ASSERT(traceLoggerState);
-    if (!events.hasSpaceForAdd()) {
+
+    // We request for 3 items to add, since if we don't have enough room
+    // we record the time it took to make more place. To log this information
+    // we need 2 extra free entries.
+    if (!events.hasSpaceForAdd(3)) {
         uint64_t start = rdtsc() - traceLoggerState->startupTime;
 
-        if (!events.ensureSpaceBeforeAdd()) {
+        if (!events.ensureSpaceBeforeAdd(3)) {
             if (graph.get())
                 graph->log(events);
 
             iteration_++;
             events.clear();
 
             // Remove the item in the pointerMap for which the payloads
             // have no uses anymore
@@ -565,17 +569,17 @@ TraceLoggerThread::log(uint32_t id)
                     e.removeFront();
                 }
             }
         }
 
         // Log the time it took to flush the events as being from the
         // Tracelogger.
         if (graph.get()) {
-            MOZ_ASSERT(events.capacity() > 2);
+            MOZ_ASSERT(events.hasSpaceForAdd(2));
             EventEntry& entryStart = events.pushUninitialized();
             entryStart.time = start;
             entryStart.textId = TraceLogger_Internal;
 
             EventEntry& entryStop = events.pushUninitialized();
             entryStop.time = rdtsc() - traceLoggerState->startupTime;
             entryStop.textId = TraceLogger_Stop;
         }