Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: src/profiler/sampler.cc

Issue 1900473002: Get rid of UnsafeCurrent in Sampler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/profiler/sampler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) 35 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
36 #include <asm/sigcontext.h> // NOLINT 36 #include <asm/sigcontext.h> // NOLINT
37 #endif 37 #endif
38 38
39 #elif V8_OS_WIN || V8_OS_CYGWIN 39 #elif V8_OS_WIN || V8_OS_CYGWIN
40 40
41 #include "src/base/win32-headers.h" 41 #include "src/base/win32-headers.h"
42 42
43 #endif 43 #endif
44 44
45 #include "src/atomic-utils.h"
45 #include "src/base/platform/platform.h" 46 #include "src/base/platform/platform.h"
46 #include "src/flags.h" 47 #include "src/flags.h"
47 #include "src/frames-inl.h" 48 #include "src/frames-inl.h"
48 #include "src/log.h" 49 #include "src/log.h"
49 #include "src/profiler/cpu-profiler-inl.h" 50 #include "src/profiler/cpu-profiler-inl.h"
50 #include "src/simulator.h" 51 #include "src/simulator.h"
51 #include "src/v8threads.h" 52 #include "src/v8threads.h"
52 #include "src/vm-state-inl.h" 53 #include "src/vm-state-inl.h"
53 54
54 55
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // pessimistically assume it could be the entire pattern match. 230 // pessimistically assume it could be the entire pattern match.
230 MSAN_MEMORY_IS_INITIALIZED(pc, pattern->bytes_count - offset); 231 MSAN_MEMORY_IS_INITIALIZED(pc, pattern->bytes_count - offset);
231 if (!memcmp(pc, pattern->bytes + offset, pattern->bytes_count - offset)) 232 if (!memcmp(pc, pattern->bytes + offset, pattern->bytes_count - offset))
232 return true; 233 return true;
233 } 234 }
234 } 235 }
235 } 236 }
236 return false; 237 return false;
237 } 238 }
238 239
240 typedef List<Sampler*> SamplerList;
241
242 #if defined(USE_SIGNALS)
243 class AtomicGuard {
244 public:
245 explicit AtomicGuard(AtomicValue<int>* atomic, bool is_block = true)
246 : atomic_(atomic),
247 is_success_(false) {
248 do {
249 // Use Acquire_Load to gain mutual exclusion, so that
250 // TSAN recognizes the atomic variable acting as guard.
jochen (gone - plz use gerrit) 2016/04/21 14:44:24 i think the point is that it doesn't act as a guar
alph 2016/04/21 16:21:28 Why? To me it looks more like TSAN bug. Isn't TryS
Michael Lippautz 2016/04/21 16:34:18 dbc (basically the comment from the other CL): Tr
251 USE(atomic_->Value());
252 is_success_ = atomic_->TrySetValue(0, 1);
253 } while (is_block && !is_success_);
254 }
255
256 bool is_success() { return is_success_; }
257
258 ~AtomicGuard() {
259 if (is_success_) {
260 atomic_->SetValue(0);
261 }
262 atomic_ = NULL;
263 }
264
265 private:
266 AtomicValue<int>* atomic_;
267 bool is_success_;
268 };
269
270
271 // Returns key for hash map.
272 void* ThreadKey(pthread_t thread_id) {
273 return reinterpret_cast<void*>(thread_id);
274 }
275
276
277 // Returns hash value for hash map.
278 uint32_t ThreadHash(pthread_t thread_id) {
279 #if V8_OS_MACOSX
280 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(thread_id));
281 #else
282 return static_cast<uint32_t>(thread_id);
283 #endif
284 }
285 #endif // USE_SIGNALS
286
239 } // namespace 287 } // namespace
240 288
241 #if defined(USE_SIGNALS) 289 #if defined(USE_SIGNALS)
242 290
243 class Sampler::PlatformData : public PlatformDataCommon { 291 class Sampler::PlatformData : public PlatformDataCommon {
244 public: 292 public:
245 PlatformData() : vm_tid_(pthread_self()) {} 293 PlatformData() : vm_tid_(pthread_self()) {}
246 pthread_t vm_tid() const { return vm_tid_; } 294 pthread_t vm_tid() const { return vm_tid_; }
247 295
248 private: 296 private:
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 415
368 static void DecreaseSamplerCount() { 416 static void DecreaseSamplerCount() {
369 base::LockGuard<base::Mutex> lock_guard(mutex_); 417 base::LockGuard<base::Mutex> lock_guard(mutex_);
370 if (--client_count_ == 0) Restore(); 418 if (--client_count_ == 0) Restore();
371 } 419 }
372 420
373 static bool Installed() { 421 static bool Installed() {
374 return signal_handler_installed_; 422 return signal_handler_installed_;
375 } 423 }
376 424
425 #if !V8_OS_NACL
426 static void CollectSample(void* context, Sampler* sampler);
427 #endif
428
377 private: 429 private:
378 static void Install() { 430 static void Install() {
379 #if !V8_OS_NACL 431 #if !V8_OS_NACL
380 struct sigaction sa; 432 struct sigaction sa;
381 sa.sa_sigaction = &HandleProfilerSignal; 433 sa.sa_sigaction = &HandleProfilerSignal;
382 sigemptyset(&sa.sa_mask); 434 sigemptyset(&sa.sa_mask);
383 #if V8_OS_QNX 435 #if V8_OS_QNX
384 sa.sa_flags = SA_SIGINFO; 436 sa.sa_flags = SA_SIGINFO;
385 #else 437 #else
386 sa.sa_flags = SA_RESTART | SA_SIGINFO; 438 sa.sa_flags = SA_RESTART | SA_SIGINFO;
(...skipping 24 matching lines...) Expand all
411 463
412 464
413 base::Mutex* SignalHandler::mutex_ = NULL; 465 base::Mutex* SignalHandler::mutex_ = NULL;
414 int SignalHandler::client_count_ = 0; 466 int SignalHandler::client_count_ = 0;
415 struct sigaction SignalHandler::old_signal_handler_; 467 struct sigaction SignalHandler::old_signal_handler_;
416 bool SignalHandler::signal_handler_installed_ = false; 468 bool SignalHandler::signal_handler_installed_ = false;
417 469
418 470
419 // As Native Client does not support signal handling, profiling is disabled. 471 // As Native Client does not support signal handling, profiling is disabled.
420 #if !V8_OS_NACL 472 #if !V8_OS_NACL
421 void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info, 473 void SignalHandler::CollectSample(void* context, Sampler* sampler) {
422 void* context) { 474 if (sampler == NULL || (!sampler->IsProfiling() &&
423 USE(info); 475 !sampler->IsRegistered())) {
424 if (signal != SIGPROF) return;
425 Isolate* isolate = Isolate::UnsafeCurrent();
426 if (isolate == NULL || !isolate->IsInUse()) {
427 // We require a fully initialized and entered isolate.
428 return; 476 return;
429 } 477 }
478 Isolate* isolate = sampler->isolate();
479
480 // We require a fully initialized and entered isolate.
481 if (isolate == NULL || !isolate->IsInUse()) return;
482
430 if (v8::Locker::IsActive() && 483 if (v8::Locker::IsActive() &&
431 !isolate->thread_manager()->IsLockedByCurrentThread()) { 484 !isolate->thread_manager()->IsLockedByCurrentThread()) {
432 return; 485 return;
433 } 486 }
434 487
435 Sampler* sampler = isolate->logger()->sampler();
436 if (sampler == NULL) return;
437
438 v8::RegisterState state; 488 v8::RegisterState state;
439 489
440 #if defined(USE_SIMULATOR) 490 #if defined(USE_SIMULATOR)
441 SimulatorHelper helper; 491 SimulatorHelper helper;
442 if (!helper.Init(isolate)) return; 492 if (!helper.Init(isolate)) return;
443 helper.FillRegisters(&state); 493 helper.FillRegisters(&state);
444 // It possible that the simulator is interrupted while it is updating 494 // It possible that the simulator is interrupted while it is updating
445 // the sp or fp register. ARM64 simulator does this in two steps: 495 // the sp or fp register. ARM64 simulator does this in two steps:
446 // first setting it to zero and then setting it to the new value. 496 // first setting it to zero and then setting it to the new value.
447 // Bailout if sp/fp doesn't contain the new value. 497 // Bailout if sp/fp doesn't contain the new value.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 #elif V8_OS_AIX 625 #elif V8_OS_AIX
576 state.pc = reinterpret_cast<Address>(mcontext.jmp_context.iar); 626 state.pc = reinterpret_cast<Address>(mcontext.jmp_context.iar);
577 state.sp = reinterpret_cast<Address>(mcontext.jmp_context.gpr[1]); 627 state.sp = reinterpret_cast<Address>(mcontext.jmp_context.gpr[1]);
578 state.fp = reinterpret_cast<Address>(mcontext.jmp_context.gpr[31]); 628 state.fp = reinterpret_cast<Address>(mcontext.jmp_context.gpr[31]);
579 #endif // V8_OS_AIX 629 #endif // V8_OS_AIX
580 #endif // USE_SIMULATOR 630 #endif // USE_SIMULATOR
581 sampler->SampleStack(state); 631 sampler->SampleStack(state);
582 } 632 }
583 #endif // V8_OS_NACL 633 #endif // V8_OS_NACL
584 634
585 #endif 635 #endif // USE_SIGNALS
586 636
587 637
588 class SamplerThread : public base::Thread { 638 class SamplerThread : public base::Thread {
589 public: 639 public:
590 static const int kSamplerThreadStackSize = 64 * KB; 640 static const int kSamplerThreadStackSize = 64 * KB;
591 641
592 explicit SamplerThread(int interval) 642 explicit SamplerThread(int interval)
593 : Thread(base::Thread::Options("SamplerThread", kSamplerThreadStackSize)), 643 : Thread(base::Thread::Options("SamplerThread", kSamplerThreadStackSize)),
594 interval_(interval) {} 644 interval_(interval) {}
595 645
596 static void SetUp() { if (!mutex_) mutex_ = new base::Mutex(); } 646 static void SetUp() { if (!mutex_) mutex_ = new base::Mutex(); }
597 static void TearDown() { delete mutex_; mutex_ = NULL; } 647 static void TearDown() { delete mutex_; mutex_ = NULL; }
598 648
599 static void AddActiveSampler(Sampler* sampler) { 649 static void AddActiveSampler(Sampler* sampler) {
600 bool need_to_start = false; 650 bool need_to_start = false;
601 base::LockGuard<base::Mutex> lock_guard(mutex_); 651 base::LockGuard<base::Mutex> lock_guard(mutex_);
602 if (instance_ == NULL) { 652 if (instance_ == NULL) {
603 // Start a thread that will send SIGPROF signal to VM threads, 653 // Start a thread that will send SIGPROF signal to VM threads,
604 // when CPU profiling will be enabled. 654 // when CPU profiling will be enabled.
605 instance_ = new SamplerThread(sampler->interval()); 655 instance_ = new SamplerThread(sampler->interval());
606 need_to_start = true; 656 need_to_start = true;
607 } 657 }
608 658
609 DCHECK(sampler->IsActive()); 659 DCHECK(sampler->IsActive());
660 DCHECK(instance_->interval_ == sampler->interval());
661
662 #if defined(USE_SIGNALS)
663 AddSampler(sampler);
664 #else
610 DCHECK(!instance_->active_samplers_.Contains(sampler)); 665 DCHECK(!instance_->active_samplers_.Contains(sampler));
611 DCHECK(instance_->interval_ == sampler->interval());
612 instance_->active_samplers_.Add(sampler); 666 instance_->active_samplers_.Add(sampler);
667 #endif // USE_SIGNALS
613 668
614 if (need_to_start) instance_->StartSynchronously(); 669 if (need_to_start) instance_->StartSynchronously();
615 } 670 }
616 671
617 static void RemoveActiveSampler(Sampler* sampler) { 672 static void RemoveSampler(Sampler* sampler) {
618 SamplerThread* instance_to_remove = NULL; 673 SamplerThread* instance_to_remove = NULL;
619 { 674 {
620 base::LockGuard<base::Mutex> lock_guard(mutex_); 675 base::LockGuard<base::Mutex> lock_guard(mutex_);
621 676
622 DCHECK(sampler->IsActive()); 677 DCHECK(sampler->IsActive() || sampler->IsRegistered());
678 #if defined(USE_SIGNALS)
679 {
680 AtomicGuard atomic_guard(&sampler_list_access_counter_);
681 // Remove sampler from map.
682 pthread_t thread_id = sampler->platform_data()->vm_tid();
683 void* thread_key = ThreadKey(thread_id);
684 uint32_t thread_hash = ThreadHash(thread_id);
685 HashMap::Entry* entry =
686 thread_id_to_samplers_.Get().Lookup(thread_key, thread_hash);
687 DCHECK(entry != NULL);
688 SamplerList* samplers = reinterpret_cast<SamplerList*>(entry->value);
689 samplers->RemoveElement(sampler);
690 if (samplers->is_empty()) {
691 thread_id_to_samplers_.Pointer()->Remove(thread_key, thread_hash);
692 delete samplers;
693 }
694 if (thread_id_to_samplers_.Get().occupancy() == 0) {
695 instance_to_remove = instance_;
696 instance_ = NULL;
697 }
698 }
699 #else
623 bool removed = instance_->active_samplers_.RemoveElement(sampler); 700 bool removed = instance_->active_samplers_.RemoveElement(sampler);
624 DCHECK(removed); 701 DCHECK(removed);
625 USE(removed); 702 USE(removed);
626 703
627 // We cannot delete the instance immediately as we need to Join() the 704 // We cannot delete the instance immediately as we need to Join() the
628 // thread but we are holding mutex_ and the thread may try to acquire it. 705 // thread but we are holding mutex_ and the thread may try to acquire it.
629 if (instance_->active_samplers_.is_empty()) { 706 if (instance_->active_samplers_.is_empty()) {
630 instance_to_remove = instance_; 707 instance_to_remove = instance_;
631 instance_ = NULL; 708 instance_ = NULL;
632 } 709 }
710 #endif // USE_SIGNALS
633 } 711 }
634 712
635 if (!instance_to_remove) return; 713 if (!instance_to_remove) return;
636 instance_to_remove->Join(); 714 instance_to_remove->Join();
637 delete instance_to_remove; 715 delete instance_to_remove;
638 } 716 }
639 717
718 // Unlike AddActiveSampler, this method only adds a sampler,
719 // but won't start the sampler thread.
720 static void RegisterSampler(Sampler* sampler) {
721 base::LockGuard<base::Mutex> lock_guard(mutex_);
722 #if defined(USE_SIGNALS)
723 AddSampler(sampler);
724 #endif // USE_SIGNALS
725 }
726
640 // Implement Thread::Run(). 727 // Implement Thread::Run().
641 virtual void Run() { 728 virtual void Run() {
642 while (true) { 729 while (true) {
643 { 730 {
644 base::LockGuard<base::Mutex> lock_guard(mutex_); 731 base::LockGuard<base::Mutex> lock_guard(mutex_);
732 #if defined(USE_SIGNALS)
733 if (thread_id_to_samplers_.Get().occupancy() == 0) break;
734 if (SignalHandler::Installed()) {
735 for (HashMap::Entry *p = thread_id_to_samplers_.Get().Start();
736 p != NULL; p = thread_id_to_samplers_.Get().Next(p)) {
737 pthread_t thread_id = reinterpret_cast<pthread_t>(p->key);
738 pthread_kill(thread_id, SIGPROF);
739 }
740 }
741 #else
645 if (active_samplers_.is_empty()) break; 742 if (active_samplers_.is_empty()) break;
646 // When CPU profiling is enabled both JavaScript and C++ code is 743 // When CPU profiling is enabled both JavaScript and C++ code is
647 // profiled. We must not suspend. 744 // profiled. We must not suspend.
648 for (int i = 0; i < active_samplers_.length(); ++i) { 745 for (int i = 0; i < active_samplers_.length(); ++i) {
649 Sampler* sampler = active_samplers_.at(i); 746 Sampler* sampler = active_samplers_.at(i);
650 if (!sampler->IsProfiling()) continue; 747 if (!sampler->IsProfiling()) continue;
651 sampler->DoSample(); 748 sampler->DoSample();
652 } 749 }
750 #endif // USE_SIGNALS
653 } 751 }
654 base::OS::Sleep(base::TimeDelta::FromMilliseconds(interval_)); 752 base::OS::Sleep(base::TimeDelta::FromMilliseconds(interval_));
655 } 753 }
656 } 754 }
657 755
658 private: 756 private:
659 // Protects the process wide state below. 757 // Protects the process wide state below.
660 static base::Mutex* mutex_; 758 static base::Mutex* mutex_;
661 static SamplerThread* instance_; 759 static SamplerThread* instance_;
662 760
663 const int interval_; 761 const int interval_;
664 List<Sampler*> active_samplers_; 762
763 #if defined(USE_SIGNALS)
764 struct HashMapCreateTrait {
765 static void Construct(HashMap* allocated_ptr) {
766 new (allocated_ptr) HashMap(HashMap::PointersMatch);
767 }
768 };
769 friend class SignalHandler;
770 static base::LazyInstance<HashMap, HashMapCreateTrait>::type
771 thread_id_to_samplers_;
772 static AtomicValue<int> sampler_list_access_counter_;
773 static void AddSampler(Sampler* sampler) {
774 AtomicGuard atomic_guard(&sampler_list_access_counter_);
775 // Add sampler into map if needed.
776 pthread_t thread_id = sampler->platform_data()->vm_tid();
777 HashMap::Entry *entry =
778 thread_id_to_samplers_.Pointer()->LookupOrInsert(ThreadKey(thread_id),
779 ThreadHash(thread_id));
780 if (entry->value == NULL) {
781 SamplerList* samplers = new SamplerList();
782 samplers->Add(sampler);
783 entry->value = samplers;
784 } else {
785 SamplerList* samplers = reinterpret_cast<SamplerList*>(entry->value);
786 if (!samplers->Contains(sampler)) {
787 samplers->Add(sampler);
788 }
789 }
790 }
791 #else
792 SamplerList active_samplers_;
793 #endif // USE_SIGNALS
665 794
666 DISALLOW_COPY_AND_ASSIGN(SamplerThread); 795 DISALLOW_COPY_AND_ASSIGN(SamplerThread);
667 }; 796 };
668 797
669 798
670 base::Mutex* SamplerThread::mutex_ = NULL; 799 base::Mutex* SamplerThread::mutex_ = NULL;
671 SamplerThread* SamplerThread::instance_ = NULL; 800 SamplerThread* SamplerThread::instance_ = NULL;
801 #if defined(USE_SIGNALS)
802 base::LazyInstance<HashMap, SamplerThread::HashMapCreateTrait>::type
803 SamplerThread::thread_id_to_samplers_ = LAZY_INSTANCE_INITIALIZER;
804 AtomicValue<int> SamplerThread::sampler_list_access_counter_(0);
805
806 // As Native Client does not support signal handling, profiling is disabled.
807 #if !V8_OS_NACL
808 void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
809 void* context) {
810 USE(info);
811 if (signal != SIGPROF) return;
812 AtomicGuard atomic_guard(&SamplerThread::sampler_list_access_counter_, false);
813 if (!atomic_guard.is_success()) return;
814 pthread_t thread_id = pthread_self();
815 HashMap::Entry* entry =
816 SamplerThread::thread_id_to_samplers_.Pointer()->Lookup(
817 ThreadKey(thread_id), ThreadHash(thread_id));
818 if (entry == NULL)
819 return;
820 SamplerList* samplers = reinterpret_cast<SamplerList*>(entry->value);
821 for (int i = 0; i < samplers->length(); ++i) {
822 Sampler* sampler = samplers->at(i);
823 CollectSample(context, sampler);
824 }
825 }
826 #endif // !V8_OS_NACL
827 #endif // USE_SIGNALs
672 828
673 829
674 // 830 //
675 // StackTracer implementation 831 // StackTracer implementation
676 // 832 //
677 DISABLE_ASAN void TickSample::Init(Isolate* isolate, 833 DISABLE_ASAN void TickSample::Init(Isolate* isolate,
678 const v8::RegisterState& regs, 834 const v8::RegisterState& regs,
679 RecordCEntryFrame record_c_entry_frame, 835 RecordCEntryFrame record_c_entry_frame,
680 bool update_stats) { 836 bool update_stats) {
681 timestamp = base::TimeTicks::HighResolutionNow(); 837 timestamp = base::TimeTicks::HighResolutionNow();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 SignalHandler::TearDown(); 938 SignalHandler::TearDown();
783 #endif 939 #endif
784 } 940 }
785 941
786 Sampler::Sampler(Isolate* isolate, int interval) 942 Sampler::Sampler(Isolate* isolate, int interval)
787 : isolate_(isolate), 943 : isolate_(isolate),
788 interval_(interval), 944 interval_(interval),
789 profiling_(false), 945 profiling_(false),
790 has_processing_thread_(false), 946 has_processing_thread_(false),
791 active_(false), 947 active_(false),
948 registered_(false),
792 is_counting_samples_(false), 949 is_counting_samples_(false),
793 js_sample_count_(0), 950 js_sample_count_(0),
794 external_sample_count_(0) { 951 external_sample_count_(0) {
795 data_ = new PlatformData; 952 data_ = new PlatformData;
796 } 953 }
797 954
798 Sampler::~Sampler() { 955 Sampler::~Sampler() {
799 DCHECK(!IsActive()); 956 DCHECK(!IsActive());
957 if (IsRegistered()) {
958 SamplerThread::RemoveSampler(this);
959 }
800 delete data_; 960 delete data_;
801 } 961 }
802 962
803 void Sampler::Start() { 963 void Sampler::Start() {
804 DCHECK(!IsActive()); 964 DCHECK(!IsActive());
805 SetActive(true); 965 SetActive(true);
806 SamplerThread::AddActiveSampler(this); 966 SamplerThread::AddActiveSampler(this);
807 } 967 }
808 968
809 969
810 void Sampler::Stop() { 970 void Sampler::Stop() {
811 DCHECK(IsActive()); 971 DCHECK(IsActive());
812 SamplerThread::RemoveActiveSampler(this); 972 SamplerThread::RemoveSampler(this);
813 SetActive(false); 973 SetActive(false);
974 SetRegistered(false);
814 } 975 }
815 976
816 977
817 void Sampler::IncreaseProfilingDepth() { 978 void Sampler::IncreaseProfilingDepth() {
818 base::NoBarrier_AtomicIncrement(&profiling_, 1); 979 base::NoBarrier_AtomicIncrement(&profiling_, 1);
819 #if defined(USE_SIGNALS) 980 #if defined(USE_SIGNALS)
820 SignalHandler::IncreaseSamplerCount(); 981 SignalHandler::IncreaseSamplerCount();
821 #endif 982 #endif
822 } 983 }
823 984
(...skipping 19 matching lines...) Expand all
843 if (sample != &sample_obj) { 1004 if (sample != &sample_obj) {
844 isolate_->cpu_profiler()->FinishTickSample(); 1005 isolate_->cpu_profiler()->FinishTickSample();
845 } 1006 }
846 } 1007 }
847 1008
848 1009
849 #if defined(USE_SIGNALS) 1010 #if defined(USE_SIGNALS)
850 1011
851 void Sampler::DoSample() { 1012 void Sampler::DoSample() {
852 if (!SignalHandler::Installed()) return; 1013 if (!SignalHandler::Installed()) return;
1014 if (!IsActive() && !IsRegistered()) {
1015 SamplerThread::RegisterSampler(this);
1016 SetRegistered(true);
1017 }
853 pthread_kill(platform_data()->vm_tid(), SIGPROF); 1018 pthread_kill(platform_data()->vm_tid(), SIGPROF);
854 } 1019 }
855 1020
856 #elif V8_OS_WIN || V8_OS_CYGWIN 1021 #elif V8_OS_WIN || V8_OS_CYGWIN
857 1022
858 void Sampler::DoSample() { 1023 void Sampler::DoSample() {
859 HANDLE profiled_thread = platform_data()->profiled_thread(); 1024 HANDLE profiled_thread = platform_data()->profiled_thread();
860 if (profiled_thread == NULL) return; 1025 if (profiled_thread == NULL) return;
861 1026
862 #if defined(USE_SIMULATOR) 1027 #if defined(USE_SIMULATOR)
(...skipping 26 matching lines...) Expand all
889 SampleStack(state); 1054 SampleStack(state);
890 } 1055 }
891 ResumeThread(profiled_thread); 1056 ResumeThread(profiled_thread);
892 } 1057 }
893 1058
894 #endif // USE_SIGNALS 1059 #endif // USE_SIGNALS
895 1060
896 1061
897 } // namespace internal 1062 } // namespace internal
898 } // namespace v8 1063 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/sampler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698