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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // Implement Thread::Run(). | 760 // Implement Thread::Run(). |
761 virtual void Run() { | 761 virtual void Run() { |
762 SamplerRegistry::State state; | 762 SamplerRegistry::State state; |
763 while ((state = SamplerRegistry::GetState()) != | 763 while ((state = SamplerRegistry::GetState()) != |
764 SamplerRegistry::HAS_NO_SAMPLERS) { | 764 SamplerRegistry::HAS_NO_SAMPLERS) { |
765 // When CPU profiling is enabled both JavaScript and C++ code is | 765 // When CPU profiling is enabled both JavaScript and C++ code is |
766 // profiled. We must not suspend. | 766 // profiled. We must not suspend. |
767 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { | 767 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { |
768 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); | 768 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); |
769 } else { | 769 } else { |
770 if (rate_limiter_.SuspendIfNecessary()) continue; | 770 if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue; |
771 } | 771 } |
772 Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough. | 772 Sleep(); // TODO(svenpanne) Figure out if OS:Sleep(interval_) is enough. |
773 } | 773 } |
774 } | 774 } |
775 | 775 |
776 static void DoCpuProfile(Sampler* sampler, void* raw_sender) { | 776 static void DoCpuProfile(Sampler* sampler, void* raw_sender) { |
777 if (!sampler->IsProfiling()) return; | 777 if (!sampler->IsProfiling()) return; |
778 SignalSender* sender = reinterpret_cast<SignalSender*>(raw_sender); | 778 SignalSender* sender = reinterpret_cast<SignalSender*>(raw_sender); |
779 sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); | 779 sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); |
780 } | 780 } |
(...skipping 14 matching lines...) Expand all Loading... |
795 "SignalSender usleep error; interval = %u, errno = %d\n", | 795 "SignalSender usleep error; interval = %u, errno = %d\n", |
796 interval, | 796 interval, |
797 errno); | 797 errno); |
798 ASSERT(result == 0 || errno == EINTR); | 798 ASSERT(result == 0 || errno == EINTR); |
799 } | 799 } |
800 #endif | 800 #endif |
801 USE(result); | 801 USE(result); |
802 } | 802 } |
803 | 803 |
804 const int interval_; | 804 const int interval_; |
805 RuntimeProfilerRateLimiter rate_limiter_; | |
806 | 805 |
807 // Protects the process wide state below. | 806 // Protects the process wide state below. |
808 static Mutex* mutex_; | 807 static Mutex* mutex_; |
809 static SignalSender* instance_; | 808 static SignalSender* instance_; |
810 static bool signal_handler_installed_; | 809 static bool signal_handler_installed_; |
811 static struct sigaction old_signal_handler_; | 810 static struct sigaction old_signal_handler_; |
812 | 811 |
813 private: | 812 private: |
814 DISALLOW_COPY_AND_ASSIGN(SignalSender); | 813 DISALLOW_COPY_AND_ASSIGN(SignalSender); |
815 }; | 814 }; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 | 862 |
864 | 863 |
865 void Sampler::Stop() { | 864 void Sampler::Stop() { |
866 ASSERT(IsActive()); | 865 ASSERT(IsActive()); |
867 SignalSender::RemoveActiveSampler(this); | 866 SignalSender::RemoveActiveSampler(this); |
868 SetActive(false); | 867 SetActive(false); |
869 } | 868 } |
870 | 869 |
871 | 870 |
872 } } // namespace v8::internal | 871 } } // namespace v8::internal |
OLD | NEW |