Index: src/log.cc |
diff --git a/src/log.cc b/src/log.cc |
index 3d3cd2d262b9604502283bf10eee1db34026e977..bda2038c658af99027567be6b32c22df0ff8ba00 100644 |
--- a/src/log.cc |
+++ b/src/log.cc |
@@ -178,7 +178,7 @@ class Ticker: public Sampler { |
void SetWindow(SlidingStateWindow* window) { |
window_ = window; |
- if (!IsActive()) Start(); |
+ if (!FLAG_prof_lazy && !IsActive()) Start(); |
Søren Thygesen Gjesse
2009/05/25 07:09:15
I am not sure about this handling of the prof_lazy
Mikhail Naganov
2009/05/25 08:23:43
That's an important thing to know, thanks for noti
|
} |
void ClearWindow() { |
@@ -188,7 +188,7 @@ class Ticker: public Sampler { |
void SetProfiler(Profiler* profiler) { |
profiler_ = profiler; |
- if (!IsActive()) Start(); |
+ if (!FLAG_prof_lazy && !IsActive()) Start(); |
} |
void ClearProfiler() { |
@@ -267,6 +267,8 @@ void Profiler::Disengage() { |
// the thread to terminate. |
running_ = false; |
TickSample sample; |
+ // Reset 'paused_' flag, otherwise semaphore may not be signalled. |
+ resume(); |
Insert(&sample); |
Join(); |
@@ -1096,14 +1098,30 @@ bool Logger::IsProfilerPaused() { |
void Logger::PauseProfiler() { |
profiler_->pause(); |
+ if (FLAG_prof_lazy) { |
+ ticker_->Stop(); |
+ FLAG_log_code = false; |
+ LOG(UncheckedStringEvent("profiler", "pause")); |
+ } |
} |
void Logger::ResumeProfiler() { |
+ if (FLAG_prof_lazy) { |
+ LOG(UncheckedStringEvent("profiler", "resume")); |
+ FLAG_log_code = true; |
+ LogCompiledFunctions(); |
+ ticker_->Start(); |
+ } |
profiler_->resume(); |
} |
+bool Logger::IsProfilerSamplerActive() { |
+ return ticker_->IsActive(); |
+} |
+ |
+ |
int Logger::GetLogLines(int from_pos, char* dest_buf, int max_size) { |
return Log::GetLogLines(from_pos, dest_buf, max_size); |
} |
@@ -1190,9 +1208,15 @@ bool Logger::Setup() { |
// --prof implies --log-code. |
if (FLAG_prof) FLAG_log_code = true; |
+ // --prof_lazy controls --log-code, implies --noprof_auto. |
+ if (FLAG_prof_lazy) { |
+ FLAG_log_code = false; |
+ FLAG_prof_auto = false; |
+ } |
+ |
bool open_log_file = FLAG_log || FLAG_log_runtime || FLAG_log_api |
|| FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect |
- || FLAG_log_regexp || FLAG_log_state_changes; |
+ || FLAG_log_regexp || FLAG_log_state_changes || FLAG_prof_lazy; |
// If we're logging anything, we need to open the log file. |
if (open_log_file) { |
@@ -1277,8 +1301,10 @@ void Logger::TearDown() { |
} |
delete sliding_state_window_; |
+ sliding_state_window_ = NULL; |
delete ticker_; |
+ ticker_ = NULL; |
Log::Close(); |
#endif |