| 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 12 matching lines...) Expand all  Loading... | 
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 27 | 27 | 
| 28 #ifndef V8_V8_PROFILER_H_ | 28 #ifndef V8_V8_PROFILER_H_ | 
| 29 #define V8_V8_PROFILER_H_ | 29 #define V8_V8_PROFILER_H_ | 
| 30 | 30 | 
| 31 #include "v8.h" | 31 #include "v8.h" | 
| 32 | 32 | 
| 33 #ifdef _WIN32 |  | 
| 34 // Setup for Windows DLL export/import. See v8.h in this directory for |  | 
| 35 // information on how to build/use V8 as a DLL. |  | 
| 36 #if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) |  | 
| 37 #error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\ |  | 
| 38   build configuration to ensure that at most one of these is set |  | 
| 39 #endif |  | 
| 40 |  | 
| 41 #ifdef BUILDING_V8_SHARED |  | 
| 42 #define V8EXPORT __declspec(dllexport) |  | 
| 43 #elif USING_V8_SHARED |  | 
| 44 #define V8EXPORT __declspec(dllimport) |  | 
| 45 #else |  | 
| 46 #define V8EXPORT |  | 
| 47 #endif |  | 
| 48 |  | 
| 49 #else  // _WIN32 |  | 
| 50 |  | 
| 51 // Setup for Linux shared library export. See v8.h in this directory for |  | 
| 52 // information on how to build/use V8 as shared library. |  | 
| 53 #if defined(__GNUC__) && ((__GNUC__ >= 4) || \ |  | 
| 54     (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED) |  | 
| 55 #define V8EXPORT __attribute__ ((visibility("default"))) |  | 
| 56 #else |  | 
| 57 #define V8EXPORT |  | 
| 58 #endif |  | 
| 59 |  | 
| 60 #endif  // _WIN32 |  | 
| 61 |  | 
| 62 |  | 
| 63 /** | 33 /** | 
| 64  * Profiler support for the V8 JavaScript engine. | 34  * Profiler support for the V8 JavaScript engine. | 
| 65  */ | 35  */ | 
| 66 namespace v8 { | 36 namespace v8 { | 
| 67 | 37 | 
| 68 typedef uint32_t SnapshotObjectId; | 38 typedef uint32_t SnapshotObjectId; | 
| 69 | 39 | 
| 70 /** | 40 /** | 
| 71  * CpuProfileNode represents a node in a call graph. | 41  * CpuProfileNode represents a node in a call graph. | 
| 72  */ | 42  */ | 
| 73 class V8EXPORT CpuProfileNode { | 43 class V8_EXPORT CpuProfileNode { | 
| 74  public: | 44  public: | 
| 75   /** Returns function name (empty string for anonymous functions.) */ | 45   /** Returns function name (empty string for anonymous functions.) */ | 
| 76   Handle<String> GetFunctionName() const; | 46   Handle<String> GetFunctionName() const; | 
| 77 | 47 | 
| 78   /** Returns id of the script where function is located. */ | 48   /** Returns id of the script where function is located. */ | 
| 79   int GetScriptId() const; | 49   int GetScriptId() const; | 
| 80 | 50 | 
| 81   /** Returns resource name for script from where the function originates. */ | 51   /** Returns resource name for script from where the function originates. */ | 
| 82   Handle<String> GetScriptResourceName() const; | 52   Handle<String> GetScriptResourceName() const; | 
| 83 | 53 | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 118   const CpuProfileNode* GetChild(int index) const; | 88   const CpuProfileNode* GetChild(int index) const; | 
| 119 | 89 | 
| 120   static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; | 90   static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; | 
| 121 }; | 91 }; | 
| 122 | 92 | 
| 123 | 93 | 
| 124 /** | 94 /** | 
| 125  * CpuProfile contains a CPU profile in a form of top-down call tree | 95  * CpuProfile contains a CPU profile in a form of top-down call tree | 
| 126  * (from main() down to functions that do all the work). | 96  * (from main() down to functions that do all the work). | 
| 127  */ | 97  */ | 
| 128 class V8EXPORT CpuProfile { | 98 class V8_EXPORT CpuProfile { | 
| 129  public: | 99  public: | 
| 130   /** Returns CPU profile UID (assigned by the profiler.) */ | 100   /** Returns CPU profile UID (assigned by the profiler.) */ | 
| 131   unsigned GetUid() const; | 101   unsigned GetUid() const; | 
| 132 | 102 | 
| 133   /** Returns CPU profile title. */ | 103   /** Returns CPU profile title. */ | 
| 134   Handle<String> GetTitle() const; | 104   Handle<String> GetTitle() const; | 
| 135 | 105 | 
| 136   /** Returns the root node of the top down call tree. */ | 106   /** Returns the root node of the top down call tree. */ | 
| 137   const CpuProfileNode* GetTopDownRoot() const; | 107   const CpuProfileNode* GetTopDownRoot() const; | 
| 138 | 108 | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 169    * to call Delete on these profiles. | 139    * to call Delete on these profiles. | 
| 170    */ | 140    */ | 
| 171   void Delete(); | 141   void Delete(); | 
| 172 }; | 142 }; | 
| 173 | 143 | 
| 174 | 144 | 
| 175 /** | 145 /** | 
| 176  * Interface for controlling CPU profiling. Instance of the | 146  * Interface for controlling CPU profiling. Instance of the | 
| 177  * profiler can be retrieved using v8::Isolate::GetCpuProfiler. | 147  * profiler can be retrieved using v8::Isolate::GetCpuProfiler. | 
| 178  */ | 148  */ | 
| 179 class V8EXPORT CpuProfiler { | 149 class V8_EXPORT CpuProfiler { | 
| 180  public: | 150  public: | 
| 181   /** | 151   /** | 
| 182    * A note on security tokens usage. As scripts from different | 152    * A note on security tokens usage. As scripts from different | 
| 183    * origins can run inside a single V8 instance, it is possible to | 153    * origins can run inside a single V8 instance, it is possible to | 
| 184    * have functions from different security contexts intermixed in a | 154    * have functions from different security contexts intermixed in a | 
| 185    * single CPU profile. To avoid exposing function names belonging to | 155    * single CPU profile. To avoid exposing function names belonging to | 
| 186    * other contexts, filtering by security token is performed while | 156    * other contexts, filtering by security token is performed while | 
| 187    * obtaining profiling results. | 157    * obtaining profiling results. | 
| 188    */ | 158    */ | 
| 189 | 159 | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 230 }; | 200 }; | 
| 231 | 201 | 
| 232 | 202 | 
| 233 class HeapGraphNode; | 203 class HeapGraphNode; | 
| 234 | 204 | 
| 235 | 205 | 
| 236 /** | 206 /** | 
| 237  * HeapSnapshotEdge represents a directed connection between heap | 207  * HeapSnapshotEdge represents a directed connection between heap | 
| 238  * graph nodes: from retainers to retained nodes. | 208  * graph nodes: from retainers to retained nodes. | 
| 239  */ | 209  */ | 
| 240 class V8EXPORT HeapGraphEdge { | 210 class V8_EXPORT HeapGraphEdge { | 
| 241  public: | 211  public: | 
| 242   enum Type { | 212   enum Type { | 
| 243     kContextVariable = 0,  // A variable from a function context. | 213     kContextVariable = 0,  // A variable from a function context. | 
| 244     kElement = 1,          // An element of an array. | 214     kElement = 1,          // An element of an array. | 
| 245     kProperty = 2,         // A named object property. | 215     kProperty = 2,         // A named object property. | 
| 246     kInternal = 3,         // A link that can't be accessed from JS, | 216     kInternal = 3,         // A link that can't be accessed from JS, | 
| 247                            // thus, its name isn't a real property name | 217                            // thus, its name isn't a real property name | 
| 248                            // (e.g. parts of a ConsString). | 218                            // (e.g. parts of a ConsString). | 
| 249     kHidden = 4,           // A link that is needed for proper sizes | 219     kHidden = 4,           // A link that is needed for proper sizes | 
| 250                            // calculation, but may be hidden from user. | 220                            // calculation, but may be hidden from user. | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 266   const HeapGraphNode* GetFromNode() const; | 236   const HeapGraphNode* GetFromNode() const; | 
| 267 | 237 | 
| 268   /** Returns destination node. */ | 238   /** Returns destination node. */ | 
| 269   const HeapGraphNode* GetToNode() const; | 239   const HeapGraphNode* GetToNode() const; | 
| 270 }; | 240 }; | 
| 271 | 241 | 
| 272 | 242 | 
| 273 /** | 243 /** | 
| 274  * HeapGraphNode represents a node in a heap graph. | 244  * HeapGraphNode represents a node in a heap graph. | 
| 275  */ | 245  */ | 
| 276 class V8EXPORT HeapGraphNode { | 246 class V8_EXPORT HeapGraphNode { | 
| 277  public: | 247  public: | 
| 278   enum Type { | 248   enum Type { | 
| 279     kHidden = 0,      // Hidden node, may be filtered when shown to user. | 249     kHidden = 0,      // Hidden node, may be filtered when shown to user. | 
| 280     kArray = 1,       // An array of elements. | 250     kArray = 1,       // An array of elements. | 
| 281     kString = 2,      // A string. | 251     kString = 2,      // A string. | 
| 282     kObject = 3,      // A JS object (except for arrays and strings). | 252     kObject = 3,      // A JS object (except for arrays and strings). | 
| 283     kCode = 4,        // Compiled code. | 253     kCode = 4,        // Compiled code. | 
| 284     kClosure = 5,     // Function closure. | 254     kClosure = 5,     // Function closure. | 
| 285     kRegExp = 6,      // RegExp. | 255     kRegExp = 6,      // RegExp. | 
| 286     kHeapNumber = 7,  // Number stored in the heap. | 256     kHeapNumber = 7,  // Number stored in the heap. | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 318    * Finds and returns a value from the heap corresponding to this node, | 288    * Finds and returns a value from the heap corresponding to this node, | 
| 319    * if the value is still reachable. | 289    * if the value is still reachable. | 
| 320    */ | 290    */ | 
| 321   Handle<Value> GetHeapValue() const; | 291   Handle<Value> GetHeapValue() const; | 
| 322 }; | 292 }; | 
| 323 | 293 | 
| 324 | 294 | 
| 325 /** | 295 /** | 
| 326  * HeapSnapshots record the state of the JS heap at some moment. | 296  * HeapSnapshots record the state of the JS heap at some moment. | 
| 327  */ | 297  */ | 
| 328 class V8EXPORT HeapSnapshot { | 298 class V8_EXPORT HeapSnapshot { | 
| 329  public: | 299  public: | 
| 330   enum SerializationFormat { | 300   enum SerializationFormat { | 
| 331     kJSON = 0  // See format description near 'Serialize' method. | 301     kJSON = 0  // See format description near 'Serialize' method. | 
| 332   }; | 302   }; | 
| 333 | 303 | 
| 334   /** Returns heap snapshot UID (assigned by the profiler.) */ | 304   /** Returns heap snapshot UID (assigned by the profiler.) */ | 
| 335   unsigned GetUid() const; | 305   unsigned GetUid() const; | 
| 336 | 306 | 
| 337   /** Returns heap snapshot title. */ | 307   /** Returns heap snapshot title. */ | 
| 338   Handle<String> GetTitle() const; | 308   Handle<String> GetTitle() const; | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 388   void Serialize(OutputStream* stream, SerializationFormat format) const; | 358   void Serialize(OutputStream* stream, SerializationFormat format) const; | 
| 389 }; | 359 }; | 
| 390 | 360 | 
| 391 | 361 | 
| 392 class RetainedObjectInfo; | 362 class RetainedObjectInfo; | 
| 393 | 363 | 
| 394 /** | 364 /** | 
| 395  * Interface for controlling heap profiling. Instance of the | 365  * Interface for controlling heap profiling. Instance of the | 
| 396  * profiler can be retrieved using v8::Isolate::GetHeapProfiler. | 366  * profiler can be retrieved using v8::Isolate::GetHeapProfiler. | 
| 397  */ | 367  */ | 
| 398 class V8EXPORT HeapProfiler { | 368 class V8_EXPORT HeapProfiler { | 
| 399  public: | 369  public: | 
| 400   /** | 370   /** | 
| 401    * Callback function invoked for obtaining RetainedObjectInfo for | 371    * Callback function invoked for obtaining RetainedObjectInfo for | 
| 402    * the given JavaScript wrapper object. It is prohibited to enter V8 | 372    * the given JavaScript wrapper object. It is prohibited to enter V8 | 
| 403    * while the callback is running: only getters on the handle and | 373    * while the callback is running: only getters on the handle and | 
| 404    * GetPointerFromInternalField on the objects are allowed. | 374    * GetPointerFromInternalField on the objects are allowed. | 
| 405    */ | 375    */ | 
| 406   typedef RetainedObjectInfo* (*WrapperInfoCallback) | 376   typedef RetainedObjectInfo* (*WrapperInfoCallback) | 
| 407       (uint16_t class_id, Handle<Value> wrapper); | 377       (uint16_t class_id, Handle<Value> wrapper); | 
| 408 | 378 | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 526  * objects for heap snapshots, he can do it in a GC prologue | 496  * objects for heap snapshots, he can do it in a GC prologue | 
| 527  * handler, and / or by assigning wrapper class ids in the following way: | 497  * handler, and / or by assigning wrapper class ids in the following way: | 
| 528  * | 498  * | 
| 529  *  1. Bind a callback to class id by calling SetWrapperClassInfoProvider. | 499  *  1. Bind a callback to class id by calling SetWrapperClassInfoProvider. | 
| 530  *  2. Call SetWrapperClassId on certain persistent handles. | 500  *  2. Call SetWrapperClassId on certain persistent handles. | 
| 531  * | 501  * | 
| 532  * V8 takes ownership of RetainedObjectInfo instances passed to it and | 502  * V8 takes ownership of RetainedObjectInfo instances passed to it and | 
| 533  * keeps them alive only during snapshot collection. Afterwards, they | 503  * keeps them alive only during snapshot collection. Afterwards, they | 
| 534  * are freed by calling the Dispose class function. | 504  * are freed by calling the Dispose class function. | 
| 535  */ | 505  */ | 
| 536 class V8EXPORT RetainedObjectInfo {  // NOLINT | 506 class V8_EXPORT RetainedObjectInfo {  // NOLINT | 
| 537  public: | 507  public: | 
| 538   /** Called by V8 when it no longer needs an instance. */ | 508   /** Called by V8 when it no longer needs an instance. */ | 
| 539   virtual void Dispose() = 0; | 509   virtual void Dispose() = 0; | 
| 540 | 510 | 
| 541   /** Returns whether two instances are equivalent. */ | 511   /** Returns whether two instances are equivalent. */ | 
| 542   virtual bool IsEquivalent(RetainedObjectInfo* other) = 0; | 512   virtual bool IsEquivalent(RetainedObjectInfo* other) = 0; | 
| 543 | 513 | 
| 544   /** | 514   /** | 
| 545    * Returns hash value for the instance. Equivalent instances | 515    * Returns hash value for the instance. Equivalent instances | 
| 546    * must have the same hash value. | 516    * must have the same hash value. | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 592     : index(index), count(count), size(size) { } | 562     : index(index), count(count), size(size) { } | 
| 593   uint32_t index;  // Index of the time interval that was changed. | 563   uint32_t index;  // Index of the time interval that was changed. | 
| 594   uint32_t count;  // New value of count field for the interval with this index. | 564   uint32_t count;  // New value of count field for the interval with this index. | 
| 595   uint32_t size;  // New value of size field for the interval with this index. | 565   uint32_t size;  // New value of size field for the interval with this index. | 
| 596 }; | 566 }; | 
| 597 | 567 | 
| 598 | 568 | 
| 599 }  // namespace v8 | 569 }  // namespace v8 | 
| 600 | 570 | 
| 601 | 571 | 
| 602 #undef V8EXPORT |  | 
| 603 |  | 
| 604 |  | 
| 605 #endif  // V8_V8_PROFILER_H_ | 572 #endif  // V8_V8_PROFILER_H_ | 
| OLD | NEW | 
|---|