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

Unified Diff: src/platform-macos.cc

Issue 1582004: C++ profiles processor: wire up to VM. (Closed)
Patch Set: Created 10 years, 9 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
Index: src/platform-macos.cc
diff --git a/src/platform-macos.cc b/src/platform-macos.cc
index 45029879f4bcf16cdbaddae2732da971d87582b6..1537ffc914db82fc4cdb8da0f6a1d4488a837b94 100644
--- a/src/platform-macos.cc
+++ b/src/platform-macos.cc
@@ -544,12 +544,18 @@ class Sampler::PlatformData : public Malloced {
// Sampler thread handler.
void Runner() {
- // Loop until the sampler is disengaged.
- while (sampler_->IsActive()) {
- TickSample sample;
+ // Loop until the sampler is disengaged, keeping the specified samling freq.
+ for ( ; sampler_->IsActive(); OS::Sleep(sampler_->interval_)) {
+#ifdef ENABLE_CPP_PROFILES_PROCESSOR
+ if (Logger::state() == GC) continue;
+
+ TickSample* sample = NULL;
+#else
+ TickSample sample_obj, *sample = &sample_obj;
// We always sample the VM state.
- sample.state = Logger::state();
+ sample->state = Logger::state();
+#endif // ENABLE_CPP_PROFILES_PROCESSOR
// If profiling, we record the pc and sp of the profiled thread.
if (sampler_->IsProfiling()
@@ -580,19 +586,23 @@ class Sampler::PlatformData : public Malloced {
flavor,
reinterpret_cast<natural_t*>(&state),
&count) == KERN_SUCCESS) {
- sample.pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
- sample.sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
- sample.fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
- sampler_->SampleStack(&sample);
+#ifdef ENABLE_CPP_PROFILES_PROCESSOR
+ sample = CpuProfiler::TickSampleEvent();
+#endif
+ if (sample != NULL) {
+ sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
+ sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
+ sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
+ sampler_->SampleStack(sample);
+ }
}
thread_resume(profiled_thread_);
}
+#ifndef ENABLE_CPP_PROFILES_PROCESSOR
// Invoke tick handler with program counter and stack pointer.
- sampler_->Tick(&sample);
-
- // Wait until next sampling.
- usleep(sampler_->interval_ * 1000);
+ sampler_->Tick(sample);
+#endif
}
}
};
« src/platform-linux.cc ('K') | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698