| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/libsampler/sampler.h" | 5 #include "src/libsampler/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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 public: | 210 public: |
| 211 PlatformData() : vm_tid_(pthread_self()) {} | 211 PlatformData() : vm_tid_(pthread_self()) {} |
| 212 pthread_t vm_tid() const { return vm_tid_; } | 212 pthread_t vm_tid() const { return vm_tid_; } |
| 213 | 213 |
| 214 private: | 214 private: |
| 215 pthread_t vm_tid_; | 215 pthread_t vm_tid_; |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 class SamplerManager { | 218 class SamplerManager { |
| 219 public: | 219 public: |
| 220 SamplerManager() : sampler_map_(base::HashMap::PointersMatch) {} | 220 SamplerManager() : sampler_map_() {} |
| 221 | 221 |
| 222 void AddSampler(Sampler* sampler) { | 222 void AddSampler(Sampler* sampler) { |
| 223 AtomicGuard atomic_guard(&samplers_access_counter_); | 223 AtomicGuard atomic_guard(&samplers_access_counter_); |
| 224 DCHECK(sampler->IsActive() || !sampler->IsRegistered()); | 224 DCHECK(sampler->IsActive() || !sampler->IsRegistered()); |
| 225 // Add sampler into map if needed. | 225 // Add sampler into map if needed. |
| 226 pthread_t thread_id = sampler->platform_data()->vm_tid(); | 226 pthread_t thread_id = sampler->platform_data()->vm_tid(); |
| 227 base::HashMap::Entry* entry = | 227 base::HashMap::Entry* entry = |
| 228 sampler_map_.LookupOrInsert(ThreadKey(thread_id), | 228 sampler_map_.LookupOrInsert(ThreadKey(thread_id), |
| 229 ThreadHash(thread_id)); | 229 ThreadHash(thread_id)); |
| 230 DCHECK(entry != nullptr); | 230 DCHECK(entry != nullptr); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 #endif | 654 #endif |
| 655 SampleStack(state); | 655 SampleStack(state); |
| 656 } | 656 } |
| 657 ResumeThread(profiled_thread); | 657 ResumeThread(profiled_thread); |
| 658 } | 658 } |
| 659 | 659 |
| 660 #endif // USE_SIGNALS | 660 #endif // USE_SIGNALS |
| 661 | 661 |
| 662 } // namespace sampler | 662 } // namespace sampler |
| 663 } // namespace v8 | 663 } // namespace v8 |
| OLD | NEW |