5 #ifndef V8_V8_PROFILER_H_ 6 #define V8_V8_PROFILER_H_ 8 #include <unordered_set> 18 struct HeapStatsUpdate;
20 typedef uint32_t SnapshotObjectId;
31 template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>;
39 std::vector<CpuProfileDeoptFrame> stack;
45 template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
58 "The profiler is created automatically with the isolate.\n" 59 "No need to create it explicitly.",
60 static std::unique_ptr<TracingCpuProfiler> Create(
Isolate*));
73 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame };
78 external_callback_entry(
nullptr),
80 has_external_callback(
false),
96 RecordCEntryFrame record_c_entry_frame,
bool update_stats,
97 bool use_simulator_reg_state =
true);
119 RecordCEntryFrame record_c_entry_frame,
120 void** frames,
size_t frames_limit,
122 bool use_simulator_reg_state =
true);
127 void* external_callback_entry;
129 static const unsigned kMaxFramesCountLog2 = 8;
130 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
131 void* stack[kMaxFramesCount];
132 unsigned frames_count : kMaxFramesCountLog2;
133 bool has_external_callback : 1;
134 bool update_stats : 1;
158 const char* GetFunctionNameStr()
const;
161 int GetScriptId()
const;
171 const char* GetScriptResourceNameStr()
const;
177 int GetLineNumber()
const;
183 int GetColumnNumber()
const;
188 unsigned int GetHitLineCount()
const;
195 bool GetLineTicks(
LineTick* entries,
unsigned int length)
const;
200 const char* GetBailoutReason()
const;
205 unsigned GetHitCount()
const;
209 "Use GetScriptId, GetLineNumber, and GetColumnNumber instead.",
210 unsigned GetCallUid()
const);
213 unsigned GetNodeId()
const;
216 int GetChildrenCount()
const;
222 const std::vector<CpuProfileDeoptInfo>& GetDeoptInfos()
const;
224 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
225 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
245 int GetSamplesCount()
const;
258 int64_t GetSampleTimestamp(
int index)
const;
264 int64_t GetStartTime()
const;
271 int64_t GetEndTime()
const;
280 enum CpuProfilingMode {
284 kLeafNodeLineNumbers,
308 static void CollectSample(
Isolate* isolate);
320 void SetSamplingInterval(
int us);
333 void StartProfiling(
Local<String> title, CpuProfilingMode mode,
334 bool record_samples =
false);
340 void StartProfiling(
Local<String> title,
bool record_samples =
false);
353 V8_DEPRECATED(
"Use static CollectSample(Isolate*) instead.",
354 void CollectSample());
359 V8_DEPRECATED(
"Use Isolate::SetIdle(bool) instead.",
360 void SetIdle(
bool is_idle));
377 kContextVariable = 0,
391 Type GetType()
const;
431 Type GetType()
const;
444 SnapshotObjectId GetId()
const;
447 size_t GetShallowSize()
const;
450 int GetChildrenCount()
const;
468 virtual void EndOfStream() = 0;
476 virtual WriteResult WriteAsciiChunk(
char* data,
int size) = 0;
493 enum SerializationFormat {
504 int GetNodesCount()
const;
510 SnapshotObjectId GetMaxSnapshotJSObjectId()
const;
546 SerializationFormat format = kJSON)
const;
565 virtual ControlOption ReportProgressValue(
int done,
int total) = 0;
644 virtual Node* GetRootNode() = 0;
648 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
649 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
671 virtual ~
Node() =
default;
672 virtual const char*
Name() = 0;
673 virtual size_t SizeInBytes() = 0;
680 virtual bool IsRootNode() {
return false; }
690 Node& operator=(
const Node&) =
delete;
703 virtual Node* AddNode(std::unique_ptr<Node> node) = 0;
710 virtual void AddEdge(Node* from, Node* to) = 0;
722 kSamplingNoFlags = 0,
723 kSamplingForceGC = 1 << 0,
726 typedef std::unordered_set<const v8::PersistentBase<v8::Value>*>
728 typedef std::vector<std::pair<v8::RetainedObjectInfo*, RetainerChildren>>
730 typedef std::vector<std::pair<const v8::PersistentBase<v8::Value>*,
735 RetainerGroups groups;
764 typedef void (*LegacyBuildEmbedderGraphCallback)(
v8::Isolate* isolate,
768 int GetSnapshotCount();
790 void ClearObjectIds();
797 static const SnapshotObjectId kUnknownObjectId = 0;
830 void StartTrackingHeapObjects(
bool track_allocations =
false);
846 int64_t* timestamp_us = NULL);
853 void StopTrackingHeapObjects();
882 bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024,
883 int stack_depth = 16,
884 SamplingFlags flags = kSamplingNoFlags);
889 void StopSamplingHeapProfiler();
903 void DeleteAllHeapSnapshots();
907 "Use AddBuildEmbedderGraphCallback to provide info about embedder nodes",
908 void SetWrapperClassInfoProvider(uint16_t class_id,
909 WrapperInfoCallback callback));
912 "Use AddBuildEmbedderGraphCallback to provide info about embedder nodes",
913 void SetGetRetainerInfosCallback(GetRetainerInfosCallback callback));
916 "Use AddBuildEmbedderGraphCallback to provide info about embedder nodes",
917 void SetBuildEmbedderGraphCallback(
918 LegacyBuildEmbedderGraphCallback callback));
919 void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
921 void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
929 static const uint16_t kPersistentHandleNoClassId = 0;
965 virtual void Dispose() = 0;
974 virtual intptr_t GetHash() = 0;
980 virtual const char* GetLabel() = 0;
1004 virtual ~RetainedObjectInfo() {}
1007 RetainedObjectInfo(
const RetainedObjectInfo&);
1008 RetainedObjectInfo& operator=(
const RetainedObjectInfo&);
1018 : index(index), count(count), size(size) { }
1024 #define CODE_EVENTS_LIST(V) \ 1029 V(InterpretedFunction) \ 1031 V(BytecodeHandler) \ 1043 #define V(Name) , k##Name##Type 1053 uintptr_t GetCodeStartAddress();
1054 size_t GetCodeSize();
1057 int GetScriptLine();
1058 int GetScriptColumn();
1065 const char* GetComment();
1067 static const char* GetCodeEventTypeName(
CodeEventType code_event_type);
1092 void* internal_listener_;
1098 #endif // V8_V8_PROFILER_H_ unsigned int hit_count
Definition: v8-profiler.h:147
Definition: v8-profiler.h:962
Definition: v8-profiler.h:575
Definition: v8-profiler.h:233
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate *data, int count)
Definition: v8-profiler.h:482
const char * deopt_reason
Definition: v8-profiler.h:38
virtual Node * WrapperNode()
Definition: v8-profiler.h:679
size_t size
Definition: v8-profiler.h:579
int script_id
Definition: v8-profiler.h:607
Definition: v8-profiler.h:1073
virtual intptr_t GetElementCount()
Definition: v8-profiler.h:997
int start_position
Definition: v8-profiler.h:612
unsigned int count
Definition: v8-profiler.h:584
Definition: v8-profiler.h:410
Definition: v8-profiler.h:36
Definition: v8-profiler.h:69
Local< String > name
Definition: v8-profiler.h:595
virtual bool IsEmbedderNode()
Definition: v8-profiler.h:682
Local< String > script_name
Definition: v8-profiler.h:601
virtual int GetChunkSize()
Definition: v8-profiler.h:470
Definition: v8-profiler.h:1016
std::vector< Node * > children
Definition: v8-profiler.h:631
Definition: v8-profiler.h:374
virtual intptr_t GetSizeInBytes()
Definition: v8-profiler.h:1000
Definition: v8-platform.h:16
Definition: v8-profiler.h:590
Definition: v8-profiler.h:23
Definition: v8-profiler.h:142
Definition: v8-profiler.h:573
int column_number
Definition: v8-profiler.h:624
Definition: v8-profiler.h:460
Definition: v8-profiler.h:734
Definition: v8-profiler.h:554
Definition: v8-profiler.h:294
CodeEventType
Definition: v8-profiler.h:1041
Definition: v8-profiler.h:802
virtual const char * GetGroupLabel()
Definition: v8-profiler.h:991
Definition: v8-profiler.h:666
Definition: v8-profiler.h:719
virtual const char * NamePrefix()
Definition: v8-profiler.h:686
Definition: v8-profiler.h:668
Definition: v8-profiler.h:140
std::vector< Allocation > allocations
Definition: v8-profiler.h:636
int line_number
Definition: v8-profiler.h:618
Definition: v8-profiler.h:55
Definition: v8-profiler.h:1051
Definition: v8-profiler.h:491
int line
Definition: v8-profiler.h:144