libv8 6.7.288.46.1-universal-darwin-15 → 8.4.255.0-universal-darwin-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/libv8/version.rb +1 -1
- data/vendor/v8/include/cppgc/allocation.h +124 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +192 -0
- data/vendor/v8/include/cppgc/heap.h +50 -0
- data/vendor/v8/include/cppgc/internal/accessors.h +26 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +44 -0
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +26 -0
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +43 -0
- data/vendor/v8/include/cppgc/internal/logging.h +50 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +109 -0
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +133 -0
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +31 -0
- data/vendor/v8/include/cppgc/liveness-broker.h +50 -0
- data/vendor/v8/include/cppgc/macros.h +26 -0
- data/vendor/v8/include/cppgc/member.h +206 -0
- data/vendor/v8/include/cppgc/persistent.h +304 -0
- data/vendor/v8/include/cppgc/platform.h +31 -0
- data/vendor/v8/include/cppgc/prefinalizer.h +54 -0
- data/vendor/v8/include/cppgc/source-location.h +59 -0
- data/vendor/v8/include/cppgc/trace-trait.h +67 -0
- data/vendor/v8/include/cppgc/type-traits.h +109 -0
- data/vendor/v8/include/cppgc/visitor.h +137 -0
- data/vendor/v8/include/libplatform/libplatform.h +13 -24
- data/vendor/v8/include/libplatform/v8-tracing.h +57 -20
- data/vendor/v8/include/v8-fast-api-calls.h +412 -0
- data/vendor/v8/include/v8-inspector-protocol.h +4 -4
- data/vendor/v8/include/v8-inspector.h +74 -36
- data/vendor/v8/include/v8-internal.h +389 -0
- data/vendor/v8/include/v8-platform.h +228 -124
- data/vendor/v8/include/v8-profiler.h +292 -228
- data/vendor/v8/include/v8-util.h +27 -25
- data/vendor/v8/include/v8-version-string.h +1 -1
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
- data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
- data/vendor/v8/include/v8.h +2966 -1362
- data/vendor/v8/include/v8config.h +156 -114
- data/vendor/v8/out.gn/libv8/obj/libv8_libbase.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_libplatform.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicui18n.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicuuc.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/zlib/google/libcompression_utils_portable.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/zlib/libchrome_zlib.a +0 -0
- metadata +37 -9
- data/vendor/v8/include/v8-testing.h +0 -48
@@ -5,9 +5,12 @@
|
|
5
5
|
#ifndef V8_V8_PROFILER_H_
|
6
6
|
#define V8_V8_PROFILER_H_
|
7
7
|
|
8
|
+
#include <limits.h>
|
9
|
+
#include <memory>
|
8
10
|
#include <unordered_set>
|
9
11
|
#include <vector>
|
10
|
-
|
12
|
+
|
13
|
+
#include "v8.h" // NOLINT(build/include_directory)
|
11
14
|
|
12
15
|
/**
|
13
16
|
* Profiler support for the V8 JavaScript engine.
|
@@ -17,14 +20,18 @@ namespace v8 {
|
|
17
20
|
class HeapGraphNode;
|
18
21
|
struct HeapStatsUpdate;
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
using NativeObject = void*;
|
24
|
+
using SnapshotObjectId = uint32_t;
|
22
25
|
|
23
26
|
struct CpuProfileDeoptFrame {
|
24
27
|
int script_id;
|
25
28
|
size_t position;
|
26
29
|
};
|
27
30
|
|
31
|
+
namespace internal {
|
32
|
+
class CpuProfile;
|
33
|
+
} // namespace internal
|
34
|
+
|
28
35
|
} // namespace v8
|
29
36
|
|
30
37
|
#ifdef V8_OS_WIN
|
@@ -47,89 +54,6 @@ template class V8_EXPORT std::vector
|
|
47
54
|
|
48
55
|
namespace v8 {
|
49
56
|
|
50
|
-
/**
|
51
|
-
* TracingCpuProfiler monitors tracing being enabled/disabled
|
52
|
-
* and emits CpuProfile trace events once v8.cpu_profiler tracing category
|
53
|
-
* is enabled. It has no overhead unless the category is enabled.
|
54
|
-
*/
|
55
|
-
class V8_EXPORT TracingCpuProfiler {
|
56
|
-
public:
|
57
|
-
static std::unique_ptr<TracingCpuProfiler> Create(Isolate*);
|
58
|
-
virtual ~TracingCpuProfiler() = default;
|
59
|
-
|
60
|
-
protected:
|
61
|
-
TracingCpuProfiler() = default;
|
62
|
-
};
|
63
|
-
|
64
|
-
// TickSample captures the information collected for each sample.
|
65
|
-
struct TickSample {
|
66
|
-
// Internal profiling (with --prof + tools/$OS-tick-processor) wants to
|
67
|
-
// include the runtime function we're calling. Externally exposed tick
|
68
|
-
// samples don't care.
|
69
|
-
enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame };
|
70
|
-
|
71
|
-
TickSample()
|
72
|
-
: state(OTHER),
|
73
|
-
pc(nullptr),
|
74
|
-
external_callback_entry(nullptr),
|
75
|
-
frames_count(0),
|
76
|
-
has_external_callback(false),
|
77
|
-
update_stats(true) {}
|
78
|
-
|
79
|
-
/**
|
80
|
-
* Initialize a tick sample from the isolate.
|
81
|
-
* \param isolate The isolate.
|
82
|
-
* \param state Execution state.
|
83
|
-
* \param record_c_entry_frame Include or skip the runtime function.
|
84
|
-
* \param update_stats Whether update the sample to the aggregated stats.
|
85
|
-
* \param use_simulator_reg_state When set to true and V8 is running under a
|
86
|
-
* simulator, the method will use the simulator
|
87
|
-
* register state rather than the one provided
|
88
|
-
* with |state| argument. Otherwise the method
|
89
|
-
* will use provided register |state| as is.
|
90
|
-
*/
|
91
|
-
void Init(Isolate* isolate, const v8::RegisterState& state,
|
92
|
-
RecordCEntryFrame record_c_entry_frame, bool update_stats,
|
93
|
-
bool use_simulator_reg_state = true);
|
94
|
-
/**
|
95
|
-
* Get a call stack sample from the isolate.
|
96
|
-
* \param isolate The isolate.
|
97
|
-
* \param state Register state.
|
98
|
-
* \param record_c_entry_frame Include or skip the runtime function.
|
99
|
-
* \param frames Caller allocated buffer to store stack frames.
|
100
|
-
* \param frames_limit Maximum number of frames to capture. The buffer must
|
101
|
-
* be large enough to hold the number of frames.
|
102
|
-
* \param sample_info The sample info is filled up by the function
|
103
|
-
* provides number of actual captured stack frames and
|
104
|
-
* the current VM state.
|
105
|
-
* \param use_simulator_reg_state When set to true and V8 is running under a
|
106
|
-
* simulator, the method will use the simulator
|
107
|
-
* register state rather than the one provided
|
108
|
-
* with |state| argument. Otherwise the method
|
109
|
-
* will use provided register |state| as is.
|
110
|
-
* \note GetStackSample is thread and signal safe and should only be called
|
111
|
-
* when the JS thread is paused or interrupted.
|
112
|
-
* Otherwise the behavior is undefined.
|
113
|
-
*/
|
114
|
-
static bool GetStackSample(Isolate* isolate, v8::RegisterState* state,
|
115
|
-
RecordCEntryFrame record_c_entry_frame,
|
116
|
-
void** frames, size_t frames_limit,
|
117
|
-
v8::SampleInfo* sample_info,
|
118
|
-
bool use_simulator_reg_state = true);
|
119
|
-
StateTag state; // The state of the VM.
|
120
|
-
void* pc; // Instruction pointer.
|
121
|
-
union {
|
122
|
-
void* tos; // Top stack value (*sp).
|
123
|
-
void* external_callback_entry;
|
124
|
-
};
|
125
|
-
static const unsigned kMaxFramesCountLog2 = 8;
|
126
|
-
static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
|
127
|
-
void* stack[kMaxFramesCount]; // Call stack.
|
128
|
-
unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames.
|
129
|
-
bool has_external_callback : 1;
|
130
|
-
bool update_stats : 1; // Whether the sample should update aggregated stats.
|
131
|
-
};
|
132
|
-
|
133
57
|
/**
|
134
58
|
* CpuProfileNode represents a node in a call graph.
|
135
59
|
*/
|
@@ -143,6 +67,20 @@ class V8_EXPORT CpuProfileNode {
|
|
143
67
|
unsigned int hit_count;
|
144
68
|
};
|
145
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.
|
81
|
+
kUnresolved = 4,
|
82
|
+
};
|
83
|
+
|
146
84
|
/** Returns function name (empty string for anonymous functions.) */
|
147
85
|
Local<String> GetFunctionName() const;
|
148
86
|
|
@@ -166,6 +104,12 @@ class V8_EXPORT CpuProfileNode {
|
|
166
104
|
*/
|
167
105
|
const char* GetScriptResourceNameStr() const;
|
168
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
|
+
|
169
113
|
/**
|
170
114
|
* Returns the number, 1-based, of the line where the function originates.
|
171
115
|
* kNoLineNumberInfo if no line number information is available.
|
@@ -200,20 +144,23 @@ class V8_EXPORT CpuProfileNode {
|
|
200
144
|
*/
|
201
145
|
unsigned GetHitCount() const;
|
202
146
|
|
203
|
-
/** Returns function entry UID. */
|
204
|
-
V8_DEPRECATE_SOON(
|
205
|
-
"Use GetScriptId, GetLineNumber, and GetColumnNumber instead.",
|
206
|
-
unsigned GetCallUid() const);
|
207
|
-
|
208
147
|
/** Returns id of the node. The id is unique within the tree */
|
209
148
|
unsigned GetNodeId() const;
|
210
149
|
|
150
|
+
/**
|
151
|
+
* Gets the type of the source which the node was captured from.
|
152
|
+
*/
|
153
|
+
SourceType GetSourceType() const;
|
154
|
+
|
211
155
|
/** Returns child nodes count of the node. */
|
212
156
|
int GetChildrenCount() const;
|
213
157
|
|
214
158
|
/** Retrieves a child node by index. */
|
215
159
|
const CpuProfileNode* GetChild(int index) const;
|
216
160
|
|
161
|
+
/** Retrieves the ancestor node, or null if the root. */
|
162
|
+
const CpuProfileNode* GetParent() const;
|
163
|
+
|
217
164
|
/** Retrieves deopt infos for the node. */
|
218
165
|
const std::vector<CpuProfileDeoptInfo>& GetDeoptInfos() const;
|
219
166
|
|
@@ -273,6 +220,76 @@ class V8_EXPORT CpuProfile {
|
|
273
220
|
void Delete();
|
274
221
|
};
|
275
222
|
|
223
|
+
enum CpuProfilingMode {
|
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.
|
227
|
+
kLeafNodeLineNumbers,
|
228
|
+
// In the resulting CpuProfile tree, nodes are separated based on the line
|
229
|
+
// number of their callsite in their parent.
|
230
|
+
kCallerLineNumbers,
|
231
|
+
};
|
232
|
+
|
233
|
+
// Determines how names are derived for functions sampled.
|
234
|
+
enum CpuProfilingNamingMode {
|
235
|
+
// Use the immediate name of functions at compilation time.
|
236
|
+
kStandardNaming,
|
237
|
+
// Use more verbose naming for functions without names, inferred from scope
|
238
|
+
// where possible.
|
239
|
+
kDebugNaming,
|
240
|
+
};
|
241
|
+
|
242
|
+
enum CpuProfilingLoggingMode {
|
243
|
+
// Enables logging when a profile is active, and disables logging when all
|
244
|
+
// profiles are detached.
|
245
|
+
kLazyLogging,
|
246
|
+
// Enables logging for the lifetime of the CpuProfiler. Calls to
|
247
|
+
// StartRecording are faster, at the expense of runtime overhead.
|
248
|
+
kEagerLogging,
|
249
|
+
};
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Optional profiling attributes.
|
253
|
+
*/
|
254
|
+
class V8_EXPORT CpuProfilingOptions {
|
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
|
+
*/
|
272
|
+
CpuProfilingOptions(
|
273
|
+
CpuProfilingMode mode = kLeafNodeLineNumbers,
|
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
|
+
|
276
293
|
/**
|
277
294
|
* Interface for controlling CPU profiling. Instance of the
|
278
295
|
* profiler can be created using v8::CpuProfiler::New method.
|
@@ -284,7 +301,9 @@ class V8_EXPORT CpuProfiler {
|
|
284
301
|
* initialized. The profiler object must be disposed after use by calling
|
285
302
|
* |Dispose| method.
|
286
303
|
*/
|
287
|
-
static CpuProfiler* New(Isolate* isolate
|
304
|
+
static CpuProfiler* New(Isolate* isolate,
|
305
|
+
CpuProfilingNamingMode = kDebugNaming,
|
306
|
+
CpuProfilingLoggingMode = kLazyLogging);
|
288
307
|
|
289
308
|
/**
|
290
309
|
* Synchronously collect current stack sample in all profilers attached to
|
@@ -306,15 +325,39 @@ class V8_EXPORT CpuProfiler {
|
|
306
325
|
void SetSamplingInterval(int us);
|
307
326
|
|
308
327
|
/**
|
309
|
-
*
|
310
|
-
*
|
311
|
-
*
|
312
|
-
*
|
313
|
-
*
|
314
|
-
|
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.
|
315
346
|
*
|
316
347
|
* |record_samples| parameter controls whether individual samples should
|
317
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.
|
318
361
|
*/
|
319
362
|
void StartProfiling(Local<String> title, bool record_samples = false);
|
320
363
|
|
@@ -325,18 +368,10 @@ class V8_EXPORT CpuProfiler {
|
|
325
368
|
CpuProfile* StopProfiling(Local<String> title);
|
326
369
|
|
327
370
|
/**
|
328
|
-
*
|
329
|
-
*
|
330
|
-
* profile statistics.
|
371
|
+
* Generate more detailed source positions to code objects. This results in
|
372
|
+
* better results when mapping profiling samples to script source.
|
331
373
|
*/
|
332
|
-
|
333
|
-
void CollectSample());
|
334
|
-
|
335
|
-
/**
|
336
|
-
* Tells the profiler whether the embedder is idle.
|
337
|
-
*/
|
338
|
-
V8_DEPRECATED("Use Isolate::SetIdle(bool) instead.",
|
339
|
-
void SetIdle(bool is_idle));
|
374
|
+
static void UseDetailedSourcePositionsForProfiling(Isolate* isolate);
|
340
375
|
|
341
376
|
private:
|
342
377
|
CpuProfiler();
|
@@ -345,7 +380,6 @@ class V8_EXPORT CpuProfiler {
|
|
345
380
|
CpuProfiler& operator=(const CpuProfiler&);
|
346
381
|
};
|
347
382
|
|
348
|
-
|
349
383
|
/**
|
350
384
|
* HeapSnapshotEdge represents a directed connection between heap
|
351
385
|
* graph nodes: from retainers to retained nodes.
|
@@ -442,7 +476,7 @@ class V8_EXPORT OutputStream { // NOLINT
|
|
442
476
|
kContinue = 0,
|
443
477
|
kAbort = 1
|
444
478
|
};
|
445
|
-
virtual ~OutputStream()
|
479
|
+
virtual ~OutputStream() = default;
|
446
480
|
/** Notify about the end of stream. */
|
447
481
|
virtual void EndOfStream() = 0;
|
448
482
|
/** Get preferred output chunk size. Called only once. */
|
@@ -536,7 +570,7 @@ class V8_EXPORT ActivityControl { // NOLINT
|
|
536
570
|
kContinue = 0,
|
537
571
|
kAbort = 1
|
538
572
|
};
|
539
|
-
virtual ~ActivityControl()
|
573
|
+
virtual ~ActivityControl() = default;
|
540
574
|
/**
|
541
575
|
* Notify about current progress. The activity can be stopped by
|
542
576
|
* returning kAbort as the callback result.
|
@@ -602,6 +636,11 @@ class V8_EXPORT AllocationProfile {
|
|
602
636
|
*/
|
603
637
|
int column_number;
|
604
638
|
|
639
|
+
/**
|
640
|
+
* Unique id of the node.
|
641
|
+
*/
|
642
|
+
uint32_t node_id;
|
643
|
+
|
605
644
|
/**
|
606
645
|
* List of callees called from this node for which we have sampled
|
607
646
|
* allocations. The lifetime of the children is scoped to the containing
|
@@ -615,14 +654,41 @@ class V8_EXPORT AllocationProfile {
|
|
615
654
|
std::vector<Allocation> allocations;
|
616
655
|
};
|
617
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
|
+
|
618
683
|
/**
|
619
684
|
* Returns the root node of the call-graph. The root node corresponds to an
|
620
685
|
* empty JS call-stack. The lifetime of the returned Node* is scoped to the
|
621
686
|
* containing AllocationProfile.
|
622
687
|
*/
|
623
688
|
virtual Node* GetRootNode() = 0;
|
689
|
+
virtual const std::vector<Sample>& GetSamples() = 0;
|
624
690
|
|
625
|
-
virtual ~AllocationProfile()
|
691
|
+
virtual ~AllocationProfile() = default;
|
626
692
|
|
627
693
|
static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
|
628
694
|
static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
|
@@ -636,7 +702,7 @@ class V8_EXPORT AllocationProfile {
|
|
636
702
|
* Usage:
|
637
703
|
* 1) Define derived class of EmbedderGraph::Node for embedder objects.
|
638
704
|
* 2) Set the build embedder graph callback on the heap profiler using
|
639
|
-
* HeapProfiler::
|
705
|
+
* HeapProfiler::AddBuildEmbedderGraphCallback.
|
640
706
|
* 3) In the callback use graph->AddEdge(node1, node2) to add an edge from
|
641
707
|
* node1 to node2.
|
642
708
|
* 4) To represent references from/to V8 object, construct V8 nodes using
|
@@ -664,7 +730,12 @@ class V8_EXPORT EmbedderGraph {
|
|
664
730
|
*/
|
665
731
|
virtual const char* NamePrefix() { return nullptr; }
|
666
732
|
|
667
|
-
|
733
|
+
/**
|
734
|
+
* Returns the NativeObject that can be used for querying the
|
735
|
+
* |HeapSnapshot|.
|
736
|
+
*/
|
737
|
+
virtual NativeObject GetNativeObject() { return nullptr; }
|
738
|
+
|
668
739
|
Node(const Node&) = delete;
|
669
740
|
Node& operator=(const Node&) = delete;
|
670
741
|
};
|
@@ -682,11 +753,14 @@ class V8_EXPORT EmbedderGraph {
|
|
682
753
|
virtual Node* AddNode(std::unique_ptr<Node> node) = 0;
|
683
754
|
|
684
755
|
/**
|
685
|
-
* Adds an edge that represents a strong reference from the given
|
686
|
-
* |from| to the given node |to|. The nodes must be added to the graph
|
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
|
687
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.
|
688
762
|
*/
|
689
|
-
virtual void AddEdge(Node* from, Node* to) = 0;
|
763
|
+
virtual void AddEdge(Node* from, Node* to, const char* name = nullptr) = 0;
|
690
764
|
|
691
765
|
virtual ~EmbedderGraph() = default;
|
692
766
|
};
|
@@ -702,33 +776,6 @@ class V8_EXPORT HeapProfiler {
|
|
702
776
|
kSamplingForceGC = 1 << 0,
|
703
777
|
};
|
704
778
|
|
705
|
-
typedef std::unordered_set<const v8::PersistentBase<v8::Value>*>
|
706
|
-
RetainerChildren;
|
707
|
-
typedef std::vector<std::pair<v8::RetainedObjectInfo*, RetainerChildren>>
|
708
|
-
RetainerGroups;
|
709
|
-
typedef std::vector<std::pair<const v8::PersistentBase<v8::Value>*,
|
710
|
-
const v8::PersistentBase<v8::Value>*>>
|
711
|
-
RetainerEdges;
|
712
|
-
|
713
|
-
struct RetainerInfos {
|
714
|
-
RetainerGroups groups;
|
715
|
-
RetainerEdges edges;
|
716
|
-
};
|
717
|
-
|
718
|
-
/**
|
719
|
-
* Callback function invoked to retrieve all RetainerInfos from the embedder.
|
720
|
-
*/
|
721
|
-
typedef RetainerInfos (*GetRetainerInfosCallback)(v8::Isolate* isolate);
|
722
|
-
|
723
|
-
/**
|
724
|
-
* Callback function invoked for obtaining RetainedObjectInfo for
|
725
|
-
* the given JavaScript wrapper object. It is prohibited to enter V8
|
726
|
-
* while the callback is running: only getters on the handle and
|
727
|
-
* GetPointerFromInternalField on the objects are allowed.
|
728
|
-
*/
|
729
|
-
typedef RetainedObjectInfo* (*WrapperInfoCallback)(uint16_t class_id,
|
730
|
-
Local<Value> wrapper);
|
731
|
-
|
732
779
|
/**
|
733
780
|
* Callback function invoked during heap snapshot generation to retrieve
|
734
781
|
* the embedder object graph. The callback should use graph->AddEdge(..) to
|
@@ -736,7 +783,8 @@ class V8_EXPORT HeapProfiler {
|
|
736
783
|
* The callback must not trigger garbage collection in V8.
|
737
784
|
*/
|
738
785
|
typedef void (*BuildEmbedderGraphCallback)(v8::Isolate* isolate,
|
739
|
-
v8::EmbedderGraph* graph
|
786
|
+
v8::EmbedderGraph* graph,
|
787
|
+
void* data);
|
740
788
|
|
741
789
|
/** Returns the number of snapshots taken. */
|
742
790
|
int GetSnapshotCount();
|
@@ -750,6 +798,12 @@ class V8_EXPORT HeapProfiler {
|
|
750
798
|
*/
|
751
799
|
SnapshotObjectId GetObjectId(Local<Value> value);
|
752
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
|
+
|
753
807
|
/**
|
754
808
|
* Returns heap object with given SnapshotObjectId if the object is alive,
|
755
809
|
* otherwise empty handle is returned.
|
@@ -782,15 +836,16 @@ class V8_EXPORT HeapProfiler {
|
|
782
836
|
virtual const char* GetName(Local<Object> object) = 0;
|
783
837
|
|
784
838
|
protected:
|
785
|
-
virtual ~ObjectNameResolver()
|
839
|
+
virtual ~ObjectNameResolver() = default;
|
786
840
|
};
|
787
841
|
|
788
842
|
/**
|
789
843
|
* Takes a heap snapshot and returns it.
|
790
844
|
*/
|
791
845
|
const HeapSnapshot* TakeHeapSnapshot(
|
792
|
-
ActivityControl* control =
|
793
|
-
ObjectNameResolver* global_object_name_resolver =
|
846
|
+
ActivityControl* control = nullptr,
|
847
|
+
ObjectNameResolver* global_object_name_resolver = nullptr,
|
848
|
+
bool treat_global_objects_as_roots = true);
|
794
849
|
|
795
850
|
/**
|
796
851
|
* Starts tracking of heap objects population statistics. After calling
|
@@ -817,7 +872,7 @@ class V8_EXPORT HeapProfiler {
|
|
817
872
|
* method.
|
818
873
|
*/
|
819
874
|
SnapshotObjectId GetHeapStats(OutputStream* stream,
|
820
|
-
int64_t* timestamp_us =
|
875
|
+
int64_t* timestamp_us = nullptr);
|
821
876
|
|
822
877
|
/**
|
823
878
|
* Stops tracking of heap objects population statistics, cleans up all
|
@@ -876,17 +931,10 @@ class V8_EXPORT HeapProfiler {
|
|
876
931
|
*/
|
877
932
|
void DeleteAllHeapSnapshots();
|
878
933
|
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
WrapperInfoCallback callback));
|
884
|
-
|
885
|
-
V8_DEPRECATED(
|
886
|
-
"Use SetBuildEmbedderGraphCallback to provide info about embedder nodes",
|
887
|
-
void SetGetRetainerInfosCallback(GetRetainerInfosCallback callback));
|
888
|
-
|
889
|
-
void SetBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback);
|
934
|
+
void AddBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
|
935
|
+
void* data);
|
936
|
+
void RemoveBuildEmbedderGraphCallback(BuildEmbedderGraphCallback callback,
|
937
|
+
void* data);
|
890
938
|
|
891
939
|
/**
|
892
940
|
* Default value of persistent handle class ID. Must not be used to
|
@@ -903,92 +951,108 @@ class V8_EXPORT HeapProfiler {
|
|
903
951
|
};
|
904
952
|
|
905
953
|
/**
|
906
|
-
*
|
907
|
-
*
|
908
|
-
*
|
909
|
-
* 1. When calling AddObjectGroup, an embedder may pass
|
910
|
-
* RetainedObjectInfo instance describing the group. To collect
|
911
|
-
* this information while taking a heap snapshot, V8 calls GC
|
912
|
-
* prologue and epilogue callbacks.
|
913
|
-
*
|
914
|
-
* 2. When a heap snapshot is collected, V8 additionally
|
915
|
-
* requests RetainedObjectInfos for persistent handles that
|
916
|
-
* were not previously reported via AddObjectGroup.
|
917
|
-
*
|
918
|
-
* Thus, if an embedder wants to provide information about native
|
919
|
-
* objects for heap snapshots, it can do it in a GC prologue
|
920
|
-
* handler, and / or by assigning wrapper class ids in the following way:
|
921
|
-
*
|
922
|
-
* 1. Bind a callback to class id by calling SetWrapperClassInfoProvider.
|
923
|
-
* 2. Call SetWrapperClassId on certain persistent handles.
|
924
|
-
*
|
925
|
-
* V8 takes ownership of RetainedObjectInfo instances passed to it and
|
926
|
-
* keeps them alive only during snapshot collection. Afterwards, they
|
927
|
-
* are freed by calling the Dispose class function.
|
954
|
+
* A struct for exporting HeapStats data from V8, using "push" model.
|
955
|
+
* See HeapProfiler::GetHeapStats.
|
928
956
|
*/
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
957
|
+
struct HeapStatsUpdate {
|
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
|
+
};
|
933
964
|
|
934
|
-
|
935
|
-
|
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)
|
936
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
|
+
*/
|
983
|
+
enum CodeEventType {
|
984
|
+
kUnknownType = 0
|
985
|
+
#define V(Name) , k##Name##Type
|
986
|
+
CODE_EVENTS_LIST(V)
|
987
|
+
#undef V
|
988
|
+
};
|
989
|
+
|
990
|
+
/**
|
991
|
+
* Representation of a code creation event
|
992
|
+
*/
|
993
|
+
class V8_EXPORT CodeEvent {
|
994
|
+
public:
|
995
|
+
uintptr_t GetCodeStartAddress();
|
996
|
+
size_t GetCodeSize();
|
997
|
+
Local<String> GetFunctionName();
|
998
|
+
Local<String> GetScriptName();
|
999
|
+
int GetScriptLine();
|
1000
|
+
int GetScriptColumn();
|
937
1001
|
/**
|
938
|
-
*
|
939
|
-
*
|
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*.
|
940
1005
|
*/
|
941
|
-
|
1006
|
+
CodeEventType GetCodeType();
|
1007
|
+
const char* GetComment();
|
942
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
|
+
*/
|
1017
|
+
class V8_EXPORT CodeEventHandler {
|
1018
|
+
public:
|
943
1019
|
/**
|
944
|
-
*
|
945
|
-
*
|
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.
|
946
1023
|
*/
|
947
|
-
|
1024
|
+
explicit CodeEventHandler(Isolate* isolate);
|
1025
|
+
virtual ~CodeEventHandler();
|
948
1026
|
|
949
1027
|
/**
|
950
|
-
*
|
951
|
-
*
|
952
|
-
*
|
953
|
-
*
|
954
|
-
*
|
955
|
-
*
|
956
|
-
* own implementation yet.
|
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()`.
|
957
1034
|
*/
|
958
|
-
virtual
|
1035
|
+
virtual void Handle(CodeEvent* code_event) = 0;
|
959
1036
|
|
960
1037
|
/**
|
961
|
-
*
|
962
|
-
*
|
1038
|
+
* Call `Enable()` to starts listening to code creation and code relocation
|
1039
|
+
* events. These events will be handled by `Handle()`.
|
963
1040
|
*/
|
964
|
-
|
965
|
-
|
966
|
-
/** Returns embedder's object size in bytes. */
|
967
|
-
virtual intptr_t GetSizeInBytes() { return -1; }
|
1041
|
+
void Enable();
|
968
1042
|
|
969
|
-
|
970
|
-
|
971
|
-
|
1043
|
+
/**
|
1044
|
+
* Call `Disable()` to stop listening to code creation and code relocation
|
1045
|
+
* events.
|
1046
|
+
*/
|
1047
|
+
void Disable();
|
972
1048
|
|
973
1049
|
private:
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
/**
|
980
|
-
* A struct for exporting HeapStats data from V8, using "push" model.
|
981
|
-
* See HeapProfiler::GetHeapStats.
|
982
|
-
*/
|
983
|
-
struct HeapStatsUpdate {
|
984
|
-
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
|
985
|
-
: index(index), count(count), size(size) { }
|
986
|
-
uint32_t index; // Index of the time interval that was changed.
|
987
|
-
uint32_t count; // New value of count field for the interval with this index.
|
988
|
-
uint32_t size; // New value of size field for the interval with this index.
|
1050
|
+
CodeEventHandler();
|
1051
|
+
CodeEventHandler(const CodeEventHandler&);
|
1052
|
+
CodeEventHandler& operator=(const CodeEventHandler&);
|
1053
|
+
void* internal_listener_;
|
989
1054
|
};
|
990
1055
|
|
991
|
-
|
992
1056
|
} // namespace v8
|
993
1057
|
|
994
1058
|
|