| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 // Start and stop sampler. | 93 // Start and stop sampler. |
| 94 void Start(); | 94 void Start(); |
| 95 void Stop(); | 95 void Stop(); |
| 96 | 96 |
| 97 // Whether the sampling thread should use this Sampler for CPU profiling? | 97 // Whether the sampling thread should use this Sampler for CPU profiling? |
| 98 bool IsProfiling() const { | 98 bool IsProfiling() const { |
| 99 return NoBarrier_Load(&profiling_) > 0 && | 99 return NoBarrier_Load(&profiling_) > 0 && |
| 100 !NoBarrier_Load(&has_processing_thread_); | 100 !NoBarrier_Load(&has_processing_thread_); |
| 101 } | 101 } |
| 102 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); } | 102 void IncreaseProfilingDepth(); |
| 103 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); } | 103 void DecreaseProfilingDepth(); |
| 104 | 104 |
| 105 // Whether the sampler is running (that is, consumes resources). | 105 // Whether the sampler is running (that is, consumes resources). |
| 106 bool IsActive() const { return NoBarrier_Load(&active_); } | 106 bool IsActive() const { return NoBarrier_Load(&active_); } |
| 107 | 107 |
| 108 void DoSample(); |
| 108 // If true next sample must be initiated on the profiler event processor | 109 // If true next sample must be initiated on the profiler event processor |
| 109 // thread right after latest sample is processed. | 110 // thread right after latest sample is processed. |
| 110 static bool CanSampleOnProfilerEventsProcessorThread(); | |
| 111 void DoSample(); | |
| 112 void SetHasProcessingThread(bool value) { | 111 void SetHasProcessingThread(bool value) { |
| 113 NoBarrier_Store(&has_processing_thread_, value); | 112 NoBarrier_Store(&has_processing_thread_, value); |
| 114 } | 113 } |
| 115 | 114 |
| 116 // Used in tests to make sure that stack sampling is performed. | 115 // Used in tests to make sure that stack sampling is performed. |
| 117 unsigned js_and_external_sample_count() const { | 116 unsigned js_and_external_sample_count() const { |
| 118 return js_and_external_sample_count_; | 117 return js_and_external_sample_count_; |
| 119 } | 118 } |
| 120 void StartCountingSamples() { | 119 void StartCountingSamples() { |
| 121 is_counting_samples_ = true; | 120 is_counting_samples_ = true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 142 bool is_counting_samples_; | 141 bool is_counting_samples_; |
| 143 // Counts stack samples taken in JS VM state. | 142 // Counts stack samples taken in JS VM state. |
| 144 unsigned js_and_external_sample_count_; | 143 unsigned js_and_external_sample_count_; |
| 145 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 144 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 146 }; | 145 }; |
| 147 | 146 |
| 148 | 147 |
| 149 } } // namespace v8::internal | 148 } } // namespace v8::internal |
| 150 | 149 |
| 151 #endif // V8_SAMPLER_H_ | 150 #endif // V8_SAMPLER_H_ |
| OLD | NEW |