v8  8.6.395(node15.0.1)
V8 is Google's open source JavaScript engine
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 #include <memory>
10 #include <unordered_set>
11 #include <vector>
12 
13 #include "v8.h" // NOLINT(build/include_directory)
14 
15 /**
16  * Profiler support for the V8 JavaScript engine.
17  */
18 namespace v8 {
19 
20 class HeapGraphNode;
21 struct HeapStatsUpdate;
22 
23 using NativeObject = void*;
24 using SnapshotObjectId = uint32_t;
25 
27  int script_id;
28  size_t position;
29 };
30 
31 namespace internal {
32 class CpuProfile;
33 } // namespace internal
34 
35 } // namespace v8
36 
37 #ifdef V8_OS_WIN
38 template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>;
39 #endif
40 
41 namespace v8 {
42 
44  /** A pointer to a static string owned by v8. */
45  const char* deopt_reason;
47 };
48 
49 } // namespace v8
50 
51 #ifdef V8_OS_WIN
52 template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
53 #endif
54 
55 namespace v8 {
56 
57 /**
58  * CpuProfileNode represents a node in a call graph.
59  */
61  public:
62  struct LineTick {
63  /** The 1-based number of the source line where the function originates. */
64  int line;
65 
66  /** The count of samples associated with the source line. */
67  unsigned int hit_count;
68  };
69 
70  // An annotation hinting at the source of a CpuProfileNode.
71  enum SourceType {
72  // User-supplied script with associated resource information.
73  kScript = 0,
74  // Native scripts and provided builtins.
75  kBuiltin = 1,
76  // Callbacks into native code.
77  kCallback = 2,
78  // VM-internal functions or state.
79  kInternal = 3,
80  // A node that failed to symbolize.
82  };
83 
84  /** Returns function name (empty string for anonymous functions.) */
85  Local<String> GetFunctionName() const;
86 
87  /**
88  * Returns function name (empty string for anonymous functions.)
89  * The string ownership is *not* passed to the caller. It stays valid until
90  * profile is deleted. The function is thread safe.
91  */
92  const char* GetFunctionNameStr() const;
93 
94  /** Returns id of the script where function is located. */
95  int GetScriptId() const;
96 
97  /** Returns resource name for script from where the function originates. */
99 
100  /**
101  * Returns resource name for script from where the function originates.
102  * The string ownership is *not* passed to the caller. It stays valid until
103  * profile is deleted. The function is thread safe.
104  */
105  const char* GetScriptResourceNameStr() const;
106 
107  /**
108  * Return true if the script from where the function originates is flagged as
109  * being shared cross-origin.
110  */
111  bool IsScriptSharedCrossOrigin() const;
112 
113  /**
114  * Returns the number, 1-based, of the line where the function originates.
115  * kNoLineNumberInfo if no line number information is available.
116  */
117  int GetLineNumber() const;
118 
119  /**
120  * Returns 1-based number of the column where the function originates.
121  * kNoColumnNumberInfo if no column number information is available.
122  */
123  int GetColumnNumber() const;
124 
125  /**
126  * Returns the number of the function's source lines that collect the samples.
127  */
128  unsigned int GetHitLineCount() const;
129 
130  /** Returns the set of source lines that collect the samples.
131  * The caller allocates buffer and responsible for releasing it.
132  * True if all available entries are copied, otherwise false.
133  * The function copies nothing if buffer is not large enough.
134  */
135  bool GetLineTicks(LineTick* entries, unsigned int length) const;
136 
137  /** Returns bailout reason for the function
138  * if the optimization was disabled for it.
139  */
140  const char* GetBailoutReason() const;
141 
142  /**
143  * Returns the count of samples where the function was currently executing.
144  */
145  unsigned GetHitCount() const;
146 
147  /** Returns id of the node. The id is unique within the tree */
148  unsigned GetNodeId() const;
149 
150  /**
151  * Gets the type of the source which the node was captured from.
152  */
153  SourceType GetSourceType() const;
154 
155  /** Returns child nodes count of the node. */
156  int GetChildrenCount() const;
157 
158  /** Retrieves a child node by index. */
159  const CpuProfileNode* GetChild(int index) const;
160 
161  /** Retrieves the ancestor node, or null if the root. */
162  const CpuProfileNode* GetParent() const;
163 
164  /** Retrieves deopt infos for the node. */
165  const std::vector<CpuProfileDeoptInfo>& GetDeoptInfos() const;
166 
169 };
170 
171 
172 /**
173  * CpuProfile contains a CPU profile in a form of top-down call tree
174  * (from main() down to functions that do all the work).
175  */
177  public:
178  /** Returns CPU profile title. */
179  Local<String> GetTitle() const;
180 
181  /** Returns the root node of the top down call tree. */
182  const CpuProfileNode* GetTopDownRoot() const;
183 
184  /**
185  * Returns number of samples recorded. The samples are not recorded unless
186  * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true.
187  */
188  int GetSamplesCount() const;
189 
190  /**
191  * Returns profile node corresponding to the top frame the sample at
192  * the given index.
193  */
194  const CpuProfileNode* GetSample(int index) const;
195 
196  /**
197  * Returns the timestamp of the sample. The timestamp is the number of
198  * microseconds since some unspecified starting point.
199  * The point is equal to the starting point used by GetStartTime.
200  */
201  int64_t GetSampleTimestamp(int index) const;
202 
203  /**
204  * Returns time when the profile recording was started (in microseconds)
205  * since some unspecified starting point.
206  */
207  int64_t GetStartTime() const;
208 
209  /**
210  * Returns time when the profile recording was stopped (in microseconds)
211  * since some unspecified starting point.
212  * The point is equal to the starting point used by GetStartTime.
213  */
214  int64_t GetEndTime() const;
215 
216  /**
217  * Deletes the profile and removes it from CpuProfiler's list.
218  * All pointers to nodes previously returned become invalid.
219  */
220  void Delete();
221 };
222 
224  // In the resulting CpuProfile tree, intermediate nodes in a stack trace
225  // (from the root to a leaf) will have line numbers that point to the start
226  // line of the function, rather than the line of the callsite of the child.
228  // In the resulting CpuProfile tree, nodes are separated based on the line
229  // number of their callsite in their parent.
231 };
232 
233 // Determines how names are derived for functions sampled.
235  // Use the immediate name of functions at compilation time.
237  // Use more verbose naming for functions without names, inferred from scope
238  // where possible.
240 };
241 
243  // Enables logging when a profile is active, and disables logging when all
244  // profiles are detached.
246  // Enables logging for the lifetime of the CpuProfiler. Calls to
247  // StartRecording are faster, at the expense of runtime overhead.
249 };
250 
251 /**
252  * Optional profiling attributes.
253  */
255  public:
256  // Indicates that the sample buffer size should not be explicitly limited.
257  static const unsigned kNoSampleLimit = UINT_MAX;
258 
259  /**
260  * \param mode Type of computation of stack frame line numbers.
261  * \param max_samples The maximum number of samples that should be recorded by
262  * the profiler. Samples obtained after this limit will be
263  * discarded.
264  * \param sampling_interval_us controls the profile-specific target
265  * sampling interval. The provided sampling
266  * interval will be snapped to the next lowest
267  * non-zero multiple of the profiler's sampling
268  * interval, set via SetSamplingInterval(). If
269  * zero, the sampling interval will be equal to
270  * the profiler's sampling interval.
271  */
274  unsigned max_samples = kNoSampleLimit, int sampling_interval_us = 0,
275  MaybeLocal<Context> filter_context = MaybeLocal<Context>());
276 
277  CpuProfilingMode mode() const { return mode_; }
278  unsigned max_samples() const { return max_samples_; }
279  int sampling_interval_us() const { return sampling_interval_us_; }
280 
281  private:
282  friend class internal::CpuProfile;
283 
284  bool has_filter_context() const { return !filter_context_.IsEmpty(); }
285  void* raw_filter_context() const;
286 
287  CpuProfilingMode mode_;
288  unsigned max_samples_;
289  int sampling_interval_us_;
290  CopyablePersistentTraits<Context>::CopyablePersistent filter_context_;
291 };
292 
293 /**
294  * Interface for controlling CPU profiling. Instance of the
295  * profiler can be created using v8::CpuProfiler::New method.
296  */
298  public:
299  /**
300  * Creates a new CPU profiler for the |isolate|. The isolate must be
301  * initialized. The profiler object must be disposed after use by calling
302  * |Dispose| method.
303  */
304  static CpuProfiler* New(Isolate* isolate,
307 
308  /**
309  * Synchronously collect current stack sample in all profilers attached to
310  * the |isolate|. The call does not affect number of ticks recorded for
311  * the current top node.
312  */
313  static void CollectSample(Isolate* isolate);
314 
315  /**
316  * Disposes the CPU profiler object.
317  */
318  void Dispose();
319 
320  /**
321  * Changes default CPU profiler sampling interval to the specified number
322  * of microseconds. Default interval is 1000us. This method must be called
323  * when there are no profiles being recorded.
324  */
325  void SetSamplingInterval(int us);
326 
327  /**
328  * Sets whether or not the profiler should prioritize consistency of sample
329  * periodicity on Windows. Disabling this can greatly reduce CPU usage, but
330  * may result in greater variance in sample timings from the platform's
331  * scheduler. Defaults to enabled. This method must be called when there are
332  * no profiles being recorded.
333  */
334  void SetUsePreciseSampling(bool);
335 
336  /**
337  * Starts collecting a CPU profile. Title may be an empty string. Several
338  * profiles may be collected at once. Attempts to start collecting several
339  * profiles with the same title are silently ignored.
340  */
341  void StartProfiling(Local<String> title, CpuProfilingOptions options);
342 
343  /**
344  * Starts profiling with the same semantics as above, except with expanded
345  * parameters.
346  *
347  * |record_samples| parameter controls whether individual samples should
348  * be recorded in addition to the aggregated tree.
349  *
350  * |max_samples| controls the maximum number of samples that should be
351  * recorded by the profiler. Samples obtained after this limit will be
352  * discarded.
353  */
354  void StartProfiling(
355  Local<String> title, CpuProfilingMode mode, bool record_samples = false,
356  unsigned max_samples = CpuProfilingOptions::kNoSampleLimit);
357  /**
358  * The same as StartProfiling above, but the CpuProfilingMode defaults to
359  * kLeafNodeLineNumbers mode, which was the previous default behavior of the
360  * profiler.
361  */
362  void StartProfiling(Local<String> title, bool record_samples = false);
363 
364  /**
365  * Stops collecting CPU profile with a given title and returns it.
366  * If the title given is empty, finishes the last profile started.
367  */
369 
370  /**
371  * Generate more detailed source positions to code objects. This results in
372  * better results when mapping profiling samples to script source.
373  */
374  static void UseDetailedSourcePositionsForProfiling(Isolate* isolate);
375 
376  private:
377  CpuProfiler();
378  ~CpuProfiler();
379  CpuProfiler(const CpuProfiler&);
380  CpuProfiler& operator=(const CpuProfiler&);
381 };
382 
383 /**
384  * HeapSnapshotEdge represents a directed connection between heap
385  * graph nodes: from retainers to retained nodes.
386  */
388  public:
389  enum Type {
390  kContextVariable = 0, // A variable from a function context.
391  kElement = 1, // An element of an array.
392  kProperty = 2, // A named object property.
393  kInternal = 3, // A link that can't be accessed from JS,
394  // thus, its name isn't a real property name
395  // (e.g. parts of a ConsString).
396  kHidden = 4, // A link that is needed for proper sizes
397  // calculation, but may be hidden from user.
398  kShortcut = 5, // A link that must not be followed during
399  // sizes calculation.
400  kWeak = 6 // A weak reference (ignored by the GC).
401  };
402 
403  /** Returns edge type (see HeapGraphEdge::Type). */
404  Type GetType() const;
405 
406  /**
407  * Returns edge name. This can be a variable name, an element index, or
408  * a property name.
409  */
410  Local<Value> GetName() const;
411 
412  /** Returns origin node. */
413  const HeapGraphNode* GetFromNode() const;
414 
415  /** Returns destination node. */
416  const HeapGraphNode* GetToNode() const;
417 };
418 
419 
420 /**
421  * HeapGraphNode represents a node in a heap graph.
422  */
424  public:
425  enum Type {
426  kHidden = 0, // Hidden node, may be filtered when shown to user.
427  kArray = 1, // An array of elements.
428  kString = 2, // A string.
429  kObject = 3, // A JS object (except for arrays and strings).
430  kCode = 4, // Compiled code.
431  kClosure = 5, // Function closure.
432  kRegExp = 6, // RegExp.
433  kHeapNumber = 7, // Number stored in the heap.
434  kNative = 8, // Native object (not from V8 heap).
435  kSynthetic = 9, // Synthetic object, usually used for grouping
436  // snapshot items together.
437  kConsString = 10, // Concatenated string. A pair of pointers to strings.
438  kSlicedString = 11, // Sliced string. A fragment of another string.
439  kSymbol = 12, // A Symbol (ES6).
440  kBigInt = 13 // BigInt.
441  };
442 
443  /** Returns node type (see HeapGraphNode::Type). */
444  Type GetType() const;
445 
446  /**
447  * Returns node name. Depending on node's type this can be the name
448  * of the constructor (for objects), the name of the function (for
449  * closures), string value, or an empty string (for compiled code).
450  */
451  Local<String> GetName() const;
452 
453  /**
454  * Returns node id. For the same heap object, the id remains the same
455  * across all snapshots.
456  */
457  SnapshotObjectId GetId() const;
458 
459  /** Returns node's own size, in bytes. */
460  size_t GetShallowSize() const;
461 
462  /** Returns child nodes count of the node. */
463  int GetChildrenCount() const;
464 
465  /** Retrieves a child by index. */
466  const HeapGraphEdge* GetChild(int index) const;
467 };
468 
469 
470 /**
471  * An interface for exporting data from V8, using "push" model.
472  */
473 class V8_EXPORT OutputStream { // NOLINT
474  public:
475  enum WriteResult {
477  kAbort = 1
478  };
479  virtual ~OutputStream() = default;
480  /** Notify about the end of stream. */
481  virtual void EndOfStream() = 0;
482  /** Get preferred output chunk size. Called only once. */
483  virtual int GetChunkSize() { return 1024; }
484  /**
485  * Writes the next chunk of snapshot data into the stream. Writing
486  * can be stopped by returning kAbort as function result. EndOfStream
487  * will not be called in case writing was aborted.
488  */
489  virtual WriteResult WriteAsciiChunk(char* data, int size) = 0;
490  /**
491  * Writes the next chunk of heap stats data into the stream. Writing
492  * can be stopped by returning kAbort as function result. EndOfStream
493  * will not be called in case writing was aborted.
494  */
495  virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate* data, int count) {
496  return kAbort;
497  }
498 };
499 
500 
501 /**
502  * HeapSnapshots record the state of the JS heap at some moment.
503  */
505  public:
507  kJSON = 0 // See format description near 'Serialize' method.
508  };
509 
510  /** Returns the root node of the heap graph. */
511  const HeapGraphNode* GetRoot() const;
512 
513  /** Returns a node by its id. */
514  const HeapGraphNode* GetNodeById(SnapshotObjectId id) const;
515 
516  /** Returns total nodes count in the snapshot. */
517  int GetNodesCount() const;
518 
519  /** Returns a node by index. */
520  const HeapGraphNode* GetNode(int index) const;
521 
522  /** Returns a max seen JS object Id. */
523  SnapshotObjectId GetMaxSnapshotJSObjectId() const;
524 
525  /**
526  * Deletes the snapshot and removes it from HeapProfiler's list.
527  * All pointers to nodes, edges and paths previously returned become
528  * invalid.
529  */
530  void Delete();
531 
532  /**
533  * Prepare a serialized representation of the snapshot. The result
534  * is written into the stream provided in chunks of specified size.
535  * The total length of the serialized snapshot is unknown in
536  * advance, it can be roughly equal to JS heap size (that means,
537  * it can be really big - tens of megabytes).
538  *
539  * For the JSON format, heap contents are represented as an object
540  * with the following structure:
541  *
542  * {
543  * snapshot: {
544  * title: "...",
545  * uid: nnn,
546  * meta: { meta-info },
547  * node_count: nnn,
548  * edge_count: nnn
549  * },
550  * nodes: [nodes array],
551  * edges: [edges array],
552  * strings: [strings array]
553  * }
554  *
555  * Nodes reference strings, other nodes, and edges by their indexes
556  * in corresponding arrays.
557  */
558  void Serialize(OutputStream* stream,
559  SerializationFormat format = kJSON) const;
560 };
561 
562 
563 /**
564  * An interface for reporting progress and controlling long-running
565  * activities.
566  */
567 class V8_EXPORT ActivityControl { // NOLINT
568  public:
571  kAbort = 1
572  };
573  virtual ~ActivityControl() = default;
574  /**
575  * Notify about current progress. The activity can be stopped by
576  * returning kAbort as the callback result.
577  */
578  virtual ControlOption ReportProgressValue(int done, int total) = 0;
579 };
580 
581 
582 /**
583  * AllocationProfile is a sampled profile of allocations done by the program.
584  * This is structured as a call-graph.
585  */
587  public:
588  struct Allocation {
589  /**
590  * Size of the sampled allocation object.
591  */
592  size_t size;
593 
594  /**
595  * The number of objects of such size that were sampled.
596  */
597  unsigned int count;
598  };
599 
600  /**
601  * Represents a node in the call-graph.
602  */
603  struct Node {
604  /**
605  * Name of the function. May be empty for anonymous functions or if the
606  * script corresponding to this function has been unloaded.
607  */
609 
610  /**
611  * Name of the script containing the function. May be empty if the script
612  * name is not available, or if the script has been unloaded.
613  */
615 
616  /**
617  * id of the script where the function is located. May be equal to
618  * v8::UnboundScript::kNoScriptId in cases where the script doesn't exist.
619  */
621 
622  /**
623  * Start position of the function in the script.
624  */
626 
627  /**
628  * 1-indexed line number where the function starts. May be
629  * kNoLineNumberInfo if no line number information is available.
630  */
632 
633  /**
634  * 1-indexed column number where the function starts. May be
635  * kNoColumnNumberInfo if no line number information is available.
636  */
638 
639  /**
640  * Unique id of the node.
641  */
642  uint32_t node_id;
643 
644  /**
645  * List of callees called from this node for which we have sampled
646  * allocations. The lifetime of the children is scoped to the containing
647  * AllocationProfile.
648  */
649  std::vector<Node*> children;
650 
651  /**
652  * List of self allocations done by this node in the call-graph.
653  */
654  std::vector<Allocation> allocations;
655  };
656 
657  /**
658  * Represent a single sample recorded for an allocation.
659  */
660  struct Sample {
661  /**
662  * id of the node in the profile tree.
663  */
664  uint32_t node_id;
665 
666  /**
667  * Size of the sampled allocation object.
668  */
669  size_t size;
670 
671  /**
672  * The number of objects of such size that were sampled.
673  */
674  unsigned int count;
675 
676  /**
677  * Unique time-ordered id of the allocation sample. Can be used to track
678  * what samples were added or removed between two snapshots.
679  */
680  uint64_t sample_id;
681  };
682 
683  /**
684  * Returns the root node of the call-graph. The root node corresponds to an
685  * empty JS call-stack. The lifetime of the returned Node* is scoped to the
686  * containing AllocationProfile.
687  */
688  virtual Node* GetRootNode() = 0;
689  virtual const std::vector<Sample>& GetSamples() = 0;
690 
691  virtual ~AllocationProfile() = default;
692 
695 };
696 
697 /**
698  * An object graph consisting of embedder objects and V8 objects.
699  * Edges of the graph are strong references between the objects.
700  * The embedder can build this graph during heap snapshot generation
701  * to include the embedder objects in the heap snapshot.
702  * Usage:
703  * 1) Define derived class of EmbedderGraph::Node for embedder objects.
704  * 2) Set the build embedder graph callback on the heap profiler using
705  * HeapProfiler::AddBuildEmbedderGraphCallback.
706  * 3) In the callback use graph->AddEdge(node1, node2) to add an edge from
707  * node1 to node2.
708  * 4) To represent references from/to V8 object, construct V8 nodes using
709  * graph->V8Node(value).
710  */
712  public:
713  class Node {
714  public:
715  Node() = default;
716  virtual ~Node() = default;
717  virtual const char* Name() = 0;
718  virtual size_t SizeInBytes() = 0;
719  /**
720  * The corresponding V8 wrapper node if not null.
721  * During heap snapshot generation the embedder node and the V8 wrapper
722  * node will be merged into one node to simplify retaining paths.
723  */
724  virtual Node* WrapperNode() { return nullptr; }
725  virtual bool IsRootNode() { return false; }
726  /** Must return true for non-V8 nodes. */
727  virtual bool IsEmbedderNode() { return true; }
728  /**
729  * Optional name prefix. It is used in Chrome for tagging detached nodes.
730  */
731  virtual const char* NamePrefix() { return nullptr; }
732 
733  /**
734  * Returns the NativeObject that can be used for querying the
735  * |HeapSnapshot|.
736  */
737  virtual NativeObject GetNativeObject() { return nullptr; }
738 
739  Node(const Node&) = delete;
740  Node& operator=(const Node&) = delete;
741  };
742 
743  /**
744  * Returns a node corresponding to the given V8 value. Ownership is not
745  * transferred. The result pointer is valid while the graph is alive.
746  */
747  virtual Node* V8Node(const v8::Local<v8::Value>& value) = 0;
748 
749  /**
750  * Adds the given node to the graph and takes ownership of the node.
751  * Returns a raw pointer to the node that is valid while the graph is alive.
752  */
753  virtual Node* AddNode(std::unique_ptr<Node> node) = 0;
754 
755  /**
756  * Adds an edge that represents a strong reference from the given
757  * node |from| to the given node |to|. The nodes must be added to the graph
758  * before calling this function.
759  *
760  * If name is nullptr, the edge will have auto-increment indexes, otherwise
761  * it will be named accordingly.
762  */
763  virtual void AddEdge(Node* from, Node* to, const char* name = nullptr) = 0;
764 
765  virtual ~EmbedderGraph() = default;
766 };
767 
768 /**
769  * Interface for controlling heap profiling. Instance of the
770  * profiler can be retrieved using v8::Isolate::GetHeapProfiler.
771  */
773  public:
777  };
778 
779  /**
780  * Callback function invoked during heap snapshot generation to retrieve
781  * the embedder object graph. The callback should use graph->AddEdge(..) to
782  * add references between the objects.
783  * The callback must not trigger garbage collection in V8.
784  */
785  typedef void (*BuildEmbedderGraphCallback)(v8::Isolate* isolate,
786  v8::EmbedderGraph* graph,
787  void* data);
788 
789  /** Returns the number of snapshots taken. */
790  int GetSnapshotCount();
791 
792  /** Returns a snapshot by index. */
793  const HeapSnapshot* GetHeapSnapshot(int index);
794 
795  /**
796  * Returns SnapshotObjectId for a heap object referenced by |value| if
797  * it has been seen by the heap profiler, kUnknownObjectId otherwise.
798  */
799  SnapshotObjectId GetObjectId(Local<Value> value);
800 
801  /**
802  * Returns SnapshotObjectId for a native object referenced by |value| if it
803  * has been seen by the heap profiler, kUnknownObjectId otherwise.
804  */
805  SnapshotObjectId GetObjectId(NativeObject value);
806 
807  /**
808  * Returns heap object with given SnapshotObjectId if the object is alive,
809  * otherwise empty handle is returned.
810  */
811  Local<Value> FindObjectById(SnapshotObjectId id);
812 
813  /**
814  * Clears internal map from SnapshotObjectId to heap object. The new objects
815  * will not be added into it unless a heap snapshot is taken or heap object
816  * tracking is kicked off.
817  */
818  void ClearObjectIds();
819 
820  /**
821  * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return
822  * it in case heap profiler cannot find id for the object passed as
823  * parameter. HeapSnapshot::GetNodeById will always return NULL for such id.
824  */
825  static const SnapshotObjectId kUnknownObjectId = 0;
826 
827  /**
828  * Callback interface for retrieving user friendly names of global objects.
829  */
831  public:
832  /**
833  * Returns name to be used in the heap snapshot for given node. Returned
834  * string must stay alive until snapshot collection is completed.
835  */
836  virtual const char* GetName(Local<Object> object) = 0;
837 
838  protected:
839  virtual ~ObjectNameResolver() = default;
840  };
841 
842  /**
843  * Takes a heap snapshot and returns it.
844  */
846  ActivityControl* control = nullptr,
847  ObjectNameResolver* global_object_name_resolver = nullptr,
848  bool treat_global_objects_as_roots = true);
849 
850  /**
851  * Starts tracking of heap objects population statistics. After calling
852  * this method, all heap objects relocations done by the garbage collector
853  * are being registered.
854  *
855  * |track_allocations| parameter controls whether stack trace of each
856  * allocation in the heap will be recorded and reported as part of
857  * HeapSnapshot.
858  */
859  void StartTrackingHeapObjects(bool track_allocations = false);
860 
861  /**
862  * Adds a new time interval entry to the aggregated statistics array. The
863  * time interval entry contains information on the current heap objects
864  * population size. The method also updates aggregated statistics and
865  * reports updates for all previous time intervals via the OutputStream
866  * object. Updates on each time interval are provided as a stream of the
867  * HeapStatsUpdate structure instances.
868  * If |timestamp_us| is supplied, timestamp of the new entry will be written
869  * into it. The return value of the function is the last seen heap object Id.
870  *
871  * StartTrackingHeapObjects must be called before the first call to this
872  * method.
873  */
874  SnapshotObjectId GetHeapStats(OutputStream* stream,
875  int64_t* timestamp_us = nullptr);
876 
877  /**
878  * Stops tracking of heap objects population statistics, cleans up all
879  * collected data. StartHeapObjectsTracking must be called again prior to
880  * calling GetHeapStats next time.
881  */
883 
884  /**
885  * Starts gathering a sampling heap profile. A sampling heap profile is
886  * similar to tcmalloc's heap profiler and Go's mprof. It samples object
887  * allocations and builds an online 'sampling' heap profile. At any point in
888  * time, this profile is expected to be a representative sample of objects
889  * currently live in the system. Each sampled allocation includes the stack
890  * trace at the time of allocation, which makes this really useful for memory
891  * leak detection.
892  *
893  * This mechanism is intended to be cheap enough that it can be used in
894  * production with minimal performance overhead.
895  *
896  * Allocations are sampled using a randomized Poisson process. On average, one
897  * allocation will be sampled every |sample_interval| bytes allocated. The
898  * |stack_depth| parameter controls the maximum number of stack frames to be
899  * captured on each allocation.
900  *
901  * NOTE: This is a proof-of-concept at this point. Right now we only sample
902  * newspace allocations. Support for paged space allocation (e.g. pre-tenured
903  * objects, large objects, code objects, etc.) and native allocations
904  * doesn't exist yet, but is anticipated in the future.
905  *
906  * Objects allocated before the sampling is started will not be included in
907  * the profile.
908  *
909  * Returns false if a sampling heap profiler is already running.
910  */
911  bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024,
912  int stack_depth = 16,
914 
915  /**
916  * Stops the sampling heap profile and discards the current profile.
917  */
919 
920  /**
921  * Returns the sampled profile of allocations allocated (and still live) since
922  * StartSamplingHeapProfiler was called. The ownership of the pointer is
923  * transferred to the caller. Returns nullptr if sampling heap profiler is not
924  * active.
925  */
927 
928  /**
929  * Deletes all snapshots taken. All previously returned pointers to
930  * snapshots and their contents become invalid after this call.
931  */
932  void DeleteAllHeapSnapshots();
933 
935  void* data);
937  void* data);
938 
939  /**
940  * Default value of persistent handle class ID. Must not be used to
941  * define a class. Can be used to reset a class of a persistent
942  * handle.
943  */
944  static const uint16_t kPersistentHandleNoClassId = 0;
945 
946  private:
947  HeapProfiler();
948  ~HeapProfiler();
949  HeapProfiler(const HeapProfiler&);
950  HeapProfiler& operator=(const HeapProfiler&);
951 };
952 
953 /**
954  * A struct for exporting HeapStats data from V8, using "push" model.
955  * See HeapProfiler::GetHeapStats.
956  */
958  HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
959  : index(index), count(count), size(size) { }
960  uint32_t index; // Index of the time interval that was changed.
961  uint32_t count; // New value of count field for the interval with this index.
962  uint32_t size; // New value of size field for the interval with this index.
963 };
964 
965 #define CODE_EVENTS_LIST(V)
966  V(Builtin)
967  V(Callback)
968  V(Eval)
969  V(Function)
970  V(InterpretedFunction)
971  V(Handler)
972  V(BytecodeHandler)
973  V(LazyCompile)
974  V(RegExp)
975  V(Script)
976  V(Stub)
977  V(Relocation)
978 
979 /**
980  * Note that this enum may be extended in the future. Please include a default
981  * case if this enum is used in a switch statement.
982  */
985 #define V(Name) , k##Name##Type
987 #undef V
988 };
989 
990 /**
991  * Representation of a code creation event
992  */
994  public:
995  uintptr_t GetCodeStartAddress();
996  size_t GetCodeSize();
999  int GetScriptLine();
1000  int GetScriptColumn();
1001  /**
1002  * NOTE (mmarchini): We can't allocate objects in the heap when we collect
1003  * existing code, and both the code type and the comment are not stored in the
1004  * heap, so we return those as const char*.
1005  */
1007  const char* GetComment();
1008 
1009  static const char* GetCodeEventTypeName(CodeEventType code_event_type);
1010 
1011  uintptr_t GetPreviousCodeStartAddress();
1012 };
1013 
1014 /**
1015  * Interface to listen to code creation and code relocation events.
1016  */
1018  public:
1019  /**
1020  * Creates a new listener for the |isolate|. The isolate must be initialized.
1021  * The listener object must be disposed after use by calling |Dispose| method.
1022  * Multiple listeners can be created for the same isolate.
1023  */
1024  explicit CodeEventHandler(Isolate* isolate);
1025  virtual ~CodeEventHandler();
1026 
1027  /**
1028  * Handle is called every time a code object is created or moved. Information
1029  * about each code event will be available through the `code_event`
1030  * parameter.
1031  *
1032  * When the CodeEventType is kRelocationType, the code for this CodeEvent has
1033  * moved from `GetPreviousCodeStartAddress()` to `GetCodeStartAddress()`.
1034  */
1035  virtual void Handle(CodeEvent* code_event) = 0;
1036 
1037  /**
1038  * Call `Enable()` to starts listening to code creation and code relocation
1039  * events. These events will be handled by `Handle()`.
1040  */
1041  void Enable();
1042 
1043  /**
1044  * Call `Disable()` to stop listening to code creation and code relocation
1045  * events.
1046  */
1047  void Disable();
1048 
1049  private:
1050  CodeEventHandler();
1051  CodeEventHandler(const CodeEventHandler&);
1052  CodeEventHandler& operator=(const CodeEventHandler&);
1053  void* internal_listener_;
1054 };
1055 
1056 } // namespace v8
1057 
1058 
1059 #endif // V8_V8_PROFILER_H_
v8::Message::kNoColumnInfo
static const int kNoColumnInfo
Definition: v8.h:2094
v8::CodeEvent::GetCodeEventTypeName
static const char * GetCodeEventTypeName(CodeEventType code_event_type)
v8::HeapGraphNode::Type
Type
Definition: v8-profiler.h:425
v8::AllocationProfile::Node::column_number
int column_number
Definition: v8-profiler.h:637
v8::CpuProfilingMode
CpuProfilingMode
Definition: v8-profiler.h:223
v8::ActivityControl::kContinue
@ kContinue
Definition: v8-profiler.h:570
v8::CpuProfile::GetSamplesCount
int GetSamplesCount() const
v8::CpuProfileNode::GetScriptResourceName
Local< String > GetScriptResourceName() const
v8::AllocationProfile::GetRootNode
virtual Node * GetRootNode()=0
v8::AllocationProfile::Node::line_number
int line_number
Definition: v8-profiler.h:631
v8::HeapProfiler::ObjectNameResolver::GetName
virtual const char * GetName(Local< Object > object)=0
v8::HeapProfiler::ClearObjectIds
void ClearObjectIds()
v8::kLazyLogging
@ kLazyLogging
Definition: v8-profiler.h:245
v8::kCallerLineNumbers
@ kCallerLineNumbers
Definition: v8-profiler.h:230
v8::HeapGraphNode::kClosure
@ kClosure
Definition: v8-profiler.h:431
v8::CpuProfilingNamingMode
CpuProfilingNamingMode
Definition: v8-profiler.h:234
v8::HeapProfiler::DeleteAllHeapSnapshots
void DeleteAllHeapSnapshots()
v8::CodeEvent::GetScriptLine
int GetScriptLine()
v8::HeapGraphNode::kString
@ kString
Definition: v8-profiler.h:428
v8::AllocationProfile::Sample::sample_id
uint64_t sample_id
Definition: v8-profiler.h:680
v8::CpuProfile::GetSample
const CpuProfileNode * GetSample(int index) const
v8::CodeEvent
Definition: v8-profiler.h:993
v8::kDebugNaming
@ kDebugNaming
Definition: v8-profiler.h:239
v8::CpuProfile::GetEndTime
int64_t GetEndTime() const
v8::CpuProfileNode::kBuiltin
@ kBuiltin
Definition: v8-profiler.h:75
v8::CpuProfiler::CollectSample
static void CollectSample(Isolate *isolate)
v8::CpuProfileNode::GetHitLineCount
unsigned int GetHitLineCount() const
v8::HeapGraphEdge::GetName
Local< Value > GetName() const
v8::HeapGraphNode::kCode
@ kCode
Definition: v8-profiler.h:430
v8::CpuProfiler::StopProfiling
CpuProfile * StopProfiling(Local< String > title)
v8::ActivityControl::ControlOption
ControlOption
Definition: v8-profiler.h:569
v8::EmbedderGraph::Node::operator=
Node & operator=(const Node &)=delete
v8::CpuProfileNode::GetChildrenCount
int GetChildrenCount() const
v8::HeapSnapshot::kJSON
@ kJSON
Definition: v8-profiler.h:507
v8::EmbedderGraph::Node::SizeInBytes
virtual size_t SizeInBytes()=0
v8::AllocationProfile::kNoColumnNumberInfo
static const int kNoColumnNumberInfo
Definition: v8-profiler.h:694
v8::CpuProfileNode::LineTick::line
int line
Definition: v8-profiler.h:64
v8::HeapGraphNode::GetShallowSize
size_t GetShallowSize() const
v8::HeapProfiler::GetObjectId
SnapshotObjectId GetObjectId(NativeObject value)
v8::CpuProfileNode::GetBailoutReason
const char * GetBailoutReason() const
v8::CodeEventHandler::Handle
virtual void Handle(CodeEvent *code_event)=0
v8::CpuProfilingOptions::CpuProfilingOptions
CpuProfilingOptions(CpuProfilingMode mode=kLeafNodeLineNumbers, unsigned max_samples=kNoSampleLimit, int sampling_interval_us=0, MaybeLocal< Context > filter_context=MaybeLocal< Context >())
v8::HeapProfiler::SamplingFlags
SamplingFlags
Definition: v8-profiler.h:774
v8::EmbedderGraph::Node::Node
Node(const Node &)=delete
v8::CpuProfileNode::GetSourceType
SourceType GetSourceType() const
v8::OutputStream::GetChunkSize
virtual int GetChunkSize()
Definition: v8-profiler.h:483
v8::HeapGraphNode::GetType
Type GetType() const
v8::CpuProfileNode::IsScriptSharedCrossOrigin
bool IsScriptSharedCrossOrigin() const
v8::ActivityControl::~ActivityControl
virtual ~ActivityControl()=default
v8::AllocationProfile::Allocation::size
size_t size
Definition: v8-profiler.h:592
v8::CpuProfileNode::GetHitCount
unsigned GetHitCount() const
v8::HeapProfiler::StopTrackingHeapObjects
void StopTrackingHeapObjects()
v8::CopyablePersistentTraits
Definition: v8.h:642
v8::AllocationProfile::Sample
Definition: v8-profiler.h:660
v8::HeapGraphNode::kHeapNumber
@ kHeapNumber
Definition: v8-profiler.h:433
v8::OutputStream::kAbort
@ kAbort
Definition: v8-profiler.h:477
v8::CodeEventHandler::Enable
void Enable()
v8::AllocationProfile::Node::node_id
uint32_t node_id
Definition: v8-profiler.h:642
v8::CodeEvent::GetFunctionName
Local< String > GetFunctionName()
v8::CpuProfileNode::GetDeoptInfos
const std::vector< CpuProfileDeoptInfo > & GetDeoptInfos() const
v8::HeapProfiler::AddBuildEmbedderGraphCallback
void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback, void *data)
v8::CodeEvent::GetScriptColumn
int GetScriptColumn()
v8::HeapGraphNode::GetId
SnapshotObjectId GetId() const
v8::EmbedderGraph::Node::Node
Node()=default
v8::CpuProfiler::New
static CpuProfiler * New(Isolate *isolate, CpuProfilingNamingMode=kDebugNaming, CpuProfilingLoggingMode=kLazyLogging)
v8::HeapProfiler::kSamplingForceGC
@ kSamplingForceGC
Definition: v8-profiler.h:776
v8::Object
Definition: v8.h:3708
v8::CpuProfiler::StartProfiling
void StartProfiling(Local< String > title, CpuProfilingMode mode, bool record_samples=false, unsigned max_samples=CpuProfilingOptions::kNoSampleLimit)
v8::CodeEventHandler::Disable
void Disable()
v8::HeapGraphNode::kObject
@ kObject
Definition: v8-profiler.h:429
v8::HeapGraphNode::kBigInt
@ kBigInt
Definition: v8-profiler.h:440
v8::AllocationProfile::~AllocationProfile
virtual ~AllocationProfile()=default
v8::OutputStream::~OutputStream
virtual ~OutputStream()=default
v8::CodeEvent::GetCodeSize
size_t GetCodeSize()
v8::CodeEventType
CodeEventType
Definition: v8-profiler.h:983
v8::HeapProfiler::kPersistentHandleNoClassId
static const uint16_t kPersistentHandleNoClassId
Definition: v8-profiler.h:944
v8::CpuProfile::GetTopDownRoot
const CpuProfileNode * GetTopDownRoot() const
v8::HeapGraphNode::kNative
@ kNative
Definition: v8-profiler.h:434
v8::CpuProfileNode
Definition: v8-profiler.h:60
v8::HeapProfiler::GetObjectId
SnapshotObjectId GetObjectId(Local< Value > value)
v8::CodeEvent::GetScriptName
Local< String > GetScriptName()
v8::CpuProfilingOptions::max_samples
unsigned max_samples() const
Definition: v8-profiler.h:278
v8::MaybeLocal::MaybeLocal
V8_INLINE MaybeLocal()
Definition: v8.h:367
v8::CpuProfileNode::LineTick
Definition: v8-profiler.h:62
v8::ActivityControl::ReportProgressValue
virtual ControlOption ReportProgressValue(int done, int total)=0
v8::CpuProfileNode::LineTick::hit_count
unsigned int hit_count
Definition: v8-profiler.h:67
v8::HeapGraphNode
Definition: v8-profiler.h:423
v8::CpuProfilingOptions::mode
CpuProfilingMode mode() const
Definition: v8-profiler.h:277
v8::CpuProfilingOptions::sampling_interval_us
int sampling_interval_us() const
Definition: v8-profiler.h:279
v8::EmbedderGraph::~EmbedderGraph
virtual ~EmbedderGraph()=default
v8::CpuProfilingOptions
Definition: v8-profiler.h:254
v8::CpuProfiler::SetSamplingInterval
void SetSamplingInterval(int us)
v8::HeapProfiler::TakeHeapSnapshot
const HeapSnapshot * TakeHeapSnapshot(ActivityControl *control=nullptr, ObjectNameResolver *global_object_name_resolver=nullptr, bool treat_global_objects_as_roots=true)
v8::HeapSnapshot::Delete
void Delete()
v8::V8::MaybeLocal
friend class MaybeLocal
Definition: v8.h:9838
v8::HeapGraphEdge
Definition: v8-profiler.h:387
v8::CpuProfileNode::GetFunctionName
Local< String > GetFunctionName() const
v8::HeapStatsUpdate::size
uint32_t size
Definition: v8-profiler.h:962
v8::HeapGraphEdge::kWeak
@ kWeak
Definition: v8-profiler.h:400
v8::Message::kNoLineNumberInfo
static const int kNoLineNumberInfo
Definition: v8.h:2093
v8::EmbedderGraph::Node::NamePrefix
virtual const char * NamePrefix()
Definition: v8-profiler.h:731
v8::HeapProfiler::ObjectNameResolver
Definition: v8-profiler.h:830
v8::CpuProfileNode::GetScriptResourceNameStr
const char * GetScriptResourceNameStr() const
v8::HeapStatsUpdate::index
uint32_t index
Definition: v8-profiler.h:960
v8::CpuProfileNode::GetLineNumber
int GetLineNumber() const
v8::HeapGraphNode::GetChild
const HeapGraphEdge * GetChild(int index) const
v8::AllocationProfile::Node::children
std::vector< Node * > children
Definition: v8-profiler.h:649
v8::HeapGraphNode::kArray
@ kArray
Definition: v8-profiler.h:427
v8::CpuProfiler::StartProfiling
void StartProfiling(Local< String > title, bool record_samples=false)
v8::HeapGraphEdge::GetType
Type GetType() const
V8_EXPORT
#define V8_EXPORT
Definition: v8config.h:477
v8::HeapProfiler::StopSamplingHeapProfiler
void StopSamplingHeapProfiler()
v8::HeapGraphEdge::kHidden
@ kHidden
Definition: v8-profiler.h:396
v8::HeapProfiler::StartTrackingHeapObjects
void StartTrackingHeapObjects(bool track_allocations=false)
v8::Message
Definition: v8.h:2010
v8::HeapProfiler::GetHeapStats
SnapshotObjectId GetHeapStats(OutputStream *stream, int64_t *timestamp_us=nullptr)
v8::CodeEvent::GetCodeStartAddress
uintptr_t GetCodeStartAddress()
v8::HeapStatsUpdate
Definition: v8-profiler.h:957
v8::CodeEvent::GetPreviousCodeStartAddress
uintptr_t GetPreviousCodeStartAddress()
v8::HeapProfiler::RemoveBuildEmbedderGraphCallback
void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback, void *data)
v8::AllocationProfile::Sample::size
size_t size
Definition: v8-profiler.h:669
v8::EmbedderGraph
Definition: v8-profiler.h:711
v8::internal
Definition: v8-cppgc.h:18
v8::HeapGraphEdge::kContextVariable
@ kContextVariable
Definition: v8-profiler.h:390
v8::CpuProfile::GetStartTime
int64_t GetStartTime() const
v8::CpuProfileNode::kCallback
@ kCallback
Definition: v8-profiler.h:77
v8::AllocationProfile::kNoLineNumberInfo
static const int kNoLineNumberInfo
Definition: v8-profiler.h:693
v8::Context
Definition: v8.h:10264
CODE_EVENTS_LIST
#define CODE_EVENTS_LIST(V)
Definition: v8-profiler.h:965
v8::HeapSnapshot::GetMaxSnapshotJSObjectId
SnapshotObjectId GetMaxSnapshotJSObjectId() const
v8::Isolate
Definition: v8.h:8176
v8::CodeEventHandler
Definition: v8-profiler.h:1017
v8::HeapProfiler::FindObjectById
Local< Value > FindObjectById(SnapshotObjectId id)
v8::kLeafNodeLineNumbers
@ kLeafNodeLineNumbers
Definition: v8-profiler.h:227
v8::ActivityControl::kAbort
@ kAbort
Definition: v8-profiler.h:571
v8::AllocationProfile
Definition: v8-profiler.h:586
v8::HeapProfiler::GetSnapshotCount
int GetSnapshotCount()
v8::HeapProfiler::GetAllocationProfile
AllocationProfile * GetAllocationProfile()
v8::CpuProfile::GetTitle
Local< String > GetTitle() const
v8::HeapSnapshot::GetRoot
const HeapGraphNode * GetRoot() const
v8::kStandardNaming
@ kStandardNaming
Definition: v8-profiler.h:236
v8::OutputStream::kContinue
@ kContinue
Definition: v8-profiler.h:476
v8::CpuProfileNode::kNoColumnNumberInfo
static const int kNoColumnNumberInfo
Definition: v8-profiler.h:168
v8
Definition: libplatform.h:15
v8::CpuProfilingOptions::kNoSampleLimit
static const unsigned kNoSampleLimit
Definition: v8-profiler.h:257
v8::ActivityControl
Definition: v8-profiler.h:567
v8::CpuProfile::GetSampleTimestamp
int64_t GetSampleTimestamp(int index) const
v8::HeapGraphEdge::kElement
@ kElement
Definition: v8-profiler.h:391
v8::CpuProfileDeoptFrame::script_id
int script_id
Definition: v8-profiler.h:27
v8::HeapSnapshot::GetNode
const HeapGraphNode * GetNode(int index) const
v8::AllocationProfile::Sample::count
unsigned int count
Definition: v8-profiler.h:674
v8::AllocationProfile::Allocation
Definition: v8-profiler.h:588
v8::OutputStream::EndOfStream
virtual void EndOfStream()=0
v8::CpuProfileNode::kScript
@ kScript
Definition: v8-profiler.h:73
v8::HeapProfiler::kSamplingNoFlags
@ kSamplingNoFlags
Definition: v8-profiler.h:775
v8::HeapGraphNode::kSymbol
@ kSymbol
Definition: v8-profiler.h:439
v8::HeapGraphNode::kRegExp
@ kRegExp
Definition: v8-profiler.h:432
v8::CpuProfile::Delete
void Delete()
v8::AllocationProfile::Node::script_id
int script_id
Definition: v8-profiler.h:620
v8::HeapGraphNode::kSlicedString
@ kSlicedString
Definition: v8-profiler.h:438
v8::CpuProfilingLoggingMode
CpuProfilingLoggingMode
Definition: v8-profiler.h:242
v8::AllocationProfile::Node::script_name
Local< String > script_name
Definition: v8-profiler.h:614
v8::kUnknownType
@ kUnknownType
Definition: v8-profiler.h:984
v8::CpuProfileNode::GetLineTicks
bool GetLineTicks(LineTick *entries, unsigned int length) const
v8::HeapGraphNode::kConsString
@ kConsString
Definition: v8-profiler.h:437
v8::HeapGraphNode::kSynthetic
@ kSynthetic
Definition: v8-profiler.h:435
v8::CpuProfileNode::GetFunctionNameStr
const char * GetFunctionNameStr() const
v8::AllocationProfile::Node
Definition: v8-profiler.h:603
v8::HeapStatsUpdate::HeapStatsUpdate
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
Definition: v8-profiler.h:958
v8::CpuProfileNode::GetNodeId
unsigned GetNodeId() const
v8::AllocationProfile::Node::name
Local< String > name
Definition: v8-profiler.h:608
v8::HeapSnapshot::GetNodesCount
int GetNodesCount() const
v8::CpuProfileDeoptInfo
Definition: v8-profiler.h:43
v8::EmbedderGraph::Node::IsRootNode
virtual bool IsRootNode()
Definition: v8-profiler.h:725
v8::OutputStream
Definition: v8-profiler.h:473
v8::HeapProfiler::BuildEmbedderGraphCallback
void(* BuildEmbedderGraphCallback)(v8::Isolate *isolate, v8::EmbedderGraph *graph, void *data)
Definition: v8-profiler.h:785
v8::CpuProfileDeoptFrame
Definition: v8-profiler.h:26
v8::EmbedderGraph::Node::GetNativeObject
virtual NativeObject GetNativeObject()
Definition: v8-profiler.h:737
v8::CpuProfileNode::GetColumnNumber
int GetColumnNumber() const
v8::V8::Local
friend class Local
Definition: v8.h:9836
v8::HeapGraphEdge::kShortcut
@ kShortcut
Definition: v8-profiler.h:398
v8::HeapGraphNode::GetName
Local< String > GetName() const
v8::HeapGraphEdge::kInternal
@ kInternal
Definition: v8-profiler.h:393
v8::AllocationProfile::GetSamples
virtual const std::vector< Sample > & GetSamples()=0
v8::OutputStream::WriteHeapStatsChunk
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate *data, int count)
Definition: v8-profiler.h:495
v8::HeapGraphEdge::kProperty
@ kProperty
Definition: v8-profiler.h:392
v8::CpuProfileNode::kUnresolved
@ kUnresolved
Definition: v8-profiler.h:81
v8::HeapGraphNode::GetChildrenCount
int GetChildrenCount() const
v8::HeapGraphEdge::GetFromNode
const HeapGraphNode * GetFromNode() const
v8::CpuProfileNode::kNoLineNumberInfo
static const int kNoLineNumberInfo
Definition: v8-profiler.h:167
v8::HeapGraphEdge::GetToNode
const HeapGraphNode * GetToNode() const
v8::CpuProfiler::SetUsePreciseSampling
void SetUsePreciseSampling(bool)
v8::CpuProfileDeoptInfo::deopt_reason
const char * deopt_reason
Definition: v8-profiler.h:45
v8::CodeEvent::GetComment
const char * GetComment()
v8::HeapProfiler::kUnknownObjectId
static const SnapshotObjectId kUnknownObjectId
Definition: v8-profiler.h:825
v8::OutputStream::WriteResult
WriteResult
Definition: v8-profiler.h:475
v8::CodeEventHandler::CodeEventHandler
CodeEventHandler(Isolate *isolate)
v8::HeapProfiler::ObjectNameResolver::~ObjectNameResolver
virtual ~ObjectNameResolver()=default
v8::HeapGraphNode::kHidden
@ kHidden
Definition: v8-profiler.h:426
v8::EmbedderGraph::AddNode
virtual Node * AddNode(std::unique_ptr< Node > node)=0
v8::AllocationProfile::Node::allocations
std::vector< Allocation > allocations
Definition: v8-profiler.h:654
v8::HeapProfiler::StartSamplingHeapProfiler
bool StartSamplingHeapProfiler(uint64_t sample_interval=512 *1024, int stack_depth=16, SamplingFlags flags=kSamplingNoFlags)
v8::EmbedderGraph::Node
Definition: v8-profiler.h:713
v8::EmbedderGraph::V8Node
virtual Node * V8Node(const v8::Local< v8::Value > &value)=0
v8::HeapProfiler::GetHeapSnapshot
const HeapSnapshot * GetHeapSnapshot(int index)
v8::HeapStatsUpdate::count
uint32_t count
Definition: v8-profiler.h:961
v8::CpuProfiler::Dispose
void Dispose()
v8::CpuProfiler::UseDetailedSourcePositionsForProfiling
static void UseDetailedSourcePositionsForProfiling(Isolate *isolate)
v8::CpuProfileNode::SourceType
SourceType
Definition: v8-profiler.h:71
v8::kEagerLogging
@ kEagerLogging
Definition: v8-profiler.h:248
v8::AllocationProfile::Node::start_position
int start_position
Definition: v8-profiler.h:625
v8::CpuProfiler
Definition: v8-profiler.h:297
v8::CpuProfiler::StartProfiling
void StartProfiling(Local< String > title, CpuProfilingOptions options)
v8::PersistentBase::IsEmpty
V8_INLINE bool IsEmpty() const
Definition: v8.h:504
v8::EmbedderGraph::Node::WrapperNode
virtual Node * WrapperNode()
Definition: v8-profiler.h:724
v8::CpuProfileNode::GetScriptId
int GetScriptId() const
v8::OutputStream::WriteAsciiChunk
virtual WriteResult WriteAsciiChunk(char *data, int size)=0
v8::EmbedderGraph::Node::Name
virtual const char * Name()=0
v8::AllocationProfile::Sample::node_id
uint32_t node_id
Definition: v8-profiler.h:664
v8::HeapSnapshot::SerializationFormat
SerializationFormat
Definition: v8-profiler.h:506
v8::Value
Definition: v8.h:2529
v8::HeapSnapshot
Definition: v8-profiler.h:504
v8::CpuProfile
Definition: v8-profiler.h:176
v8::EmbedderGraph::AddEdge
virtual void AddEdge(Node *from, Node *to, const char *name=nullptr)=0
v8::CodeEvent::GetCodeType
CodeEventType GetCodeType()
v8::CpuProfileNode::kInternal
@ kInternal
Definition: v8-profiler.h:79
v8::EmbedderGraph::Node::IsEmbedderNode
virtual bool IsEmbedderNode()
Definition: v8-profiler.h:727
v8::CpuProfileNode::GetParent
const CpuProfileNode * GetParent() const
v8::CpuProfileDeoptInfo::stack
std::vector< CpuProfileDeoptFrame > stack
Definition: v8-profiler.h:46
v8::HeapSnapshot::GetNodeById
const HeapGraphNode * GetNodeById(SnapshotObjectId id) const
v8::AllocationProfile::Allocation::count
unsigned int count
Definition: v8-profiler.h:597
v8::HeapProfiler
Definition: v8-profiler.h:772
v8::CpuProfileNode::GetChild
const CpuProfileNode * GetChild(int index) const
v8::CodeEventHandler::~CodeEventHandler
virtual ~CodeEventHandler()
v8::CpuProfileDeoptFrame::position
size_t position
Definition: v8-profiler.h:28
v8::HeapGraphEdge::Type
Type
Definition: v8-profiler.h:389
v8::HeapSnapshot::Serialize
void Serialize(OutputStream *stream, SerializationFormat format=kJSON) const
v8::String
Definition: v8.h:3002
v8::EmbedderGraph::Node::~Node
virtual ~Node()=default