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

Unified Diff: src/platform-win32.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-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index 48f306d4eab37970bae6ceef1083a6977de3a879..2666cc04bc4e2f1159c313f179884ac712142811 100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -1803,37 +1803,47 @@ class Sampler::PlatformData : public Malloced {
// Context used for sampling the register state of the profiled thread.
CONTEXT context;
memset(&context, 0, sizeof(context));
- // 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(); 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()
&& SuspendThread(profiled_thread_) != (DWORD)-1) {
context.ContextFlags = CONTEXT_FULL;
if (GetThreadContext(profiled_thread_, &context) != 0) {
+#ifdef ENABLE_CPP_PROFILES_PROCESSOR
+ sample = CpuProfiler::TickSampleEvent();
+#endif
+ if (sample != NULL) {
#if V8_HOST_ARCH_X64
- sample.pc = reinterpret_cast<Address>(context.Rip);
- sample.sp = reinterpret_cast<Address>(context.Rsp);
- sample.fp = reinterpret_cast<Address>(context.Rbp);
+ sample->pc = reinterpret_cast<Address>(context.Rip);
+ sample->sp = reinterpret_cast<Address>(context.Rsp);
+ sample->fp = reinterpret_cast<Address>(context.Rbp);
#else
- sample.pc = reinterpret_cast<Address>(context.Eip);
- sample.sp = reinterpret_cast<Address>(context.Esp);
- sample.fp = reinterpret_cast<Address>(context.Ebp);
+ sample->pc = reinterpret_cast<Address>(context.Eip);
+ sample->sp = reinterpret_cast<Address>(context.Esp);
+ sample->fp = reinterpret_cast<Address>(context.Ebp);
#endif
- sampler_->SampleStack(&sample);
+ sampler_->SampleStack(sample);
+ }
}
ResumeThread(profiled_thread_);
}
+#ifndef ENABLE_CPP_PROFILES_PROCESSOR
// Invoke tick handler with program counter and stack pointer.
- sampler_->Tick(&sample);
-
- // Wait until next sampling.
- Sleep(sampler_->interval_);
+ sampler_->Tick(sample);
+#endif
}
}
};
« src/platform-linux.cc ('K') | « src/platform-macos.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698