diff -r cd52a7f89548 js/src/vm/TraceLogging.cpp --- a/js/src/vm/TraceLogging.cpp Thu Jul 17 14:10:32 2014 -0400 +++ b/js/src/vm/TraceLogging.cpp Sat Nov 08 12:30:05 2014 +0100 @@ -106,7 +106,7 @@ char treeFilename[sizeof TRACE_LOG_DIR "tl-tree.100.tl"]; sprintf(treeFilename, TRACE_LOG_DIR "tl-tree.%d.tl", loggerId); - treeFile = fopen(treeFilename, "wb"); + treeFile = fopen(treeFilename, "wb+"); if (!treeFile) { fclose(dictFile); dictFile = nullptr; @@ -280,7 +280,7 @@ if (bytesWritten < tree.size()) return false; - treeOffset += tree.currentId(); + treeOffset += tree.nextId(); tree.clear(); } @@ -466,7 +466,7 @@ { // Entry is still in memory if (treeId >= treeOffset) { - *entry = tree[treeId]; + *entry = tree[treeId - treeOffset]; return true; } @@ -570,8 +570,8 @@ stackEntry.setActive(false); return; } - - if (!tree.ensureSpaceBeforeAdd()) { + + if (tree.sizeBytes() > 100 * 1024 * 1024 || !tree.ensureSpaceBeforeAdd()) { uint64_t start = rdtsc() - traceLoggers.startupTime; if (!flush()) { fprintf(stderr, "TraceLogging: Couldn't write the data to disk.\n"); @@ -633,8 +633,8 @@ #endif if (parent.lastChildId() == 0) { - MOZ_ASSERT(!entry.hasChildren()); - MOZ_ASSERT(parent.treeId() == tree.currentId() + treeOffset); + MOZ_ASSERT_IF(tree.nextId() > 0, parent.treeId() == tree.currentId() + treeOffset); + MOZ_ASSERT_IF(tree.nextId() == 0, parent.treeId() == treeOffset - 1); if (!updateHasChildren(parent.treeId())) return false; diff -r cd52a7f89548 js/src/vm/TraceLogging.h --- a/js/src/vm/TraceLogging.h Thu Jul 17 14:10:32 2014 -0400 +++ b/js/src/vm/TraceLogging.h Sat Nov 08 12:30:05 2014 +0100 @@ -182,6 +182,10 @@ return next_; } + uint32_t sizeBytes() { + return next_ * sizeof(T); + } + uint32_t nextId() { return next_; }