OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 * Prepare a serialized representation of the snapshot. The result | 361 * Prepare a serialized representation of the snapshot. The result |
362 * is written into the stream provided in chunks of specified size. | 362 * is written into the stream provided in chunks of specified size. |
363 * The total length of the serialized snapshot is unknown in | 363 * The total length of the serialized snapshot is unknown in |
364 * advance, it can be roughly equal to JS heap size (that means, | 364 * advance, it can be roughly equal to JS heap size (that means, |
365 * it can be really big - tens of megabytes). | 365 * it can be really big - tens of megabytes). |
366 * | 366 * |
367 * For the JSON format, heap contents are represented as an object | 367 * For the JSON format, heap contents are represented as an object |
368 * with the following structure: | 368 * with the following structure: |
369 * | 369 * |
370 * { | 370 * { |
371 * snapshot: {title: "...", uid: nnn}, | 371 * snapshot: { |
372 * nodes: [ | 372 * title: "...", |
373 * meta-info (JSON string), | 373 * uid: nnn, |
374 * nodes themselves | 374 * meta: { meta-info }, |
375 * ], | 375 * node_count: nnn, |
376 * strings: [strings] | 376 * edge_count: nnn |
| 377 * }, |
| 378 * nodes: [nodes array], |
| 379 * edges: [edges array], |
| 380 * strings: [strings array] |
377 * } | 381 * } |
378 * | 382 * |
379 * Outgoing node links are stored after each node. Nodes reference strings | 383 * Nodes reference strings, other nodes, and edges by their indexes |
380 * and other nodes by their indexes in corresponding arrays. | 384 * in corresponding arrays. |
381 */ | 385 */ |
382 void Serialize(OutputStream* stream, SerializationFormat format) const; | 386 void Serialize(OutputStream* stream, SerializationFormat format) const; |
383 }; | 387 }; |
384 | 388 |
385 | 389 |
386 class RetainedObjectInfo; | 390 class RetainedObjectInfo; |
387 | 391 |
388 /** | 392 /** |
389 * Interface for controlling heap profiling. | 393 * Interface for controlling heap profiling. |
390 */ | 394 */ |
(...skipping 11 matching lines...) Expand all Loading... |
402 /** Returns the number of snapshots taken. */ | 406 /** Returns the number of snapshots taken. */ |
403 static int GetSnapshotsCount(); | 407 static int GetSnapshotsCount(); |
404 | 408 |
405 /** Returns a snapshot by index. */ | 409 /** Returns a snapshot by index. */ |
406 static const HeapSnapshot* GetSnapshot(int index); | 410 static const HeapSnapshot* GetSnapshot(int index); |
407 | 411 |
408 /** Returns a profile by uid. */ | 412 /** Returns a profile by uid. */ |
409 static const HeapSnapshot* FindSnapshot(unsigned uid); | 413 static const HeapSnapshot* FindSnapshot(unsigned uid); |
410 | 414 |
411 /** | 415 /** |
| 416 * Returns SnapshotObjectId for a heap object referenced by |value| if |
| 417 * it has been seen by the heap profiler, kUnknownObjectId otherwise. |
| 418 */ |
| 419 static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value); |
| 420 |
| 421 /** |
| 422 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return |
| 423 * it in case heap profiler cannot find id for the object passed as |
| 424 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. |
| 425 */ |
| 426 static const SnapshotObjectId kUnknownObjectId = 0; |
| 427 |
| 428 /** |
412 * Takes a heap snapshot and returns it. Title may be an empty string. | 429 * Takes a heap snapshot and returns it. Title may be an empty string. |
413 * See HeapSnapshot::Type for types description. | 430 * See HeapSnapshot::Type for types description. |
414 */ | 431 */ |
415 static const HeapSnapshot* TakeSnapshot( | 432 static const HeapSnapshot* TakeSnapshot( |
416 Handle<String> title, | 433 Handle<String> title, |
417 HeapSnapshot::Type type = HeapSnapshot::kFull, | 434 HeapSnapshot::Type type = HeapSnapshot::kFull, |
418 ActivityControl* control = NULL); | 435 ActivityControl* control = NULL); |
419 | 436 |
420 /** | 437 /** |
421 * Starts tracking of heap objects population statistics. After calling | 438 * Starts tracking of heap objects population statistics. After calling |
422 * this method, all heap objects relocations done by the garbage collector | 439 * this method, all heap objects relocations done by the garbage collector |
423 * are being registered. | 440 * are being registered. |
424 */ | 441 */ |
425 static void StartHeapObjectsTracking(); | 442 static void StartHeapObjectsTracking(); |
426 | 443 |
427 /** | 444 /** |
428 * Adds a new time interval entry to the aggregated statistics array. The | 445 * Adds a new time interval entry to the aggregated statistics array. The |
429 * time interval entry contains information on the current heap objects | 446 * time interval entry contains information on the current heap objects |
430 * population size. The method also updates aggregated statistics and | 447 * population size. The method also updates aggregated statistics and |
431 * reports updates for all previous time intervals via the OutputStream | 448 * reports updates for all previous time intervals via the OutputStream |
432 * object. Updates on each time interval are provided as pairs of time | 449 * object. Updates on each time interval are provided as a triplet. It has |
433 * interval index and updated heap objects count. | 450 * time interval index, updated heap objects count and updated heap objects |
| 451 * size. |
434 * | 452 * |
435 * StartHeapObjectsTracking must be called before the first call to this | 453 * StartHeapObjectsTracking must be called before the first call to this |
436 * method. | 454 * method. |
437 */ | 455 */ |
438 static void PushHeapObjectsStats(OutputStream* stream); | 456 static void PushHeapObjectsStats(OutputStream* stream); |
439 | 457 |
440 /** | 458 /** |
441 * Stops tracking of heap objects population statistics, cleans up all | 459 * Stops tracking of heap objects population statistics, cleans up all |
442 * collected data. StartHeapObjectsTracking must be called again prior to | 460 * collected data. StartHeapObjectsTracking must be called again prior to |
443 * calling PushHeapObjectsStats next time. | 461 * calling PushHeapObjectsStats next time. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 }; | 559 }; |
542 | 560 |
543 | 561 |
544 } // namespace v8 | 562 } // namespace v8 |
545 | 563 |
546 | 564 |
547 #undef V8EXPORT | 565 #undef V8EXPORT |
548 | 566 |
549 | 567 |
550 #endif // V8_V8_PROFILER_H_ | 568 #endif // V8_V8_PROFILER_H_ |
OLD | NEW |