diff options
Diffstat (limited to 'deps/v8/src/platform-linux.cc')
-rw-r--r-- | deps/v8/src/platform-linux.cc | 57 |
1 files changed, 45 insertions, 12 deletions
diff --git a/deps/v8/src/platform-linux.cc b/deps/v8/src/platform-linux.cc index 7a186413b..beb2ccee2 100644 --- a/deps/v8/src/platform-linux.cc +++ b/deps/v8/src/platform-linux.cc @@ -722,11 +722,6 @@ bool VirtualMemory::ReleaseRegion(void* base, size_t size) { } -bool VirtualMemory::HasLazyCommits() { - return true; -} - - class Thread::PlatformData : public Malloced { public: PlatformData() : thread_(kNoThread) {} @@ -1091,6 +1086,11 @@ class Sampler::PlatformData : public Malloced { class SignalSender : public Thread { public: + enum SleepInterval { + HALF_INTERVAL, + FULL_INTERVAL + }; + static const int kSignalSenderStackSize = 64 * KB; explicit SignalSender(int interval) @@ -1146,16 +1146,43 @@ class SignalSender : public Thread { SamplerRegistry::State state; while ((state = SamplerRegistry::GetState()) != SamplerRegistry::HAS_NO_SAMPLERS) { + bool cpu_profiling_enabled = + (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS); + bool runtime_profiler_enabled = RuntimeProfiler::IsEnabled(); + if (cpu_profiling_enabled && !signal_handler_installed_) { + InstallSignalHandler(); + } else if (!cpu_profiling_enabled && signal_handler_installed_) { + RestoreSignalHandler(); + } // When CPU profiling is enabled both JavaScript and C++ code is // profiled. We must not suspend. - if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { - if (!signal_handler_installed_) InstallSignalHandler(); - SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); - } else { - if (signal_handler_installed_) RestoreSignalHandler(); + if (!cpu_profiling_enabled) { if (rate_limiter_.SuspendIfNecessary()) continue; } - Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough. + if (cpu_profiling_enabled && runtime_profiler_enabled) { + if (!SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this)) { + return; + } + Sleep(HALF_INTERVAL); + if (!SamplerRegistry::IterateActiveSamplers(&DoRuntimeProfile, NULL)) { + return; + } + Sleep(HALF_INTERVAL); + } else { + if (cpu_profiling_enabled) { + if (!SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, + this)) { + return; + } + } + if (runtime_profiler_enabled) { + if (!SamplerRegistry::IterateActiveSamplers(&DoRuntimeProfile, + NULL)) { + return; + } + } + Sleep(FULL_INTERVAL); + } } } @@ -1165,6 +1192,11 @@ class SignalSender : public Thread { sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); } + static void DoRuntimeProfile(Sampler* sampler, void* ignored) { + if (!sampler->isolate()->IsInitialized()) return; + sampler->isolate()->runtime_profiler()->NotifyTick(); + } + void SendProfilingSignal(int tid) { if (!signal_handler_installed_) return; // Glibc doesn't provide a wrapper for tgkill(2). @@ -1175,10 +1207,11 @@ class SignalSender : public Thread { #endif } - void Sleep() { + void Sleep(SleepInterval full_or_half) { // Convert ms to us and subtract 100 us to compensate delays // occuring during signal delivery. useconds_t interval = interval_ * 1000 - 100; + if (full_or_half == HALF_INTERVAL) interval /= 2; #if defined(ANDROID) usleep(interval); #else |