| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/sampler.h" | 5 #include "src/sampler.h" |
| 6 | 6 |
| 7 #if V8_OS_POSIX && !V8_OS_CYGWIN | 7 #if V8_OS_POSIX && !V8_OS_CYGWIN |
| 8 | 8 |
| 9 #define USE_SIGNALS | 9 #define USE_SIGNALS |
| 10 | 10 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 base::LockGuard<base::Mutex> lock_guard(mutex_); | 551 base::LockGuard<base::Mutex> lock_guard(mutex_); |
| 552 if (active_samplers_.is_empty()) break; | 552 if (active_samplers_.is_empty()) break; |
| 553 // When CPU profiling is enabled both JavaScript and C++ code is | 553 // When CPU profiling is enabled both JavaScript and C++ code is |
| 554 // profiled. We must not suspend. | 554 // profiled. We must not suspend. |
| 555 for (int i = 0; i < active_samplers_.length(); ++i) { | 555 for (int i = 0; i < active_samplers_.length(); ++i) { |
| 556 Sampler* sampler = active_samplers_.at(i); | 556 Sampler* sampler = active_samplers_.at(i); |
| 557 if (!sampler->IsProfiling()) continue; | 557 if (!sampler->IsProfiling()) continue; |
| 558 sampler->DoSample(); | 558 sampler->DoSample(); |
| 559 } | 559 } |
| 560 } | 560 } |
| 561 base::OS::Sleep(interval_); | 561 base::OS::Sleep(base::TimeDelta::FromMilliseconds(interval_)); |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 | 564 |
| 565 private: | 565 private: |
| 566 // Protects the process wide state below. | 566 // Protects the process wide state below. |
| 567 static base::Mutex* mutex_; | 567 static base::Mutex* mutex_; |
| 568 static SamplerThread* instance_; | 568 static SamplerThread* instance_; |
| 569 | 569 |
| 570 const int interval_; | 570 const int interval_; |
| 571 List<Sampler*> active_samplers_; | 571 List<Sampler*> active_samplers_; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 #endif // USE_SIMULATOR | 769 #endif // USE_SIMULATOR |
| 770 SampleStack(state); | 770 SampleStack(state); |
| 771 } | 771 } |
| 772 ResumeThread(profiled_thread); | 772 ResumeThread(profiled_thread); |
| 773 } | 773 } |
| 774 | 774 |
| 775 #endif // USE_SIGNALS | 775 #endif // USE_SIGNALS |
| 776 | 776 |
| 777 | 777 |
| 778 } } // namespace v8::internal | 778 } } // namespace v8::internal |
| OLD | NEW |