5 #ifndef V8_V8_PROFILER_H_
6 #define V8_V8_PROFILER_H_
10 #include <unordered_set>
21 struct HeapStatsUpdate;
38 template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>;
46 std::vector<CpuProfileDeoptFrame>
stack;
52 template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
92 const char* GetFunctionNameStr()
const;
95 int GetScriptId()
const;
105 const char* GetScriptResourceNameStr()
const;
111 bool IsScriptSharedCrossOrigin()
const;
117 int GetLineNumber()
const;
123 int GetColumnNumber()
const;
128 unsigned int GetHitLineCount()
const;
135 bool GetLineTicks(LineTick* entries,
unsigned int length)
const;
140 const char* GetBailoutReason()
const;
145 unsigned GetHitCount()
const;
148 unsigned GetNodeId()
const;
153 SourceType GetSourceType()
const;
156 int GetChildrenCount()
const;
165 const std::vector<CpuProfileDeoptInfo>& GetDeoptInfos()
const;
167 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
168 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
188 int GetSamplesCount()
const;
201 int64_t GetSampleTimestamp(
int index)
const;
207 int64_t GetStartTime()
const;
214 int64_t GetEndTime()
const;
257 static const unsigned kNoSampleLimit = UINT_MAX;
274 unsigned max_samples = kNoSampleLimit,
int sampling_interval_us = 0,
282 friend class internal::CpuProfile;
284 bool has_filter_context()
const {
return !filter_context_.IsEmpty(); }
285 void* raw_filter_context()
const;
288 unsigned max_samples_;
289 int sampling_interval_us_;
313 static void CollectSample(
Isolate* isolate);
325 void SetSamplingInterval(
int us);
334 void SetUsePreciseSampling(
bool);
356 unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
362 void StartProfiling(
Local<String> title,
bool record_samples =
false);
374 static void UseDetailedSourcePositionsForProfiling(
Isolate* isolate);
390 kContextVariable = 0,
404 Type GetType()
const;
444 Type GetType()
const;
460 size_t GetShallowSize()
const;
463 int GetChildrenCount()
const;
481 virtual void EndOfStream() = 0;
489 virtual WriteResult WriteAsciiChunk(
char* data,
int size) = 0;
517 int GetNodesCount()
const;
559 SerializationFormat format = kJSON)
const;
578 virtual ControlOption ReportProgressValue(
int done,
int total) = 0;
688 virtual Node* GetRootNode() = 0;
689 virtual const std::vector<Sample>& GetSamples() = 0;
693 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
694 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
716 virtual ~
Node() =
default;
717 virtual const char*
Name() = 0;
718 virtual size_t SizeInBytes() = 0;
740 Node& operator=(
const Node&) =
delete;
753 virtual Node* AddNode(std::unique_ptr<Node> node) = 0;
763 virtual void AddEdge(Node* from, Node* to,
const char* name =
nullptr) = 0;
775 kSamplingNoFlags = 0,
776 kSamplingForceGC = 1 << 0,
790 int GetSnapshotCount();
818 void ClearObjectIds();
848 bool treat_global_objects_as_roots =
true);
859 void StartTrackingHeapObjects(
bool track_allocations =
false);
875 int64_t* timestamp_us =
nullptr);
882 void StopTrackingHeapObjects();
911 bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024,
912 int stack_depth = 16,
918 void StopSamplingHeapProfiler();
932 void DeleteAllHeapSnapshots();
934 void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
936 void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
944 static const uint16_t kPersistentHandleNoClassId = 0;
959 : index(index), count(count), size(size) { }
965 #define CODE_EVENTS_LIST(V) \
970 V(InterpretedFunction) \
985 #define V(Name) , k##Name##Type
995 uintptr_t GetCodeStartAddress();
996 size_t GetCodeSize();
1000 int GetScriptColumn();
1007 const char* GetComment();
1009 static const char* GetCodeEventTypeName(
CodeEventType code_event_type);
1011 uintptr_t GetPreviousCodeStartAddress();
1053 void* internal_listener_;
1059 #endif // V8_V8_PROFILER_H_