5 #ifndef V8_V8_PROFILER_H_ 6 #define V8_V8_PROFILER_H_ 8 #include <unordered_set> 18 struct HeapStatsUpdate;
31 template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>;
39 std::vector<CpuProfileDeoptFrame> stack;
45 template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
55 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame };
60 external_callback_entry(
nullptr),
62 has_external_callback(
false),
78 RecordCEntryFrame record_c_entry_frame,
bool update_stats,
79 bool use_simulator_reg_state =
true);
101 RecordCEntryFrame record_c_entry_frame,
102 void** frames,
size_t frames_limit,
104 bool use_simulator_reg_state =
true);
109 void* external_callback_entry;
111 static const unsigned kMaxFramesCountLog2 = 8;
112 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
113 void* stack[kMaxFramesCount];
114 unsigned frames_count : kMaxFramesCountLog2;
115 bool has_external_callback : 1;
116 bool update_stats : 1;
140 const char* GetFunctionNameStr()
const;
143 int GetScriptId()
const;
153 const char* GetScriptResourceNameStr()
const;
159 int GetLineNumber()
const;
165 int GetColumnNumber()
const;
170 unsigned int GetHitLineCount()
const;
177 bool GetLineTicks(
LineTick* entries,
unsigned int length)
const;
182 const char* GetBailoutReason()
const;
187 unsigned GetHitCount()
const;
191 "Use GetScriptId, GetLineNumber, and GetColumnNumber instead.",
192 unsigned GetCallUid()
const);
195 unsigned GetNodeId()
const;
198 int GetChildrenCount()
const;
204 const std::vector<CpuProfileDeoptInfo>& GetDeoptInfos()
const;
206 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
207 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
227 int GetSamplesCount()
const;
240 int64_t GetSampleTimestamp(
int index)
const;
262 enum CpuProfilingMode {
266 kLeafNodeLineNumbers,
290 static void CollectSample(Isolate* isolate);
302 void SetSamplingInterval(
int us);
315 void StartProfiling(
Local<String> title, CpuProfilingMode mode,
316 bool record_samples =
false);
322 void StartProfiling(
Local<String> title,
bool record_samples =
false);
335 V8_DEPRECATED(
"Use static CollectSample(Isolate*) instead.",
336 void CollectSample());
341 V8_DEPRECATED(
"Use Isolate::SetIdle(bool) instead.",
342 void SetIdle(
bool is_idle));
348 static void UseDetailedSourcePositionsForProfiling(Isolate* isolate);
365 kContextVariable = 0,
379 Type GetType()
const;
419 Type GetType()
const;
435 size_t GetShallowSize()
const;
438 int GetChildrenCount()
const;
456 virtual void EndOfStream() = 0;
464 virtual WriteResult WriteAsciiChunk(
char* data,
int size) = 0;
481 enum SerializationFormat {
492 int GetNodesCount()
const;
534 SerializationFormat format = kJSON)
const;
553 virtual ControlOption ReportProgressValue(
int done,
int total) = 0;
663 virtual Node* GetRootNode() = 0;
664 virtual const std::vector<Sample>& GetSamples() = 0;
668 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
669 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
691 virtual ~
Node() =
default;
692 virtual const char*
Name() = 0;
693 virtual size_t SizeInBytes() = 0;
700 virtual bool IsRootNode() {
return false; }
710 Node& operator=(
const Node&) =
delete;
723 virtual Node* AddNode(std::unique_ptr<Node> node) = 0;
733 virtual void AddEdge(Node* from, Node* to,
const char* name =
nullptr) = 0;
745 kSamplingNoFlags = 0,
746 kSamplingForceGC = 1 << 0,
749 typedef std::unordered_set<const v8::PersistentBase<v8::Value>*>
751 typedef std::vector<std::pair<v8::RetainedObjectInfo*, RetainerChildren>>
753 typedef std::vector<std::pair<const v8::PersistentBase<v8::Value>*,
758 RetainerGroups groups;
782 typedef void (*BuildEmbedderGraphCallback)(v8::Isolate* isolate,
787 typedef void (*LegacyBuildEmbedderGraphCallback)(v8::Isolate* isolate,
791 int GetSnapshotCount();
813 void ClearObjectIds();
853 void StartTrackingHeapObjects(
bool track_allocations =
false);
869 int64_t* timestamp_us =
nullptr);
876 void StopTrackingHeapObjects();
905 bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024,
906 int stack_depth = 16,
907 SamplingFlags flags = kSamplingNoFlags);
912 void StopSamplingHeapProfiler();
926 void DeleteAllHeapSnapshots();
930 "Use AddBuildEmbedderGraphCallback to provide info about embedder nodes",
931 void SetWrapperClassInfoProvider(uint16_t class_id,
932 WrapperInfoCallback callback));
935 "Use AddBuildEmbedderGraphCallback to provide info about embedder nodes",
936 void SetGetRetainerInfosCallback(GetRetainerInfosCallback callback));
939 "Use AddBuildEmbedderGraphCallback to provide info about embedder nodes",
940 void SetBuildEmbedderGraphCallback(
941 LegacyBuildEmbedderGraphCallback callback));
942 void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
944 void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
952 static const uint16_t kPersistentHandleNoClassId = 0;
988 virtual void Dispose() = 0;
997 virtual intptr_t GetHash() = 0;
1003 virtual const char* GetLabel() = 0;
1041 : index(index), count(count), size(size) { }
1047 #define CODE_EVENTS_LIST(V) \ 1052 V(InterpretedFunction) \ 1054 V(BytecodeHandler) \ 1066 #define V(Name) , k##Name##Type 1077 size_t GetCodeSize();
1080 int GetScriptLine();
1081 int GetScriptColumn();
1088 const char* GetComment();
1090 static const char* GetCodeEventTypeName(
CodeEventType code_event_type);
1115 void* internal_listener_;
1121 #endif // V8_V8_PROFILER_H_
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate *data, int count)
const char * deopt_reason
virtual Node * WrapperNode()
virtual intptr_t GetElementCount()
virtual bool IsEmbedderNode()
Local< String > script_name
virtual int GetChunkSize()
std::vector< Node * > children
virtual intptr_t GetSizeInBytes()
virtual const char * GetGroupLabel()
virtual const char * NamePrefix()
std::vector< Allocation > allocations