From 27d80810714da801f749e6b6b0917282caaab788 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Thu, 20 Nov 2014 17:44:01 +0100 Subject: [PATCH] Bug 1072903 - TraceLogger: Part 5: Log whenever tracelogger gets enabled or disabled, r=bbouvier --- js/src/vm/TraceLogging.cpp | 15 +++------------ js/src/vm/TraceLoggingGraph.cpp | 14 +++++++------- js/src/vm/TraceLoggingGraph.h | 8 ++++---- js/src/vm/TraceLoggingTypes.h | 2 ++ 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/js/src/vm/TraceLogging.cpp b/js/src/vm/TraceLogging.cpp index 64f971ef6d2..adee34b5e80 100644 --- a/js/src/vm/TraceLogging.cpp +++ b/js/src/vm/TraceLogging.cpp @@ -130,7 +130,7 @@ TraceLoggerThread::init() } enabled = 1; - graph.enable(); + logTimestamp(TraceLogger_Enable); return true; } @@ -157,12 +157,8 @@ TraceLoggerThread::enable() if (failed) return false; - // TODO: Remove this. This is so the refactor works with mimimal changes, - // It is the intention to remove this by logging TraceLogger_Enable/TraceLogger_Disable. - events.clear(); - enabled = 1; - graph.enable(); + logTimestamp(TraceLogger_Enable); return true; } @@ -233,12 +229,7 @@ TraceLoggerThread::disable() return true; } - graph.log(events); - events.clear(); - - uint64_t time = rdtsc() - traceLoggers.startupTime; - graph.disable(time); - + logTimestamp(TraceLogger_Disable); enabled = 0; return true; diff --git a/js/src/vm/TraceLoggingGraph.cpp b/js/src/vm/TraceLoggingGraph.cpp index 5049e69f705..57712b231e0 100644 --- a/js/src/vm/TraceLoggingGraph.cpp +++ b/js/src/vm/TraceLoggingGraph.cpp @@ -377,7 +377,7 @@ TraceLoggerGraph::stopEvent(uint64_t timestamp) return; // Forcefully disable logging. We have no stack information anymore. - disable(timestamp); + logTimestamp(TraceLogger_Disable, timestamp); return; } stack.pop(); @@ -386,6 +386,9 @@ TraceLoggerGraph::stopEvent(uint64_t timestamp) void TraceLoggerGraph::logTimestamp(uint32_t id, uint64_t timestamp) { + if (id == TraceLogger_Enable) + enabled = true; + if (!enabled) return; @@ -395,6 +398,9 @@ TraceLoggerGraph::logTimestamp(uint32_t id, uint64_t timestamp) return; } + if (id == TraceLogger_Disable) + disable(timestamp); + EventEntry &entry = events.pushUninitialized(); entry.time = timestamp; entry.textId = id; @@ -488,12 +494,6 @@ TraceLoggerGraph::updateStop(uint32_t treeId, uint64_t timestamp) return true; } -void -TraceLoggerGraph::enable() -{ - enabled = true; -} - void TraceLoggerGraph::disable(uint64_t timestamp) { diff --git a/js/src/vm/TraceLoggingGraph.h b/js/src/vm/TraceLoggingGraph.h index 394d801eb8e..101ab6f018b 100644 --- a/js/src/vm/TraceLoggingGraph.h +++ b/js/src/vm/TraceLoggingGraph.h @@ -199,10 +199,6 @@ class TraceLoggerGraph // Create a tree out of all the given events. void log(ContinuousSpace &events); - // Disable/enable the logger. - void disable(uint64_t timestamp); - void enable(); - private: bool failed; bool enabled; @@ -250,6 +246,10 @@ class TraceLoggerGraph // Log an (non-tree) event. void logTimestamp(uint32_t id, uint64_t timestamp); + + // Disable logging and forcefully report all not yet stopped tree events + // as stopped. + void disable(uint64_t timestamp); }; #endif /* TraceLoggingGraph_h */ diff --git a/js/src/vm/TraceLoggingTypes.h b/js/src/vm/TraceLoggingTypes.h index 87b488d8a3b..4c8ac0ed920 100644 --- a/js/src/vm/TraceLoggingTypes.h +++ b/js/src/vm/TraceLoggingTypes.h @@ -57,6 +57,8 @@ #define TRACELOGGER_LOG_ITEMS(_) \ _(Bailout) \ + _(Disable) \ + _(Enable) \ _(Stop) // Predefined IDs for common operations. These IDs can be used