| 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 |
| 33 /** | 63 /** |
| 34 * Profiler support for the V8 JavaScript engine. | 64 * Profiler support for the V8 JavaScript engine. |
| 35 */ | 65 */ |
| 36 namespace v8 { | 66 namespace v8 { |
| 37 | 67 |
| 38 typedef uint32_t SnapshotObjectId; | 68 typedef uint32_t SnapshotObjectId; |
| 39 | 69 |
| 40 /** | 70 /** |
| 41 * CpuProfileNode represents a node in a call graph. | 71 * CpuProfileNode represents a node in a call graph. |
| 42 */ | 72 */ |
| 43 class V8_EXPORT CpuProfileNode { | 73 class V8EXPORT CpuProfileNode { |
| 44 public: | 74 public: |
| 45 /** Returns function name (empty string for anonymous functions.) */ | 75 /** Returns function name (empty string for anonymous functions.) */ |
| 46 Handle<String> GetFunctionName() const; | 76 Handle<String> GetFunctionName() const; |
| 47 | 77 |
| 48 /** Returns id of the script where function is located. */ | 78 /** Returns id of the script where function is located. */ |
| 49 int GetScriptId() const; | 79 int GetScriptId() const; |
| 50 | 80 |
| 51 /** Returns resource name for script from where the function originates. */ | 81 /** Returns resource name for script from where the function originates. */ |
| 52 Handle<String> GetScriptResourceName() const; | 82 Handle<String> GetScriptResourceName() const; |
| 53 | 83 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 const CpuProfileNode* GetChild(int index) const; | 118 const CpuProfileNode* GetChild(int index) const; |
| 89 | 119 |
| 90 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; | 120 static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; |
| 91 }; | 121 }; |
| 92 | 122 |
| 93 | 123 |
| 94 /** | 124 /** |
| 95 * CpuProfile contains a CPU profile in a form of top-down call tree | 125 * CpuProfile contains a CPU profile in a form of top-down call tree |
| 96 * (from main() down to functions that do all the work). | 126 * (from main() down to functions that do all the work). |
| 97 */ | 127 */ |
| 98 class V8_EXPORT CpuProfile { | 128 class V8EXPORT CpuProfile { |
| 99 public: | 129 public: |
| 100 /** Returns CPU profile UID (assigned by the profiler.) */ | 130 /** Returns CPU profile UID (assigned by the profiler.) */ |
| 101 unsigned GetUid() const; | 131 unsigned GetUid() const; |
| 102 | 132 |
| 103 /** Returns CPU profile title. */ | 133 /** Returns CPU profile title. */ |
| 104 Handle<String> GetTitle() const; | 134 Handle<String> GetTitle() const; |
| 105 | 135 |
| 106 /** Returns the root node of the top down call tree. */ | 136 /** Returns the root node of the top down call tree. */ |
| 107 const CpuProfileNode* GetTopDownRoot() const; | 137 const CpuProfileNode* GetTopDownRoot() const; |
| 108 | 138 |
| 109 /** | 139 /** |
| 110 * Returns number of samples recorded. The samples are not recorded unless | 140 * Returns number of samples recorded. The samples are not recorded unless |
| 111 * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true. | 141 * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true. |
| 112 */ | 142 */ |
| 113 int GetSamplesCount() const; | 143 int GetSamplesCount() const; |
| 114 | 144 |
| 115 /** | 145 /** |
| 116 * Returns profile node corresponding to the top frame the sample at | 146 * Returns profile node corresponding to the top frame the sample at |
| 117 * the given index. | 147 * the given index. |
| 118 */ | 148 */ |
| 119 const CpuProfileNode* GetSample(int index) const; | 149 const CpuProfileNode* GetSample(int index) const; |
| 120 | 150 |
| 121 /** | 151 /** |
| 122 * Returns time when the profile recording started (in microseconds | |
| 123 * since the Epoch). | |
| 124 */ | |
| 125 int64_t GetStartTime() const; | |
| 126 | |
| 127 /** | |
| 128 * Returns time when the profile recording was stopped (in microseconds | |
| 129 * since the Epoch). | |
| 130 */ | |
| 131 int64_t GetEndTime() const; | |
| 132 | |
| 133 /** | |
| 134 * Deletes the profile and removes it from CpuProfiler's list. | 152 * Deletes the profile and removes it from CpuProfiler's list. |
| 135 * All pointers to nodes previously returned become invalid. | 153 * All pointers to nodes previously returned become invalid. |
| 136 * Profiles with the same uid but obtained using different | 154 * Profiles with the same uid but obtained using different |
| 137 * security token are not deleted, but become inaccessible | 155 * security token are not deleted, but become inaccessible |
| 138 * using FindProfile method. It is embedder's responsibility | 156 * using FindProfile method. It is embedder's responsibility |
| 139 * to call Delete on these profiles. | 157 * to call Delete on these profiles. |
| 140 */ | 158 */ |
| 141 void Delete(); | 159 void Delete(); |
| 142 }; | 160 }; |
| 143 | 161 |
| 144 | 162 |
| 145 /** | 163 /** |
| 146 * Interface for controlling CPU profiling. Instance of the | 164 * Interface for controlling CPU profiling. Instance of the |
| 147 * profiler can be retrieved using v8::Isolate::GetCpuProfiler. | 165 * profiler can be retrieved using v8::Isolate::GetCpuProfiler. |
| 148 */ | 166 */ |
| 149 class V8_EXPORT CpuProfiler { | 167 class V8EXPORT CpuProfiler { |
| 150 public: | 168 public: |
| 151 /** | 169 /** |
| 152 * A note on security tokens usage. As scripts from different | 170 * A note on security tokens usage. As scripts from different |
| 153 * origins can run inside a single V8 instance, it is possible to | 171 * origins can run inside a single V8 instance, it is possible to |
| 154 * have functions from different security contexts intermixed in a | 172 * have functions from different security contexts intermixed in a |
| 155 * single CPU profile. To avoid exposing function names belonging to | 173 * single CPU profile. To avoid exposing function names belonging to |
| 156 * other contexts, filtering by security token is performed while | 174 * other contexts, filtering by security token is performed while |
| 157 * obtaining profiling results. | 175 * obtaining profiling results. |
| 158 */ | 176 */ |
| 159 | 177 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 }; | 218 }; |
| 201 | 219 |
| 202 | 220 |
| 203 class HeapGraphNode; | 221 class HeapGraphNode; |
| 204 | 222 |
| 205 | 223 |
| 206 /** | 224 /** |
| 207 * HeapSnapshotEdge represents a directed connection between heap | 225 * HeapSnapshotEdge represents a directed connection between heap |
| 208 * graph nodes: from retainers to retained nodes. | 226 * graph nodes: from retainers to retained nodes. |
| 209 */ | 227 */ |
| 210 class V8_EXPORT HeapGraphEdge { | 228 class V8EXPORT HeapGraphEdge { |
| 211 public: | 229 public: |
| 212 enum Type { | 230 enum Type { |
| 213 kContextVariable = 0, // A variable from a function context. | 231 kContextVariable = 0, // A variable from a function context. |
| 214 kElement = 1, // An element of an array. | 232 kElement = 1, // An element of an array. |
| 215 kProperty = 2, // A named object property. | 233 kProperty = 2, // A named object property. |
| 216 kInternal = 3, // A link that can't be accessed from JS, | 234 kInternal = 3, // A link that can't be accessed from JS, |
| 217 // thus, its name isn't a real property name | 235 // thus, its name isn't a real property name |
| 218 // (e.g. parts of a ConsString). | 236 // (e.g. parts of a ConsString). |
| 219 kHidden = 4, // A link that is needed for proper sizes | 237 kHidden = 4, // A link that is needed for proper sizes |
| 220 // calculation, but may be hidden from user. | 238 // calculation, but may be hidden from user. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 236 const HeapGraphNode* GetFromNode() const; | 254 const HeapGraphNode* GetFromNode() const; |
| 237 | 255 |
| 238 /** Returns destination node. */ | 256 /** Returns destination node. */ |
| 239 const HeapGraphNode* GetToNode() const; | 257 const HeapGraphNode* GetToNode() const; |
| 240 }; | 258 }; |
| 241 | 259 |
| 242 | 260 |
| 243 /** | 261 /** |
| 244 * HeapGraphNode represents a node in a heap graph. | 262 * HeapGraphNode represents a node in a heap graph. |
| 245 */ | 263 */ |
| 246 class V8_EXPORT HeapGraphNode { | 264 class V8EXPORT HeapGraphNode { |
| 247 public: | 265 public: |
| 248 enum Type { | 266 enum Type { |
| 249 kHidden = 0, // Hidden node, may be filtered when shown to user. | 267 kHidden = 0, // Hidden node, may be filtered when shown to user. |
| 250 kArray = 1, // An array of elements. | 268 kArray = 1, // An array of elements. |
| 251 kString = 2, // A string. | 269 kString = 2, // A string. |
| 252 kObject = 3, // A JS object (except for arrays and strings). | 270 kObject = 3, // A JS object (except for arrays and strings). |
| 253 kCode = 4, // Compiled code. | 271 kCode = 4, // Compiled code. |
| 254 kClosure = 5, // Function closure. | 272 kClosure = 5, // Function closure. |
| 255 kRegExp = 6, // RegExp. | 273 kRegExp = 6, // RegExp. |
| 256 kHeapNumber = 7, // Number stored in the heap. | 274 kHeapNumber = 7, // Number stored in the heap. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 * Finds and returns a value from the heap corresponding to this node, | 306 * Finds and returns a value from the heap corresponding to this node, |
| 289 * if the value is still reachable. | 307 * if the value is still reachable. |
| 290 */ | 308 */ |
| 291 Handle<Value> GetHeapValue() const; | 309 Handle<Value> GetHeapValue() const; |
| 292 }; | 310 }; |
| 293 | 311 |
| 294 | 312 |
| 295 /** | 313 /** |
| 296 * HeapSnapshots record the state of the JS heap at some moment. | 314 * HeapSnapshots record the state of the JS heap at some moment. |
| 297 */ | 315 */ |
| 298 class V8_EXPORT HeapSnapshot { | 316 class V8EXPORT HeapSnapshot { |
| 299 public: | 317 public: |
| 300 enum SerializationFormat { | 318 enum SerializationFormat { |
| 301 kJSON = 0 // See format description near 'Serialize' method. | 319 kJSON = 0 // See format description near 'Serialize' method. |
| 302 }; | 320 }; |
| 303 | 321 |
| 304 /** Returns heap snapshot UID (assigned by the profiler.) */ | 322 /** Returns heap snapshot UID (assigned by the profiler.) */ |
| 305 unsigned GetUid() const; | 323 unsigned GetUid() const; |
| 306 | 324 |
| 307 /** Returns heap snapshot title. */ | 325 /** Returns heap snapshot title. */ |
| 308 Handle<String> GetTitle() const; | 326 Handle<String> GetTitle() const; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 void Serialize(OutputStream* stream, SerializationFormat format) const; | 376 void Serialize(OutputStream* stream, SerializationFormat format) const; |
| 359 }; | 377 }; |
| 360 | 378 |
| 361 | 379 |
| 362 class RetainedObjectInfo; | 380 class RetainedObjectInfo; |
| 363 | 381 |
| 364 /** | 382 /** |
| 365 * Interface for controlling heap profiling. Instance of the | 383 * Interface for controlling heap profiling. Instance of the |
| 366 * profiler can be retrieved using v8::Isolate::GetHeapProfiler. | 384 * profiler can be retrieved using v8::Isolate::GetHeapProfiler. |
| 367 */ | 385 */ |
| 368 class V8_EXPORT HeapProfiler { | 386 class V8EXPORT HeapProfiler { |
| 369 public: | 387 public: |
| 370 /** | 388 /** |
| 371 * Callback function invoked for obtaining RetainedObjectInfo for | 389 * Callback function invoked for obtaining RetainedObjectInfo for |
| 372 * the given JavaScript wrapper object. It is prohibited to enter V8 | 390 * the given JavaScript wrapper object. It is prohibited to enter V8 |
| 373 * while the callback is running: only getters on the handle and | 391 * while the callback is running: only getters on the handle and |
| 374 * GetPointerFromInternalField on the objects are allowed. | 392 * GetPointerFromInternalField on the objects are allowed. |
| 375 */ | 393 */ |
| 376 typedef RetainedObjectInfo* (*WrapperInfoCallback) | 394 typedef RetainedObjectInfo* (*WrapperInfoCallback) |
| 377 (uint16_t class_id, Handle<Value> wrapper); | 395 (uint16_t class_id, Handle<Value> wrapper); |
| 378 | 396 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 * objects for heap snapshots, he can do it in a GC prologue | 514 * objects for heap snapshots, he can do it in a GC prologue |
| 497 * handler, and / or by assigning wrapper class ids in the following way: | 515 * handler, and / or by assigning wrapper class ids in the following way: |
| 498 * | 516 * |
| 499 * 1. Bind a callback to class id by calling SetWrapperClassInfoProvider. | 517 * 1. Bind a callback to class id by calling SetWrapperClassInfoProvider. |
| 500 * 2. Call SetWrapperClassId on certain persistent handles. | 518 * 2. Call SetWrapperClassId on certain persistent handles. |
| 501 * | 519 * |
| 502 * V8 takes ownership of RetainedObjectInfo instances passed to it and | 520 * V8 takes ownership of RetainedObjectInfo instances passed to it and |
| 503 * keeps them alive only during snapshot collection. Afterwards, they | 521 * keeps them alive only during snapshot collection. Afterwards, they |
| 504 * are freed by calling the Dispose class function. | 522 * are freed by calling the Dispose class function. |
| 505 */ | 523 */ |
| 506 class V8_EXPORT RetainedObjectInfo { // NOLINT | 524 class V8EXPORT RetainedObjectInfo { // NOLINT |
| 507 public: | 525 public: |
| 508 /** Called by V8 when it no longer needs an instance. */ | 526 /** Called by V8 when it no longer needs an instance. */ |
| 509 virtual void Dispose() = 0; | 527 virtual void Dispose() = 0; |
| 510 | 528 |
| 511 /** Returns whether two instances are equivalent. */ | 529 /** Returns whether two instances are equivalent. */ |
| 512 virtual bool IsEquivalent(RetainedObjectInfo* other) = 0; | 530 virtual bool IsEquivalent(RetainedObjectInfo* other) = 0; |
| 513 | 531 |
| 514 /** | 532 /** |
| 515 * Returns hash value for the instance. Equivalent instances | 533 * Returns hash value for the instance. Equivalent instances |
| 516 * must have the same hash value. | 534 * must have the same hash value. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 : index(index), count(count), size(size) { } | 580 : index(index), count(count), size(size) { } |
| 563 uint32_t index; // Index of the time interval that was changed. | 581 uint32_t index; // Index of the time interval that was changed. |
| 564 uint32_t count; // New value of count field for the interval with this index. | 582 uint32_t count; // New value of count field for the interval with this index. |
| 565 uint32_t size; // New value of size field for the interval with this index. | 583 uint32_t size; // New value of size field for the interval with this index. |
| 566 }; | 584 }; |
| 567 | 585 |
| 568 | 586 |
| 569 } // namespace v8 | 587 } // namespace v8 |
| 570 | 588 |
| 571 | 589 |
| 590 #undef V8EXPORT |
| 591 |
| 592 |
| 572 #endif // V8_V8_PROFILER_H_ | 593 #endif // V8_V8_PROFILER_H_ |
| OLD | NEW |