bug 1530011: When calculating event durations, if we reach the end of the event list then use the last event as the end event for any events that remain on the stack r=sfink

An assert occurs while calculating durations whenever we reach the end of the event list and we didn't encounter the TraceLogger_Stop events for events that were still active when the profiler stopped.  The fix is to use the last event as the end event for any remaining events on the stack.

Differential Revision: https://phabricator.services.mozilla.com/D29926

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Denis Palmeiro 2019-05-08 20:49:19 +00:00
Родитель 28355093cb
Коммит dfac78ef7c
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -903,6 +903,24 @@ size_t JS::TraceLoggerDurationImpl::NextChunk(JSContext* cx, size_t* dataIndex,
return 0;
}
}
// If we reach the end of the list, use the last event as the end
// event for all events remaining on the stack.
if (j == events.size() - 1) {
while (!eventStack.empty()) {
uint32_t prev = eventStack.popCopy();
double delta =
(events[j].time - events[prev].time).ToMicroseconds();
if (prev == *dataIndex) {
MOZ_ASSERT(eventStack.empty());
duration = delta;
} else {
if (!eventMap.putNew(prev, delta)) {
return 0;
}
}
}
}
}
}