Reviewers: Vitaly Repeshko,
Message:
I think, CPUProfiler should have its own Sampler, but let's first introduce
a
simple fix.
Description:
Fix DevTools CPU profiler after isolates merge.
There was an obvious bug with missing call to SamplerRegistry::GetState.
I've also updated CpuProfiler to avoid stopping sampler, if it didn't
started
it.
[email protected]
BUG=none
TEST=none
Please review this at http://codereview.chromium.org/6712062/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/cpu-profiler.h
M src/cpu-profiler.cc
M src/platform-linux.cc
M src/platform-win32.cc
Index: src/cpu-profiler.cc
diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc
index
c0a2c2b4ffe4ae9e1826c6e29416c1e81abafcf0..7387a4c4f88345712a68ba6a705dcda530de3272
100644
--- a/src/cpu-profiler.cc
+++ b/src/cpu-profiler.cc
@@ -441,6 +441,7 @@ CpuProfiler::CpuProfiler()
token_enumerator_(new TokenEnumerator()),
generator_(NULL),
processor_(NULL),
+ need_to_stop_sampler_(false),
is_profiling_(false) {
}
@@ -486,7 +487,10 @@ void CpuProfiler::StartProcessorIfNotStarted() {
}
// Enable stack sampling.
Sampler* sampler = reinterpret_cast<Sampler*>(LOGGER->ticker_);
- if (!sampler->IsActive()) sampler->Start();
+ if (!sampler->IsActive()) {
+ sampler->Start();
+ need_to_stop_sampler_ = true;
+ }
sampler->IncreaseProfilingDepth();
}
}
@@ -520,7 +524,10 @@ void CpuProfiler::StopProcessorIfLastProfile(const
char* title) {
if (profiles_->IsLastProfile(title)) {
Sampler* sampler = reinterpret_cast<Sampler*>(LOGGER->ticker_);
sampler->DecreaseProfilingDepth();
- sampler->Stop();
+ if (need_to_stop_sampler_) {
+ sampler->Stop();
+ need_to_stop_sampler_ = false;
+ }
processor_->Stop();
processor_->Join();
delete processor_;
Index: src/cpu-profiler.h
diff --git a/src/cpu-profiler.h b/src/cpu-profiler.h
index
9485d0c19709cc97c5c5728283424a541142f61f..b06f6abb3c9df79f1c94ec07d4547ce03d24dc66
100644
--- a/src/cpu-profiler.h
+++ b/src/cpu-profiler.h
@@ -283,6 +283,7 @@ class CpuProfiler {
ProfileGenerator* generator_;
ProfilerEventsProcessor* processor_;
int saved_logging_nesting_;
+ bool need_to_stop_sampler_;
Atomic32 is_profiling_;
#else
Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index
50b0b67d891a3f506fe7243c5d5bc2e92b147423..0624dd97522df40952358af0bec02fca26ee76aa
100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -950,6 +950,7 @@ class SignalSender : public Thread {
}
Sleep(FULL_INTERVAL);
}
+ state = SamplerRegistry::GetState();
}
}
Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index
31b65c1b051171f835f9260af855f3a042b22b31..5704f55c39f7f9f42127ad300cff494dda5ce06e
100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -1931,6 +1931,7 @@ class SamplerThread : public Thread {
}
}
OS::Sleep(interval_);
+ state = SamplerRegistry::GetState();
}
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev