5#ifndef V8_PROFILER_SAMPLING_HEAP_PROFILER_H_
6#define V8_PROFILER_SAMPLING_HEAP_PROFILER_H_
11#include <unordered_map>
20class RandomNumberGenerator;
35 const std::vector<v8::AllocationProfile::Sample>&
GetSamples()
override {
40 std::deque<v8::AllocationProfile::Node>
nodes_;
41 std::vector<v8::AllocationProfile::Sample>
samples_;
52 int start_position, uint32_t
id)
63 return it !=
children_.end() ? it->second.get() :
nullptr;
67 std::unique_ptr<AllocationNode> node) {
68 return children_.emplace(
id, std::move(node)).first->second.get();
78 return reinterpret_cast<intptr_t
>(
name) | 1;
83 DCHECK(
static_cast<unsigned>(start_position) < (1u << 31));
84 return (
static_cast<uint64_t
>(script_id) << 32) + (start_position << 1);
91 std::map<FunctionId, std::unique_ptr<AllocationNode>>
children_;
141 void Step(
int bytes_allocated,
Address soon_object,
size_t size)
override {
163 const std::vector<v8::AllocationProfile::Sample>
BuildSamples()
const;
166 int script_id,
int start_position);
183 unsigned int count)
const;
193 std::unordered_map<Sample*, std::unique_ptr<Sample>>
samples_;
static const int kNoScriptId
std::vector< v8::AllocationProfile::Sample > samples_
AllocationProfile()=default
AllocationProfile(const AllocationProfile &)=delete
std::deque< v8::AllocationProfile::Node > nodes_
AllocationProfile & operator=(const AllocationProfile &)=delete
const std::vector< v8::AllocationProfile::Sample > & GetSamples() override
v8::AllocationProfile::Node * GetRootNode() override
HeapState gc_state() const
AllocationNode & operator=(const AllocationNode &)=delete
AllocationNode *const parent_
AllocationNode(const AllocationNode &)=delete
AllocationNode * FindChildNode(FunctionId id)
AllocationNode(AllocationNode *parent, const char *name, int script_id, int start_position, uint32_t id)
std::map< FunctionId, std::unique_ptr< AllocationNode > > children_
static FunctionId function_id(int script_id, int start_position, const char *name)
const int script_position_
std::map< size_t, unsigned int > allocations_
AllocationNode * AddChildNode(FunctionId id, std::unique_ptr< AllocationNode > node)
Observer(Heap *heap, intptr_t step_size, uint64_t rate, SamplingHeapProfiler *profiler, base::RandomNumberGenerator *random)
intptr_t GetNextStepSize() override
intptr_t GetNextSampleInterval(uint64_t rate)
base::RandomNumberGenerator *const random_
SamplingHeapProfiler *const profiler_
void Step(int bytes_allocated, Address soon_object, size_t size) override
v8::HeapProfiler::SamplingFlags flags_
const std::vector< v8::AllocationProfile::Sample > BuildSamples() const
v8::AllocationProfile::Allocation ScaleSample(size_t size, unsigned int count) const
void SampleObject(Address soon_object, size_t size)
SamplingHeapProfiler & operator=(const SamplingHeapProfiler &)=delete
v8::AllocationProfile * GetAllocationProfile()
AllocationNode * AddStack()
AllocationNode profile_root_
static void OnWeakCallback(const WeakCallbackInfo< Sample > &data)
StringsStorage * names() const
SamplingHeapProfiler(Heap *heap, StringsStorage *names, uint64_t rate, int stack_depth, v8::HeapProfiler::SamplingFlags flags)
std::unordered_map< Sample *, std::unique_ptr< Sample > > samples_
AllocationNode * FindOrAddChildNode(AllocationNode *parent, const char *name, int script_id, int start_position)
v8::AllocationProfile::Node * TranslateAllocationNode(AllocationProfile *profile, SamplingHeapProfiler::AllocationNode *node, const std::map< int, Handle< Script > > &scripts)
uint64_t next_sample_id()
Observer allocation_observer_
StringsStorage *const names_
SamplingHeapProfiler(const SamplingHeapProfiler &)=delete
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
refactor address components for immediate indexing make OptimizeMaglevOnNextCall optimize to turbofan instead of maglev filter for tracing turbofan compilation nullptr
#define DCHECK(condition)
Sample & operator=(const Sample &)=delete
Sample(size_t size_, AllocationNode *owner_, Local< Value > local_, SamplingHeapProfiler *profiler_, uint64_t sample_id)
Sample(const Sample &)=delete
AllocationNode *const owner
SamplingHeapProfiler *const profiler