5 #ifndef V8_LIBSAMPLER_SAMPLER_H_ 6 #define V8_LIBSAMPLER_SAMPLER_H_ 8 #include "include/v8.h" 10 #include "src/base/atomicops.h" 11 #include "src/base/macros.h" 25 static const int kMaxFramesCountLog2 = 8;
26 static const unsigned kMaxFramesCount = (1u << kMaxFramesCountLog2) - 1;
30 static void TearDown();
33 explicit Sampler(Isolate* isolate);
36 Isolate* isolate()
const {
return isolate_; }
48 bool IsProfiling()
const {
49 return base::Relaxed_Load(&profiling_) > 0 &&
50 !base::Relaxed_Load(&has_processing_thread_);
52 void IncreaseProfilingDepth();
53 void DecreaseProfilingDepth();
56 bool IsActive()
const {
return base::Relaxed_Load(&active_) != 0; }
61 bool IsRegistered()
const {
return base::Relaxed_Load(®istered_) != 0; }
67 void UnregisterIfRegistered();
71 void SetHasProcessingThread(
bool value) {
72 base::Relaxed_Store(&has_processing_thread_, value);
76 unsigned js_sample_count()
const {
return js_sample_count_; }
77 unsigned external_sample_count()
const {
return external_sample_count_; }
78 void StartCountingSamples() {
80 external_sample_count_ = 0;
81 is_counting_samples_ =
true;
85 PlatformData* platform_data()
const {
return data_; }
89 bool is_counting_samples_;
90 unsigned js_sample_count_;
91 unsigned external_sample_count_;
94 void SetActive(
bool value) { base::Relaxed_Store(&active_, value); }
95 void SetRegistered(
bool value) { base::Relaxed_Store(®istered_, value); }
98 base::Atomic32 profiling_;
99 base::Atomic32 has_processing_thread_;
100 base::Atomic32 active_;
101 base::Atomic32 registered_;
103 DISALLOW_IMPLICIT_CONSTRUCTORS(
Sampler);
109 #endif // V8_LIBSAMPLER_SAMPLER_H_