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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Is the sampler used for profiling? | 97 // Is the sampler used for profiling? |
98 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; } | 98 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; } |
99 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); } | 99 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); } |
100 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); } | 100 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); } |
101 | 101 |
102 // Whether the sampler is running (that is, consumes resources). | 102 // Whether the sampler is running (that is, consumes resources). |
103 bool IsActive() const { return NoBarrier_Load(&active_); } | 103 bool IsActive() const { return NoBarrier_Load(&active_); } |
104 | 104 |
105 // Used in tests to make sure that stack sampling is performed. | 105 // Used in tests to make sure that stack sampling is performed. |
106 int samples_taken() const { return samples_taken_; } | 106 unsigned js_and_external_sample_count() const { |
107 void ResetSamplesTaken() { samples_taken_ = 0; } | 107 return js_and_external_sample_count_; |
| 108 } |
| 109 void StartCountingSamples() { |
| 110 is_counting_samples_ = true; |
| 111 js_and_external_sample_count_ = 0; |
| 112 } |
108 | 113 |
109 class PlatformData; | 114 class PlatformData; |
110 PlatformData* platform_data() const { return data_; } | 115 PlatformData* platform_data() const { return data_; } |
111 | 116 |
112 protected: | 117 protected: |
113 // This method is called for each sampling period with the current | 118 // This method is called for each sampling period with the current |
114 // program counter. | 119 // program counter. |
115 virtual void Tick(TickSample* sample) = 0; | 120 virtual void Tick(TickSample* sample) = 0; |
116 | 121 |
117 private: | 122 private: |
118 void SetActive(bool value) { NoBarrier_Store(&active_, value); } | 123 void SetActive(bool value) { NoBarrier_Store(&active_, value); } |
119 | 124 |
120 Isolate* isolate_; | 125 Isolate* isolate_; |
121 const int interval_; | 126 const int interval_; |
122 Atomic32 profiling_; | 127 Atomic32 profiling_; |
123 Atomic32 active_; | 128 Atomic32 active_; |
124 PlatformData* data_; // Platform specific data. | 129 PlatformData* data_; // Platform specific data. |
125 int samples_taken_; // Counts stack samples taken. | 130 bool is_counting_samples_; |
| 131 // Counts stack samples taken in JS VM state. |
| 132 unsigned js_and_external_sample_count_; |
126 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 133 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
127 }; | 134 }; |
128 | 135 |
129 | 136 |
130 } } // namespace v8::internal | 137 } } // namespace v8::internal |
131 | 138 |
132 #endif // V8_SAMPLER_H_ | 139 #endif // V8_SAMPLER_H_ |
OLD | NEW |