~ubuntu-branches/ubuntu/precise/nodejs/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jérémy Lal
  • Date: 2010-08-20 11:49:04 UTC
  • mfrom: (7.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100820114904-lz22w6fkth7yh179
Tags: 0.2.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
};
185
185
 
186
186
 
 
187
class HeapGraphNode;
 
188
 
 
189
 
 
190
/**
 
191
 * HeapSnapshotEdge represents a directed connection between heap
 
192
 * graph nodes: from retaners to retained nodes.
 
193
 */
 
194
class V8EXPORT HeapGraphEdge {
 
195
 public:
 
196
  enum Type {
 
197
    kContextVariable = 0,  // A variable from a function context.
 
198
    kElement = 1,          // An element of an array.
 
199
    kProperty = 2,         // A named object property.
 
200
    kInternal = 3          // A link that can't be accessed from JS,
 
201
                           // thus, its name isn't a real property name.
 
202
  };
 
203
 
 
204
  /** Returns edge type (see HeapGraphEdge::Type). */
 
205
  Type GetType() const;
 
206
 
 
207
  /**
 
208
   * Returns edge name. This can be a variable name, an element index, or
 
209
   * a property name.
 
210
   */
 
211
  Handle<Value> GetName() const;
 
212
 
 
213
  /** Returns origin node. */
 
214
  const HeapGraphNode* GetFromNode() const;
 
215
 
 
216
  /** Returns destination node. */
 
217
  const HeapGraphNode* GetToNode() const;
 
218
};
 
219
 
 
220
 
 
221
class V8EXPORT HeapGraphPath {
 
222
 public:
 
223
  /** Returns the number of edges in the path. */
 
224
  int GetEdgesCount() const;
 
225
 
 
226
  /** Returns an edge from the path. */
 
227
  const HeapGraphEdge* GetEdge(int index) const;
 
228
 
 
229
  /** Returns origin node. */
 
230
  const HeapGraphNode* GetFromNode() const;
 
231
 
 
232
  /** Returns destination node. */
 
233
  const HeapGraphNode* GetToNode() const;
 
234
};
 
235
 
 
236
 
 
237
/**
 
238
 * HeapGraphNode represents a node in a heap graph.
 
239
 */
 
240
class V8EXPORT HeapGraphNode {
 
241
 public:
 
242
  enum Type {
 
243
    kInternal = 0,   // Internal node, a virtual one, for housekeeping.
 
244
    kArray = 1,      // An array of elements.
 
245
    kString = 2,     // A string.
 
246
    kObject = 3,     // A JS object (except for arrays and strings).
 
247
    kCode = 4,       // Compiled code.
 
248
    kClosure = 5     // Function closure.
 
249
  };
 
250
 
 
251
  /** Returns node type (see HeapGraphNode::Type). */
 
252
  Type GetType() const;
 
253
 
 
254
  /**
 
255
   * Returns node name. Depending on node's type this can be the name
 
256
   * of the constructor (for objects), the name of the function (for
 
257
   * closures), string value, or an empty string (for compiled code).
 
258
   */
 
259
  Handle<String> GetName() const;
 
260
 
 
261
  /**
 
262
   * Returns node id. For the same heap object, the id remains the same
 
263
   * across all snapshots.
 
264
   */
 
265
  uint64_t GetId() const;
 
266
 
 
267
  /** Returns node's own size, in bytes. */
 
268
  int GetSelfSize() const;
 
269
 
 
270
  /** Returns node's network (self + reachable nodes) size, in bytes. */
 
271
  int GetReachableSize() const;
 
272
 
 
273
  /**
 
274
   * Returns node's retained size, in bytes. That is, self + sizes of
 
275
   * the objects that are reachable only from this object. In other
 
276
   * words, the size of memory that will be reclaimed having this node
 
277
   * collected.
 
278
   */
 
279
  int GetRetainedSize() const;
 
280
 
 
281
  /** Returns child nodes count of the node. */
 
282
  int GetChildrenCount() const;
 
283
 
 
284
  /** Retrieves a child by index. */
 
285
  const HeapGraphEdge* GetChild(int index) const;
 
286
 
 
287
  /** Returns retainer nodes count of the node. */
 
288
  int GetRetainersCount() const;
 
289
 
 
290
  /** Returns a retainer by index. */
 
291
  const HeapGraphEdge* GetRetainer(int index) const;
 
292
 
 
293
  /** Returns the number of simple retaining paths from the root to the node. */
 
294
  int GetRetainingPathsCount() const;
 
295
 
 
296
  /** Returns a retaining path by index. */
 
297
  const HeapGraphPath* GetRetainingPath(int index) const;
 
298
};
 
299
 
 
300
 
 
301
class V8EXPORT HeapSnapshotsDiff {
 
302
 public:
 
303
  /** Returns the root node for added nodes. */
 
304
  const HeapGraphNode* GetAdditionsRoot() const;
 
305
 
 
306
  /** Returns the root node for deleted nodes. */
 
307
  const HeapGraphNode* GetDeletionsRoot() const;
 
308
};
 
309
 
 
310
 
 
311
/**
 
312
 * HeapSnapshots record the state of the JS heap at some moment.
 
313
 */
 
314
class V8EXPORT HeapSnapshot {
 
315
 public:
 
316
  /** Returns heap snapshot UID (assigned by the profiler.) */
 
317
  unsigned GetUid() const;
 
318
 
 
319
  /** Returns heap snapshot title. */
 
320
  Handle<String> GetTitle() const;
 
321
 
 
322
  /** Returns the root node of the heap graph. */
 
323
  const HeapGraphNode* GetRoot() const;
 
324
 
 
325
  /** Returns a diff between this snapshot and another one. */
 
326
  const HeapSnapshotsDiff* CompareWith(const HeapSnapshot* snapshot) const;
 
327
};
 
328
 
 
329
 
 
330
/**
 
331
 * Interface for controlling heap profiling.
 
332
 */
 
333
class V8EXPORT HeapProfiler {
 
334
 public:
 
335
  /** Returns the number of snapshots taken. */
 
336
  static int GetSnapshotsCount();
 
337
 
 
338
  /** Returns a snapshot by index. */
 
339
  static const HeapSnapshot* GetSnapshot(int index);
 
340
 
 
341
  /** Returns a profile by uid. */
 
342
  static const HeapSnapshot* FindSnapshot(unsigned uid);
 
343
 
 
344
  /** Takes a heap snapshot and returns it. Title may be an empty string. */
 
345
  static const HeapSnapshot* TakeSnapshot(Handle<String> title);
 
346
};
 
347
 
 
348
 
187
349
}  // namespace v8
188
350
 
189
351