Index: src/platform-linux.cc |
diff --git a/src/platform-linux.cc b/src/platform-linux.cc |
index cd7bcb12655c35f4d8eb75e67eda1e662628933d..0e463114005f67c004af9c15ff0eb603b62f15a7 100644 |
--- a/src/platform-linux.cc |
+++ b/src/platform-linux.cc |
@@ -727,44 +727,61 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { |
if (signal != SIGPROF) return; |
if (active_sampler_ == NULL) return; |
- TickSample sample; |
+#ifdef ENABLE_CPP_PROFILES_PROCESSOR |
+ if (Logger::state() == GC || !IsVmThread()) return; |
+ |
+ TickSample* sample = NULL; |
+#else |
+ TickSample sample_obj, *sample = &sample_obj; |
Kevin Millikin (Chromium)
2010/04/06 09:10:47
This is probably better as:
TickSample sample_obj
mnaganov (inactive)
2010/04/06 10:31:42
Done.
|
// We always sample the VM state. |
- sample.state = Logger::state(); |
+ sample->state = Logger::state(); |
+#endif |
// If profiling, we extract the current pc and sp. |
if (active_sampler_->IsProfiling()) { |
// Extracting the sample from the context is extremely machine dependent. |
ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
mcontext_t& mcontext = ucontext->uc_mcontext; |
+#ifdef ENABLE_CPP_PROFILES_PROCESSOR |
+ sample = CpuProfiler::TickSampleEvent(); |
+#endif |
+ if (sample != NULL) { |
#if V8_HOST_ARCH_IA32 |
- sample.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
- sample.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
- sample.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
+ sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
+ sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
+ sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
#elif V8_HOST_ARCH_X64 |
- sample.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); |
- sample.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); |
- sample.fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); |
+ sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); |
+ sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); |
+ sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); |
#elif V8_HOST_ARCH_ARM |
// An undefined macro evaluates to 0, so this applies to Android's Bionic also. |
#if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
- sample.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
- sample.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
- sample.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
+ sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
+ sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
+ sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
#else |
- sample.pc = reinterpret_cast<Address>(mcontext.arm_pc); |
- sample.sp = reinterpret_cast<Address>(mcontext.arm_sp); |
- sample.fp = reinterpret_cast<Address>(mcontext.arm_fp); |
+ sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); |
+ sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); |
+ sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); |
#endif |
#elif V8_HOST_ARCH_MIPS |
// Implement this on MIPS. |
- UNIMPLEMENTED(); |
+ UNIMPLEMENTED(); |
+#endif |
+#ifdef ENABLE_CPP_PROFILES_PROCESSOR |
Søren Thygesen Gjesse
2010/04/06 10:37:43
If this #ifdef block needed? From above IsVmThread
mnaganov (inactive)
2010/04/06 11:44:52
Right, not needed actually. I will remove it in my
|
+ active_sampler_->SampleStack(sample); |
+#else |
+ if (IsVmThread()) { |
+ active_sampler_->SampleStack(sample); |
+ } |
#endif |
- if (IsVmThread()) |
- active_sampler_->SampleStack(&sample); |
+ } |
} |
- |
- active_sampler_->Tick(&sample); |
+#ifndef ENABLE_CPP_PROFILES_PROCESSOR |
+ active_sampler_->Tick(sample); |
+#endif |
#endif |
} |