Bug 996285 - Profiler stops duplicating samples during sleeping periods after buffer wraps. r=benwa

This commit is contained in:
Viktor Stanchev 2014-04-21 11:46:48 -04:00
Родитель d407cd825b
Коммит 0f296aff8a
1 изменённых файлов: 8 добавлений и 6 удалений

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

@ -462,13 +462,15 @@ mozilla::Mutex* ThreadProfile::GetMutex()
void ThreadProfile::DuplicateLastSample() {
// Scan the whole buffer (even unflushed parts)
// we add mEntrySize to mReadPos to make sure that when
// we wrap around the result is mEntrySize-1 and not -1
for (int readPos = mWritePos; readPos != (mReadPos + mEntrySize - 1) % mEntrySize; readPos = (readPos + mEntrySize - 1) % mEntrySize) {
// Found the start of the last entry at position i
// Adding mEntrySize makes the result of the modulus positive
// We search backwards from mWritePos-1 to mReadPos
for (int readPos = (mWritePos + mEntrySize - 1) % mEntrySize;
readPos != (mReadPos + mEntrySize - 1) % mEntrySize;
readPos = (readPos + mEntrySize - 1) % mEntrySize) {
if (mEntries[readPos].mTagName == 's') {
// Found the start of the last entry at position readPos
int copyEndIdx = mWritePos;
// Go through the whole entry and duplicate it using a simple state machine
// Go through the whole entry and duplicate it
for (;readPos != copyEndIdx; readPos = (readPos + 1) % mEntrySize) {
switch (mEntries[readPos].mTagName) {
// Copy with new time
@ -479,7 +481,7 @@ void ThreadProfile::DuplicateLastSample() {
case 'm':
break;
// Copy anything else we don't know about
// L, B, S, m, c, s, d, l, f, h, r, t, p
// L, B, S, c, s, d, l, f, h, r, t, p
default:
addTag(mEntries[readPos]);
break;