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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 instance_->StartSynchronously(); | 780 instance_->StartSynchronously(); |
781 } else { | 781 } else { |
782 ASSERT(instance_->interval_ == sampler->interval()); | 782 ASSERT(instance_->interval_ == sampler->interval()); |
783 } | 783 } |
784 } | 784 } |
785 | 785 |
786 static void RemoveActiveSampler(Sampler* sampler) { | 786 static void RemoveActiveSampler(Sampler* sampler) { |
787 ScopedLock lock(mutex_); | 787 ScopedLock lock(mutex_); |
788 SamplerRegistry::RemoveActiveSampler(sampler); | 788 SamplerRegistry::RemoveActiveSampler(sampler); |
789 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { | 789 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { |
790 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_); | 790 instance_->Join(); |
791 delete instance_; | 791 delete instance_; |
792 instance_ = NULL; | 792 instance_ = NULL; |
793 } | 793 } |
794 } | 794 } |
795 | 795 |
796 // Implement Thread::Run(). | 796 // Implement Thread::Run(). |
797 virtual void Run() { | 797 virtual void Run() { |
798 SamplerRegistry::State state; | 798 SamplerRegistry::State state; |
799 while ((state = SamplerRegistry::GetState()) != | 799 while ((state = SamplerRegistry::GetState()) != |
800 SamplerRegistry::HAS_NO_SAMPLERS) { | 800 SamplerRegistry::HAS_NO_SAMPLERS) { |
801 // When CPU profiling is enabled both JavaScript and C++ code is | 801 // When CPU profiling is enabled both JavaScript and C++ code is |
802 // profiled. We must not suspend. | 802 // profiled. We must not suspend. |
803 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { | 803 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { |
804 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); | 804 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); |
805 } else { | |
806 if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue; | |
807 } | 805 } |
808 OS::Sleep(interval_); | 806 OS::Sleep(interval_); |
809 } | 807 } |
810 } | 808 } |
811 | 809 |
812 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) { | 810 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) { |
813 if (!sampler->isolate()->IsInitialized()) return; | 811 if (!sampler->isolate()->IsInitialized()) return; |
814 if (!sampler->IsProfiling()) return; | 812 if (!sampler->IsProfiling()) return; |
815 SamplerThread* sampler_thread = | 813 SamplerThread* sampler_thread = |
816 reinterpret_cast<SamplerThread*>(raw_sampler_thread); | 814 reinterpret_cast<SamplerThread*>(raw_sampler_thread); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 | 916 |
919 | 917 |
920 void Sampler::Stop() { | 918 void Sampler::Stop() { |
921 ASSERT(IsActive()); | 919 ASSERT(IsActive()); |
922 SamplerThread::RemoveActiveSampler(this); | 920 SamplerThread::RemoveActiveSampler(this); |
923 SetActive(false); | 921 SetActive(false); |
924 } | 922 } |
925 | 923 |
926 | 924 |
927 } } // namespace v8::internal | 925 } } // namespace v8::internal |
OLD | NEW |