| 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 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2008 // Implement Thread::Run(). | 2008 // Implement Thread::Run(). |
| 2009 virtual void Run() { | 2009 virtual void Run() { |
| 2010 SamplerRegistry::State state; | 2010 SamplerRegistry::State state; |
| 2011 while ((state = SamplerRegistry::GetState()) != | 2011 while ((state = SamplerRegistry::GetState()) != |
| 2012 SamplerRegistry::HAS_NO_SAMPLERS) { | 2012 SamplerRegistry::HAS_NO_SAMPLERS) { |
| 2013 // When CPU profiling is enabled both JavaScript and C++ code is | 2013 // When CPU profiling is enabled both JavaScript and C++ code is |
| 2014 // profiled. We must not suspend. | 2014 // profiled. We must not suspend. |
| 2015 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { | 2015 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) { |
| 2016 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); | 2016 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this); |
| 2017 } else { | 2017 } else { |
| 2018 if (rate_limiter_.SuspendIfNecessary()) continue; | 2018 if (RuntimeProfiler::WaitForSomeIsolateToEnterJS()) continue; |
| 2019 } | 2019 } |
| 2020 OS::Sleep(interval_); | 2020 OS::Sleep(interval_); |
| 2021 } | 2021 } |
| 2022 } | 2022 } |
| 2023 | 2023 |
| 2024 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) { | 2024 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) { |
| 2025 if (!sampler->isolate()->IsInitialized()) return; | 2025 if (!sampler->isolate()->IsInitialized()) return; |
| 2026 if (!sampler->IsProfiling()) return; | 2026 if (!sampler->IsProfiling()) return; |
| 2027 SamplerThread* sampler_thread = | 2027 SamplerThread* sampler_thread = |
| 2028 reinterpret_cast<SamplerThread*>(raw_sampler_thread); | 2028 reinterpret_cast<SamplerThread*>(raw_sampler_thread); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2056 sample->sp = reinterpret_cast<Address>(context.Esp); | 2056 sample->sp = reinterpret_cast<Address>(context.Esp); |
| 2057 sample->fp = reinterpret_cast<Address>(context.Ebp); | 2057 sample->fp = reinterpret_cast<Address>(context.Ebp); |
| 2058 #endif | 2058 #endif |
| 2059 sampler->SampleStack(sample); | 2059 sampler->SampleStack(sample); |
| 2060 sampler->Tick(sample); | 2060 sampler->Tick(sample); |
| 2061 } | 2061 } |
| 2062 ResumeThread(profiled_thread); | 2062 ResumeThread(profiled_thread); |
| 2063 } | 2063 } |
| 2064 | 2064 |
| 2065 const int interval_; | 2065 const int interval_; |
| 2066 RuntimeProfilerRateLimiter rate_limiter_; | |
| 2067 | 2066 |
| 2068 // Protects the process wide state below. | 2067 // Protects the process wide state below. |
| 2069 static Mutex* mutex_; | 2068 static Mutex* mutex_; |
| 2070 static SamplerThread* instance_; | 2069 static SamplerThread* instance_; |
| 2071 | 2070 |
| 2072 private: | 2071 private: |
| 2073 DISALLOW_COPY_AND_ASSIGN(SamplerThread); | 2072 DISALLOW_COPY_AND_ASSIGN(SamplerThread); |
| 2074 }; | 2073 }; |
| 2075 | 2074 |
| 2076 | 2075 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2121 | 2120 |
| 2122 | 2121 |
| 2123 void Sampler::Stop() { | 2122 void Sampler::Stop() { |
| 2124 ASSERT(IsActive()); | 2123 ASSERT(IsActive()); |
| 2125 SamplerThread::RemoveActiveSampler(this); | 2124 SamplerThread::RemoveActiveSampler(this); |
| 2126 SetActive(false); | 2125 SetActive(false); |
| 2127 } | 2126 } |
| 2128 | 2127 |
| 2129 | 2128 |
| 2130 } } // namespace v8::internal | 2129 } } // namespace v8::internal |
| OLD | NEW |