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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 SamplerRegistry::State state; | 755 SamplerRegistry::State state; |
756 while ((state = SamplerRegistry::GetState()) != | 756 while ((state = SamplerRegistry::GetState()) != |
757 SamplerRegistry::HAS_NO_SAMPLERS) { | 757 SamplerRegistry::HAS_NO_SAMPLERS) { |
758 // When CPU profiling is enabled both JavaScript and C++ code is | 758 // When CPU profiling is enabled both JavaScript and C++ code is |
759 // profiled. We must not suspend. | 759 // profiled. We must not suspend. |
760 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { | 760 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { |
761 if (!signal_handler_installed_) InstallSignalHandler(); | 761 if (!signal_handler_installed_) InstallSignalHandler(); |
762 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); | 762 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); |
763 } else { | 763 } else { |
764 if (signal_handler_installed_) RestoreSignalHandler(); | 764 if (signal_handler_installed_) RestoreSignalHandler(); |
765 if (rate_limiter_.SuspendIfNecessary()) continue; | 765 if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue; |
766 } | 766 } |
767 Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough. | 767 Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough. |
768 } | 768 } |
769 } | 769 } |
770 | 770 |
771 static void DoCpuProfile(Sampler* sampler, void* raw_sender) { | 771 static void DoCpuProfile(Sampler* sampler, void* raw_sender) { |
772 if (!sampler->IsProfiling()) return; | 772 if (!sampler->IsProfiling()) return; |
773 SignalSender* sender = reinterpret_cast<SignalSender*>(raw_sender); | 773 SignalSender* sender = reinterpret_cast<SignalSender*>(raw_sender); |
774 sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); | 774 sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); |
775 } | 775 } |
(...skipping 14 matching lines...) Expand all Loading... |
790 "SignalSender usleep error; interval = %u, errno = %d\n", | 790 "SignalSender usleep error; interval = %u, errno = %d\n", |
791 interval, | 791 interval, |
792 errno); | 792 errno); |
793 ASSERT(result == 0 || errno == EINTR); | 793 ASSERT(result == 0 || errno == EINTR); |
794 } | 794 } |
795 #endif | 795 #endif |
796 USE(result); | 796 USE(result); |
797 } | 797 } |
798 | 798 |
799 const int interval_; | 799 const int interval_; |
800 RuntimeProfilerRateLimiter rate_limiter_; | |
801 | 800 |
802 // Protects the process wide state below. | 801 // Protects the process wide state below. |
803 static Mutex* mutex_; | 802 static Mutex* mutex_; |
804 static SignalSender* instance_; | 803 static SignalSender* instance_; |
805 static bool signal_handler_installed_; | 804 static bool signal_handler_installed_; |
806 static struct sigaction old_signal_handler_; | 805 static struct sigaction old_signal_handler_; |
807 | 806 |
808 private: | 807 private: |
809 DISALLOW_COPY_AND_ASSIGN(SignalSender); | 808 DISALLOW_COPY_AND_ASSIGN(SignalSender); |
810 }; | 809 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 } | 856 } |
858 | 857 |
859 | 858 |
860 void Sampler::Stop() { | 859 void Sampler::Stop() { |
861 ASSERT(IsActive()); | 860 ASSERT(IsActive()); |
862 SignalSender::RemoveActiveSampler(this); | 861 SignalSender::RemoveActiveSampler(this); |
863 SetActive(false); | 862 SetActive(false); |
864 } | 863 } |
865 | 864 |
866 } } // namespace v8::internal | 865 } } // namespace v8::internal |
OLD | NEW |