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

Unified Diff: src/log.cc

Issue 340013: Fix crbug/24815. Changes affect profiler "lazy" mode used for V8 in Chromium. (Closed)
Patch Set: Comments addressed Created 11 years, 2 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
« no previous file with comments | « no previous file | 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 d1d9a31e49b1b76a8201f9a13d8849a2f9bc299d..2e7796a7ac09021843a2bd79f0df0f37de28b1a6 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -125,6 +125,9 @@ class Profiler: public Thread {
bool overflow_; // Tell whether a buffer overflow has occurred.
Semaphore* buffer_semaphore_; // Sempahore used for buffer synchronization.
+ // Tells whether profiler is engaged, that is, processing thread is stated.
+ bool engaged_;
+
// Tells whether worker thread should continue running.
bool running_;
@@ -243,17 +246,25 @@ void SlidingStateWindow::AddState(StateTag state) {
//
// Profiler implementation.
//
-Profiler::Profiler() {
- buffer_semaphore_ = OS::CreateSemaphore(0);
- head_ = 0;
- tail_ = 0;
- overflow_ = false;
- running_ = false;
+Profiler::Profiler()
+ : head_(0),
+ tail_(0),
+ overflow_(false),
+ buffer_semaphore_(OS::CreateSemaphore(0)),
+ engaged_(false),
+ running_(false) {
}
void Profiler::Engage() {
- OS::LogSharedLibraryAddresses();
+ if (engaged_) return;
+ engaged_ = true;
+
+ // TODO(mnaganov): This is actually "Chromium" mode. Flags need to be revised.
+ // http://code.google.com/p/v8/issues/detail?id=487
+ if (!FLAG_prof_lazy) {
+ OS::LogSharedLibraryAddresses();
+ }
// Start thread processing the profiler buffer.
running_ = true;
@@ -268,6 +279,8 @@ void Profiler::Engage() {
void Profiler::Disengage() {
+ if (!engaged_) return;
+
// Stop receiving ticks.
Logger::ticker_->ClearProfiler();
@@ -1053,6 +1066,7 @@ void Logger::ResumeProfiler(int flags) {
}
if (modules_to_enable & PROFILER_MODULE_CPU) {
if (FLAG_prof_lazy) {
+ profiler_->Engage();
LOG(UncheckedStringEvent("profiler", "resume"));
FLAG_log_code = true;
LogCompiledFunctions();
@@ -1245,7 +1259,9 @@ bool Logger::Setup() {
} else {
is_logging_ = true;
}
- profiler_->Engage();
+ if (!FLAG_prof_lazy) {
+ profiler_->Engage();
+ }
}
LogMessageBuilder::set_write_failure_handler(StopLoggingAndProfiling);
« no previous file with comments | « no previous file | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698