Chromium Code Reviews| Index: src/log.cc |
| diff --git a/src/log.cc b/src/log.cc |
| index 0e3f998bdf8b81113c9c60062cca62bc131fd903..39176e85d490663b2bd3a52e9a300be7b9b12bee 100644 |
| --- a/src/log.cc |
| +++ b/src/log.cc |
| @@ -330,6 +330,8 @@ SlidingStateWindow* Logger::sliding_state_window_ = NULL; |
| const char** Logger::log_events_ = NULL; |
| CompressionHelper* Logger::compression_helper_ = NULL; |
| bool Logger::is_logging_ = false; |
| +int Logger::cpu_profiler_nesting_ = 0; |
| +int Logger::heap_profiler_nesting_ = 0; |
| #define DECLARE_LONG_EVENT(ignore1, long_name, ignore2) long_name, |
| const char* kLongLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { |
| @@ -1164,53 +1166,60 @@ int Logger::GetActiveProfilerModules() { |
| } |
| -void Logger::PauseProfiler(int flags) { |
| +void Logger::PauseProfiler(int flags, int tag) { |
| 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")); |
| + if (flags & PROFILER_MODULE_CPU) { |
| + if (--cpu_profiler_nesting_ == 0) { |
|
Søren Thygesen Gjesse
2010/02/17 13:18:26
Maybe make a note that these counters can be both
mnaganov (inactive)
2010/02/17 13:22:50
Done.
|
| + 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 & |
| + if (flags & |
| (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { |
| - FLAG_log_gc = false; |
| + if (--heap_profiler_nesting_ == 0) { |
| + FLAG_log_gc = false; |
| + } |
| } |
| - // Turn off logging if no active modules remain. |
| - if ((active_modules & ~flags) == PROFILER_MODULE_NONE) { |
| + if (tag != 0) { |
| + IntEvent("close-tag", tag); |
| + } |
| + if (GetActiveProfilerModules() == PROFILER_MODULE_NONE) { |
| is_logging_ = false; |
| } |
| } |
| -void Logger::ResumeProfiler(int flags) { |
| +void Logger::ResumeProfiler(int flags, int tag) { |
| if (!Log::IsEnabled()) return; |
| - const int modules_to_enable = ~GetActiveProfilerModules() & flags; |
| - if (modules_to_enable != PROFILER_MODULE_NONE) { |
| - is_logging_ = true; |
| + if (tag != 0) { |
| + IntEvent("open-tag", tag); |
| } |
| - if (modules_to_enable & PROFILER_MODULE_CPU) { |
| - if (FLAG_prof_lazy) { |
| - profiler_->Engage(); |
| - LOG(UncheckedStringEvent("profiler", "resume")); |
| - FLAG_log_code = true; |
| - LogCompiledFunctions(); |
| - LogFunctionObjects(); |
| - LogAccessorCallbacks(); |
| - if (!FLAG_sliding_state_window) ticker_->Start(); |
| + if (flags & PROFILER_MODULE_CPU) { |
| + if (cpu_profiler_nesting_++ == 0) { |
| + is_logging_ = true; |
| + if (FLAG_prof_lazy) { |
| + profiler_->Engage(); |
| + LOG(UncheckedStringEvent("profiler", "resume")); |
| + FLAG_log_code = true; |
| + LogCompiledFunctions(); |
| + LogFunctionObjects(); |
| + LogAccessorCallbacks(); |
| + if (!FLAG_sliding_state_window) ticker_->Start(); |
| + } |
| + profiler_->resume(); |
| } |
| - profiler_->resume(); |
| } |
| - if (modules_to_enable & |
| + if (flags & |
| (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) { |
| - FLAG_log_gc = true; |
| + if (heap_profiler_nesting_++ == 0) { |
| + is_logging_ = true; |
| + FLAG_log_gc = true; |
| + } |
| } |
| } |
| @@ -1219,7 +1228,7 @@ void Logger::ResumeProfiler(int flags) { |
| // either from main or Profiler's thread. |
| void Logger::StopLoggingAndProfiling() { |
| Log::stop(); |
| - PauseProfiler(PROFILER_MODULE_CPU); |
| + PauseProfiler(PROFILER_MODULE_CPU, 0); |
| } |