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;
960 kSamplingNoFlags = 0,
961 kSamplingForceGC = 1 << 0,
962 kSamplingIncludeObjectsCollectedByMajorGC = 1 << 1,
963 kSamplingIncludeObjectsCollectedByMinorGC = 1 << 2,
986 uint16_t class_id,
void* data);
1061 kExposeNumericValues
1110 bool hide_internals =
true,
bool capture_numeric_value =
false);
1143 int64_t* timestamp_us =
nullptr);
1178 int stack_depth = 16,
1224 static const uint16_t kPersistentHandleNoClassId = 0;
1239 : index(index), count(count), size(size) { }
1245#define CODE_EVENTS_LIST(V) \
1250 V(InterpretedFunction) \
1252 V(BytecodeHandler) \
1265#define V(Name) , k##Name##Type
1275 uintptr_t GetCodeStartAddress();
1276 size_t GetCodeSize();
1279 int GetScriptLine();
1280 int GetScriptColumn();
1287 const char* GetComment();
1289 static const char* GetCodeEventTypeName(
CodeEventType code_event_type);
1291 uintptr_t GetPreviousCodeStartAddress();
1333 void* internal_listener_;
Definition: v8-profiler.h:694
ControlOption
Definition: v8-profiler.h:696
virtual ControlOption ReportProgressValue(uint32_t done, uint32_t total)=0
virtual ~ActivityControl()=default
Definition: v8-profiler.h:712
virtual const std::vector< Sample > & GetSamples()=0
virtual Node * GetRootNode()=0
virtual ~AllocationProfile()=default
Definition: v8-profiler.h:1296
Definition: v8-profiler.h:1272
Definition: v8-profiler.h:68
const CpuProfileNode * GetChild(int index) const
bool GetLineTicks(LineTick *entries, unsigned int length) const
const CpuProfileNode * GetParent() const
unsigned GetHitCount() const
unsigned int GetHitLineCount() const
int GetLineNumber() const
unsigned GetNodeId() const
const char * GetScriptResourceNameStr() const
const char * GetFunctionNameStr() const
const std::vector< CpuProfileDeoptInfo > & GetDeoptInfos() const
SourceType
Definition: v8-profiler.h:79
int GetColumnNumber() const
Local< String > GetFunctionName() const
Local< String > GetScriptResourceName() const
SourceType GetSourceType() const
const char * GetBailoutReason() const
bool IsScriptSharedCrossOrigin() const
int GetChildrenCount() const
Definition: v8-profiler.h:210
const CpuProfileNode * GetTopDownRoot() const
int GetSamplesCount() const
StateTag GetSampleState(int index) const
Local< String > GetTitle() const
int64_t GetEndTime() const
const CpuProfileNode * GetSample(int index) const
SerializationFormat
Definition: v8-profiler.h:212
int64_t GetSampleTimestamp(int index) const
int64_t GetStartTime() const
EmbedderStateTag GetSampleEmbedderState(int index) const
void Serialize(OutputStream *stream, SerializationFormat format=kJSON) const
Definition: v8-profiler.h:406
CpuProfilingResult Start(CpuProfilingOptions options, std::unique_ptr< DiscardedSamplesDelegate > delegate=nullptr)
CpuProfilingStatus StartProfiling(Local< String > title, CpuProfilingOptions options, std::unique_ptr< DiscardedSamplesDelegate > delegate=nullptr)
void SetUsePreciseSampling(bool)
static CpuProfiler * New(Isolate *isolate, CpuProfilingNamingMode=kDebugNaming, CpuProfilingLoggingMode=kLazyLogging)
CpuProfilingResult Start(Local< String > title, CpuProfilingMode mode, bool record_samples=false, unsigned max_samples=CpuProfilingOptions::kNoSampleLimit)
CpuProfilingStatus StartProfiling(Local< String > title, CpuProfilingMode mode, bool record_samples=false, unsigned max_samples=CpuProfilingOptions::kNoSampleLimit)
static void CollectSample(Isolate *isolate)
CpuProfile * StopProfiling(Local< String > title)
CpuProfilingResult Start(Local< String > title, CpuProfilingOptions options, std::unique_ptr< DiscardedSamplesDelegate > delegate=nullptr)
void SetSamplingInterval(int us)
CpuProfile * Stop(ProfilerId id)
static void UseDetailedSourcePositionsForProfiling(Isolate *isolate)
CpuProfilingStatus StartProfiling(Local< String > title, bool record_samples=false)
CpuProfilingResult Start(Local< String > title, bool record_samples=false)
Definition: v8-profiler.h:358
CpuProfilingOptions & operator=(CpuProfilingOptions &&)=default
int sampling_interval_us() const
Definition: v8-profiler.h:388
CpuProfilingMode mode() const
Definition: v8-profiler.h:386
unsigned max_samples() const
Definition: v8-profiler.h:387
CpuProfilingOptions(CpuProfilingOptions &&)=default
CpuProfilingOptions(CpuProfilingMode mode=kLeafNodeLineNumbers, unsigned max_samples=kNoSampleLimit, int sampling_interval_us=0, MaybeLocal< Context > filter_context=MaybeLocal< Context >())
Definition: v8-profiler.h:338
ProfilerId GetId() const
Definition: v8-profiler.h:345
DiscardedSamplesDelegate()=default
virtual ~DiscardedSamplesDelegate()=default
Definition: v8-profiler.h:839
virtual Detachedness GetDetachedness()
Definition: v8-profiler.h:884
Detachedness
Definition: v8-profiler.h:848
Node & operator=(const Node &)=delete
virtual size_t SizeInBytes()=0
virtual bool IsEmbedderNode()
Definition: v8-profiler.h:866
virtual const char * Name()=0
virtual NativeObject GetNativeObject()
Definition: v8-profiler.h:876
virtual Node * WrapperNode()
Definition: v8-profiler.h:863
Node(const Node &)=delete
virtual const char * NamePrefix()
Definition: v8-profiler.h:870
virtual const void * GetAddress()
Definition: v8-profiler.h:893
virtual bool IsRootNode()
Definition: v8-profiler.h:864
Definition: v8-profiler.h:837
virtual ~EmbedderGraph()=default
virtual void AddEdge(Node *from, Node *to, const char *name=nullptr)=0
virtual Node * AddNode(std::unique_ptr< Node > node)=0
virtual Node * V8Node(const v8::Local< v8::Data > &value)
virtual Node * V8Node(const v8::Local< v8::Value > &value)=0
Definition: v8-persistent-handle.h:347
Definition: v8-profiler.h:544
Type
Definition: v8-profiler.h:546
const HeapGraphNode * GetToNode() const
const HeapGraphNode * GetFromNode() const
Local< Value > GetName() const
Definition: v8-profiler.h:580
Local< String > GetName() const
SnapshotObjectId GetId() const
Type
Definition: v8-profiler.h:582
const HeapGraphEdge * GetChild(int index) const
size_t GetShallowSize() const
int GetChildrenCount() const
Definition: v8-profiler.h:1029
virtual ~ObjectNameResolver()=default
virtual const char * GetName(Local< Object > object)=0
Definition: v8-profiler.h:953
void StartTrackingHeapObjects(bool track_allocations=false)
void SetGetDetachednessCallback(GetDetachednessCallback callback, void *data)
Local< Value > FindObjectById(SnapshotObjectId id)
AllocationProfile * GetAllocationProfile()
void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback, void *data)
void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback, void *data)
std::vector< v8::Local< v8::Value > > GetDetachedJSWrapperObjects()
void DeleteAllHeapSnapshots()
bool StartSamplingHeapProfiler(uint64_t sample_interval=512 *1024, int stack_depth=16, SamplingFlags flags=kSamplingNoFlags)
const char * CopyNameForHeapSnapshot(const char *name)
HeapSnapshotMode
Definition: v8-profiler.h:1041
const HeapSnapshot * TakeHeapSnapshot(ActivityControl *control, ObjectNameResolver *global_object_name_resolver=nullptr, bool hide_internals=true, bool capture_numeric_value=false)
SamplingFlags
Definition: v8-profiler.h:959
void QueryObjects(v8::Local< v8::Context > context, QueryObjectPredicate *predicate, std::vector< v8::Global< v8::Object > > *objects)
SnapshotObjectId GetObjectId(NativeObject value)
SnapshotObjectId GetObjectId(Local< Value > value)
void StopSamplingHeapProfiler()
const HeapSnapshot * TakeHeapSnapshot(const HeapSnapshotOptions &options=HeapSnapshotOptions())
const HeapSnapshot * GetHeapSnapshot(int index)
SnapshotObjectId GetHeapStats(OutputStream *stream, int64_t *timestamp_us=nullptr)
void StopTrackingHeapObjects()
EmbedderGraph::Node::Detachedness(*)(v8::Isolate *isolate, const v8::Local< v8::Value > &v8_value, uint16_t class_id, void *data) GetDetachednessCallback
Definition: v8-profiler.h:986
NumericsMode
Definition: v8-profiler.h:1052
Definition: v8-profiler.h:631
const HeapGraphNode * GetNodeById(SnapshotObjectId id) const
int GetNodesCount() const
SerializationFormat
Definition: v8-profiler.h:633
const HeapGraphNode * GetRoot() const
SnapshotObjectId GetMaxSnapshotJSObjectId() const
const HeapGraphNode * GetNode(int index) const
void Serialize(OutputStream *stream, SerializationFormat format=kJSON) const
Definition: v8-isolate.h:212
Definition: v8-local-handle.h:266
Definition: v8-local-handle.h:632
Definition: v8-profiler.h:182
virtual ~OutputStream()=default
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate *data, int count)
Definition: v8-profiler.h:201
WriteResult
Definition: v8-profiler.h:184
virtual WriteResult WriteAsciiChunk(char *data, int size)=0
virtual void EndOfStream()=0
virtual int GetChunkSize()
Definition: v8-profiler.h:189
Definition: v8-profiler.h:943
virtual bool Filter(v8::Local< v8::Object > object)=0
virtual ~QueryObjectPredicate()=default
EmbedderStackState
Definition: common.h:15
@ kMayContainHeapPointers
Definition: libplatform.h:15
uint32_t SnapshotObjectId
Definition: v8-profiler.h:31
CpuProfilingStatus
Definition: v8-profiler.h:320
uint32_t ProfilerId
Definition: v8-profiler.h:32
CpuProfilingLoggingMode
Definition: v8-profiler.h:308
@ kEagerLogging
Definition: v8-profiler.h:314
@ kLazyLogging
Definition: v8-profiler.h:311
EmbedderStateTag
Definition: v8-embedder-state-scope.h:22
CpuProfilingMode
Definition: v8-profiler.h:289
@ kLeafNodeLineNumbers
Definition: v8-profiler.h:293
@ kCallerLineNumbers
Definition: v8-profiler.h:296
void * NativeObject
Definition: v8-profiler.h:30
CpuProfilingNamingMode
Definition: v8-profiler.h:300
@ kStandardNaming
Definition: v8-profiler.h:302
@ kDebugNaming
Definition: v8-profiler.h:305
CodeEventType
Definition: v8-profiler.h:1263
@ kUnknownType
Definition: v8-profiler.h:1264
StateTag
Definition: v8-unwinder.h:36
Definition: v8-profiler.h:714
unsigned int count
Definition: v8-profiler.h:723
size_t size
Definition: v8-profiler.h:718
Definition: v8-profiler.h:729
std::vector< Node * > children
Definition: v8-profiler.h:775
int script_id
Definition: v8-profiler.h:746
int start_position
Definition: v8-profiler.h:751
std::vector< Allocation > allocations
Definition: v8-profiler.h:780
int column_number
Definition: v8-profiler.h:763
uint32_t node_id
Definition: v8-profiler.h:768
int line_number
Definition: v8-profiler.h:757
Local< String > script_name
Definition: v8-profiler.h:740
Local< String > name
Definition: v8-profiler.h:734
Definition: v8-profiler.h:786
unsigned int count
Definition: v8-profiler.h:800
size_t size
Definition: v8-profiler.h:795
uint32_t node_id
Definition: v8-profiler.h:790
uint64_t sample_id
Definition: v8-profiler.h:806
Definition: v8-profiler.h:34
size_t position
Definition: v8-profiler.h:36
int script_id
Definition: v8-profiler.h:35
Definition: v8-profiler.h:51
const char * deopt_reason
Definition: v8-profiler.h:53
std::vector< CpuProfileDeoptFrame > stack
Definition: v8-profiler.h:54
Definition: v8-profiler.h:70
unsigned int hit_count
Definition: v8-profiler.h:75
int line
Definition: v8-profiler.h:72
Definition: v8-profiler.h:330
const ProfilerId id
Definition: v8-profiler.h:331
const CpuProfilingStatus status
Definition: v8-profiler.h:332
Definition: v8-profiler.h:1064
HeapSnapshotOptions()
Definition: v8-profiler.h:1068
Definition: v8-profiler.h:1237
uint32_t size
Definition: v8-profiler.h:1242
uint32_t index
Definition: v8-profiler.h:1240
uint32_t count
Definition: v8-profiler.h:1241
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
Definition: v8-profiler.h:1238
#define CODE_EVENTS_LIST(V)
Definition: v8-profiler.h:1245
#define V8_EXPORT
Definition: v8config.h:793