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