| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 static const int kNoColumnNumberInfo = Message::kNoColumnInfo; | 89 static const int kNoColumnNumberInfo = Message::kNoColumnInfo; |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * CpuProfile contains a CPU profile in a form of top-down call tree | 94 * CpuProfile contains a CPU profile in a form of top-down call tree |
| 95 * (from main() down to functions that do all the work). | 95 * (from main() down to functions that do all the work). |
| 96 */ | 96 */ |
| 97 class V8_EXPORT CpuProfile { | 97 class V8_EXPORT CpuProfile { |
| 98 public: | 98 public: |
| 99 /** Returns CPU profile UID (assigned by the profiler.) */ | |
| 100 unsigned GetUid() const; | |
| 101 | |
| 102 /** Returns CPU profile title. */ | 99 /** Returns CPU profile title. */ |
| 103 Handle<String> GetTitle() const; | 100 Handle<String> GetTitle() const; |
| 104 | 101 |
| 105 /** Returns the root node of the top down call tree. */ | 102 /** Returns the root node of the top down call tree. */ |
| 106 const CpuProfileNode* GetTopDownRoot() const; | 103 const CpuProfileNode* GetTopDownRoot() const; |
| 107 | 104 |
| 108 /** | 105 /** |
| 109 * Returns number of samples recorded. The samples are not recorded unless | 106 * Returns number of samples recorded. The samples are not recorded unless |
| 110 * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true. | 107 * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true. |
| 111 */ | 108 */ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 125 | 122 |
| 126 /** | 123 /** |
| 127 * Returns time when the profile recording was stopped (in microseconds | 124 * Returns time when the profile recording was stopped (in microseconds |
| 128 * since the Epoch). | 125 * since the Epoch). |
| 129 */ | 126 */ |
| 130 int64_t GetEndTime() const; | 127 int64_t GetEndTime() const; |
| 131 | 128 |
| 132 /** | 129 /** |
| 133 * Deletes the profile and removes it from CpuProfiler's list. | 130 * Deletes the profile and removes it from CpuProfiler's list. |
| 134 * All pointers to nodes previously returned become invalid. | 131 * All pointers to nodes previously returned become invalid. |
| 135 * Profiles with the same uid but obtained using different | |
| 136 * security token are not deleted, but become inaccessible | |
| 137 * using FindProfile method. It is embedder's responsibility | |
| 138 * to call Delete on these profiles. | |
| 139 */ | 132 */ |
| 140 void Delete(); | 133 void Delete(); |
| 141 }; | 134 }; |
| 142 | 135 |
| 143 | 136 |
| 144 /** | 137 /** |
| 145 * Interface for controlling CPU profiling. Instance of the | 138 * Interface for controlling CPU profiling. Instance of the |
| 146 * profiler can be retrieved using v8::Isolate::GetCpuProfiler. | 139 * profiler can be retrieved using v8::Isolate::GetCpuProfiler. |
| 147 */ | 140 */ |
| 148 class V8_EXPORT CpuProfiler { | 141 class V8_EXPORT CpuProfiler { |
| 149 public: | 142 public: |
| 150 /** | 143 /** |
| 151 * Changes default CPU profiler sampling interval to the specified number | 144 * Changes default CPU profiler sampling interval to the specified number |
| 152 * of microseconds. Default interval is 1000us. This method must be called | 145 * of microseconds. Default interval is 1000us. This method must be called |
| 153 * when there are no profiles being recorded. | 146 * when there are no profiles being recorded. |
| 154 */ | 147 */ |
| 155 void SetSamplingInterval(int us); | 148 void SetSamplingInterval(int us); |
| 156 | 149 |
| 157 /** | 150 /** |
| 158 * Returns the number of profiles collected (doesn't include | |
| 159 * profiles that are being collected at the moment of call.) | |
| 160 */ | |
| 161 int GetProfileCount(); | |
| 162 | |
| 163 /** Returns a profile by index. */ | |
| 164 const CpuProfile* GetCpuProfile(int index); | |
| 165 | |
| 166 /** | |
| 167 * Starts collecting CPU profile. Title may be an empty string. It | 151 * Starts collecting CPU profile. Title may be an empty string. It |
| 168 * is allowed to have several profiles being collected at | 152 * is allowed to have several profiles being collected at |
| 169 * once. Attempts to start collecting several profiles with the same | 153 * once. Attempts to start collecting several profiles with the same |
| 170 * title are silently ignored. While collecting a profile, functions | 154 * title are silently ignored. While collecting a profile, functions |
| 171 * from all security contexts are included in it. The token-based | 155 * from all security contexts are included in it. The token-based |
| 172 * filtering is only performed when querying for a profile. | 156 * filtering is only performed when querying for a profile. |
| 173 * | 157 * |
| 174 * |record_samples| parameter controls whether individual samples should | 158 * |record_samples| parameter controls whether individual samples should |
| 175 * be recorded in addition to the aggregated tree. | 159 * be recorded in addition to the aggregated tree. |
| 176 */ | 160 */ |
| 177 void StartCpuProfiling(Handle<String> title, bool record_samples = false); | 161 void StartCpuProfiling(Handle<String> title, bool record_samples = false); |
| 178 | 162 |
| 179 /** | 163 /** |
| 180 * Stops collecting CPU profile with a given title and returns it. | 164 * Stops collecting CPU profile with a given title and returns it. |
| 181 * If the title given is empty, finishes the last profile started. | 165 * If the title given is empty, finishes the last profile started. |
| 182 */ | 166 */ |
| 183 const CpuProfile* StopCpuProfiling(Handle<String> title); | 167 const CpuProfile* StopCpuProfiling(Handle<String> title); |
| 184 | 168 |
| 185 /** | 169 /** |
| 186 * Deletes all existing profiles, also cancelling all profiling | |
| 187 * activity. All previously returned pointers to profiles and their | |
| 188 * contents become invalid after this call. | |
| 189 */ | |
| 190 void DeleteAllCpuProfiles(); | |
| 191 | |
| 192 /** | |
| 193 * Tells the profiler whether the embedder is idle. | 170 * Tells the profiler whether the embedder is idle. |
| 194 */ | 171 */ |
| 195 void SetIdle(bool is_idle); | 172 void SetIdle(bool is_idle); |
| 196 | 173 |
| 197 private: | 174 private: |
| 198 CpuProfiler(); | 175 CpuProfiler(); |
| 199 ~CpuProfiler(); | 176 ~CpuProfiler(); |
| 200 CpuProfiler(const CpuProfiler&); | 177 CpuProfiler(const CpuProfiler&); |
| 201 CpuProfiler& operator=(const CpuProfiler&); | 178 CpuProfiler& operator=(const CpuProfiler&); |
| 202 }; | 179 }; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 SnapshotObjectId GetId() const; | 257 SnapshotObjectId GetId() const; |
| 281 | 258 |
| 282 /** Returns node's own size, in bytes. */ | 259 /** Returns node's own size, in bytes. */ |
| 283 int GetSelfSize() const; | 260 int GetSelfSize() const; |
| 284 | 261 |
| 285 /** Returns child nodes count of the node. */ | 262 /** Returns child nodes count of the node. */ |
| 286 int GetChildrenCount() const; | 263 int GetChildrenCount() const; |
| 287 | 264 |
| 288 /** Retrieves a child by index. */ | 265 /** Retrieves a child by index. */ |
| 289 const HeapGraphEdge* GetChild(int index) const; | 266 const HeapGraphEdge* GetChild(int index) const; |
| 290 | |
| 291 /** | |
| 292 * Finds and returns a value from the heap corresponding to this node, | |
| 293 * if the value is still reachable. | |
| 294 */ | |
| 295 Handle<Value> GetHeapValue() const; | |
| 296 }; | 267 }; |
| 297 | 268 |
| 298 | 269 |
| 299 /** | 270 /** |
| 300 * HeapSnapshots record the state of the JS heap at some moment. | 271 * HeapSnapshots record the state of the JS heap at some moment. |
| 301 */ | 272 */ |
| 302 class V8_EXPORT HeapSnapshot { | 273 class V8_EXPORT HeapSnapshot { |
| 303 public: | 274 public: |
| 304 enum SerializationFormat { | 275 enum SerializationFormat { |
| 305 kJSON = 0 // See format description near 'Serialize' method. | 276 kJSON = 0 // See format description near 'Serialize' method. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 /** Returns a snapshot by index. */ | 357 /** Returns a snapshot by index. */ |
| 387 const HeapSnapshot* GetHeapSnapshot(int index); | 358 const HeapSnapshot* GetHeapSnapshot(int index); |
| 388 | 359 |
| 389 /** | 360 /** |
| 390 * Returns SnapshotObjectId for a heap object referenced by |value| if | 361 * Returns SnapshotObjectId for a heap object referenced by |value| if |
| 391 * it has been seen by the heap profiler, kUnknownObjectId otherwise. | 362 * it has been seen by the heap profiler, kUnknownObjectId otherwise. |
| 392 */ | 363 */ |
| 393 SnapshotObjectId GetObjectId(Handle<Value> value); | 364 SnapshotObjectId GetObjectId(Handle<Value> value); |
| 394 | 365 |
| 395 /** | 366 /** |
| 367 * Returns heap object with given SnapshotObjectId if the object is alive, |
| 368 * otherwise empty handle is returned. |
| 369 */ |
| 370 Handle<Value> FindObjectById(SnapshotObjectId id); |
| 371 |
| 372 /** |
| 373 * Clears internal map from SnapshotObjectId to heap object. The new objects |
| 374 * will not be added into it unless a heap snapshot is taken or heap object |
| 375 * tracking is kicked off. |
| 376 */ |
| 377 void ClearObjectIds(); |
| 378 |
| 379 /** |
| 396 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return | 380 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return |
| 397 * it in case heap profiler cannot find id for the object passed as | 381 * it in case heap profiler cannot find id for the object passed as |
| 398 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. | 382 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. |
| 399 */ | 383 */ |
| 400 static const SnapshotObjectId kUnknownObjectId = 0; | 384 static const SnapshotObjectId kUnknownObjectId = 0; |
| 401 | 385 |
| 402 /** | 386 /** |
| 403 * Callback interface for retrieving user friendly names of global objects. | 387 * Callback interface for retrieving user friendly names of global objects. |
| 404 */ | 388 */ |
| 405 class ObjectNameResolver { | 389 class ObjectNameResolver { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 static const uint16_t kPersistentHandleNoClassId = 0; | 456 static const uint16_t kPersistentHandleNoClassId = 0; |
| 473 | 457 |
| 474 /** Returns memory used for profiler internal data and snapshots. */ | 458 /** Returns memory used for profiler internal data and snapshots. */ |
| 475 size_t GetProfilerMemorySize(); | 459 size_t GetProfilerMemorySize(); |
| 476 | 460 |
| 477 /** | 461 /** |
| 478 * Sets a RetainedObjectInfo for an object group (see V8::SetObjectGroupId). | 462 * Sets a RetainedObjectInfo for an object group (see V8::SetObjectGroupId). |
| 479 */ | 463 */ |
| 480 void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); | 464 void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); |
| 481 | 465 |
| 482 /** | |
| 483 * Starts recording JS allocations immediately as they arrive and tracking of | |
| 484 * heap objects population statistics. | |
| 485 */ | |
| 486 V8_DEPRECATED("Use StartTrackingHeapObjects instead", | |
| 487 void StartRecordingHeapAllocations()); | |
| 488 | |
| 489 /** | |
| 490 * Stops recording JS allocations and tracking of heap objects population | |
| 491 * statistics, cleans all collected heap objects population statistics data. | |
| 492 */ | |
| 493 V8_DEPRECATED("Use StopTrackingHeapObjects instead", | |
| 494 void StopRecordingHeapAllocations()); | |
| 495 | |
| 496 | |
| 497 private: | 466 private: |
| 498 HeapProfiler(); | 467 HeapProfiler(); |
| 499 ~HeapProfiler(); | 468 ~HeapProfiler(); |
| 500 HeapProfiler(const HeapProfiler&); | 469 HeapProfiler(const HeapProfiler&); |
| 501 HeapProfiler& operator=(const HeapProfiler&); | 470 HeapProfiler& operator=(const HeapProfiler&); |
| 502 }; | 471 }; |
| 503 | 472 |
| 504 | 473 |
| 505 /** | 474 /** |
| 506 * Interface for providing information about embedder's objects | 475 * Interface for providing information about embedder's objects |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 uint32_t index; // Index of the time interval that was changed. | 555 uint32_t index; // Index of the time interval that was changed. |
| 587 uint32_t count; // New value of count field for the interval with this index. | 556 uint32_t count; // New value of count field for the interval with this index. |
| 588 uint32_t size; // New value of size field for the interval with this index. | 557 uint32_t size; // New value of size field for the interval with this index. |
| 589 }; | 558 }; |
| 590 | 559 |
| 591 | 560 |
| 592 } // namespace v8 | 561 } // namespace v8 |
| 593 | 562 |
| 594 | 563 |
| 595 #endif // V8_V8_PROFILER_H_ | 564 #endif // V8_V8_PROFILER_H_ |
| OLD | NEW |