Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Side by Side Diff: include/v8-profiler.h

Issue 12475016: Maintain API compatibility with older versions of V8. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 /** Returns the count of samples where function exists. */ 99 /** Returns the count of samples where function exists. */
100 double GetTotalSamplesCount() const; 100 double GetTotalSamplesCount() const;
101 101
102 /** Returns the count of samples where function was currently executing. */ 102 /** Returns the count of samples where function was currently executing. */
103 double GetSelfSamplesCount() const; 103 double GetSelfSamplesCount() const;
104 104
105 /** Returns function entry UID. */ 105 /** Returns function entry UID. */
106 unsigned GetCallUid() const; 106 unsigned GetCallUid() const;
107 107
108 /** Returns id of the node. The id is unique within the tree */
109 unsigned GetNodeId() const;
110
111 /** Returns child nodes count of the node. */ 108 /** Returns child nodes count of the node. */
112 int GetChildrenCount() const; 109 int GetChildrenCount() const;
113 110
114 /** Retrieves a child node by index. */ 111 /** Retrieves a child node by index. */
115 const CpuProfileNode* GetChild(int index) const; 112 const CpuProfileNode* GetChild(int index) const;
116 113
117 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; 114 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
118 }; 115 };
119 116
120 117
121 /** 118 /**
122 * CpuProfile contains a CPU profile in a form of top-down call tree 119 * CpuProfile contains a CPU profile in a form of top-down call tree
123 * (from main() down to functions that do all the work). 120 * (from main() down to functions that do all the work).
124 */ 121 */
125 class V8EXPORT CpuProfile { 122 class V8EXPORT CpuProfile {
126 public: 123 public:
127 /** Returns CPU profile UID (assigned by the profiler.) */ 124 /** Returns CPU profile UID (assigned by the profiler.) */
128 unsigned GetUid() const; 125 unsigned GetUid() const;
129 126
130 /** Returns CPU profile title. */ 127 /** Returns CPU profile title. */
131 Handle<String> GetTitle() const; 128 Handle<String> GetTitle() const;
132 129
133 /** Returns the root node of the top down call tree. */ 130 /** Returns the root node of the top down call tree. */
134 const CpuProfileNode* GetTopDownRoot() const; 131 const CpuProfileNode* GetTopDownRoot() const;
135 132
136 /** 133 /**
137 * Returns number of samples recorded. The samples are not recorded unless
138 * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true.
139 */
140 int GetSamplesCount() const;
141
142 /**
143 * Returns profile node corresponding to the top frame the sample at
144 * the given index.
145 */
146 const CpuProfileNode* GetSample(int index) const;
147
148 /**
149 * Deletes the profile and removes it from CpuProfiler's list. 134 * Deletes the profile and removes it from CpuProfiler's list.
150 * All pointers to nodes previously returned become invalid. 135 * All pointers to nodes previously returned become invalid.
151 * Profiles with the same uid but obtained using different 136 * Profiles with the same uid but obtained using different
152 * security token are not deleted, but become inaccessible 137 * security token are not deleted, but become inaccessible
153 * using FindProfile method. It is embedder's responsibility 138 * using FindProfile method. It is embedder's responsibility
154 * to call Delete on these profiles. 139 * to call Delete on these profiles.
155 */ 140 */
156 void Delete(); 141 void Delete();
157 }; 142 };
158 143
159 144
160 /** 145 /**
161 * Interface for controlling CPU profiling. Instance of the 146 * Interface for controlling CPU profiling.
162 * profiler can be retrieved using v8::Isolate::GetCpuProfiler.
163 */ 147 */
164 class V8EXPORT CpuProfiler { 148 class V8EXPORT CpuProfiler {
165 public: 149 public:
166 /** 150 /**
167 * A note on security tokens usage. As scripts from different 151 * A note on security tokens usage. As scripts from different
168 * origins can run inside a single V8 instance, it is possible to 152 * origins can run inside a single V8 instance, it is possible to
169 * have functions from different security contexts intermixed in a 153 * have functions from different security contexts intermixed in a
170 * single CPU profile. To avoid exposing function names belonging to 154 * single CPU profile. To avoid exposing function names belonging to
171 * other contexts, filtering by security token is performed while 155 * other contexts, filtering by security token is performed while
172 * obtaining profiling results. 156 * obtaining profiling results.
173 */ 157 */
174 158
175 /** Deprecated. Use GetProfileCount instead. */
176 static int GetProfilesCount();
177 /** 159 /**
178 * Returns the number of profiles collected (doesn't include 160 * Returns the number of profiles collected (doesn't include
179 * profiles that are being collected at the moment of call.) 161 * profiles that are being collected at the moment of call.)
180 */ 162 */
181 int GetProfileCount(); 163 static int GetProfilesCount();
182 164
183 /** Deprecated. Use GetCpuProfile instead. */ 165 /** Returns a profile by index. */
184 static const CpuProfile* GetProfile( 166 static const CpuProfile* GetProfile(
185 int index, 167 int index,
186 Handle<Value> security_token = Handle<Value>()); 168 Handle<Value> security_token = Handle<Value>());
187 /** Returns a profile by index. */
188 const CpuProfile* GetCpuProfile(
189 int index,
190 Handle<Value> security_token = Handle<Value>());
191 169
192 /** Deprecated. Use FindProfile instead. */ 170 /** Returns a profile by uid. */
193 static const CpuProfile* FindProfile( 171 static const CpuProfile* FindProfile(
194 unsigned uid, 172 unsigned uid,
195 Handle<Value> security_token = Handle<Value>()); 173 Handle<Value> security_token = Handle<Value>());
196 /** Returns a profile by uid. */
197 const CpuProfile* FindCpuProfile(
198 unsigned uid,
199 Handle<Value> security_token = Handle<Value>());
200 174
201 /** Deprecated. Use StartCpuProfiling instead. */
202 static void StartProfiling(Handle<String> title, bool record_samples = false);
203 /** 175 /**
204 * Starts collecting CPU profile. Title may be an empty string. It 176 * Starts collecting CPU profile. Title may be an empty string. It
205 * is allowed to have several profiles being collected at 177 * is allowed to have several profiles being collected at
206 * once. Attempts to start collecting several profiles with the same 178 * once. Attempts to start collecting several profiles with the same
207 * title are silently ignored. While collecting a profile, functions 179 * title are silently ignored. While collecting a profile, functions
208 * from all security contexts are included in it. The token-based 180 * from all security contexts are included in it. The token-based
209 * filtering is only performed when querying for a profile. 181 * filtering is only performed when querying for a profile.
210 *
211 * |record_samples| parameter controls whether individual samples should
212 * be recorded in addition to the aggregated tree.
213 */ 182 */
214 void StartCpuProfiling(Handle<String> title, bool record_samples = false); 183 static void StartProfiling(Handle<String> title);
215 184
216 /** Deprecated. Use StopCpuProfiling instead. */
217 static const CpuProfile* StopProfiling(
218 Handle<String> title,
219 Handle<Value> security_token = Handle<Value>());
220 /** 185 /**
221 * Stops collecting CPU profile with a given title and returns it. 186 * Stops collecting CPU profile with a given title and returns it.
222 * If the title given is empty, finishes the last profile started. 187 * If the title given is empty, finishes the last profile started.
223 */ 188 */
224 const CpuProfile* StopCpuProfiling( 189 static const CpuProfile* StopProfiling(
225 Handle<String> title, 190 Handle<String> title,
226 Handle<Value> security_token = Handle<Value>()); 191 Handle<Value> security_token = Handle<Value>());
227 192
228 /** Deprecated. Use DeleteAllCpuProfiles instead. */
229 static void DeleteAllProfiles();
230 /** 193 /**
231 * Deletes all existing profiles, also cancelling all profiling 194 * Deletes all existing profiles, also cancelling all profiling
232 * activity. All previously returned pointers to profiles and their 195 * activity. All previously returned pointers to profiles and their
233 * contents become invalid after this call. 196 * contents become invalid after this call.
234 */ 197 */
235 void DeleteAllCpuProfiles(); 198 static void DeleteAllProfiles();
236
237 private:
238 CpuProfiler();
239 ~CpuProfiler();
240 CpuProfiler(const CpuProfiler&);
241 CpuProfiler& operator=(const CpuProfiler&);
242 }; 199 };
243 200
244 201
245 class HeapGraphNode; 202 class HeapGraphNode;
246 203
247 204
248 /** 205 /**
249 * HeapSnapshotEdge represents a directed connection between heap 206 * HeapSnapshotEdge represents a directed connection between heap
250 * graph nodes: from retainers to retained nodes. 207 * graph nodes: from retainers to retained nodes.
251 */ 208 */
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 */ 296 */
340 class V8EXPORT HeapSnapshot { 297 class V8EXPORT HeapSnapshot {
341 public: 298 public:
342 enum Type { 299 enum Type {
343 kFull = 0 // Heap snapshot with all instances and references. 300 kFull = 0 // Heap snapshot with all instances and references.
344 }; 301 };
345 enum SerializationFormat { 302 enum SerializationFormat {
346 kJSON = 0 // See format description near 'Serialize' method. 303 kJSON = 0 // See format description near 'Serialize' method.
347 }; 304 };
348 305
349 /** Deprecated. Returns kFull. */ 306 /** Returns heap snapshot type. */
350 V8_DEPRECATED(Type GetType() const); 307 Type GetType() const;
351 308
352 /** Returns heap snapshot UID (assigned by the profiler.) */ 309 /** Returns heap snapshot UID (assigned by the profiler.) */
353 unsigned GetUid() const; 310 unsigned GetUid() const;
354 311
355 /** Returns heap snapshot title. */ 312 /** Returns heap snapshot title. */
356 Handle<String> GetTitle() const; 313 Handle<String> GetTitle() const;
357 314
358 /** Returns the root node of the heap graph. */ 315 /** Returns the root node of the heap graph. */
359 const HeapGraphNode* GetRoot() const; 316 const HeapGraphNode* GetRoot() const;
360 317
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 * Nodes reference strings, other nodes, and edges by their indexes 360 * Nodes reference strings, other nodes, and edges by their indexes
404 * in corresponding arrays. 361 * in corresponding arrays.
405 */ 362 */
406 void Serialize(OutputStream* stream, SerializationFormat format) const; 363 void Serialize(OutputStream* stream, SerializationFormat format) const;
407 }; 364 };
408 365
409 366
410 class RetainedObjectInfo; 367 class RetainedObjectInfo;
411 368
412 /** 369 /**
413 * Interface for controlling heap profiling. Instance of the 370 * Interface for controlling heap profiling.
414 * profiler can be retrieved using v8::Isolate::GetHeapProfiler.
415 */ 371 */
416 class V8EXPORT HeapProfiler { 372 class V8EXPORT HeapProfiler {
417 public: 373 public:
418 /** 374 /**
419 * Callback function invoked for obtaining RetainedObjectInfo for 375 * Callback function invoked for obtaining RetainedObjectInfo for
420 * the given JavaScript wrapper object. It is prohibited to enter V8 376 * the given JavaScript wrapper object. It is prohibited to enter V8
421 * while the callback is running: only getters on the handle and 377 * while the callback is running: only getters on the handle and
422 * GetPointerFromInternalField on the objects are allowed. 378 * GetPointerFromInternalField on the objects are allowed.
423 */ 379 */
424 typedef RetainedObjectInfo* (*WrapperInfoCallback) 380 typedef RetainedObjectInfo* (*WrapperInfoCallback)
425 (uint16_t class_id, Handle<Value> wrapper); 381 (uint16_t class_id, Handle<Value> wrapper);
426 382
427 /** Deprecated. Use GetSnapshotCount instead. */ 383 /** Returns the number of snapshots taken. */
428 static int GetSnapshotsCount(); 384 static int GetSnapshotsCount();
429 /** Returns the number of snapshots taken. */
430 int GetSnapshotCount();
431 385
432 /** Deprecated. Use GetHeapSnapshot instead. */ 386 /** Returns a snapshot by index. */
433 static const HeapSnapshot* GetSnapshot(int index); 387 static const HeapSnapshot* GetSnapshot(int index);
434 /** Returns a snapshot by index. */
435 const HeapSnapshot* GetHeapSnapshot(int index);
436 388
437 /** Deprecated. Use FindHeapSnapshot instead. */ 389 /** Returns a profile by uid. */
438 static const HeapSnapshot* FindSnapshot(unsigned uid); 390 static const HeapSnapshot* FindSnapshot(unsigned uid);
439 /** Returns a profile by uid. */
440 const HeapSnapshot* FindHeapSnapshot(unsigned uid);
441 391
442 /** Deprecated. Use GetObjectId instead. */
443 static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
444 /** 392 /**
445 * Returns SnapshotObjectId for a heap object referenced by |value| if 393 * Returns SnapshotObjectId for a heap object referenced by |value| if
446 * it has been seen by the heap profiler, kUnknownObjectId otherwise. 394 * it has been seen by the heap profiler, kUnknownObjectId otherwise.
447 */ 395 */
448 SnapshotObjectId GetObjectId(Handle<Value> value); 396 static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
449 397
450 /** 398 /**
451 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return 399 * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return
452 * it in case heap profiler cannot find id for the object passed as 400 * it in case heap profiler cannot find id for the object passed as
453 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. 401 * parameter. HeapSnapshot::GetNodeById will always return NULL for such id.
454 */ 402 */
455 static const SnapshotObjectId kUnknownObjectId = 0; 403 static const SnapshotObjectId kUnknownObjectId = 0;
456 404
457 /** 405 /**
458 * Callback interface for retrieving user friendly names of global objects. 406 * Callback interface for retrieving user friendly names of global objects.
459 */ 407 */
460 class ObjectNameResolver { 408 class ObjectNameResolver {
461 public: 409 public:
462 /** 410 /**
463 * Returns name to be used in the heap snapshot for given node. Returned 411 * Returns name to be used in the heap snapshot for given node. Returned
464 * string must stay alive until snapshot collection is completed. 412 * string must stay alive until snapshot collection is completed.
465 */ 413 */
466 virtual const char* GetName(Handle<Object> object) = 0; 414 virtual const char* GetName(Handle<Object> object) = 0;
467 protected: 415 protected:
468 virtual ~ObjectNameResolver() {} 416 virtual ~ObjectNameResolver() {}
469 }; 417 };
470 418
471 /** Deprecated. Use TakeHeapSnapshot instead. */ 419 /**
420 * Takes a heap snapshot and returns it. Title may be an empty string.
421 * See HeapSnapshot::Type for types description.
422 */
472 static const HeapSnapshot* TakeSnapshot( 423 static const HeapSnapshot* TakeSnapshot(
473 Handle<String> title, 424 Handle<String> title,
474 HeapSnapshot::Type type = HeapSnapshot::kFull, 425 HeapSnapshot::Type type = HeapSnapshot::kFull,
475 ActivityControl* control = NULL, 426 ActivityControl* control = NULL,
476 ObjectNameResolver* global_object_name_resolver = NULL); 427 ObjectNameResolver* global_object_name_resolver = NULL);
477 /**
478 * Takes a heap snapshot and returns it. Title may be an empty string.
479 */
480 const HeapSnapshot* TakeHeapSnapshot(
481 Handle<String> title,
482 ActivityControl* control = NULL,
483 ObjectNameResolver* global_object_name_resolver = NULL);
484 428
485
486 /** Deprecated. Use StartTrackingHeapObjects instead. */
487 static void StartHeapObjectsTracking();
488 /** 429 /**
489 * Starts tracking of heap objects population statistics. After calling 430 * Starts tracking of heap objects population statistics. After calling
490 * this method, all heap objects relocations done by the garbage collector 431 * this method, all heap objects relocations done by the garbage collector
491 * are being registered. 432 * are being registered.
492 */ 433 */
493 void StartTrackingHeapObjects(); 434 static void StartHeapObjectsTracking();
494 435
495 /** Deprecated. Use GetHeapStats instead. */
496 static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
497 /** 436 /**
498 * Adds a new time interval entry to the aggregated statistics array. The 437 * Adds a new time interval entry to the aggregated statistics array. The
499 * time interval entry contains information on the current heap objects 438 * time interval entry contains information on the current heap objects
500 * population size. The method also updates aggregated statistics and 439 * population size. The method also updates aggregated statistics and
501 * reports updates for all previous time intervals via the OutputStream 440 * reports updates for all previous time intervals via the OutputStream
502 * object. Updates on each time interval are provided as a stream of the 441 * object. Updates on each time interval are provided as a stream of the
503 * HeapStatsUpdate structure instances. 442 * HeapStatsUpdate structure instances.
504 * The return value of the function is the last seen heap object Id. 443 * The return value of the function is the last seen heap object Id.
505 * 444 *
506 * StartTrackingHeapObjects must be called before the first call to this 445 * StartHeapObjectsTracking must be called before the first call to this
507 * method. 446 * method.
508 */ 447 */
509 SnapshotObjectId GetHeapStats(OutputStream* stream); 448 static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
510 449
511 /** Deprecated. Use StopTrackingHeapObjects instead. */
512 static void StopHeapObjectsTracking();
513 /** 450 /**
514 * Stops tracking of heap objects population statistics, cleans up all 451 * Stops tracking of heap objects population statistics, cleans up all
515 * collected data. StartHeapObjectsTracking must be called again prior to 452 * collected data. StartHeapObjectsTracking must be called again prior to
516 * calling PushHeapObjectsStats next time. 453 * calling PushHeapObjectsStats next time.
517 */ 454 */
518 void StopTrackingHeapObjects(); 455 static void StopHeapObjectsTracking();
519 456
520 /** Deprecated. Use DeleteAllHeapSnapshots instead. */
521 static void DeleteAllSnapshots();
522 /** 457 /**
523 * Deletes all snapshots taken. All previously returned pointers to 458 * Deletes all snapshots taken. All previously returned pointers to
524 * snapshots and their contents become invalid after this call. 459 * snapshots and their contents become invalid after this call.
525 */ 460 */
526 void DeleteAllHeapSnapshots(); 461 static void DeleteAllSnapshots();
527 462
528 /** Deprecated. Use SetWrapperClassInfoProvider instead. */ 463 /** Binds a callback to embedder's class ID. */
529 static void DefineWrapperClass( 464 static void DefineWrapperClass(
530 uint16_t class_id, 465 uint16_t class_id,
531 WrapperInfoCallback callback); 466 WrapperInfoCallback callback);
532 /** Binds a callback to embedder's class ID. */
533 void SetWrapperClassInfoProvider(
534 uint16_t class_id,
535 WrapperInfoCallback callback);
536 467
537 /** 468 /**
538 * Default value of persistent handle class ID. Must not be used to 469 * 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 470 * define a class. Can be used to reset a class of a persistent
540 * handle. 471 * handle.
541 */ 472 */
542 static const uint16_t kPersistentHandleNoClassId = 0; 473 static const uint16_t kPersistentHandleNoClassId = 0;
543 474
544 /** 475 /** Returns the number of currently existing persistent handles. */
545 * Deprecated. Returns the number of currently existing persistent handles.
546 */
547 static int GetPersistentHandleCount(); 476 static int GetPersistentHandleCount();
548 477
549 /** Deprecated. Use GetHeapProfilerMemorySize instead. */ 478 /** Returns memory used for profiler internal data and snapshots. */
550 static size_t GetMemorySizeUsedByProfiler(); 479 static size_t GetMemorySizeUsedByProfiler();
551 /** Returns memory used for profiler internal data and snapshots. */
552 size_t GetProfilerMemorySize();
553
554 private:
555 HeapProfiler();
556 ~HeapProfiler();
557 HeapProfiler(const HeapProfiler&);
558 HeapProfiler& operator=(const HeapProfiler&);
559 }; 480 };
560 481
561 482
562 /** 483 /**
563 * Interface for providing information about embedder's objects 484 * Interface for providing information about embedder's objects
564 * held by global handles. This information is reported in two ways: 485 * held by global handles. This information is reported in two ways:
565 * 486 *
566 * 1. When calling AddObjectGroup, an embedder may pass 487 * 1. When calling AddObjectGroup, an embedder may pass
567 * RetainedObjectInfo instance describing the group. To collect 488 * RetainedObjectInfo instance describing the group. To collect
568 * this information while taking a heap snapshot, V8 calls GC 489 * this information while taking a heap snapshot, V8 calls GC
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 virtual ~RetainedObjectInfo() {} 549 virtual ~RetainedObjectInfo() {}
629 550
630 private: 551 private:
631 RetainedObjectInfo(const RetainedObjectInfo&); 552 RetainedObjectInfo(const RetainedObjectInfo&);
632 RetainedObjectInfo& operator=(const RetainedObjectInfo&); 553 RetainedObjectInfo& operator=(const RetainedObjectInfo&);
633 }; 554 };
634 555
635 556
636 /** 557 /**
637 * A struct for exporting HeapStats data from V8, using "push" model. 558 * A struct for exporting HeapStats data from V8, using "push" model.
638 * See HeapProfiler::GetHeapStats. 559 * See HeapProfiler::PushHeapObjectsStats.
639 */ 560 */
640 struct HeapStatsUpdate { 561 struct HeapStatsUpdate {
641 HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size) 562 HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
642 : index(index), count(count), size(size) { } 563 : index(index), count(count), size(size) { }
643 uint32_t index; // Index of the time interval that was changed. 564 uint32_t index; // Index of the time interval that was changed.
644 uint32_t count; // New value of count field for the interval with this index. 565 uint32_t count; // New value of count field for the interval with this index.
645 uint32_t size; // New value of size field for the interval with this index. 566 uint32_t size; // New value of size field for the interval with this index.
646 }; 567 };
647 568
648 569
649 } // namespace v8 570 } // namespace v8
650 571
651 572
652 #undef V8EXPORT 573 #undef V8EXPORT
653 574
654 575
655 #endif // V8_V8_PROFILER_H_ 576 #endif // V8_V8_PROFILER_H_
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698