5#ifndef V8_V8_PROFILER_H_
6#define V8_V8_PROFILER_H_
11#include <unordered_set>
25struct HeapStatsUpdate;
45template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>;
53 std::vector<CpuProfileDeoptFrame>
stack;
59template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
174 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
175 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
299 friend internal::CpuProfile;
301 void SetId(
ProfilerId id) { profiler_id_ = id; }
303 ProfilerId profiler_id_;
312 static const unsigned kNoSampleLimit = UINT_MAX;
331 unsigned max_samples = kNoSampleLimit,
int sampling_interval_us = 0,
339 friend class internal::CpuProfile;
341 bool has_filter_context()
const {
return !filter_context_.IsEmpty(); }
342 void* raw_filter_context()
const;
345 unsigned max_samples_;
346 int sampling_interval_us_;
399 std::unique_ptr<DiscardedSamplesDelegate> delegate =
nullptr);
408 std::unique_ptr<DiscardedSamplesDelegate> delegate =
nullptr);
423 unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
439 std::unique_ptr<DiscardedSamplesDelegate> delegate =
nullptr);
454 unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
462 bool record_samples =
false);
495 kContextVariable = 0,
796 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
797 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
833 virtual const char*
Name() = 0;
899 kSamplingNoFlags = 0,
900 kSamplingForceGC = 1 << 0,
923 uint16_t class_id,
void* data);
984 bool treat_global_objects_as_roots =
true,
985 bool capture_numeric_value =
false);
1012 int64_t* timestamp_us =
nullptr);
1049 int stack_depth = 16,
1083 static const uint16_t kPersistentHandleNoClassId = 0;
1098 : index(index), count(count), size(size) { }
1104#define CODE_EVENTS_LIST(V) \
1109 V(InterpretedFunction) \
1111 V(BytecodeHandler) \
1124#define V(Name) , k##Name##Type
1192 void* internal_listener_;
virtual ~ActivityControl()=default
virtual ControlOption ReportProgressValue(uint32_t done, uint32_t total)=0
virtual ~AllocationProfile()=default
virtual Node * GetRootNode()=0
virtual const std::vector< Sample > & GetSamples()=0
virtual void Handle(CodeEvent *code_event)=0
virtual ~CodeEventHandler()
CodeEventHandler(Isolate *isolate)
CodeEventType GetCodeType()
Local< String > GetFunctionName()
Local< String > GetScriptName()
uintptr_t GetCodeStartAddress()
const char * GetComment()
static const char * GetCodeEventTypeName(CodeEventType code_event_type)
uintptr_t GetPreviousCodeStartAddress()
int64_t GetStartTime() const
StateTag GetSampleState(int index) const
const CpuProfileNode * GetTopDownRoot() const
EmbedderStateTag GetSampleEmbedderState(int index) const
int64_t GetSampleTimestamp(int index) const
Local< String > GetTitle() const
int GetSamplesCount() const
int64_t GetEndTime() const
const CpuProfileNode * GetSample(int index) const
const char * GetBailoutReason() const
const CpuProfileNode * GetParent() const
Local< String > GetFunctionName() const
int GetChildrenCount() const
const std::vector< CpuProfileDeoptInfo > & GetDeoptInfos() const
unsigned GetNodeId() const
const char * GetScriptResourceNameStr() const
bool IsScriptSharedCrossOrigin() const
Local< String > GetScriptResourceName() const
bool GetLineTicks(LineTick *entries, unsigned int length) const
int GetLineNumber() const
const CpuProfileNode * GetChild(int index) const
int GetColumnNumber() const
unsigned int GetHitLineCount() const
SourceType GetSourceType() const
const char * GetFunctionNameStr() const
unsigned GetHitCount() const
CpuProfilingResult Start(Local< String > title, bool record_samples=false)
CpuProfile * StopProfiling(Local< String > title)
CpuProfilingResult Start(Local< String > title, CpuProfilingOptions options, std::unique_ptr< DiscardedSamplesDelegate > delegate=nullptr)
static void CollectSample(Isolate *isolate)
CpuProfilingResult Start(Local< String > title, CpuProfilingMode mode, bool record_samples=false, unsigned max_samples=CpuProfilingOptions::kNoSampleLimit)
CpuProfile * Stop(ProfilerId id)
void SetSamplingInterval(int us)
CpuProfilingStatus StartProfiling(Local< String > title, CpuProfilingMode mode, bool record_samples=false, unsigned max_samples=CpuProfilingOptions::kNoSampleLimit)
CpuProfilingStatus StartProfiling(Local< String > title, bool record_samples=false)
static void UseDetailedSourcePositionsForProfiling(Isolate *isolate)
void SetUsePreciseSampling(bool)
CpuProfilingStatus StartProfiling(Local< String > title, CpuProfilingOptions options, std::unique_ptr< DiscardedSamplesDelegate > delegate=nullptr)
CpuProfilingResult Start(CpuProfilingOptions options, std::unique_ptr< DiscardedSamplesDelegate > delegate=nullptr)
static CpuProfiler * New(Isolate *isolate, CpuProfilingNamingMode=kDebugNaming, CpuProfilingLoggingMode=kLazyLogging)
unsigned max_samples() const
CpuProfilingMode mode() const
int sampling_interval_us() const
CpuProfilingOptions(CpuProfilingMode mode=kLeafNodeLineNumbers, unsigned max_samples=kNoSampleLimit, int sampling_interval_us=0, MaybeLocal< Context > filter_context=MaybeLocal< Context >())
DiscardedSamplesDelegate()=default
virtual ~DiscardedSamplesDelegate()=default
virtual const char * NamePrefix()
virtual const char * Name()=0
virtual bool IsRootNode()
virtual Node * WrapperNode()
Node & operator=(const Node &)=delete
Node(const Node &)=delete
virtual NativeObject GetNativeObject()
virtual Detachedness GetDetachedness()
virtual size_t SizeInBytes()=0
virtual bool IsEmbedderNode()
virtual Node * V8Node(const v8::Local< v8::Value > &value)=0
virtual ~EmbedderGraph()=default
virtual void AddEdge(Node *from, Node *to, const char *name=nullptr)=0
virtual Node * AddNode(std::unique_ptr< Node > node)=0
const HeapGraphNode * GetToNode() const
Local< Value > GetName() const
const HeapGraphNode * GetFromNode() const
const HeapGraphEdge * GetChild(int index) const
SnapshotObjectId GetId() const
int GetChildrenCount() const
Local< String > GetName() const
size_t GetShallowSize() const
virtual ~ObjectNameResolver()=default
virtual const char * GetName(Local< Object > object)=0
bool StartSamplingHeapProfiler(uint64_t sample_interval=512 *1024, int stack_depth=16, SamplingFlags flags=kSamplingNoFlags)
SnapshotObjectId GetObjectId(Local< Value > value)
void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback, void *data)
void DeleteAllHeapSnapshots()
EmbedderGraph::Node::Detachedness(*)(v8::Isolate *isolate, const v8::Local< v8::Value > &v8_value, uint16_t class_id, void *data) GetDetachednessCallback
AllocationProfile * GetAllocationProfile()
void StopTrackingHeapObjects()
const HeapSnapshot * TakeHeapSnapshot(ActivityControl *control=nullptr, ObjectNameResolver *global_object_name_resolver=nullptr, bool treat_global_objects_as_roots=true, bool capture_numeric_value=false)
void SetGetDetachednessCallback(GetDetachednessCallback callback, void *data)
SnapshotObjectId GetHeapStats(OutputStream *stream, int64_t *timestamp_us=nullptr)
const HeapSnapshot * GetHeapSnapshot(int index)
Local< Value > FindObjectById(SnapshotObjectId id)
void StartTrackingHeapObjects(bool track_allocations=false)
void StopSamplingHeapProfiler()
SnapshotObjectId GetObjectId(NativeObject value)
void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback, void *data)
const HeapGraphNode * GetNodeById(SnapshotObjectId id) const
SnapshotObjectId GetMaxSnapshotJSObjectId() const
const HeapGraphNode * GetNode(int index) const
void Serialize(OutputStream *stream, SerializationFormat format=kJSON) const
int GetNodesCount() const
const HeapGraphNode * GetRoot() const
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate *data, int count)
virtual WriteResult WriteAsciiChunk(char *data, int size)=0
virtual int GetChunkSize()
virtual void EndOfStream()=0
virtual ~OutputStream()=default
uint32_t SnapshotObjectId
std::vector< Node * > children
Local< String > script_name
std::vector< Allocation > allocations
const char * deopt_reason
std::vector< CpuProfileDeoptFrame > stack
const CpuProfilingStatus status
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
#define CODE_EVENTS_LIST(V)