| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. */ | 175 /** Deprecated. Use GetProfileCount instead. */ |
| 176 static int GetProfilesCount(); | 176 V8_DEPRECATED(static int GetProfilesCount()); |
| 177 /** | 177 /** |
| 178 * Returns the number of profiles collected (doesn't include | 178 * Returns the number of profiles collected (doesn't include |
| 179 * profiles that are being collected at the moment of call.) | 179 * profiles that are being collected at the moment of call.) |
| 180 */ | 180 */ |
| 181 int GetProfileCount(); | 181 int GetProfileCount(); |
| 182 | 182 |
| 183 /** Deprecated. Use GetCpuProfile instead. */ | 183 /** Deprecated. Use GetCpuProfile instead. */ |
| 184 static const CpuProfile* GetProfile( | 184 V8_DEPRECATED(static const CpuProfile* GetProfile( |
| 185 int index, | 185 int index, |
| 186 Handle<Value> security_token = Handle<Value>()); | 186 Handle<Value> security_token = Handle<Value>())); |
| 187 /** Returns a profile by index. */ | 187 /** Returns a profile by index. */ |
| 188 const CpuProfile* GetCpuProfile( | 188 const CpuProfile* GetCpuProfile( |
| 189 int index, | 189 int index, |
| 190 Handle<Value> security_token = Handle<Value>()); | 190 Handle<Value> security_token = Handle<Value>()); |
| 191 | 191 |
| 192 /** Deprecated. Use FindProfile instead. */ | 192 /** Deprecated. Use FindProfile instead. */ |
| 193 static const CpuProfile* FindProfile( | 193 V8_DEPRECATED(static const CpuProfile* FindProfile( |
| 194 unsigned uid, | 194 unsigned uid, |
| 195 Handle<Value> security_token = Handle<Value>()); | 195 Handle<Value> security_token = Handle<Value>())); |
| 196 /** Returns a profile by uid. */ | 196 /** Returns a profile by uid. */ |
| 197 const CpuProfile* FindCpuProfile( | 197 const CpuProfile* FindCpuProfile( |
| 198 unsigned uid, | 198 unsigned uid, |
| 199 Handle<Value> security_token = Handle<Value>()); | 199 Handle<Value> security_token = Handle<Value>()); |
| 200 | 200 |
| 201 /** Deprecated. Use StartCpuProfiling instead. */ | 201 /** Deprecated. Use StartCpuProfiling instead. */ |
| 202 static void StartProfiling(Handle<String> title, bool record_samples = false); | 202 V8_DEPRECATED(static void StartProfiling(Handle<String> title, |
| 203 bool record_samples = false)); |
| 203 /** | 204 /** |
| 204 * Starts collecting CPU profile. Title may be an empty string. It | 205 * Starts collecting CPU profile. Title may be an empty string. It |
| 205 * is allowed to have several profiles being collected at | 206 * is allowed to have several profiles being collected at |
| 206 * once. Attempts to start collecting several profiles with the same | 207 * once. Attempts to start collecting several profiles with the same |
| 207 * title are silently ignored. While collecting a profile, functions | 208 * title are silently ignored. While collecting a profile, functions |
| 208 * from all security contexts are included in it. The token-based | 209 * from all security contexts are included in it. The token-based |
| 209 * filtering is only performed when querying for a profile. | 210 * filtering is only performed when querying for a profile. |
| 210 * | 211 * |
| 211 * |record_samples| parameter controls whether individual samples should | 212 * |record_samples| parameter controls whether individual samples should |
| 212 * be recorded in addition to the aggregated tree. | 213 * be recorded in addition to the aggregated tree. |
| 213 */ | 214 */ |
| 214 void StartCpuProfiling(Handle<String> title, bool record_samples = false); | 215 void StartCpuProfiling(Handle<String> title, bool record_samples = false); |
| 215 | 216 |
| 216 /** Deprecated. Use StopCpuProfiling instead. */ | 217 /** Deprecated. Use StopCpuProfiling instead. */ |
| 217 static const CpuProfile* StopProfiling( | 218 V8_DEPRECATED(static const CpuProfile* StopProfiling( |
| 218 Handle<String> title, | 219 Handle<String> title, |
| 219 Handle<Value> security_token = Handle<Value>()); | 220 Handle<Value> security_token = Handle<Value>())); |
| 220 /** | 221 /** |
| 221 * Stops collecting CPU profile with a given title and returns it. | 222 * Stops collecting CPU profile with a given title and returns it. |
| 222 * If the title given is empty, finishes the last profile started. | 223 * If the title given is empty, finishes the last profile started. |
| 223 */ | 224 */ |
| 224 const CpuProfile* StopCpuProfiling( | 225 const CpuProfile* StopCpuProfiling( |
| 225 Handle<String> title, | 226 Handle<String> title, |
| 226 Handle<Value> security_token = Handle<Value>()); | 227 Handle<Value> security_token = Handle<Value>()); |
| 227 | 228 |
| 228 /** Deprecated. Use DeleteAllCpuProfiles instead. */ | 229 /** Deprecated. Use DeleteAllCpuProfiles instead. */ |
| 229 static void DeleteAllProfiles(); | 230 V8_DEPRECATED(static void DeleteAllProfiles()); |
| 230 /** | 231 /** |
| 231 * Deletes all existing profiles, also cancelling all profiling | 232 * Deletes all existing profiles, also cancelling all profiling |
| 232 * activity. All previously returned pointers to profiles and their | 233 * activity. All previously returned pointers to profiles and their |
| 233 * contents become invalid after this call. | 234 * contents become invalid after this call. |
| 234 */ | 235 */ |
| 235 void DeleteAllCpuProfiles(); | 236 void DeleteAllCpuProfiles(); |
| 236 | 237 |
| 237 private: | 238 private: |
| 238 CpuProfiler(); | 239 CpuProfiler(); |
| 239 ~CpuProfiler(); | 240 ~CpuProfiler(); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 /** | 419 /** |
| 419 * Callback function invoked for obtaining RetainedObjectInfo for | 420 * Callback function invoked for obtaining RetainedObjectInfo for |
| 420 * the given JavaScript wrapper object. It is prohibited to enter V8 | 421 * the given JavaScript wrapper object. It is prohibited to enter V8 |
| 421 * while the callback is running: only getters on the handle and | 422 * while the callback is running: only getters on the handle and |
| 422 * GetPointerFromInternalField on the objects are allowed. | 423 * GetPointerFromInternalField on the objects are allowed. |
| 423 */ | 424 */ |
| 424 typedef RetainedObjectInfo* (*WrapperInfoCallback) | 425 typedef RetainedObjectInfo* (*WrapperInfoCallback) |
| 425 (uint16_t class_id, Handle<Value> wrapper); | 426 (uint16_t class_id, Handle<Value> wrapper); |
| 426 | 427 |
| 427 /** Deprecated. Use GetSnapshotCount instead. */ | 428 /** Deprecated. Use GetSnapshotCount instead. */ |
| 428 static int GetSnapshotsCount(); | 429 V8_DEPRECATED(static int GetSnapshotsCount()); |
| 429 /** Returns the number of snapshots taken. */ | 430 /** Returns the number of snapshots taken. */ |
| 430 int GetSnapshotCount(); | 431 int GetSnapshotCount(); |
| 431 | 432 |
| 432 /** Deprecated. Use GetHeapSnapshot instead. */ | 433 /** Deprecated. Use GetHeapSnapshot instead. */ |
| 433 static const HeapSnapshot* GetSnapshot(int index); | 434 V8_DEPRECATED(static const HeapSnapshot* GetSnapshot(int index)); |
| 434 /** Returns a snapshot by index. */ | 435 /** Returns a snapshot by index. */ |
| 435 const HeapSnapshot* GetHeapSnapshot(int index); | 436 const HeapSnapshot* GetHeapSnapshot(int index); |
| 436 | 437 |
| 437 /** Deprecated. Use FindHeapSnapshot instead. */ | 438 /** Deprecated. Use FindHeapSnapshot instead. */ |
| 438 static const HeapSnapshot* FindSnapshot(unsigned uid); | 439 V8_DEPRECATED(static const HeapSnapshot* FindSnapshot(unsigned uid)); |
| 439 /** Returns a profile by uid. */ | 440 /** Returns a profile by uid. */ |
| 440 const HeapSnapshot* FindHeapSnapshot(unsigned uid); | 441 const HeapSnapshot* FindHeapSnapshot(unsigned uid); |
| 441 | 442 |
| 442 /** Deprecated. Use GetObjectId instead. */ | 443 /** Deprecated. Use GetObjectId instead. */ |
| 443 static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value); | 444 V8_DEPRECATED(static SnapshotObjectId GetSnapshotObjectId( |
| 445 Handle<Value> value)); |
| 444 /** | 446 /** |
| 445 * Returns SnapshotObjectId for a heap object referenced by |value| if | 447 * Returns SnapshotObjectId for a heap object referenced by |value| if |
| 446 * it has been seen by the heap profiler, kUnknownObjectId otherwise. | 448 * it has been seen by the heap profiler, kUnknownObjectId otherwise. |
| 447 */ | 449 */ |
| 448 SnapshotObjectId GetObjectId(Handle<Value> value); | 450 SnapshotObjectId GetObjectId(Handle<Value> value); |
| 449 | 451 |
| 450 /** | 452 /** |
| 451 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return | 453 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return |
| 452 * it in case heap profiler cannot find id for the object passed as | 454 * it in case heap profiler cannot find id for the object passed as |
| 453 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. | 455 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. |
| 454 */ | 456 */ |
| 455 static const SnapshotObjectId kUnknownObjectId = 0; | 457 static const SnapshotObjectId kUnknownObjectId = 0; |
| 456 | 458 |
| 457 /** | 459 /** |
| 458 * Callback interface for retrieving user friendly names of global objects. | 460 * Callback interface for retrieving user friendly names of global objects. |
| 459 */ | 461 */ |
| 460 class ObjectNameResolver { | 462 class ObjectNameResolver { |
| 461 public: | 463 public: |
| 462 /** | 464 /** |
| 463 * Returns name to be used in the heap snapshot for given node. Returned | 465 * Returns name to be used in the heap snapshot for given node. Returned |
| 464 * string must stay alive until snapshot collection is completed. | 466 * string must stay alive until snapshot collection is completed. |
| 465 */ | 467 */ |
| 466 virtual const char* GetName(Handle<Object> object) = 0; | 468 virtual const char* GetName(Handle<Object> object) = 0; |
| 467 protected: | 469 protected: |
| 468 virtual ~ObjectNameResolver() {} | 470 virtual ~ObjectNameResolver() {} |
| 469 }; | 471 }; |
| 470 | 472 |
| 471 /** Deprecated. Use TakeHeapSnapshot instead. */ | 473 /** Deprecated. Use TakeHeapSnapshot instead. */ |
| 472 static const HeapSnapshot* TakeSnapshot( | 474 V8_DEPRECATED(static const HeapSnapshot* TakeSnapshot( |
| 473 Handle<String> title, | 475 Handle<String> title, |
| 474 HeapSnapshot::Type type = HeapSnapshot::kFull, | 476 HeapSnapshot::Type type = HeapSnapshot::kFull, |
| 475 ActivityControl* control = NULL, | 477 ActivityControl* control = NULL, |
| 476 ObjectNameResolver* global_object_name_resolver = NULL); | 478 ObjectNameResolver* global_object_name_resolver = NULL)); |
| 477 /** | 479 /** |
| 478 * Takes a heap snapshot and returns it. Title may be an empty string. | 480 * Takes a heap snapshot and returns it. Title may be an empty string. |
| 479 */ | 481 */ |
| 480 const HeapSnapshot* TakeHeapSnapshot( | 482 const HeapSnapshot* TakeHeapSnapshot( |
| 481 Handle<String> title, | 483 Handle<String> title, |
| 482 ActivityControl* control = NULL, | 484 ActivityControl* control = NULL, |
| 483 ObjectNameResolver* global_object_name_resolver = NULL); | 485 ObjectNameResolver* global_object_name_resolver = NULL); |
| 484 | 486 |
| 485 | 487 |
| 486 /** Deprecated. Use StartTrackingHeapObjects instead. */ | 488 /** Deprecated. Use StartTrackingHeapObjects instead. */ |
| 487 static void StartHeapObjectsTracking(); | 489 V8_DEPRECATED(static void StartHeapObjectsTracking()); |
| 488 /** | 490 /** |
| 489 * Starts tracking of heap objects population statistics. After calling | 491 * Starts tracking of heap objects population statistics. After calling |
| 490 * this method, all heap objects relocations done by the garbage collector | 492 * this method, all heap objects relocations done by the garbage collector |
| 491 * are being registered. | 493 * are being registered. |
| 492 */ | 494 */ |
| 493 void StartTrackingHeapObjects(); | 495 void StartTrackingHeapObjects(); |
| 494 | 496 |
| 495 /** Deprecated. Use GetHeapStats instead. */ | 497 /** Deprecated. Use GetHeapStats instead. */ |
| 496 static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); | 498 V8_DEPRECATED(static SnapshotObjectId PushHeapObjectsStats( |
| 499 OutputStream* stream)); |
| 497 /** | 500 /** |
| 498 * Adds a new time interval entry to the aggregated statistics array. The | 501 * Adds a new time interval entry to the aggregated statistics array. The |
| 499 * time interval entry contains information on the current heap objects | 502 * time interval entry contains information on the current heap objects |
| 500 * population size. The method also updates aggregated statistics and | 503 * population size. The method also updates aggregated statistics and |
| 501 * reports updates for all previous time intervals via the OutputStream | 504 * reports updates for all previous time intervals via the OutputStream |
| 502 * object. Updates on each time interval are provided as a stream of the | 505 * object. Updates on each time interval are provided as a stream of the |
| 503 * HeapStatsUpdate structure instances. | 506 * HeapStatsUpdate structure instances. |
| 504 * The return value of the function is the last seen heap object Id. | 507 * The return value of the function is the last seen heap object Id. |
| 505 * | 508 * |
| 506 * StartTrackingHeapObjects must be called before the first call to this | 509 * StartTrackingHeapObjects must be called before the first call to this |
| 507 * method. | 510 * method. |
| 508 */ | 511 */ |
| 509 SnapshotObjectId GetHeapStats(OutputStream* stream); | 512 SnapshotObjectId GetHeapStats(OutputStream* stream); |
| 510 | 513 |
| 511 /** Deprecated. Use StopTrackingHeapObjects instead. */ | 514 /** Deprecated. Use StopTrackingHeapObjects instead. */ |
| 512 static void StopHeapObjectsTracking(); | 515 V8_DEPRECATED(static void StopHeapObjectsTracking()); |
| 513 /** | 516 /** |
| 514 * Stops tracking of heap objects population statistics, cleans up all | 517 * Stops tracking of heap objects population statistics, cleans up all |
| 515 * collected data. StartHeapObjectsTracking must be called again prior to | 518 * collected data. StartHeapObjectsTracking must be called again prior to |
| 516 * calling PushHeapObjectsStats next time. | 519 * calling PushHeapObjectsStats next time. |
| 517 */ | 520 */ |
| 518 void StopTrackingHeapObjects(); | 521 void StopTrackingHeapObjects(); |
| 519 | 522 |
| 520 /** Deprecated. Use DeleteAllHeapSnapshots instead. */ | 523 /** Deprecated. Use DeleteAllHeapSnapshots instead. */ |
| 521 static void DeleteAllSnapshots(); | 524 V8_DEPRECATED(static void DeleteAllSnapshots()); |
| 522 /** | 525 /** |
| 523 * Deletes all snapshots taken. All previously returned pointers to | 526 * Deletes all snapshots taken. All previously returned pointers to |
| 524 * snapshots and their contents become invalid after this call. | 527 * snapshots and their contents become invalid after this call. |
| 525 */ | 528 */ |
| 526 void DeleteAllHeapSnapshots(); | 529 void DeleteAllHeapSnapshots(); |
| 527 | 530 |
| 528 /** Deprecated. Use SetWrapperClassInfoProvider instead. */ | 531 /** Deprecated. Use SetWrapperClassInfoProvider instead. */ |
| 529 static void DefineWrapperClass( | 532 V8_DEPRECATED(static void DefineWrapperClass( |
| 530 uint16_t class_id, | 533 uint16_t class_id, |
| 531 WrapperInfoCallback callback); | 534 WrapperInfoCallback callback)); |
| 532 /** Binds a callback to embedder's class ID. */ | 535 /** Binds a callback to embedder's class ID. */ |
| 533 void SetWrapperClassInfoProvider( | 536 void SetWrapperClassInfoProvider( |
| 534 uint16_t class_id, | 537 uint16_t class_id, |
| 535 WrapperInfoCallback callback); | 538 WrapperInfoCallback callback); |
| 536 | 539 |
| 537 /** | 540 /** |
| 538 * Default value of persistent handle class ID. Must not be used to | 541 * Default value of persistent handle class ID. Must not be used to |
| 539 * define a class. Can be used to reset a class of a persistent | 542 * define a class. Can be used to reset a class of a persistent |
| 540 * handle. | 543 * handle. |
| 541 */ | 544 */ |
| 542 static const uint16_t kPersistentHandleNoClassId = 0; | 545 static const uint16_t kPersistentHandleNoClassId = 0; |
| 543 | 546 |
| 544 /** | 547 /** |
| 545 * Deprecated. Returns the number of currently existing persistent handles. | 548 * Deprecated. Returns the number of currently existing persistent handles. |
| 546 */ | 549 */ |
| 547 static int GetPersistentHandleCount(); | 550 V8_DEPRECATED(static int GetPersistentHandleCount()); |
| 548 | 551 |
| 549 /** Deprecated. Use GetHeapProfilerMemorySize instead. */ | 552 /** Deprecated. Use GetHeapProfilerMemorySize instead. */ |
| 550 static size_t GetMemorySizeUsedByProfiler(); | 553 V8_DEPRECATED(static size_t GetMemorySizeUsedByProfiler()); |
| 551 /** Returns memory used for profiler internal data and snapshots. */ | 554 /** Returns memory used for profiler internal data and snapshots. */ |
| 552 size_t GetProfilerMemorySize(); | 555 size_t GetProfilerMemorySize(); |
| 553 | 556 |
| 554 private: | 557 private: |
| 555 HeapProfiler(); | 558 HeapProfiler(); |
| 556 ~HeapProfiler(); | 559 ~HeapProfiler(); |
| 557 HeapProfiler(const HeapProfiler&); | 560 HeapProfiler(const HeapProfiler&); |
| 558 HeapProfiler& operator=(const HeapProfiler&); | 561 HeapProfiler& operator=(const HeapProfiler&); |
| 559 }; | 562 }; |
| 560 | 563 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 }; | 649 }; |
| 647 | 650 |
| 648 | 651 |
| 649 } // namespace v8 | 652 } // namespace v8 |
| 650 | 653 |
| 651 | 654 |
| 652 #undef V8EXPORT | 655 #undef V8EXPORT |
| 653 | 656 |
| 654 | 657 |
| 655 #endif // V8_V8_PROFILER_H_ | 658 #endif // V8_V8_PROFILER_H_ |
| OLD | NEW |