Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 void DoSample(); | 748 void DoSample(); |
| 749 | 749 |
| 750 // This method is called for each sampling period with the current | 750 // This method is called for each sampling period with the current |
| 751 // program counter. | 751 // program counter. |
| 752 virtual void Tick(TickSample* sample) = 0; | 752 virtual void Tick(TickSample* sample) = 0; |
| 753 | 753 |
| 754 // Start and stop sampler. | 754 // Start and stop sampler. |
| 755 void Start(); | 755 void Start(); |
| 756 void Stop(); | 756 void Stop(); |
| 757 | 757 |
| 758 // Is the sampler used for profiling? | 758 // Whether the sampling thread should use this Sampler for CPU profiling? |
| 759 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; } | 759 bool IsProfiling() const { |
| 760 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); } | 760 return NoBarrier_Load(&profiling_) > 0 && |
| 761 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); } | 761 !NoBarrier_Load(&has_processing_thread_); |
| 762 } | |
| 763 // Perform platform-specific initialization before DoSample() may be involed. | |
|
Jakob Kummerow
2012/10/19 15:56:42
typo: invoked
| |
| 764 void StartSampling(); | |
| 765 // Perform platform-specific cleanup after samping. | |
| 766 void StopSampling(); | |
| 767 void IncreaseProfilingDepth() { | |
| 768 if (NoBarrier_AtomicIncrement(&profiling_, 1) == 1) | |
| 769 StartSampling(); | |
|
Jakob Kummerow
2012/10/19 15:56:42
nit: {} please
| |
| 770 } | |
| 771 void DecreaseProfilingDepth() { | |
| 772 if (!NoBarrier_AtomicIncrement(&profiling_, -1)) | |
| 773 StopSampling(); | |
|
Jakob Kummerow
2012/10/19 15:56:42
nit: {} please
| |
| 774 } | |
| 775 void SetHasProcessingThread(bool value) { | |
| 776 NoBarrier_Store(&has_processing_thread_, value); | |
| 777 } | |
| 762 | 778 |
| 763 // Whether the sampler is running (that is, consumes resources). | 779 // Whether the sampler is running (that is, consumes resources). |
| 764 bool IsActive() const { return NoBarrier_Load(&active_); } | 780 bool IsActive() const { return NoBarrier_Load(&active_); } |
| 765 | 781 |
| 766 Isolate* isolate() { return isolate_; } | 782 Isolate* isolate() { return isolate_; } |
| 767 | 783 |
| 768 // Used in tests to make sure that stack sampling is performed. | 784 // Used in tests to make sure that stack sampling is performed. |
| 769 int samples_taken() const { return samples_taken_; } | 785 int samples_taken() const { return samples_taken_; } |
| 770 void ResetSamplesTaken() { samples_taken_ = 0; } | 786 void ResetSamplesTaken() { samples_taken_ = 0; } |
| 771 | 787 |
| 772 class PlatformData; | 788 class PlatformData; |
| 773 PlatformData* data() { return data_; } | 789 PlatformData* data() { return data_; } |
| 774 | 790 |
| 775 PlatformData* platform_data() { return data_; } | 791 PlatformData* platform_data() { return data_; } |
| 776 | 792 |
| 777 protected: | 793 protected: |
| 778 virtual void DoSampleStack(TickSample* sample) = 0; | 794 virtual void DoSampleStack(TickSample* sample) = 0; |
| 779 | 795 |
| 780 private: | 796 private: |
| 781 void SetActive(bool value) { NoBarrier_Store(&active_, value); } | 797 void SetActive(bool value) { NoBarrier_Store(&active_, value); } |
| 782 void IncSamplesTaken() { if (++samples_taken_ < 0) samples_taken_ = 0; } | 798 void IncSamplesTaken() { if (++samples_taken_ < 0) samples_taken_ = 0; } |
| 783 | 799 |
| 784 Isolate* isolate_; | 800 Isolate* isolate_; |
| 785 const int interval_; | 801 const int interval_; |
| 786 Atomic32 profiling_; | 802 Atomic32 profiling_; |
| 787 Atomic32 active_; | 803 Atomic32 active_; |
| 804 Atomic32 has_processing_thread_; | |
| 788 PlatformData* data_; // Platform specific data. | 805 PlatformData* data_; // Platform specific data. |
| 789 int samples_taken_; // Counts stack samples taken. | 806 int samples_taken_; // Counts stack samples taken. |
| 790 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 807 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 791 }; | 808 }; |
| 792 | 809 |
| 793 | 810 |
| 794 } } // namespace v8::internal | 811 } } // namespace v8::internal |
| 795 | 812 |
| 796 #endif // V8_PLATFORM_H_ | 813 #endif // V8_PLATFORM_H_ |
| OLD | NEW |