OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 SamplerRegistry::State state; | 839 SamplerRegistry::State state; |
840 while ((state = SamplerRegistry::GetState()) != | 840 while ((state = SamplerRegistry::GetState()) != |
841 SamplerRegistry::HAS_NO_SAMPLERS) { | 841 SamplerRegistry::HAS_NO_SAMPLERS) { |
842 // When CPU profiling is enabled both JavaScript and C++ code is | 842 // When CPU profiling is enabled both JavaScript and C++ code is |
843 // profiled. We must not suspend. | 843 // profiled. We must not suspend. |
844 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { | 844 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { |
845 if (!signal_handler_installed_) InstallSignalHandler(); | 845 if (!signal_handler_installed_) InstallSignalHandler(); |
846 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); | 846 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); |
847 } else { | 847 } else { |
848 if (signal_handler_installed_) RestoreSignalHandler(); | 848 if (signal_handler_installed_) RestoreSignalHandler(); |
849 if (rate_limiter_.SuspendIfNecessary()) continue; | 849 if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue; |
850 } | 850 } |
851 Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough. | 851 Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough. |
852 } | 852 } |
853 } | 853 } |
854 | 854 |
855 static void DoCpuProfile(Sampler* sampler, void* raw_sender) { | 855 static void DoCpuProfile(Sampler* sampler, void* raw_sender) { |
856 if (!sampler->IsProfiling()) return; | 856 if (!sampler->IsProfiling()) return; |
857 SignalSender* sender = reinterpret_cast<SignalSender*>(raw_sender); | 857 SignalSender* sender = reinterpret_cast<SignalSender*>(raw_sender); |
858 sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); | 858 sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); |
859 } | 859 } |
(...skipping 15 matching lines...) Expand all Loading... |
875 interval, | 875 interval, |
876 errno); | 876 errno); |
877 ASSERT(result == 0 || errno == EINTR); | 877 ASSERT(result == 0 || errno == EINTR); |
878 } | 878 } |
879 #endif | 879 #endif |
880 USE(result); | 880 USE(result); |
881 } | 881 } |
882 | 882 |
883 const int vm_tgid_; | 883 const int vm_tgid_; |
884 const int interval_; | 884 const int interval_; |
885 RuntimeProfilerRateLimiter rate_limiter_; | |
886 | 885 |
887 // Protects the process wide state below. | 886 // Protects the process wide state below. |
888 static Mutex* mutex_; | 887 static Mutex* mutex_; |
889 static SignalSender* instance_; | 888 static SignalSender* instance_; |
890 static bool signal_handler_installed_; | 889 static bool signal_handler_installed_; |
891 static struct sigaction old_signal_handler_; | 890 static struct sigaction old_signal_handler_; |
892 | 891 |
893 private: | 892 private: |
894 DISALLOW_COPY_AND_ASSIGN(SignalSender); | 893 DISALLOW_COPY_AND_ASSIGN(SignalSender); |
895 }; | 894 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 | 939 |
941 | 940 |
942 void Sampler::Stop() { | 941 void Sampler::Stop() { |
943 ASSERT(IsActive()); | 942 ASSERT(IsActive()); |
944 SignalSender::RemoveActiveSampler(this); | 943 SignalSender::RemoveActiveSampler(this); |
945 SetActive(false); | 944 SetActive(false); |
946 } | 945 } |
947 | 946 |
948 | 947 |
949 } } // namespace v8::internal | 948 } } // namespace v8::internal |
OLD | NEW |