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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 * Nodes reference strings, other nodes, and edges by their indexes | 378 * Nodes reference strings, other nodes, and edges by their indexes |
379 * in corresponding arrays. | 379 * in corresponding arrays. |
380 */ | 380 */ |
381 void Serialize(OutputStream* stream, SerializationFormat format) const; | 381 void Serialize(OutputStream* stream, SerializationFormat format) const; |
382 }; | 382 }; |
383 | 383 |
384 | 384 |
385 class RetainedObjectInfo; | 385 class RetainedObjectInfo; |
386 | 386 |
387 /** | 387 /** |
388 * Interface for controlling heap profiling. | 388 * Interface for controlling heap profiling. Instance of the |
| 389 * profiler can be retrieved using v8::Isolate::GetHeapProfiler. |
389 */ | 390 */ |
390 class V8EXPORT HeapProfiler { | 391 class V8EXPORT HeapProfiler { |
391 public: | 392 public: |
392 /** | 393 /** |
393 * Callback function invoked for obtaining RetainedObjectInfo for | 394 * Callback function invoked for obtaining RetainedObjectInfo for |
394 * the given JavaScript wrapper object. It is prohibited to enter V8 | 395 * the given JavaScript wrapper object. It is prohibited to enter V8 |
395 * while the callback is running: only getters on the handle and | 396 * while the callback is running: only getters on the handle and |
396 * GetPointerFromInternalField on the objects are allowed. | 397 * GetPointerFromInternalField on the objects are allowed. |
397 */ | 398 */ |
398 typedef RetainedObjectInfo* (*WrapperInfoCallback) | 399 typedef RetainedObjectInfo* (*WrapperInfoCallback) |
399 (uint16_t class_id, Handle<Value> wrapper); | 400 (uint16_t class_id, Handle<Value> wrapper); |
400 | 401 |
| 402 /** Deprecated. Use GetSnapshotCount instead. */ |
| 403 static int GetSnapshotsCount(); |
401 /** Returns the number of snapshots taken. */ | 404 /** Returns the number of snapshots taken. */ |
402 static int GetSnapshotsCount(); | 405 int GetSnapshotCount(); |
403 | 406 |
| 407 /** Deprecated. Use GetHeapSnapshot instead. */ |
| 408 static const HeapSnapshot* GetSnapshot(int index); |
404 /** Returns a snapshot by index. */ | 409 /** Returns a snapshot by index. */ |
405 static const HeapSnapshot* GetSnapshot(int index); | 410 const HeapSnapshot* GetHeapSnapshot(int index); |
406 | 411 |
| 412 /** Deprecated. Use FindHeapSnapshot instead. */ |
| 413 static const HeapSnapshot* FindSnapshot(unsigned uid); |
407 /** Returns a profile by uid. */ | 414 /** Returns a profile by uid. */ |
408 static const HeapSnapshot* FindSnapshot(unsigned uid); | 415 const HeapSnapshot* FindHeapSnapshot(unsigned uid); |
409 | 416 |
| 417 /** Deprecated. Use GetObjectId instead. */ |
| 418 static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value); |
410 /** | 419 /** |
411 * Returns SnapshotObjectId for a heap object referenced by |value| if | 420 * Returns SnapshotObjectId for a heap object referenced by |value| if |
412 * it has been seen by the heap profiler, kUnknownObjectId otherwise. | 421 * it has been seen by the heap profiler, kUnknownObjectId otherwise. |
413 */ | 422 */ |
414 static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value); | 423 SnapshotObjectId GetObjectId(Handle<Value> value); |
415 | 424 |
416 /** | 425 /** |
417 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return | 426 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return |
418 * it in case heap profiler cannot find id for the object passed as | 427 * it in case heap profiler cannot find id for the object passed as |
419 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. | 428 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. |
420 */ | 429 */ |
421 static const SnapshotObjectId kUnknownObjectId = 0; | 430 static const SnapshotObjectId kUnknownObjectId = 0; |
422 | 431 |
423 /** | 432 /** |
424 * Callback interface for retrieving user friendly names of global objects. | 433 * Callback interface for retrieving user friendly names of global objects. |
425 */ | 434 */ |
426 class ObjectNameResolver { | 435 class ObjectNameResolver { |
427 public: | 436 public: |
428 /** | 437 /** |
429 * Returns name to be used in the heap snapshot for given node. Returned | 438 * Returns name to be used in the heap snapshot for given node. Returned |
430 * string must stay alive until snapshot collection is completed. | 439 * string must stay alive until snapshot collection is completed. |
431 */ | 440 */ |
432 virtual const char* GetName(Handle<Object> object) = 0; | 441 virtual const char* GetName(Handle<Object> object) = 0; |
433 protected: | 442 protected: |
434 virtual ~ObjectNameResolver() {} | 443 virtual ~ObjectNameResolver() {} |
435 }; | 444 }; |
436 | 445 |
437 /** | 446 /** Deprecated. Use TakeHeapSnapshot instead. */ |
438 * Takes a heap snapshot and returns it. Title may be an empty string. | |
439 * See HeapSnapshot::Type for types description. | |
440 */ | |
441 static const HeapSnapshot* TakeSnapshot( | 447 static const HeapSnapshot* TakeSnapshot( |
442 Handle<String> title, | 448 Handle<String> title, |
443 HeapSnapshot::Type type = HeapSnapshot::kFull, | 449 HeapSnapshot::Type type = HeapSnapshot::kFull, |
444 ActivityControl* control = NULL, | 450 ActivityControl* control = NULL, |
445 ObjectNameResolver* global_object_name_resolver = NULL); | 451 ObjectNameResolver* global_object_name_resolver = NULL); |
| 452 /** |
| 453 * Takes a heap snapshot and returns it. Title may be an empty string. |
| 454 * See HeapSnapshot::Type for types description. |
| 455 */ |
| 456 const HeapSnapshot* TakeHeapSnapshot( |
| 457 Handle<String> title, |
| 458 ActivityControl* control = NULL, |
| 459 ObjectNameResolver* global_object_name_resolver = NULL); |
446 | 460 |
| 461 |
| 462 /** Deprecated. Use StartTrackingHeapObjects instead. */ |
| 463 static void StartHeapObjectsTracking(); |
447 /** | 464 /** |
448 * Starts tracking of heap objects population statistics. After calling | 465 * Starts tracking of heap objects population statistics. After calling |
449 * this method, all heap objects relocations done by the garbage collector | 466 * this method, all heap objects relocations done by the garbage collector |
450 * are being registered. | 467 * are being registered. |
451 */ | 468 */ |
452 static void StartHeapObjectsTracking(); | 469 void StartTrackingHeapObjects(); |
453 | 470 |
| 471 /** Deprecated. Use GetHeapStats instead. */ |
| 472 static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); |
454 /** | 473 /** |
455 * Adds a new time interval entry to the aggregated statistics array. The | 474 * Adds a new time interval entry to the aggregated statistics array. The |
456 * time interval entry contains information on the current heap objects | 475 * time interval entry contains information on the current heap objects |
457 * population size. The method also updates aggregated statistics and | 476 * population size. The method also updates aggregated statistics and |
458 * reports updates for all previous time intervals via the OutputStream | 477 * reports updates for all previous time intervals via the OutputStream |
459 * object. Updates on each time interval are provided as a stream of the | 478 * object. Updates on each time interval are provided as a stream of the |
460 * HeapStatsUpdate structure instances. | 479 * HeapStatsUpdate structure instances. |
461 * The return value of the function is the last seen heap object Id. | 480 * The return value of the function is the last seen heap object Id. |
462 * | 481 * |
463 * StartHeapObjectsTracking must be called before the first call to this | 482 * StartTrackingHeapObjects must be called before the first call to this |
464 * method. | 483 * method. |
465 */ | 484 */ |
466 static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); | 485 SnapshotObjectId GetHeapStats(OutputStream* stream); |
467 | 486 |
| 487 /** Deprecated. Use StopTrackingHeapObjects instead. */ |
| 488 static void StopHeapObjectsTracking(); |
468 /** | 489 /** |
469 * Stops tracking of heap objects population statistics, cleans up all | 490 * Stops tracking of heap objects population statistics, cleans up all |
470 * collected data. StartHeapObjectsTracking must be called again prior to | 491 * collected data. StartHeapObjectsTracking must be called again prior to |
471 * calling PushHeapObjectsStats next time. | 492 * calling PushHeapObjectsStats next time. |
472 */ | 493 */ |
473 static void StopHeapObjectsTracking(); | 494 void StopTrackingHeapObjects(); |
474 | 495 |
| 496 /** Deprecated. Use DeleteAllHeapSnapshots instead. */ |
| 497 static void DeleteAllSnapshots(); |
475 /** | 498 /** |
476 * Deletes all snapshots taken. All previously returned pointers to | 499 * Deletes all snapshots taken. All previously returned pointers to |
477 * snapshots and their contents become invalid after this call. | 500 * snapshots and their contents become invalid after this call. |
478 */ | 501 */ |
479 static void DeleteAllSnapshots(); | 502 void DeleteAllHeapSnapshots(); |
480 | 503 |
| 504 /** Deprecated. Use SetWrapperClassInfoProvider instead. */ |
| 505 static void DefineWrapperClass( |
| 506 uint16_t class_id, |
| 507 WrapperInfoCallback callback); |
481 /** Binds a callback to embedder's class ID. */ | 508 /** Binds a callback to embedder's class ID. */ |
482 static void DefineWrapperClass( | 509 void SetWrapperClassInfoProvider( |
483 uint16_t class_id, | 510 uint16_t class_id, |
484 WrapperInfoCallback callback); | 511 WrapperInfoCallback callback); |
485 | 512 |
486 /** | 513 /** |
487 * Default value of persistent handle class ID. Must not be used to | 514 * Default value of persistent handle class ID. Must not be used to |
488 * define a class. Can be used to reset a class of a persistent | 515 * define a class. Can be used to reset a class of a persistent |
489 * handle. | 516 * handle. |
490 */ | 517 */ |
491 static const uint16_t kPersistentHandleNoClassId = 0; | 518 static const uint16_t kPersistentHandleNoClassId = 0; |
492 | 519 |
493 /** Returns the number of currently existing persistent handles. */ | 520 /** |
| 521 * Deprecated. Returns the number of currently existing persistent handles. |
| 522 */ |
494 static int GetPersistentHandleCount(); | 523 static int GetPersistentHandleCount(); |
495 | 524 |
| 525 /** Deprecated. Use GetHeapProfilerMemorySize instead. */ |
| 526 static size_t GetMemorySizeUsedByProfiler(); |
496 /** Returns memory used for profiler internal data and snapshots. */ | 527 /** Returns memory used for profiler internal data and snapshots. */ |
497 static size_t GetMemorySizeUsedByProfiler(); | 528 size_t GetProfilerMemorySize(); |
| 529 |
| 530 private: |
| 531 HeapProfiler(); |
| 532 ~HeapProfiler(); |
| 533 HeapProfiler(const HeapProfiler&); |
| 534 HeapProfiler& operator=(const HeapProfiler&); |
498 }; | 535 }; |
499 | 536 |
500 | 537 |
501 /** | 538 /** |
502 * Interface for providing information about embedder's objects | 539 * Interface for providing information about embedder's objects |
503 * held by global handles. This information is reported in two ways: | 540 * held by global handles. This information is reported in two ways: |
504 * | 541 * |
505 * 1. When calling AddObjectGroup, an embedder may pass | 542 * 1. When calling AddObjectGroup, an embedder may pass |
506 * RetainedObjectInfo instance describing the group. To collect | 543 * RetainedObjectInfo instance describing the group. To collect |
507 * this information while taking a heap snapshot, V8 calls GC | 544 * this information while taking a heap snapshot, V8 calls GC |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 virtual ~RetainedObjectInfo() {} | 604 virtual ~RetainedObjectInfo() {} |
568 | 605 |
569 private: | 606 private: |
570 RetainedObjectInfo(const RetainedObjectInfo&); | 607 RetainedObjectInfo(const RetainedObjectInfo&); |
571 RetainedObjectInfo& operator=(const RetainedObjectInfo&); | 608 RetainedObjectInfo& operator=(const RetainedObjectInfo&); |
572 }; | 609 }; |
573 | 610 |
574 | 611 |
575 /** | 612 /** |
576 * A struct for exporting HeapStats data from V8, using "push" model. | 613 * A struct for exporting HeapStats data from V8, using "push" model. |
577 * See HeapProfiler::PushHeapObjectsStats. | 614 * See HeapProfiler::GetHeapStats. |
578 */ | 615 */ |
579 struct HeapStatsUpdate { | 616 struct HeapStatsUpdate { |
580 HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size) | 617 HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size) |
581 : index(index), count(count), size(size) { } | 618 : index(index), count(count), size(size) { } |
582 uint32_t index; // Index of the time interval that was changed. | 619 uint32_t index; // Index of the time interval that was changed. |
583 uint32_t count; // New value of count field for the interval with this index. | 620 uint32_t count; // New value of count field for the interval with this index. |
584 uint32_t size; // New value of size field for the interval with this index. | 621 uint32_t size; // New value of size field for the interval with this index. |
585 }; | 622 }; |
586 | 623 |
587 | 624 |
588 } // namespace v8 | 625 } // namespace v8 |
589 | 626 |
590 | 627 |
591 #undef V8EXPORT | 628 #undef V8EXPORT |
592 | 629 |
593 | 630 |
594 #endif // V8_V8_PROFILER_H_ | 631 #endif // V8_V8_PROFILER_H_ |
OLD | NEW |