5#ifndef RUNTIME_VM_HEAP_SAMPLER_H_
6#define RUNTIME_VM_HEAP_SAMPLER_H_
8#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
39 static bool enabled() {
return enabled_; }
55 return delete_callback_;
61 last_sample_size_ = kUninitialized;
77 return schedule_thread_enable_.exchange(
false);
99 return schedule_thread_set_sampling_interval_.exchange(
false);
120 void HandleNewTLAB(intptr_t old_tlab_remaining_space,
bool is_first_tlab);
125 return last_sample_size_ != kUninitialized;
133 void ResetIntervalState() { interval_to_next_sample_ = kUninitialized; }
135 void UpdateThreadEnableLocked();
137 void SetThreadSamplingIntervalLocked();
138 void SetNextSamplingIntervalLocked(intptr_t next_interval);
140 intptr_t GetNextSamplingIntervalLocked();
141 intptr_t NumberOfSamplesLocked(intptr_t allocation_size);
145 intptr_t remaining_TLAB_interval()
const;
147 std::atomic<bool> schedule_thread_enable_ =
false;
148 std::atomic<bool> schedule_thread_set_sampling_interval_ =
false;
156 static RwLock* lock_;
157 static bool enabled_;
160 static intptr_t sampling_interval_;
162 static constexpr intptr_t kUninitialized = -1;
163 static constexpr intptr_t kDefaultSamplingInterval = 512 *
KB;
165 bool thread_enabled_ =
false;
166 intptr_t interval_to_next_sample_ = kUninitialized;
167 intptr_t next_tlab_offset_ = kUninitialized;
168 intptr_t last_sample_size_ = kUninitialized;
static void SetSamplingCallback(Dart_HeapSamplingCreateCallback create_callback, Dart_HeapSamplingDeleteCallback delete_callback)
HeapProfileSampler(Thread *thread)
void SetThreadSamplingInterval()
void HandleNewTLAB(intptr_t old_tlab_remaining_space, bool is_first_tlab)
void ScheduleUpdateThreadEnable()
void HandleReleasedTLAB(Thread *thread)
void UpdateThreadEnable()
static void SetSamplingInterval(intptr_t bytes_interval)
void ScheduleSetThreadSamplingInterval()
bool ShouldSetThreadSamplingInterval()
bool ShouldUpdateThreadEnable()
static Dart_HeapSamplingDeleteCallback delete_callback()
bool HasOutstandingSample() const
static void Enable(bool enabled)
void SampleNewSpaceAllocation(intptr_t allocation_size)
void SampleOldSpaceAllocation(intptr_t allocation_size)
void * InvokeCallbackForLastSample(intptr_t cid)
void *(* Dart_HeapSamplingCreateCallback)(Dart_Isolate isolate, Dart_IsolateGroup isolate_group, const char *cls_name, intptr_t allocation_size)
void(* Dart_HeapSamplingDeleteCallback)(void *data)