Loading...
Searching...
No Matches
v8-profiler.h
Go to the documentation of this file.
1// Copyright 2010 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_V8_PROFILER_H_
6#define V8_V8_PROFILER_H_
7
8#include <limits.h>
9
10#include <memory>
11#include <unordered_set>
12#include <vector>
13
14#include "cppgc/common.h" // NOLINT(build/include_directory)
15#include "v8-local-handle.h" // NOLINT(build/include_directory)
16#include "v8-message.h" // NOLINT(build/include_directory)
17#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
18
22namespace v8 {
23
24enum class EmbedderStateTag : uint8_t;
25class HeapGraphNode;
26struct HeapStatsUpdate;
27class Object;
28enum StateTag : uint16_t;
29
30using NativeObject = void*;
31using SnapshotObjectId = uint32_t;
32using ProfilerId = uint32_t;
33
65using SampleContextExtractor = void* (*)(Isolate*);
66
69 size_t position;
70};
71
72namespace internal {
73class CpuProfile;
74} // namespace internal
75
76} // namespace v8
77
78#ifdef V8_OS_WIN
79template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>;
80#endif
81
82namespace v8 {
83
87enum class CpuProfileSource : uint8_t {
89 kUnspecified = 0,
91 kInspector = 1,
96 kInternal = 3,
97};
98
101 const char* deopt_reason;
102 std::vector<CpuProfileDeoptFrame> stack;
103};
104
105} // namespace v8
106
107#ifdef V8_OS_WIN
108template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
109#endif
110
111namespace v8 {
112
117 public:
118 struct LineTick {
120 int line;
121
125
127 unsigned int hit_count;
128 };
129
130 // An annotation hinting at the source of a CpuProfileNode.
132 // User-supplied script with associated resource information.
133 kScript = 0,
134 // Native scripts and provided builtins.
135 kBuiltin = 1,
136 // Callbacks into native code.
137 kCallback = 2,
138 // VM-internal functions or state.
140 // A node that failed to symbolize.
141 kUnresolved = 4,
142 };
143
146
152 const char* GetFunctionNameStr() const;
153
155 int GetScriptId() const;
156
159
165 const char* GetScriptResourceNameStr() const;
166
172
177 int GetLineNumber() const;
178
183 int GetColumnNumber() const;
184
188 unsigned int GetHitLineCount() const;
189
195 bool GetLineTicks(LineTick* entries, unsigned int length) const;
196
200 const char* GetBailoutReason() const;
201
205 unsigned GetHitCount() const;
206
208 unsigned GetNodeId() const;
209
214
216 int GetChildrenCount() const;
217
219 const CpuProfileNode* GetChild(int index) const;
220
222 const CpuProfileNode* GetParent() const;
223
225 const std::vector<CpuProfileDeoptInfo>& GetDeoptInfos() const;
226
227 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
228 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
229};
230
235 public:
236 enum WriteResult { kContinue = 0, kAbort = 1 };
237 virtual ~OutputStream() = default;
239 virtual void EndOfStream() = 0;
241 virtual int GetChunkSize() { return 1024; }
247 virtual WriteResult WriteAsciiChunk(char* data, int size) = 0;
254 return kAbort;
255 }
256};
257
263 public:
265 kJSON = 0 // See format description near 'Serialize' method.
266 };
269
272
277 int GetSamplesCount() const;
278
283 const CpuProfileNode* GetSample(int index) const;
284
290 int64_t GetSampleTimestamp(int index) const;
291
296 int64_t GetStartTime() const;
297
301 StateTag GetSampleState(int index) const;
302
307
315 void* GetSampleContext(int index) const;
316
322 int64_t GetEndTime() const;
323
328 void Delete();
329
347 SerializationFormat format = kJSON) const;
348};
349
351 // In the resulting CpuProfile tree, intermediate nodes in a stack trace
352 // (from the root to a leaf) will have line numbers that point to the start
353 // line of the function, rather than the line of the callsite of the child.
355 // In the resulting CpuProfile tree, nodes are separated based on the line
356 // number of their callsite in their parent.
358};
359
360// Determines how names are derived for functions sampled.
362 // Use the immediate name of functions at compilation time.
364 // Use more verbose naming for functions without names, inferred from scope
365 // where possible.
367};
368
370 // Enables logging when a profile is active, and disables logging when all
371 // profiles are detached.
373 // Enables logging for the lifetime of the CpuProfiler. Calls to
374 // StartRecording are faster, at the expense of runtime overhead.
376};
377
378// Enum for returning profiling status. Once StartProfiling is called,
379// we want to return to clients whether the profiling was able to start
380// correctly, or return a descriptive error.
382 kStarted,
385};
386
394};
395
400 public:
402
403 virtual ~DiscardedSamplesDelegate() = default;
404 virtual void Notify() = 0;
405
406 ProfilerId GetId() const { return profiler_id_; }
407
408 private:
409 friend internal::CpuProfile;
410
411 void SetId(ProfilerId id) { profiler_id_ = id; }
412
413 ProfilerId profiler_id_;
414};
415
420 public:
421 // Indicates that the sample buffer size should not be explicitly limited.
422 static const unsigned kNoSampleLimit = UINT_MAX;
423
447 CpuProfilingMode mode = kLeafNodeLineNumbers,
448 unsigned max_samples = kNoSampleLimit, int sampling_interval_us = 0,
449 MaybeLocal<Context> filter_context = MaybeLocal<Context>(),
450 CpuProfileSource profile_source = CpuProfileSource::kUnspecified,
451 SampleContextExtractor sample_context_extractor = nullptr);
452
455
456 CpuProfilingMode mode() const { return mode_; }
457 unsigned max_samples() const { return max_samples_; }
458 int sampling_interval_us() const { return sampling_interval_us_; }
459 CpuProfileSource profile_source() const { return profile_source_; }
461 return sample_context_extractor_;
462 }
463
464 private:
465 friend class internal::CpuProfile;
466
467 bool has_filter_context() const { return !filter_context_.IsEmpty(); }
468 void* raw_filter_context() const;
469
470 CpuProfilingMode mode_;
471 unsigned max_samples_;
472 int sampling_interval_us_;
473 Global<Context> filter_context_;
474 CpuProfileSource profile_source_;
475 SampleContextExtractor sample_context_extractor_ = nullptr;
476};
477
483 public:
489 static CpuProfiler* New(Isolate* isolate,
490 CpuProfilingNamingMode = kDebugNaming,
491 CpuProfilingLoggingMode = kLazyLogging);
492
500 static void CollectSample(
501 Isolate* isolate, const std::optional<uint64_t> trace_id = std::nullopt);
502
506 void Dispose();
507
514
523
529 CpuProfilingOptions options,
530 std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);
531
538 Local<String> title, CpuProfilingOptions options,
539 std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);
540
553 Local<String> title, CpuProfilingMode mode, bool record_samples = false,
554 unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
555
561 CpuProfilingResult Start(Local<String> title, bool record_samples = false);
562
569 Local<String> title, CpuProfilingOptions options,
570 std::unique_ptr<DiscardedSamplesDelegate> delegate = nullptr);
571
584 Local<String> title, CpuProfilingMode mode, bool record_samples = false,
585 unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
586
593 bool record_samples = false);
594
599
605
611
612 private:
613 CpuProfiler();
614 ~CpuProfiler();
615 CpuProfiler(const CpuProfiler&);
616 CpuProfiler& operator=(const CpuProfiler&);
617};
618
624 public:
625 enum Type {
626 kContextVariable = 0, // A variable from a function context.
627 kElement = 1, // An element of an array.
628 kProperty = 2, // A named object property.
629 kInternal = 3, // A link that can't be accessed from JS,
630 // thus, its name isn't a real property name
631 // (e.g. parts of a ConsString).
632 kHidden = 4, // A link that is needed for proper sizes
633 // calculation, but may be hidden from user.
634 kShortcut = 5, // A link that must not be followed during
635 // sizes calculation.
636 kWeak = 6 // A weak reference (ignored by the GC).
637 };
638
640 Type GetType() const;
641
647
650
652 const HeapGraphNode* GetToNode() const;
653};
654
655
660 public:
661 enum Type {
662 kHidden = 0, // Hidden node, may be filtered when shown to user.
663 kArray = 1, // An array of elements.
664 kString = 2, // A string.
665 kObject = 3, // A JS object (except for arrays and strings).
666 kCode = 4, // Compiled code.
667 kClosure = 5, // Function closure.
668 kRegExp = 6, // RegExp.
669 kHeapNumber = 7, // Number stored in the heap.
670 kNative = 8, // Native object (not from V8 heap).
671 kSynthetic = 9, // Synthetic object, usually used for grouping
672 // snapshot items together.
673 kConsString = 10, // Concatenated string. A pair of pointers to strings.
674 kSlicedString = 11, // Sliced string. A fragment of another string.
675 kSymbol = 12, // A Symbol (ES6).
676 kBigInt = 13, // BigInt.
677 kObjectShape = 14, // Internal data used for tracking the shapes (or
678 // "hidden classes") of JS objects.
679 };
680
682 Type GetType() const;
683
690
696
698 size_t GetShallowSize() const;
699
701 int GetChildrenCount() const;
702
704 const HeapGraphEdge* GetChild(int index) const;
705};
706
711 public:
713 kJSON = 0 // See format description near 'Serialize' method.
714 };
715
717 const HeapGraphNode* GetRoot() const;
718
721
723 int GetNodesCount() const;
724
726 const HeapGraphNode* GetNode(int index) const;
727
730
736 void Delete();
737
765 SerializationFormat format = kJSON) const;
766};
767
768
774 public:
776 kContinue = 0,
777 kAbort = 1
778 };
779 virtual ~ActivityControl() = default;
784 virtual ControlOption ReportProgressValue(uint32_t done, uint32_t total) = 0;
785};
786
792 public:
793 struct Allocation {
797 size_t size;
798
802 unsigned int count;
803 };
804
808 struct Node {
814
820
826
831
837
843
847 uint32_t node_id;
848
854 std::vector<Node*> children;
855
859 std::vector<Allocation> allocations;
860 };
861
865 struct Sample {
869 uint32_t node_id;
870
874 size_t size;
875
879 unsigned int count;
880
885 uint64_t sample_id;
886
892
897
904 void* context = nullptr;
905 };
906
912 virtual Node* GetRootNode() = 0;
913 virtual const std::vector<Sample>& GetSamples() = 0;
914
915 virtual ~AllocationProfile() = default;
916
917 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
918 static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
919};
920
936 public:
937 class Node {
938 public:
946 enum class Detachedness : uint8_t {
947 kUnknown = 0,
948 kAttached = 1,
949 kDetached = 2,
950 };
951
952 Node() = default;
953 virtual ~Node() = default;
954 virtual const char* Name() = 0;
955 virtual size_t SizeInBytes() = 0;
961 virtual Node* WrapperNode() { return nullptr; }
962 virtual bool IsRootNode() { return false; }
964 virtual bool IsEmbedderNode() { return true; }
968 virtual const char* NamePrefix() { return nullptr; }
969
974 virtual NativeObject GetNativeObject() { return nullptr; }
975
982 virtual Detachedness GetDetachedness() { return Detachedness::kUnknown; }
983
991 virtual const void* GetAddress() { return nullptr; }
992
993 Node(const Node&) = delete;
994 Node& operator=(const Node&) = delete;
995 };
996
1007 virtual Node* V8Node(const v8::Local<v8::Value>& value) = 0;
1008
1020 virtual Node* V8Node(const v8::Local<v8::Data>& value);
1021
1026 virtual Node* AddNode(std::unique_ptr<Node> node) = 0;
1027
1036 virtual void AddEdge(Node* from, Node* to, const char* name = nullptr) = 0;
1037
1046 virtual void AddWeakEdge(Node* from, Node* to, const char* name = nullptr) {
1047 AddEdge(from, to, name);
1048 }
1049
1057 virtual void AddNativeSize(size_t size) {}
1058
1059 virtual ~EmbedderGraph() = default;
1060};
1061
1063 public:
1064 virtual ~QueryObjectPredicate() = default;
1065 virtual bool Filter(v8::Local<v8::Object> object) = 0;
1066};
1067
1073 public:
1075 QueryObjectPredicate* predicate,
1076 std::vector<v8::Global<v8::Object>>* objects);
1077
1079 kSamplingNoFlags = 0,
1080 kSamplingForceGC = 1 << 0,
1081 kSamplingIncludeObjectsCollectedByMajorGC = 1 << 1,
1082 kSamplingIncludeObjectsCollectedByMinorGC = 1 << 2,
1083 };
1084
1091 typedef void (*BuildEmbedderGraphCallback)(v8::Isolate* isolate,
1092 v8::EmbedderGraph* graph,
1093 void* data);
1094
1104 v8::Isolate* isolate, const v8::Local<v8::Value>& v8_value,
1105 uint16_t class_id, void* data);
1106
1109
1112
1118
1124
1130
1137
1143 static const SnapshotObjectId kUnknownObjectId = 0;
1144
1150 class V8_DEPRECATE_SOON("Use ContextNameResolver instead.")
1152 public:
1157 virtual const char* GetName(Local<Object> object) = 0;
1158
1159 protected:
1160 virtual ~ObjectNameResolver() = default;
1161 };
1162
1168 public:
1174 virtual const char* GetName(Local<Context> context) = 0;
1175
1176 protected:
1177 virtual ~ContextNameResolver() = default;
1178 };
1179
1180 enum class HeapSnapshotMode {
1184 kRegular,
1188 kExposeInternals,
1189 };
1190
1191 enum class NumericsMode {
1196 kHideNumericValues,
1200 kExposeNumericValues
1201 };
1202
1203 struct HeapSnapshotOptions final {
1204 // Manually define default constructor here to be able to use it in
1205 // `TakeSnapshot()` below.
1206 // NOLINTNEXTLINE
1208
1212 ActivityControl* control = nullptr;
1217 ContextNameResolver* context_name_resolver = nullptr;
1221 HeapSnapshotMode snapshot_mode = HeapSnapshotMode::kRegular;
1225 NumericsMode numerics_mode = NumericsMode::kHideNumericValues;
1231 };
1232
1239 const HeapSnapshotOptions& options = HeapSnapshotOptions());
1240
1248 ContextNameResolver* resolver = nullptr,
1249 bool hide_internals = true,
1250 bool capture_numeric_value = false);
1251
1256 std::vector<v8::Local<v8::Value>> GetDetachedJSWrapperObjects();
1257
1267 void StartTrackingHeapObjects(bool track_allocations = false);
1268
1283 int64_t* timestamp_us = nullptr);
1284
1291
1325 uint64_t sample_interval = 512 * 1024, int stack_depth = 16,
1326 SamplingFlags flags = kSamplingNoFlags,
1327 SampleContextExtractor sample_context_extractor = nullptr);
1328
1333
1340 void SetSamplingHeapProfilerInterval(uint64_t sample_interval);
1341
1348 std::vector<AllocationProfile::Sample> GetSamplingHeapProfilerSamples();
1349
1357
1363
1364 void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
1365 void* data);
1366 void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
1367 void* data);
1368
1370
1375
1381 const char* CopyNameForHeapSnapshot(const char* name);
1382
1388 static const uint16_t kPersistentHandleNoClassId = 0;
1389
1390 private:
1391 HeapProfiler();
1392 ~HeapProfiler();
1393 HeapProfiler(const HeapProfiler&);
1394 HeapProfiler& operator=(const HeapProfiler&);
1395};
1396
1402 HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
1403 : index(index), count(count), size(size) { }
1404 uint32_t index; // Index of the time interval that was changed.
1405 uint32_t count; // New value of count field for the interval with this index.
1406 uint32_t size; // New value of size field for the interval with this index.
1407};
1408
1409#define CODE_EVENTS_LIST(V) \
1410 V(Builtin) \
1411 V(Callback) \
1412 V(Eval) \
1413 V(Function) \
1414 V(InterpretedFunction) \
1415 V(Handler) \
1416 V(BytecodeHandler) \
1417 V(LazyCompile) /* Unused, use kFunction instead */ \
1418 V(RegExp) \
1419 V(Script) \
1420 V(Stub) \
1421 V(Relocation)
1422
1428 kUnknownType = 0
1429#define V(Name) , k##Name##Type
1431#undef V
1432};
1433
1437class V8_EXPORT CodeEvent {
1438 public:
1439 uintptr_t GetCodeStartAddress();
1440 size_t GetCodeSize();
1441 Local<String> GetFunctionName();
1442 Local<String> GetScriptName();
1443 int GetScriptLine();
1444 int GetScriptColumn();
1450 CodeEventType GetCodeType();
1451 const char* GetComment();
1453 static const char* GetCodeEventTypeName(CodeEventType code_event_type);
1455 uintptr_t GetPreviousCodeStartAddress();
1456};
1457
1462 public:
1468 explicit CodeEventHandler(Isolate* isolate);
1469 virtual ~CodeEventHandler();
1470
1479 virtual void Handle(CodeEvent* code_event) = 0;
1480
1485 void Enable();
1486
1491 void Disable();
1492
1493 private:
1496 CodeEventHandler& operator=(const CodeEventHandler&);
1497 void* internal_listener_;
1498};
1499
1500} // namespace v8
1501
1502
1503#endif // V8_V8_PROFILER_H_
Definition: v8-profiler.h:773
ControlOption
Definition: v8-profiler.h:775
virtual ControlOption ReportProgressValue(uint32_t done, uint32_t total)=0
virtual ~ActivityControl()=default
Definition: v8-profiler.h:791
virtual const std::vector< Sample > & GetSamples()=0
virtual Node * GetRootNode()=0
virtual ~AllocationProfile()=default
Definition: v8-profiler.h:1460
Definition: v8-profiler.h:1436
Definition: v8-profiler.h:116
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:131
int GetColumnNumber() const
Local< String > GetFunctionName() const
Local< String > GetScriptResourceName() const
SourceType GetSourceType() const
const char * GetBailoutReason() const
int GetScriptId() const
bool IsScriptSharedCrossOrigin() const
int GetChildrenCount() const
Definition: v8-profiler.h:262
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:264
int64_t GetSampleTimestamp(int index) const
int64_t GetStartTime() const
EmbedderStateTag GetSampleEmbedderState(int index) const
void * GetSampleContext(int index) const
void Serialize(OutputStream *stream, SerializationFormat format=kJSON) const
Definition: v8-profiler.h:482
CpuProfilingResult Start(CpuProfilingOptions options, std::unique_ptr< DiscardedSamplesDelegate > delegate=nullptr)
static void CollectSample(Isolate *isolate, const std::optional< uint64_t > trace_id=std::nullopt)
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)
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:419
CpuProfilingOptions & operator=(CpuProfilingOptions &&)=default
int sampling_interval_us() const
Definition: v8-profiler.h:458
CpuProfileSource profile_source() const
Definition: v8-profiler.h:459
CpuProfilingOptions(CpuProfilingMode mode=kLeafNodeLineNumbers, unsigned max_samples=kNoSampleLimit, int sampling_interval_us=0, MaybeLocal< Context > filter_context=MaybeLocal< Context >(), CpuProfileSource profile_source=CpuProfileSource::kUnspecified, SampleContextExtractor sample_context_extractor=nullptr)
CpuProfilingMode mode() const
Definition: v8-profiler.h:456
unsigned max_samples() const
Definition: v8-profiler.h:457
CpuProfilingOptions(CpuProfilingOptions &&)=default
SampleContextExtractor sample_context_extractor() const
Definition: v8-profiler.h:460
Definition: v8-profiler.h:399
ProfilerId GetId() const
Definition: v8-profiler.h:406
virtual ~DiscardedSamplesDelegate()=default
Definition: v8-profiler.h:937
virtual Detachedness GetDetachedness()
Definition: v8-profiler.h:982
Detachedness
Definition: v8-profiler.h:946
Node & operator=(const Node &)=delete
virtual size_t SizeInBytes()=0
virtual bool IsEmbedderNode()
Definition: v8-profiler.h:964
virtual const char * Name()=0
virtual NativeObject GetNativeObject()
Definition: v8-profiler.h:974
virtual ~Node()=default
virtual Node * WrapperNode()
Definition: v8-profiler.h:961
Node(const Node &)=delete
virtual const char * NamePrefix()
Definition: v8-profiler.h:968
virtual const void * GetAddress()
Definition: v8-profiler.h:991
virtual bool IsRootNode()
Definition: v8-profiler.h:962
Definition: v8-profiler.h:935
virtual void AddNativeSize(size_t size)
Definition: v8-profiler.h:1057
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 void AddWeakEdge(Node *from, Node *to, const char *name=nullptr)
Definition: v8-profiler.h:1046
virtual Node * V8Node(const v8::Local< v8::Value > &value)=0
Definition: v8-persistent-handle.h:353
Definition: v8-profiler.h:623
Type
Definition: v8-profiler.h:625
const HeapGraphNode * GetToNode() const
const HeapGraphNode * GetFromNode() const
Type GetType() const
Local< Value > GetName() const
Definition: v8-profiler.h:659
Local< String > GetName() const
SnapshotObjectId GetId() const
Type GetType() const
Type
Definition: v8-profiler.h:661
const HeapGraphEdge * GetChild(int index) const
size_t GetShallowSize() const
int GetChildrenCount() const
Definition: v8-profiler.h:1167
virtual const char * GetName(Local< Context > context)=0
Definition: v8-profiler.h:1151
virtual const char * GetName(Local< Object > object)=0
Definition: v8-profiler.h:1072
void StartTrackingHeapObjects(bool track_allocations=false)
void SetGetDetachednessCallback(GetDetachednessCallback callback, void *data)
bool StartSamplingHeapProfiler(uint64_t sample_interval=512 *1024, int stack_depth=16, SamplingFlags flags=kSamplingNoFlags, SampleContextExtractor sample_context_extractor=nullptr)
const HeapSnapshot * TakeHeapSnapshot(ActivityControl *control, ContextNameResolver *resolver=nullptr, bool hide_internals=true, bool capture_numeric_value=false)
bool IsTakingSnapshot()
Local< Value > FindObjectById(SnapshotObjectId id)
AllocationProfile * GetAllocationProfile()
void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback, void *data)
void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback, void *data)
std::vector< AllocationProfile::Sample > GetSamplingHeapProfilerSamples()
std::vector< v8::Local< v8::Value > > GetDetachedJSWrapperObjects()
void DeleteAllHeapSnapshots()
void SetSamplingHeapProfilerInterval(uint64_t sample_interval)
const char * CopyNameForHeapSnapshot(const char *name)
HeapSnapshotMode
Definition: v8-profiler.h:1180
SamplingFlags
Definition: v8-profiler.h:1078
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:1105
NumericsMode
Definition: v8-profiler.h:1191
Definition: v8-profiler.h:710
const HeapGraphNode * GetNodeById(SnapshotObjectId id) const
int GetNodesCount() const
SerializationFormat
Definition: v8-profiler.h:712
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:305
Definition: v8-local-handle.h:359
Definition: v8-local-handle.h:730
Definition: v8-profiler.h:234
virtual ~OutputStream()=default
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate *data, int count)
Definition: v8-profiler.h:253
WriteResult
Definition: v8-profiler.h:236
virtual WriteResult WriteAsciiChunk(char *data, int size)=0
virtual void EndOfStream()=0
virtual int GetChunkSize()
Definition: v8-profiler.h:241
Definition: v8-profiler.h:1062
virtual bool Filter(v8::Local< v8::Object > object)=0
virtual ~QueryObjectPredicate()=default
EmbedderStackState
Definition: common.h:20
Definition: libplatform.h:15
uint32_t SnapshotObjectId
Definition: v8-profiler.h:31
CpuProfilingStatus
Definition: v8-profiler.h:381
uint32_t ProfilerId
Definition: v8-profiler.h:32
CpuProfilingLoggingMode
Definition: v8-profiler.h:369
@ kEagerLogging
Definition: v8-profiler.h:375
@ kLazyLogging
Definition: v8-profiler.h:372
EmbedderStateTag
Definition: v8-embedder-state-scope.h:22
CpuProfilingMode
Definition: v8-profiler.h:350
@ kLeafNodeLineNumbers
Definition: v8-profiler.h:354
@ kCallerLineNumbers
Definition: v8-profiler.h:357
void * NativeObject
Definition: v8-profiler.h:30
CpuProfileSource
Definition: v8-profiler.h:87
void *(*)(Isolate *) SampleContextExtractor
Definition: v8-profiler.h:65
CpuProfilingNamingMode
Definition: v8-profiler.h:361
@ kStandardNaming
Definition: v8-profiler.h:363
@ kDebugNaming
Definition: v8-profiler.h:366
CodeEventType
Definition: v8-profiler.h:1427
@ kUnknownType
Definition: v8-profiler.h:1428
StateTag
Definition: v8-unwinder.h:39
Definition: v8-profiler.h:793
unsigned int count
Definition: v8-profiler.h:802
size_t size
Definition: v8-profiler.h:797
Definition: v8-profiler.h:808
std::vector< Node * > children
Definition: v8-profiler.h:854
int script_id
Definition: v8-profiler.h:825
int start_position
Definition: v8-profiler.h:830
std::vector< Allocation > allocations
Definition: v8-profiler.h:859
int column_number
Definition: v8-profiler.h:842
uint32_t node_id
Definition: v8-profiler.h:847
int line_number
Definition: v8-profiler.h:836
Local< String > script_name
Definition: v8-profiler.h:819
Local< String > name
Definition: v8-profiler.h:813
Definition: v8-profiler.h:865
unsigned int count
Definition: v8-profiler.h:879
size_t size
Definition: v8-profiler.h:874
uint64_t sample_interval
Definition: v8-profiler.h:896
uint32_t node_id
Definition: v8-profiler.h:869
bool is_live
Definition: v8-profiler.h:891
uint64_t sample_id
Definition: v8-profiler.h:885
Definition: v8-profiler.h:67
size_t position
Definition: v8-profiler.h:69
int script_id
Definition: v8-profiler.h:68
Definition: v8-profiler.h:99
const char * deopt_reason
Definition: v8-profiler.h:101
std::vector< CpuProfileDeoptFrame > stack
Definition: v8-profiler.h:102
Definition: v8-profiler.h:118
unsigned int hit_count
Definition: v8-profiler.h:127
int column
Definition: v8-profiler.h:124
int line
Definition: v8-profiler.h:120
Definition: v8-profiler.h:391
const ProfilerId id
Definition: v8-profiler.h:392
const CpuProfilingStatus status
Definition: v8-profiler.h:393
Definition: v8-profiler.h:1203
HeapSnapshotOptions()
Definition: v8-profiler.h:1207
Definition: v8-profiler.h:1401
uint32_t size
Definition: v8-profiler.h:1406
uint32_t index
Definition: v8-profiler.h:1404
uint32_t count
Definition: v8-profiler.h:1405
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
Definition: v8-profiler.h:1402
#define V(Name)
#define CODE_EVENTS_LIST(V)
Definition: v8-profiler.h:1409
#define V8_EXPORT
Definition: v8config.h:874
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:631