Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Unified Diff: src/log.cc

Issue 159787: Add snapshot mode for heap profiling. (Closed)
Patch Set: Reworked to hide explicit GC inside Profiler API Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/api.cc ('K') | « src/log.h ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 0c1b76d7f42d6b3cc4e809517f89dba21f86586a..6c188f45b15f4f189b1479285b3ebc10bf0321da 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -957,38 +957,63 @@ void Logger::TickEvent(TickSample* sample, bool overflow) {
}
-bool Logger::IsProfilerPaused() {
- return profiler_->paused();
+int Logger::GetActiveProfilerModules() {
+ int result = PROFILER_MODULE_NONE;
+ if (!profiler_->paused()) {
+ result |= PROFILER_MODULE_CPU;
+ }
+ if (FLAG_log_gc) {
+ result |= PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS;
+ }
+ return result;
}
-void Logger::PauseProfiler() {
- if (profiler_->paused()) {
- return;
+void Logger::PauseProfiler(int flags) {
+ if (!Log::IsEnabled()) return;
+ const int active_modules = GetActiveProfilerModules();
+ const int modules_to_disable = active_modules & flags;
+ if (modules_to_disable == PROFILER_MODULE_NONE) return;
+
+ if (modules_to_disable & PROFILER_MODULE_CPU) {
+ profiler_->pause();
+ if (FLAG_prof_lazy) {
+ if (!FLAG_sliding_state_window) ticker_->Stop();
+ FLAG_log_code = false;
+ // Must be the same message as Log::kDynamicBufferSeal.
+ LOG(UncheckedStringEvent("profiler", "pause"));
+ }
}
- profiler_->pause();
- if (FLAG_prof_lazy) {
- if (!FLAG_sliding_state_window) ticker_->Stop();
- FLAG_log_code = false;
- // Must be the same message as Log::kDynamicBufferSeal.
- LOG(UncheckedStringEvent("profiler", "pause"));
+ if (modules_to_disable &
+ (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
+ FLAG_log_gc = false;
+ }
+ // Turn off logging if no active modules remain.
+ if (active_modules & ~flags == PROFILER_MODULE_NONE) {
+ is_logging_ = false;
}
- is_logging_ = false;
}
-void Logger::ResumeProfiler() {
- if (!profiler_->paused() || !Log::IsEnabled()) {
- return;
+void Logger::ResumeProfiler(int flags) {
+ if (!Log::IsEnabled()) return;
+ const int modules_to_enable = ~GetActiveProfilerModules() & flags;
+ if (modules_to_enable != PROFILER_MODULE_NONE) {
+ is_logging_ = true;
}
- is_logging_ = true;
- if (FLAG_prof_lazy) {
- LOG(UncheckedStringEvent("profiler", "resume"));
- FLAG_log_code = true;
- LogCompiledFunctions();
- if (!FLAG_sliding_state_window) ticker_->Start();
+ if (modules_to_enable & PROFILER_MODULE_CPU) {
+ if (FLAG_prof_lazy) {
+ LOG(UncheckedStringEvent("profiler", "resume"));
+ FLAG_log_code = true;
+ LogCompiledFunctions();
+ if (!FLAG_sliding_state_window) ticker_->Start();
+ }
+ profiler_->resume();
+ }
+ if (modules_to_enable &
+ (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
+ FLAG_log_gc = true;
}
- profiler_->resume();
}
@@ -996,7 +1021,7 @@ void Logger::ResumeProfiler() {
// either from main or Profiler's thread.
void Logger::StopLoggingAndProfiling() {
Log::stop();
- PauseProfiler();
+ PauseProfiler(PROFILER_MODULE_CPU);
}
« src/api.cc ('K') | « src/log.h ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698