~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to deps/v8/include/v8-profiler.h

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
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)
 
56
#else
56
57
#define V8EXPORT
57
 
#endif  // defined(__GNUC__) && (__GNUC__ >= 4)
 
58
#endif
58
59
 
59
60
#endif  // _WIN32
60
61
 
64
65
 */
65
66
namespace v8 {
66
67
 
 
68
typedef uint32_t SnapshotObjectId;
67
69
 
68
70
/**
69
71
 * CpuProfileNode represents a node in a call graph.
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).
224
227
  };
225
228
 
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.
258
263
  };
259
264
 
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.
273
278
   */
274
 
  uint64_t GetId() const;
 
279
  SnapshotObjectId GetId() const;
275
280
 
276
281
  /** Returns node's own size, in bytes. */
277
282
  int GetSelfSize() const;
278
283
 
279
 
  /**
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
283
 
   * collected.
284
 
   *
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.
290
 
   */
291
 
  int GetRetainedSize(bool exact) const;
292
 
 
293
284
  /** Returns child nodes count of the node. */
294
285
  int GetChildrenCount() const;
295
286
 
296
287
  /** Retrieves a child by index. */
297
288
  const HeapGraphEdge* GetChild(int index) const;
298
289
 
299
 
  /** Returns retainer nodes count of the node. */
300
 
  int GetRetainersCount() const;
301
 
 
302
 
  /** Returns a retainer by index. */
303
 
  const HeapGraphEdge* GetRetainer(int index) const;
304
 
 
305
 
  /**
306
 
   * Returns a dominator node. This is the node that participates in every
307
 
   * path from the snapshot root to the current node.
308
 
   */
309
 
  const HeapGraphNode* GetDominatorNode() const;
310
 
 
311
290
  /**
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;
342
321
 
343
322
  /** Returns a node by its id. */
344
 
  const HeapGraphNode* GetNodeById(uint64_t id) const;
 
323
  const HeapGraphNode* GetNodeById(SnapshotObjectId id) const;
345
324
 
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;
351
330
 
 
331
  /** Returns a max seen JS object Id. */
 
332
  SnapshotObjectId GetMaxSnapshotJSObjectId() const;
 
333
 
352
334
  /**
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:
368
350
   *
369
351
   *  {
370
 
   *    snapshot: {title: "...", uid: nnn},
371
 
   *    nodes: [
372
 
   *      meta-info (JSON string),
373
 
   *      nodes themselves
374
 
   *    ],
375
 
   *    strings: [strings]
 
352
   *    snapshot: {
 
353
   *      title: "...",
 
354
   *      uid: nnn,
 
355
   *      meta: { meta-info },
 
356
   *      node_count: nnn,
 
357
   *      edge_count: nnn
 
358
   *    },
 
359
   *    nodes: [nodes array],
 
360
   *    edges: [edges array],
 
361
   *    strings: [strings array]
376
362
   *  }
377
363
   *
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.
380
366
   */
381
367
  void Serialize(OutputStream* stream, SerializationFormat format) const;
382
368
};
408
394
  static const HeapSnapshot* FindSnapshot(unsigned uid);
409
395
 
410
396
  /**
 
397
   * Returns SnapshotObjectId for a heap object referenced by |value| if
 
398
   * it has been seen by the heap profiler, kUnknownObjectId otherwise.
 
399
   */
 
400
  static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
 
401
 
 
402
  /**
 
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.
 
406
   */
 
407
  static const SnapshotObjectId kUnknownObjectId = 0;
 
408
 
 
409
  /**
411
410
   * Takes a heap snapshot and returns it. Title may be an empty string.
412
411
   * See HeapSnapshot::Type for types description.
413
412
   */
417
416
      ActivityControl* control = NULL);
418
417
 
419
418
  /**
 
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.
 
422
   */
 
423
  static void StartHeapObjectsTracking();
 
424
 
 
425
  /**
 
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.
 
433
   *
 
434
   * StartHeapObjectsTracking must be called before the first call to this
 
435
   * method.
 
436
   */
 
437
  static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
 
438
 
 
439
  /**
 
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.
 
443
   */
 
444
  static void StopHeapObjectsTracking();
 
445
 
 
446
  /**
420
447
   * Deletes all snapshots taken. All previously returned pointers to
421
448
   * snapshots and their contents become invalid after this call.
422
449
   */
433
460
   * handle.
434
461
   */
435
462
  static const uint16_t kPersistentHandleNoClassId = 0;
 
463
 
 
464
  /** Returns the number of currently existing persistent handles. */
 
465
  static int GetPersistentHandleCount();
 
466
 
 
467
  /** Returns memory used for profiler internal data and snapshots. */
 
468
  static size_t GetMemorySizeUsedByProfiler();
436
469
};
437
470
 
438
471
 
475
508
  virtual intptr_t GetHash() = 0;
476
509
 
477
510
  /**
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.
480
513
   */
481
514
  virtual const char* GetLabel() = 0;
482
515
 
483
516
  /**
 
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.
 
524
   */
 
525
  virtual const char* GetGroupLabel() { return GetLabel(); }
 
526
 
 
527
  /**
484
528
   * Returns element count in case if a global handle retains
485
529
   * a subgraph by holding one of its nodes.
486
530
   */
499
543
};
500
544
 
501
545
 
 
546
/**
 
547
 * A struct for exporting HeapStats data from V8, using "push" model.
 
548
 * See HeapProfiler::PushHeapObjectsStats.
 
549
 */
 
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.
 
556
};
 
557
 
 
558
 
502
559
}  // namespace v8
503
560
 
504
561