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

Side by Side Diff: src/platform.h

Issue 12592002: Revert "Send SIGPROF signals on the profiler event processor thread" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/flag-definitions.h ('k') | src/platform-cygwin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 759 }
760 760
761 // This method is called for each sampling period with the current 761 // This method is called for each sampling period with the current
762 // program counter. 762 // program counter.
763 virtual void Tick(TickSample* sample) = 0; 763 virtual void Tick(TickSample* sample) = 0;
764 764
765 // Start and stop sampler. 765 // Start and stop sampler.
766 void Start(); 766 void Start();
767 void Stop(); 767 void Stop();
768 768
769 // Whether the sampling thread should use this Sampler for CPU profiling? 769 // Is the sampler used for profiling?
770 bool IsProfiling() const { 770 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; }
771 return NoBarrier_Load(&profiling_) > 0 && 771 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); }
772 !NoBarrier_Load(&has_processing_thread_); 772 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); }
773 }
774 void IncreaseProfilingDepth() {
775 if (NoBarrier_AtomicIncrement(&profiling_, 1) == 1) StartProfiling();
776 }
777 void DecreaseProfilingDepth() {
778 if (!NoBarrier_AtomicIncrement(&profiling_, -1)) StopProfiling();
779 }
780 773
781 // Whether the sampler is running (that is, consumes resources). 774 // Whether the sampler is running (that is, consumes resources).
782 bool IsActive() const { return NoBarrier_Load(&active_); } 775 bool IsActive() const { return NoBarrier_Load(&active_); }
783 776
784 Isolate* isolate() { return isolate_; } 777 Isolate* isolate() { return isolate_; }
785 778
786 // Used in tests to make sure that stack sampling is performed. 779 // Used in tests to make sure that stack sampling is performed.
787 int samples_taken() const { return samples_taken_; } 780 int samples_taken() const { return samples_taken_; }
788 void ResetSamplesTaken() { samples_taken_ = 0; } 781 void ResetSamplesTaken() { samples_taken_ = 0; }
789 782
790 class PlatformData; 783 class PlatformData;
791 PlatformData* data() { return data_; } 784 PlatformData* data() { return data_; }
792 785
793 PlatformData* platform_data() { return data_; } 786 PlatformData* platform_data() { return data_; }
794 787
795 // If true next sample must be initiated on the profiler event processor
796 // thread right after latest sample is processed.
797 static bool CanSampleOnProfilerEventsProcessorThread();
798 void DoSample();
799 void SetHasProcessingThread(bool value) {
800 NoBarrier_Store(&has_processing_thread_, value);
801 }
802
803 protected: 788 protected:
804 virtual void DoSampleStack(TickSample* sample) = 0; 789 virtual void DoSampleStack(TickSample* sample) = 0;
805 790
806 private: 791 private:
807 void SetActive(bool value) { NoBarrier_Store(&active_, value); } 792 void SetActive(bool value) { NoBarrier_Store(&active_, value); }
808 void IncSamplesTaken() { if (++samples_taken_ < 0) samples_taken_ = 0; } 793 void IncSamplesTaken() { if (++samples_taken_ < 0) samples_taken_ = 0; }
809 794
810 // Perform platform-specific initialization before DoSample() may be invoked.
811 void StartProfiling();
812 // Perform platform-specific cleanup after profiling.
813 void StopProfiling();
814
815 Isolate* isolate_; 795 Isolate* isolate_;
816 const int interval_; 796 const int interval_;
817 Atomic32 profiling_; 797 Atomic32 profiling_;
818 Atomic32 has_processing_thread_;
819 Atomic32 active_; 798 Atomic32 active_;
820 PlatformData* data_; // Platform specific data. 799 PlatformData* data_; // Platform specific data.
821 int samples_taken_; // Counts stack samples taken. 800 int samples_taken_; // Counts stack samples taken.
822 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 801 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
823 }; 802 };
824 803
825 804
826 } } // namespace v8::internal 805 } } // namespace v8::internal
827 806
828 #endif // V8_PLATFORM_H_ 807 #endif // V8_PLATFORM_H_
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/platform-cygwin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698