OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_V8_PROFILER_H_ | 5 #ifndef V8_V8_PROFILER_H_ |
6 #define V8_V8_PROFILER_H_ | 6 #define V8_V8_PROFILER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 #include "v8.h" | 9 #include "v8.h" |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 public: | 53 public: |
54 struct LineTick { | 54 struct LineTick { |
55 /** The 1-based number of the source line where the function originates. */ | 55 /** The 1-based number of the source line where the function originates. */ |
56 int line; | 56 int line; |
57 | 57 |
58 /** The count of samples associated with the source line. */ | 58 /** The count of samples associated with the source line. */ |
59 unsigned int hit_count; | 59 unsigned int hit_count; |
60 }; | 60 }; |
61 | 61 |
62 /** Returns function name (empty string for anonymous functions.) */ | 62 /** Returns function name (empty string for anonymous functions.) */ |
63 Handle<String> GetFunctionName() const; | 63 Local<String> GetFunctionName() const; |
64 | 64 |
65 /** Returns id of the script where function is located. */ | 65 /** Returns id of the script where function is located. */ |
66 int GetScriptId() const; | 66 int GetScriptId() const; |
67 | 67 |
68 /** Returns resource name for script from where the function originates. */ | 68 /** Returns resource name for script from where the function originates. */ |
69 Handle<String> GetScriptResourceName() const; | 69 Local<String> GetScriptResourceName() const; |
70 | 70 |
71 /** | 71 /** |
72 * Returns the number, 1-based, of the line where the function originates. | 72 * Returns the number, 1-based, of the line where the function originates. |
73 * kNoLineNumberInfo if no line number information is available. | 73 * kNoLineNumberInfo if no line number information is available. |
74 */ | 74 */ |
75 int GetLineNumber() const; | 75 int GetLineNumber() const; |
76 | 76 |
77 /** | 77 /** |
78 * Returns 1-based number of the column where the function originates. | 78 * Returns 1-based number of the column where the function originates. |
79 * kNoColumnNumberInfo if no column number information is available. | 79 * kNoColumnNumberInfo if no column number information is available. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 }; | 122 }; |
123 | 123 |
124 | 124 |
125 /** | 125 /** |
126 * CpuProfile contains a CPU profile in a form of top-down call tree | 126 * CpuProfile contains a CPU profile in a form of top-down call tree |
127 * (from main() down to functions that do all the work). | 127 * (from main() down to functions that do all the work). |
128 */ | 128 */ |
129 class V8_EXPORT CpuProfile { | 129 class V8_EXPORT CpuProfile { |
130 public: | 130 public: |
131 /** Returns CPU profile title. */ | 131 /** Returns CPU profile title. */ |
132 Handle<String> GetTitle() const; | 132 Local<String> GetTitle() const; |
133 | 133 |
134 /** Returns the root node of the top down call tree. */ | 134 /** Returns the root node of the top down call tree. */ |
135 const CpuProfileNode* GetTopDownRoot() const; | 135 const CpuProfileNode* GetTopDownRoot() const; |
136 | 136 |
137 /** | 137 /** |
138 * Returns number of samples recorded. The samples are not recorded unless | 138 * Returns number of samples recorded. The samples are not recorded unless |
139 * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true. | 139 * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true. |
140 */ | 140 */ |
141 int GetSamplesCount() const; | 141 int GetSamplesCount() const; |
142 | 142 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 * Starts collecting CPU profile. Title may be an empty string. It | 191 * Starts collecting CPU profile. Title may be an empty string. It |
192 * is allowed to have several profiles being collected at | 192 * is allowed to have several profiles being collected at |
193 * once. Attempts to start collecting several profiles with the same | 193 * once. Attempts to start collecting several profiles with the same |
194 * title are silently ignored. While collecting a profile, functions | 194 * title are silently ignored. While collecting a profile, functions |
195 * from all security contexts are included in it. The token-based | 195 * from all security contexts are included in it. The token-based |
196 * filtering is only performed when querying for a profile. | 196 * filtering is only performed when querying for a profile. |
197 * | 197 * |
198 * |record_samples| parameter controls whether individual samples should | 198 * |record_samples| parameter controls whether individual samples should |
199 * be recorded in addition to the aggregated tree. | 199 * be recorded in addition to the aggregated tree. |
200 */ | 200 */ |
201 void StartProfiling(Handle<String> title, bool record_samples = false); | 201 void StartProfiling(Local<String> title, bool record_samples = false); |
202 | 202 |
203 /** | 203 /** |
204 * Stops collecting CPU profile with a given title and returns it. | 204 * Stops collecting CPU profile with a given title and returns it. |
205 * If the title given is empty, finishes the last profile started. | 205 * If the title given is empty, finishes the last profile started. |
206 */ | 206 */ |
207 CpuProfile* StopProfiling(Handle<String> title); | 207 CpuProfile* StopProfiling(Local<String> title); |
208 | 208 |
209 /** | 209 /** |
210 * Tells the profiler whether the embedder is idle. | 210 * Tells the profiler whether the embedder is idle. |
211 */ | 211 */ |
212 void SetIdle(bool is_idle); | 212 void SetIdle(bool is_idle); |
213 | 213 |
214 private: | 214 private: |
215 CpuProfiler(); | 215 CpuProfiler(); |
216 ~CpuProfiler(); | 216 ~CpuProfiler(); |
217 CpuProfiler(const CpuProfiler&); | 217 CpuProfiler(const CpuProfiler&); |
(...skipping 21 matching lines...) Expand all Loading... |
239 kWeak = 6 // A weak reference (ignored by the GC). | 239 kWeak = 6 // A weak reference (ignored by the GC). |
240 }; | 240 }; |
241 | 241 |
242 /** Returns edge type (see HeapGraphEdge::Type). */ | 242 /** Returns edge type (see HeapGraphEdge::Type). */ |
243 Type GetType() const; | 243 Type GetType() const; |
244 | 244 |
245 /** | 245 /** |
246 * Returns edge name. This can be a variable name, an element index, or | 246 * Returns edge name. This can be a variable name, an element index, or |
247 * a property name. | 247 * a property name. |
248 */ | 248 */ |
249 Handle<Value> GetName() const; | 249 Local<Value> GetName() const; |
250 | 250 |
251 /** Returns origin node. */ | 251 /** Returns origin node. */ |
252 const HeapGraphNode* GetFromNode() const; | 252 const HeapGraphNode* GetFromNode() const; |
253 | 253 |
254 /** Returns destination node. */ | 254 /** Returns destination node. */ |
255 const HeapGraphNode* GetToNode() const; | 255 const HeapGraphNode* GetToNode() const; |
256 }; | 256 }; |
257 | 257 |
258 | 258 |
259 /** | 259 /** |
(...skipping 20 matching lines...) Expand all Loading... |
280 }; | 280 }; |
281 | 281 |
282 /** Returns node type (see HeapGraphNode::Type). */ | 282 /** Returns node type (see HeapGraphNode::Type). */ |
283 Type GetType() const; | 283 Type GetType() const; |
284 | 284 |
285 /** | 285 /** |
286 * Returns node name. Depending on node's type this can be the name | 286 * Returns node name. Depending on node's type this can be the name |
287 * of the constructor (for objects), the name of the function (for | 287 * of the constructor (for objects), the name of the function (for |
288 * closures), string value, or an empty string (for compiled code). | 288 * closures), string value, or an empty string (for compiled code). |
289 */ | 289 */ |
290 Handle<String> GetName() const; | 290 Local<String> GetName() const; |
291 | 291 |
292 /** | 292 /** |
293 * Returns node id. For the same heap object, the id remains the same | 293 * Returns node id. For the same heap object, the id remains the same |
294 * across all snapshots. | 294 * across all snapshots. |
295 */ | 295 */ |
296 SnapshotObjectId GetId() const; | 296 SnapshotObjectId GetId() const; |
297 | 297 |
298 /** Returns node's own size, in bytes. */ | 298 /** Returns node's own size, in bytes. */ |
299 size_t GetShallowSize() const; | 299 size_t GetShallowSize() const; |
300 | 300 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 * profiler can be retrieved using v8::Isolate::GetHeapProfiler. | 423 * profiler can be retrieved using v8::Isolate::GetHeapProfiler. |
424 */ | 424 */ |
425 class V8_EXPORT HeapProfiler { | 425 class V8_EXPORT HeapProfiler { |
426 public: | 426 public: |
427 /** | 427 /** |
428 * Callback function invoked for obtaining RetainedObjectInfo for | 428 * Callback function invoked for obtaining RetainedObjectInfo for |
429 * the given JavaScript wrapper object. It is prohibited to enter V8 | 429 * the given JavaScript wrapper object. It is prohibited to enter V8 |
430 * while the callback is running: only getters on the handle and | 430 * while the callback is running: only getters on the handle and |
431 * GetPointerFromInternalField on the objects are allowed. | 431 * GetPointerFromInternalField on the objects are allowed. |
432 */ | 432 */ |
433 typedef RetainedObjectInfo* (*WrapperInfoCallback) | 433 typedef RetainedObjectInfo* (*WrapperInfoCallback)(uint16_t class_id, |
434 (uint16_t class_id, Handle<Value> wrapper); | 434 Local<Value> wrapper); |
435 | 435 |
436 /** Returns the number of snapshots taken. */ | 436 /** Returns the number of snapshots taken. */ |
437 int GetSnapshotCount(); | 437 int GetSnapshotCount(); |
438 | 438 |
439 /** Returns a snapshot by index. */ | 439 /** Returns a snapshot by index. */ |
440 const HeapSnapshot* GetHeapSnapshot(int index); | 440 const HeapSnapshot* GetHeapSnapshot(int index); |
441 | 441 |
442 /** | 442 /** |
443 * Returns SnapshotObjectId for a heap object referenced by |value| if | 443 * Returns SnapshotObjectId for a heap object referenced by |value| if |
444 * it has been seen by the heap profiler, kUnknownObjectId otherwise. | 444 * it has been seen by the heap profiler, kUnknownObjectId otherwise. |
445 */ | 445 */ |
446 SnapshotObjectId GetObjectId(Handle<Value> value); | 446 SnapshotObjectId GetObjectId(Local<Value> value); |
447 | 447 |
448 /** | 448 /** |
449 * Returns heap object with given SnapshotObjectId if the object is alive, | 449 * Returns heap object with given SnapshotObjectId if the object is alive, |
450 * otherwise empty handle is returned. | 450 * otherwise empty handle is returned. |
451 */ | 451 */ |
452 Handle<Value> FindObjectById(SnapshotObjectId id); | 452 Local<Value> FindObjectById(SnapshotObjectId id); |
453 | 453 |
454 /** | 454 /** |
455 * Clears internal map from SnapshotObjectId to heap object. The new objects | 455 * Clears internal map from SnapshotObjectId to heap object. The new objects |
456 * will not be added into it unless a heap snapshot is taken or heap object | 456 * will not be added into it unless a heap snapshot is taken or heap object |
457 * tracking is kicked off. | 457 * tracking is kicked off. |
458 */ | 458 */ |
459 void ClearObjectIds(); | 459 void ClearObjectIds(); |
460 | 460 |
461 /** | 461 /** |
462 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return | 462 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return |
463 * it in case heap profiler cannot find id for the object passed as | 463 * it in case heap profiler cannot find id for the object passed as |
464 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. | 464 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. |
465 */ | 465 */ |
466 static const SnapshotObjectId kUnknownObjectId = 0; | 466 static const SnapshotObjectId kUnknownObjectId = 0; |
467 | 467 |
468 /** | 468 /** |
469 * Callback interface for retrieving user friendly names of global objects. | 469 * Callback interface for retrieving user friendly names of global objects. |
470 */ | 470 */ |
471 class ObjectNameResolver { | 471 class ObjectNameResolver { |
472 public: | 472 public: |
473 /** | 473 /** |
474 * Returns name to be used in the heap snapshot for given node. Returned | 474 * Returns name to be used in the heap snapshot for given node. Returned |
475 * string must stay alive until snapshot collection is completed. | 475 * string must stay alive until snapshot collection is completed. |
476 */ | 476 */ |
477 virtual const char* GetName(Handle<Object> object) = 0; | 477 virtual const char* GetName(Local<Object> object) = 0; |
| 478 |
478 protected: | 479 protected: |
479 virtual ~ObjectNameResolver() {} | 480 virtual ~ObjectNameResolver() {} |
480 }; | 481 }; |
481 | 482 |
482 /** | 483 /** |
483 * Takes a heap snapshot and returns it. | 484 * Takes a heap snapshot and returns it. |
484 */ | 485 */ |
485 const HeapSnapshot* TakeHeapSnapshot( | 486 const HeapSnapshot* TakeHeapSnapshot( |
486 ActivityControl* control = NULL, | 487 ActivityControl* control = NULL, |
487 ObjectNameResolver* global_object_name_resolver = NULL); | 488 ObjectNameResolver* global_object_name_resolver = NULL); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 uint32_t index; // Index of the time interval that was changed. | 639 uint32_t index; // Index of the time interval that was changed. |
639 uint32_t count; // New value of count field for the interval with this index. | 640 uint32_t count; // New value of count field for the interval with this index. |
640 uint32_t size; // New value of size field for the interval with this index. | 641 uint32_t size; // New value of size field for the interval with this index. |
641 }; | 642 }; |
642 | 643 |
643 | 644 |
644 } // namespace v8 | 645 } // namespace v8 |
645 | 646 |
646 | 647 |
647 #endif // V8_V8_PROFILER_H_ | 648 #endif // V8_V8_PROFILER_H_ |
OLD | NEW |