5#ifndef V8_V8_PROFILER_H_
6#define V8_V8_PROFILER_H_
11#include <unordered_set>
26struct HeapStatsUpdate;
46template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>;
54 std::vector<CpuProfileDeoptFrame>
stack;
60template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
175 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
176 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
348 friend internal::CpuProfile;
350 void SetId(
ProfilerId id) { profiler_id_ = id; }
352 ProfilerId profiler_id_;
361 static const unsigned kNoSampleLimit = UINT_MAX;
380 unsigned max_samples = kNoSampleLimit,
int sampling_interval_us = 0,
391 friend class internal::CpuProfile;
393 bool has_filter_context()
const {
return !filter_context_.IsEmpty(); }
394 void* raw_filter_context()
const;
397 unsigned max_samples_;
398 int sampling_interval_us_;
451 std::unique_ptr<DiscardedSamplesDelegate> delegate =
nullptr);
460 std::unique_ptr<DiscardedSamplesDelegate> delegate =
nullptr);
475 unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
491 std::unique_ptr<DiscardedSamplesDelegate> delegate =
nullptr);
506 unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
514 bool record_samples =
false);
547 kContextVariable = 0,
819 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
820 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
856 virtual const char*
Name() = 0;
941 kSamplingNoFlags = 0,
942 kSamplingForceGC = 1 << 0,
943 kSamplingIncludeObjectsCollectedByMajorGC = 1 << 1,
944 kSamplingIncludeObjectsCollectedByMinorGC = 1 << 2,
967 uint16_t class_id,
void* data);
1042 kExposeNumericValues
1091 bool hide_internals =
true,
bool capture_numeric_value =
false);
1118 int64_t* timestamp_us =
nullptr);
1153 int stack_depth = 16,
1187 static const uint16_t kPersistentHandleNoClassId = 0;
1202 : index(index), count(count), size(size) { }
1208#define CODE_EVENTS_LIST(V) \
1213 V(InterpretedFunction) \
1215 V(BytecodeHandler) \
1228#define V(Name) , k##Name##Type
1296 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
void Serialize(OutputStream *stream, SerializationFormat format=kJSON) 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
CpuProfilingOptions & operator=(CpuProfilingOptions &&)=default
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 >())
CpuProfilingOptions(CpuProfilingOptions &&)=default
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 const void * GetAddress()
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
const HeapSnapshot * TakeHeapSnapshot(ActivityControl *control, ObjectNameResolver *global_object_name_resolver=nullptr, bool hide_internals=true, bool capture_numeric_value=false)
bool StartSamplingHeapProfiler(uint64_t sample_interval=512 *1024, int stack_depth=16, SamplingFlags flags=kSamplingNoFlags)
SnapshotObjectId GetObjectId(Local< Value > value)
const HeapSnapshot * TakeHeapSnapshot(const HeapSnapshotOptions &options=HeapSnapshotOptions())
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()
void SetGetDetachednessCallback(GetDetachednessCallback callback, void *data)
void QueryObjects(v8::Local< v8::Context > context, QueryObjectPredicate *predicate, std::vector< v8::Global< v8::Object > > *objects)
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
virtual bool Filter(v8::Local< v8::Object > object)=0
virtual ~QueryObjectPredicate()=default
@ kMayContainHeapPointers
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)