| 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/profiler/sampler.h" | 5 #include "src/profiler/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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 // Implement Thread::Run(). | 726 // Implement Thread::Run(). |
| 727 virtual void Run() { | 727 virtual void Run() { |
| 728 while (true) { | 728 while (true) { |
| 729 { | 729 { |
| 730 base::LockGuard<base::Mutex> lock_guard(mutex_); | 730 base::LockGuard<base::Mutex> lock_guard(mutex_); |
| 731 #if defined(USE_SIGNALS) | 731 #if defined(USE_SIGNALS) |
| 732 if (thread_id_to_samplers_.Get().occupancy() == 0) break; | 732 if (thread_id_to_samplers_.Get().occupancy() == 0) break; |
| 733 if (SignalHandler::Installed()) { | 733 if (SignalHandler::Installed()) { |
| 734 for (HashMap::Entry *p = thread_id_to_samplers_.Get().Start(); | 734 for (HashMap::Entry *p = thread_id_to_samplers_.Get().Start(); |
| 735 p != NULL; p = thread_id_to_samplers_.Get().Next(p)) { | 735 p != NULL; p = thread_id_to_samplers_.Get().Next(p)) { |
| 736 #if V8_OS_AIX && V8_TARGET_ARCH_PPC64 |
| 737 // on AIX64, cannot cast (void *) to pthread_t which is |
| 738 // of type unsigned int (4bytes) |
| 739 pthread_t thread_id = reinterpret_cast<intptr_t>(p->key); |
| 740 #else |
| 736 pthread_t thread_id = reinterpret_cast<pthread_t>(p->key); | 741 pthread_t thread_id = reinterpret_cast<pthread_t>(p->key); |
| 742 #endif |
| 737 pthread_kill(thread_id, SIGPROF); | 743 pthread_kill(thread_id, SIGPROF); |
| 738 } | 744 } |
| 739 } | 745 } |
| 740 #else | 746 #else |
| 741 if (active_samplers_.is_empty()) break; | 747 if (active_samplers_.is_empty()) break; |
| 742 // When CPU profiling is enabled both JavaScript and C++ code is | 748 // When CPU profiling is enabled both JavaScript and C++ code is |
| 743 // profiled. We must not suspend. | 749 // profiled. We must not suspend. |
| 744 for (int i = 0; i < active_samplers_.length(); ++i) { | 750 for (int i = 0; i < active_samplers_.length(); ++i) { |
| 745 Sampler* sampler = active_samplers_.at(i); | 751 Sampler* sampler = active_samplers_.at(i); |
| 746 if (!sampler->IsProfiling()) continue; | 752 if (!sampler->IsProfiling()) continue; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 SampleStack(state); | 1059 SampleStack(state); |
| 1054 } | 1060 } |
| 1055 ResumeThread(profiled_thread); | 1061 ResumeThread(profiled_thread); |
| 1056 } | 1062 } |
| 1057 | 1063 |
| 1058 #endif // USE_SIGNALS | 1064 #endif // USE_SIGNALS |
| 1059 | 1065 |
| 1060 | 1066 |
| 1061 } // namespace internal | 1067 } // namespace internal |
| 1062 } // namespace v8 | 1068 } // namespace v8 |
| OLD | NEW |