diff --git a/js/src/vm/TraceLoggingGraph.cpp b/js/src/vm/TraceLoggingGraph.cpp index 3abb6da4463..ace93203fba 100644 --- a/js/src/vm/TraceLoggingGraph.cpp +++ b/js/src/vm/TraceLoggingGraph.cpp @@ -114,10 +114,6 @@ TraceLoggerGraphState::nextLoggerId() bool TraceLoggerGraph::init(uint64_t startTimestamp) { - if (!events.init()) { - failed = true; - return false; - } if (!tree.init()) { failed = true; return false; @@ -253,19 +249,6 @@ TraceLoggerGraph::flush() tree.clear(); } - if (eventFile) { - // Format data in big endian - for (size_t i = 0; i < events.size(); i++) { - events[i].time = NativeEndian::swapToBigEndian(events[i].time); - events[i].textId = NativeEndian::swapToBigEndian(events[i].textId); - } - - size_t bytesWritten = fwrite(events.data(), sizeof(EventEntry), events.size(), eventFile); - if (bytesWritten < events.size()) - return false; - events.clear(); - } - return true; } @@ -419,24 +402,33 @@ TraceLoggerGraph::stopEvent(uint64_t timestamp) void TraceLoggerGraph::logTimestamp(uint32_t id, uint64_t timestamp) { + if (failed) + return; + if (id == TraceLogger_Enable) enabled = true; if (!enabled) return; - if (!events.ensureSpaceBeforeAdd()) { - fprintf(stderr, "TraceLogging: Disabled a tracelogger due to OOM.\n"); - enabled = 0; - return; - } - if (id == TraceLogger_Disable) disable(timestamp); - EventEntry &entry = events.pushUninitialized(); - entry.time = timestamp; - entry.textId = id; + MOZ_ASSERT(eventFile); + + // Format data in big endian + timestamp = NativeEndian::swapToBigEndian(timestamp); + id = NativeEndian::swapToBigEndian(id); + + // The layout of the event log in the log file is: + // [timestamp, textId] + size_t itemsWritten = 0; + itemsWritten += fwrite(×tamp, sizeof(uint64_t), 1, eventFile); + itemsWritten += fwrite(&id, sizeof(uint32_t), 1, eventFile); + if (itemsWritten < 2) { + failed = true; + enabled = false; + } } bool diff --git a/js/src/vm/TraceLoggingGraph.h b/js/src/vm/TraceLoggingGraph.h index 94ab926d988..e602454d20b 100644 --- a/js/src/vm/TraceLoggingGraph.h +++ b/js/src/vm/TraceLoggingGraph.h @@ -214,8 +214,6 @@ class TraceLoggerGraph ContinuousSpace stack; uint32_t treeOffset; - ContinuousSpace events; - // Helper functions that convert a TreeEntry in different endianness // in place. void entryToBigEndian(TreeEntry *entry); @@ -239,7 +237,7 @@ class TraceLoggerGraph bool updateNextId(uint32_t treeId, uint32_t nextId); bool updateStop(uint32_t treeId, uint64_t timestamp); - // Flush the tree and events. + // Flush the tree. bool flush(); // Stop a tree event.