51
51
// Setup for Linux shared library export. See v8.h in this directory for
52
52
// information on how to build/use V8 as shared library.
53
#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
53
#if defined(__GNUC__) && ((__GNUC__ >= 4) || \
54
(__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED)
54
55
#define V8EXPORT __attribute__ ((visibility("default")))
55
#else // defined(__GNUC__) && (__GNUC__ >= 4)
57
#endif // defined(__GNUC__) && (__GNUC__ >= 4)
219
221
// (e.g. parts of a ConsString).
220
222
kHidden = 4, // A link that is needed for proper sizes
221
223
// calculation, but may be hidden from user.
222
kShortcut = 5 // A link that must not be followed during
224
kShortcut = 5, // A link that must not be followed during
223
225
// sizes calculation.
226
kWeak = 6 // A weak reference (ignored by the GC).
226
229
/** Returns edge type (see HeapGraphEdge::Type). */
254
257
kClosure = 5, // Function closure.
255
258
kRegExp = 6, // RegExp.
256
259
kHeapNumber = 7, // Number stored in the heap.
257
kNative = 8 // Native object (not from V8 heap).
260
kNative = 8, // Native object (not from V8 heap).
261
kSynthetic = 9 // Synthetic object, usualy used for grouping
262
// snapshot items together.
260
265
/** Returns node type (see HeapGraphNode::Type). */
271
276
* Returns node id. For the same heap object, the id remains the same
272
277
* across all snapshots.
274
uint64_t GetId() const;
279
SnapshotObjectId GetId() const;
276
281
/** Returns node's own size, in bytes. */
277
282
int GetSelfSize() const;
280
* Returns node's retained size, in bytes. That is, self + sizes of
281
* the objects that are reachable only from this object. In other
282
* words, the size of memory that will be reclaimed having this node
285
* Exact retained size calculation has O(N) (number of nodes)
286
* computational complexity, while approximate has O(1). It is
287
* assumed that initially heap profiling tools provide approximate
288
* sizes for all nodes, and then exact sizes are calculated for the
289
* most 'interesting' nodes.
291
int GetRetainedSize(bool exact) const;
293
284
/** Returns child nodes count of the node. */
294
285
int GetChildrenCount() const;
296
287
/** Retrieves a child by index. */
297
288
const HeapGraphEdge* GetChild(int index) const;
299
/** Returns retainer nodes count of the node. */
300
int GetRetainersCount() const;
302
/** Returns a retainer by index. */
303
const HeapGraphEdge* GetRetainer(int index) const;
306
* Returns a dominator node. This is the node that participates in every
307
* path from the snapshot root to the current node.
309
const HeapGraphNode* GetDominatorNode() const;
312
291
* Finds and returns a value from the heap corresponding to this node,
313
292
* if the value is still reachable.
341
320
const HeapGraphNode* GetRoot() const;
343
322
/** Returns a node by its id. */
344
const HeapGraphNode* GetNodeById(uint64_t id) const;
323
const HeapGraphNode* GetNodeById(SnapshotObjectId id) const;
346
325
/** Returns total nodes count in the snapshot. */
347
326
int GetNodesCount() const;
349
328
/** Returns a node by index. */
350
329
const HeapGraphNode* GetNode(int index) const;
331
/** Returns a max seen JS object Id. */
332
SnapshotObjectId GetMaxSnapshotJSObjectId() const;
353
335
* Deletes the snapshot and removes it from HeapProfiler's list.
354
336
* All pointers to nodes, edges and paths previously returned become
367
349
* with the following structure:
370
* snapshot: {title: "...", uid: nnn},
372
* meta-info (JSON string),
355
* meta: { meta-info },
359
* nodes: [nodes array],
360
* edges: [edges array],
361
* strings: [strings array]
378
* Outgoing node links are stored after each node. Nodes reference strings
379
* and other nodes by their indexes in corresponding arrays.
364
* Nodes reference strings, other nodes, and edges by their indexes
365
* in corresponding arrays.
381
367
void Serialize(OutputStream* stream, SerializationFormat format) const;
408
394
static const HeapSnapshot* FindSnapshot(unsigned uid);
397
* Returns SnapshotObjectId for a heap object referenced by |value| if
398
* it has been seen by the heap profiler, kUnknownObjectId otherwise.
400
static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
403
* A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return
404
* it in case heap profiler cannot find id for the object passed as
405
* parameter. HeapSnapshot::GetNodeById will always return NULL for such id.
407
static const SnapshotObjectId kUnknownObjectId = 0;
411
410
* Takes a heap snapshot and returns it. Title may be an empty string.
412
411
* See HeapSnapshot::Type for types description.
417
416
ActivityControl* control = NULL);
419
* Starts tracking of heap objects population statistics. After calling
420
* this method, all heap objects relocations done by the garbage collector
421
* are being registered.
423
static void StartHeapObjectsTracking();
426
* Adds a new time interval entry to the aggregated statistics array. The
427
* time interval entry contains information on the current heap objects
428
* population size. The method also updates aggregated statistics and
429
* reports updates for all previous time intervals via the OutputStream
430
* object. Updates on each time interval are provided as a stream of the
431
* HeapStatsUpdate structure instances.
432
* The return value of the function is the last seen heap object Id.
434
* StartHeapObjectsTracking must be called before the first call to this
437
static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
440
* Stops tracking of heap objects population statistics, cleans up all
441
* collected data. StartHeapObjectsTracking must be called again prior to
442
* calling PushHeapObjectsStats next time.
444
static void StopHeapObjectsTracking();
420
447
* Deletes all snapshots taken. All previously returned pointers to
421
448
* snapshots and their contents become invalid after this call.
435
462
static const uint16_t kPersistentHandleNoClassId = 0;
464
/** Returns the number of currently existing persistent handles. */
465
static int GetPersistentHandleCount();
467
/** Returns memory used for profiler internal data and snapshots. */
468
static size_t GetMemorySizeUsedByProfiler();
475
508
virtual intptr_t GetHash() = 0;
478
* Returns human-readable label. It must be a NUL-terminated UTF-8
511
* Returns human-readable label. It must be a null-terminated UTF-8
479
512
* encoded string. V8 copies its contents during a call to GetLabel.
481
514
virtual const char* GetLabel() = 0;
517
* Returns human-readable group label. It must be a null-terminated UTF-8
518
* encoded string. V8 copies its contents during a call to GetGroupLabel.
519
* Heap snapshot generator will collect all the group names, create
520
* top level entries with these names and attach the objects to the
521
* corresponding top level group objects. There is a default
522
* implementation which is required because embedders don't have their
523
* own implementation yet.
525
virtual const char* GetGroupLabel() { return GetLabel(); }
484
528
* Returns element count in case if a global handle retains
485
529
* a subgraph by holding one of its nodes.
547
* A struct for exporting HeapStats data from V8, using "push" model.
548
* See HeapProfiler::PushHeapObjectsStats.
550
struct HeapStatsUpdate {
551
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
552
: index(index), count(count), size(size) { }
553
uint32_t index; // Index of the time interval that was changed.
554
uint32_t count; // New value of count field for the interval with this index.
555
uint32_t size; // New value of size field for the interval with this index.
502
559
} // namespace v8