| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 public: | 165 public: |
| 166 /** | 166 /** |
| 167 * A note on security tokens usage. As scripts from different | 167 * A note on security tokens usage. As scripts from different |
| 168 * origins can run inside a single V8 instance, it is possible to | 168 * origins can run inside a single V8 instance, it is possible to |
| 169 * have functions from different security contexts intermixed in a | 169 * have functions from different security contexts intermixed in a |
| 170 * single CPU profile. To avoid exposing function names belonging to | 170 * single CPU profile. To avoid exposing function names belonging to |
| 171 * other contexts, filtering by security token is performed while | 171 * other contexts, filtering by security token is performed while |
| 172 * obtaining profiling results. | 172 * obtaining profiling results. |
| 173 */ | 173 */ |
| 174 | 174 |
| 175 /** Deprecated. Use GetProfileCount instead. */ | |
| 176 V8_DEPRECATED(static int GetProfilesCount()); | |
| 177 /** | 175 /** |
| 178 * Returns the number of profiles collected (doesn't include | 176 * Returns the number of profiles collected (doesn't include |
| 179 * profiles that are being collected at the moment of call.) | 177 * profiles that are being collected at the moment of call.) |
| 180 */ | 178 */ |
| 181 int GetProfileCount(); | 179 int GetProfileCount(); |
| 182 | 180 |
| 183 /** Deprecated. Use GetCpuProfile instead. */ | |
| 184 V8_DEPRECATED(static const CpuProfile* GetProfile( | |
| 185 int index, | |
| 186 Handle<Value> security_token = Handle<Value>())); | |
| 187 /** Deprecated. Use GetCpuProfile with single parameter. */ | 181 /** Deprecated. Use GetCpuProfile with single parameter. */ |
| 188 V8_DEPRECATED(const CpuProfile* GetCpuProfile( | 182 V8_DEPRECATED(const CpuProfile* GetCpuProfile( |
| 189 int index, | 183 int index, |
| 190 Handle<Value> security_token)); | 184 Handle<Value> security_token)); |
| 191 /** Returns a profile by index. */ | 185 /** Returns a profile by index. */ |
| 192 const CpuProfile* GetCpuProfile(int index); | 186 const CpuProfile* GetCpuProfile(int index); |
| 193 | 187 |
| 194 /** Deprecated. Use FindProfile instead. */ | |
| 195 V8_DEPRECATED(static const CpuProfile* FindProfile( | |
| 196 unsigned uid, | |
| 197 Handle<Value> security_token = Handle<Value>())); | |
| 198 /** Returns a profile by uid. */ | 188 /** Returns a profile by uid. */ |
| 199 V8_DEPRECATED(const CpuProfile* FindCpuProfile( | 189 V8_DEPRECATED(const CpuProfile* FindCpuProfile( |
| 200 unsigned uid, | 190 unsigned uid, |
| 201 Handle<Value> security_token = Handle<Value>())); | 191 Handle<Value> security_token = Handle<Value>())); |
| 202 | 192 |
| 203 /** Deprecated. Use StartCpuProfiling instead. */ | |
| 204 V8_DEPRECATED(static void StartProfiling(Handle<String> title, | |
| 205 bool record_samples = false)); | |
| 206 /** | 193 /** |
| 207 * Starts collecting CPU profile. Title may be an empty string. It | 194 * Starts collecting CPU profile. Title may be an empty string. It |
| 208 * is allowed to have several profiles being collected at | 195 * is allowed to have several profiles being collected at |
| 209 * once. Attempts to start collecting several profiles with the same | 196 * once. Attempts to start collecting several profiles with the same |
| 210 * title are silently ignored. While collecting a profile, functions | 197 * title are silently ignored. While collecting a profile, functions |
| 211 * from all security contexts are included in it. The token-based | 198 * from all security contexts are included in it. The token-based |
| 212 * filtering is only performed when querying for a profile. | 199 * filtering is only performed when querying for a profile. |
| 213 * | 200 * |
| 214 * |record_samples| parameter controls whether individual samples should | 201 * |record_samples| parameter controls whether individual samples should |
| 215 * be recorded in addition to the aggregated tree. | 202 * be recorded in addition to the aggregated tree. |
| 216 */ | 203 */ |
| 217 void StartCpuProfiling(Handle<String> title, bool record_samples = false); | 204 void StartCpuProfiling(Handle<String> title, bool record_samples = false); |
| 218 | 205 |
| 219 /** Deprecated. Use StopCpuProfiling instead. */ | |
| 220 V8_DEPRECATED(static const CpuProfile* StopProfiling( | |
| 221 Handle<String> title, | |
| 222 Handle<Value> security_token = Handle<Value>())); | |
| 223 /** | 206 /** |
| 224 * Deprecated. Use StopCpuProfiling with one parameter instead. | 207 * Deprecated. Use StopCpuProfiling with one parameter instead. |
| 225 */ | 208 */ |
| 226 V8_DEPRECATED(const CpuProfile* StopCpuProfiling( | 209 V8_DEPRECATED(const CpuProfile* StopCpuProfiling( |
| 227 Handle<String> title, | 210 Handle<String> title, |
| 228 Handle<Value> security_token)); | 211 Handle<Value> security_token)); |
| 229 /** | 212 /** |
| 230 * Stops collecting CPU profile with a given title and returns it. | 213 * Stops collecting CPU profile with a given title and returns it. |
| 231 * If the title given is empty, finishes the last profile started. | 214 * If the title given is empty, finishes the last profile started. |
| 232 */ | 215 */ |
| 233 const CpuProfile* StopCpuProfiling(Handle<String> title); | 216 const CpuProfile* StopCpuProfiling(Handle<String> title); |
| 234 | 217 |
| 235 /** Deprecated. Use DeleteAllCpuProfiles instead. */ | |
| 236 V8_DEPRECATED(static void DeleteAllProfiles()); | |
| 237 /** | 218 /** |
| 238 * Deletes all existing profiles, also cancelling all profiling | 219 * Deletes all existing profiles, also cancelling all profiling |
| 239 * activity. All previously returned pointers to profiles and their | 220 * activity. All previously returned pointers to profiles and their |
| 240 * contents become invalid after this call. | 221 * contents become invalid after this call. |
| 241 */ | 222 */ |
| 242 void DeleteAllCpuProfiles(); | 223 void DeleteAllCpuProfiles(); |
| 243 | 224 |
| 244 private: | 225 private: |
| 245 CpuProfiler(); | 226 CpuProfiler(); |
| 246 ~CpuProfiler(); | 227 ~CpuProfiler(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 */ | 320 */ |
| 340 Handle<Value> GetHeapValue() const; | 321 Handle<Value> GetHeapValue() const; |
| 341 }; | 322 }; |
| 342 | 323 |
| 343 | 324 |
| 344 /** | 325 /** |
| 345 * HeapSnapshots record the state of the JS heap at some moment. | 326 * HeapSnapshots record the state of the JS heap at some moment. |
| 346 */ | 327 */ |
| 347 class V8EXPORT HeapSnapshot { | 328 class V8EXPORT HeapSnapshot { |
| 348 public: | 329 public: |
| 349 enum Type { | |
| 350 kFull = 0 // Heap snapshot with all instances and references. | |
| 351 }; | |
| 352 enum SerializationFormat { | 330 enum SerializationFormat { |
| 353 kJSON = 0 // See format description near 'Serialize' method. | 331 kJSON = 0 // See format description near 'Serialize' method. |
| 354 }; | 332 }; |
| 355 | 333 |
| 356 /** Deprecated. Returns kFull. */ | |
| 357 V8_DEPRECATED(Type GetType() const); | |
| 358 | |
| 359 /** Returns heap snapshot UID (assigned by the profiler.) */ | 334 /** Returns heap snapshot UID (assigned by the profiler.) */ |
| 360 unsigned GetUid() const; | 335 unsigned GetUid() const; |
| 361 | 336 |
| 362 /** Returns heap snapshot title. */ | 337 /** Returns heap snapshot title. */ |
| 363 Handle<String> GetTitle() const; | 338 Handle<String> GetTitle() const; |
| 364 | 339 |
| 365 /** Returns the root node of the heap graph. */ | 340 /** Returns the root node of the heap graph. */ |
| 366 const HeapGraphNode* GetRoot() const; | 341 const HeapGraphNode* GetRoot() const; |
| 367 | 342 |
| 368 /** Returns a node by its id. */ | 343 /** Returns a node by its id. */ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 public: | 399 public: |
| 425 /** | 400 /** |
| 426 * Callback function invoked for obtaining RetainedObjectInfo for | 401 * Callback function invoked for obtaining RetainedObjectInfo for |
| 427 * the given JavaScript wrapper object. It is prohibited to enter V8 | 402 * the given JavaScript wrapper object. It is prohibited to enter V8 |
| 428 * while the callback is running: only getters on the handle and | 403 * while the callback is running: only getters on the handle and |
| 429 * GetPointerFromInternalField on the objects are allowed. | 404 * GetPointerFromInternalField on the objects are allowed. |
| 430 */ | 405 */ |
| 431 typedef RetainedObjectInfo* (*WrapperInfoCallback) | 406 typedef RetainedObjectInfo* (*WrapperInfoCallback) |
| 432 (uint16_t class_id, Handle<Value> wrapper); | 407 (uint16_t class_id, Handle<Value> wrapper); |
| 433 | 408 |
| 434 /** Deprecated. Use GetSnapshotCount instead. */ | |
| 435 V8_DEPRECATED(static int GetSnapshotsCount()); | |
| 436 /** Returns the number of snapshots taken. */ | 409 /** Returns the number of snapshots taken. */ |
| 437 int GetSnapshotCount(); | 410 int GetSnapshotCount(); |
| 438 | 411 |
| 439 /** Deprecated. Use GetHeapSnapshot instead. */ | |
| 440 V8_DEPRECATED(static const HeapSnapshot* GetSnapshot(int index)); | |
| 441 /** Returns a snapshot by index. */ | 412 /** Returns a snapshot by index. */ |
| 442 const HeapSnapshot* GetHeapSnapshot(int index); | 413 const HeapSnapshot* GetHeapSnapshot(int index); |
| 443 | 414 |
| 444 /** Deprecated. Use FindHeapSnapshot instead. */ | |
| 445 V8_DEPRECATED(static const HeapSnapshot* FindSnapshot(unsigned uid)); | |
| 446 /** Returns a profile by uid. */ | 415 /** Returns a profile by uid. */ |
| 447 V8_DEPRECATED(const HeapSnapshot* FindHeapSnapshot(unsigned uid)); | 416 V8_DEPRECATED(const HeapSnapshot* FindHeapSnapshot(unsigned uid)); |
| 448 | 417 |
| 449 /** Deprecated. Use GetObjectId instead. */ | |
| 450 V8_DEPRECATED(static SnapshotObjectId GetSnapshotObjectId( | |
| 451 Handle<Value> value)); | |
| 452 /** | 418 /** |
| 453 * Returns SnapshotObjectId for a heap object referenced by |value| if | 419 * Returns SnapshotObjectId for a heap object referenced by |value| if |
| 454 * it has been seen by the heap profiler, kUnknownObjectId otherwise. | 420 * it has been seen by the heap profiler, kUnknownObjectId otherwise. |
| 455 */ | 421 */ |
| 456 SnapshotObjectId GetObjectId(Handle<Value> value); | 422 SnapshotObjectId GetObjectId(Handle<Value> value); |
| 457 | 423 |
| 458 /** | 424 /** |
| 459 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return | 425 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return |
| 460 * it in case heap profiler cannot find id for the object passed as | 426 * it in case heap profiler cannot find id for the object passed as |
| 461 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. | 427 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. |
| 462 */ | 428 */ |
| 463 static const SnapshotObjectId kUnknownObjectId = 0; | 429 static const SnapshotObjectId kUnknownObjectId = 0; |
| 464 | 430 |
| 465 /** | 431 /** |
| 466 * Callback interface for retrieving user friendly names of global objects. | 432 * Callback interface for retrieving user friendly names of global objects. |
| 467 */ | 433 */ |
| 468 class ObjectNameResolver { | 434 class ObjectNameResolver { |
| 469 public: | 435 public: |
| 470 /** | 436 /** |
| 471 * Returns name to be used in the heap snapshot for given node. Returned | 437 * Returns name to be used in the heap snapshot for given node. Returned |
| 472 * string must stay alive until snapshot collection is completed. | 438 * string must stay alive until snapshot collection is completed. |
| 473 */ | 439 */ |
| 474 virtual const char* GetName(Handle<Object> object) = 0; | 440 virtual const char* GetName(Handle<Object> object) = 0; |
| 475 protected: | 441 protected: |
| 476 virtual ~ObjectNameResolver() {} | 442 virtual ~ObjectNameResolver() {} |
| 477 }; | 443 }; |
| 478 | 444 |
| 479 /** Deprecated. Use TakeHeapSnapshot instead. */ | |
| 480 V8_DEPRECATED(static const HeapSnapshot* TakeSnapshot( | |
| 481 Handle<String> title, | |
| 482 HeapSnapshot::Type type = HeapSnapshot::kFull, | |
| 483 ActivityControl* control = NULL, | |
| 484 ObjectNameResolver* global_object_name_resolver = NULL)); | |
| 485 /** | 445 /** |
| 486 * Takes a heap snapshot and returns it. Title may be an empty string. | 446 * Takes a heap snapshot and returns it. Title may be an empty string. |
| 487 */ | 447 */ |
| 488 const HeapSnapshot* TakeHeapSnapshot( | 448 const HeapSnapshot* TakeHeapSnapshot( |
| 489 Handle<String> title, | 449 Handle<String> title, |
| 490 ActivityControl* control = NULL, | 450 ActivityControl* control = NULL, |
| 491 ObjectNameResolver* global_object_name_resolver = NULL); | 451 ObjectNameResolver* global_object_name_resolver = NULL); |
| 492 | 452 |
| 493 | |
| 494 /** Deprecated. Use StartTrackingHeapObjects instead. */ | |
| 495 V8_DEPRECATED(static void StartHeapObjectsTracking()); | |
| 496 /** | 453 /** |
| 497 * Starts tracking of heap objects population statistics. After calling | 454 * Starts tracking of heap objects population statistics. After calling |
| 498 * this method, all heap objects relocations done by the garbage collector | 455 * this method, all heap objects relocations done by the garbage collector |
| 499 * are being registered. | 456 * are being registered. |
| 500 */ | 457 */ |
| 501 void StartTrackingHeapObjects(); | 458 void StartTrackingHeapObjects(); |
| 502 | 459 |
| 503 /** Deprecated. Use GetHeapStats instead. */ | |
| 504 V8_DEPRECATED(static SnapshotObjectId PushHeapObjectsStats( | |
| 505 OutputStream* stream)); | |
| 506 /** | 460 /** |
| 507 * Adds a new time interval entry to the aggregated statistics array. The | 461 * Adds a new time interval entry to the aggregated statistics array. The |
| 508 * time interval entry contains information on the current heap objects | 462 * time interval entry contains information on the current heap objects |
| 509 * population size. The method also updates aggregated statistics and | 463 * population size. The method also updates aggregated statistics and |
| 510 * reports updates for all previous time intervals via the OutputStream | 464 * reports updates for all previous time intervals via the OutputStream |
| 511 * object. Updates on each time interval are provided as a stream of the | 465 * object. Updates on each time interval are provided as a stream of the |
| 512 * HeapStatsUpdate structure instances. | 466 * HeapStatsUpdate structure instances. |
| 513 * The return value of the function is the last seen heap object Id. | 467 * The return value of the function is the last seen heap object Id. |
| 514 * | 468 * |
| 515 * StartTrackingHeapObjects must be called before the first call to this | 469 * StartTrackingHeapObjects must be called before the first call to this |
| 516 * method. | 470 * method. |
| 517 */ | 471 */ |
| 518 SnapshotObjectId GetHeapStats(OutputStream* stream); | 472 SnapshotObjectId GetHeapStats(OutputStream* stream); |
| 519 | 473 |
| 520 /** Deprecated. Use StopTrackingHeapObjects instead. */ | |
| 521 V8_DEPRECATED(static void StopHeapObjectsTracking()); | |
| 522 /** | 474 /** |
| 523 * Stops tracking of heap objects population statistics, cleans up all | 475 * Stops tracking of heap objects population statistics, cleans up all |
| 524 * collected data. StartHeapObjectsTracking must be called again prior to | 476 * collected data. StartHeapObjectsTracking must be called again prior to |
| 525 * calling PushHeapObjectsStats next time. | 477 * calling PushHeapObjectsStats next time. |
| 526 */ | 478 */ |
| 527 void StopTrackingHeapObjects(); | 479 void StopTrackingHeapObjects(); |
| 528 | 480 |
| 529 /** Deprecated. Use DeleteAllHeapSnapshots instead. */ | |
| 530 V8_DEPRECATED(static void DeleteAllSnapshots()); | |
| 531 /** | 481 /** |
| 532 * Deletes all snapshots taken. All previously returned pointers to | 482 * Deletes all snapshots taken. All previously returned pointers to |
| 533 * snapshots and their contents become invalid after this call. | 483 * snapshots and their contents become invalid after this call. |
| 534 */ | 484 */ |
| 535 void DeleteAllHeapSnapshots(); | 485 void DeleteAllHeapSnapshots(); |
| 536 | 486 |
| 537 /** Deprecated. Use SetWrapperClassInfoProvider instead. */ | |
| 538 V8_DEPRECATED(static void DefineWrapperClass( | |
| 539 uint16_t class_id, | |
| 540 WrapperInfoCallback callback)); | |
| 541 /** Binds a callback to embedder's class ID. */ | 487 /** Binds a callback to embedder's class ID. */ |
| 542 void SetWrapperClassInfoProvider( | 488 void SetWrapperClassInfoProvider( |
| 543 uint16_t class_id, | 489 uint16_t class_id, |
| 544 WrapperInfoCallback callback); | 490 WrapperInfoCallback callback); |
| 545 | 491 |
| 546 /** | 492 /** |
| 547 * Default value of persistent handle class ID. Must not be used to | 493 * Default value of persistent handle class ID. Must not be used to |
| 548 * define a class. Can be used to reset a class of a persistent | 494 * define a class. Can be used to reset a class of a persistent |
| 549 * handle. | 495 * handle. |
| 550 */ | 496 */ |
| 551 static const uint16_t kPersistentHandleNoClassId = 0; | 497 static const uint16_t kPersistentHandleNoClassId = 0; |
| 552 | 498 |
| 553 /** | |
| 554 * Deprecated. Returns the number of currently existing persistent handles. | |
| 555 */ | |
| 556 V8_DEPRECATED(static int GetPersistentHandleCount()); | |
| 557 | |
| 558 /** Deprecated. Use GetHeapProfilerMemorySize instead. */ | |
| 559 V8_DEPRECATED(static size_t GetMemorySizeUsedByProfiler()); | |
| 560 /** Returns memory used for profiler internal data and snapshots. */ | 499 /** Returns memory used for profiler internal data and snapshots. */ |
| 561 size_t GetProfilerMemorySize(); | 500 size_t GetProfilerMemorySize(); |
| 562 | 501 |
| 563 /** | 502 /** |
| 564 * Sets a RetainedObjectInfo for an object group (see V8::SetObjectGroupId). | 503 * Sets a RetainedObjectInfo for an object group (see V8::SetObjectGroupId). |
| 565 */ | 504 */ |
| 566 void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); | 505 void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); |
| 567 | 506 |
| 568 private: | 507 private: |
| 569 HeapProfiler(); | 508 HeapProfiler(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 583 * prologue and epilogue callbacks. | 522 * prologue and epilogue callbacks. |
| 584 * | 523 * |
| 585 * 2. When a heap snapshot is collected, V8 additionally | 524 * 2. When a heap snapshot is collected, V8 additionally |
| 586 * requests RetainedObjectInfos for persistent handles that | 525 * requests RetainedObjectInfos for persistent handles that |
| 587 * were not previously reported via AddObjectGroup. | 526 * were not previously reported via AddObjectGroup. |
| 588 * | 527 * |
| 589 * Thus, if an embedder wants to provide information about native | 528 * Thus, if an embedder wants to provide information about native |
| 590 * objects for heap snapshots, he can do it in a GC prologue | 529 * objects for heap snapshots, he can do it in a GC prologue |
| 591 * handler, and / or by assigning wrapper class ids in the following way: | 530 * handler, and / or by assigning wrapper class ids in the following way: |
| 592 * | 531 * |
| 593 * 1. Bind a callback to class id by calling DefineWrapperClass. | 532 * 1. Bind a callback to class id by calling SetWrapperClassInfoProvider. |
| 594 * 2. Call SetWrapperClassId on certain persistent handles. | 533 * 2. Call SetWrapperClassId on certain persistent handles. |
| 595 * | 534 * |
| 596 * V8 takes ownership of RetainedObjectInfo instances passed to it and | 535 * V8 takes ownership of RetainedObjectInfo instances passed to it and |
| 597 * keeps them alive only during snapshot collection. Afterwards, they | 536 * keeps them alive only during snapshot collection. Afterwards, they |
| 598 * are freed by calling the Dispose class function. | 537 * are freed by calling the Dispose class function. |
| 599 */ | 538 */ |
| 600 class V8EXPORT RetainedObjectInfo { // NOLINT | 539 class V8EXPORT RetainedObjectInfo { // NOLINT |
| 601 public: | 540 public: |
| 602 /** Called by V8 when it no longer needs an instance. */ | 541 /** Called by V8 when it no longer needs an instance. */ |
| 603 virtual void Dispose() = 0; | 542 virtual void Dispose() = 0; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 }; | 599 }; |
| 661 | 600 |
| 662 | 601 |
| 663 } // namespace v8 | 602 } // namespace v8 |
| 664 | 603 |
| 665 | 604 |
| 666 #undef V8EXPORT | 605 #undef V8EXPORT |
| 667 | 606 |
| 668 | 607 |
| 669 #endif // V8_V8_PROFILER_H_ | 608 #endif // V8_V8_PROFILER_H_ |
| OLD | NEW |