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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 /** | 177 /** |
178 * Stops collecting CPU profile with a given title and returns it. | 178 * Stops collecting CPU profile with a given title and returns it. |
179 * If the title given is empty, finishes the last profile started. | 179 * If the title given is empty, finishes the last profile started. |
180 */ | 180 */ |
181 static const CpuProfile* StopProfiling( | 181 static const CpuProfile* StopProfiling( |
182 Handle<String> title, | 182 Handle<String> title, |
183 Handle<Value> security_token = Handle<Value>()); | 183 Handle<Value> security_token = Handle<Value>()); |
184 }; | 184 }; |
185 | 185 |
186 | 186 |
| 187 class HeapGraphNode; |
| 188 |
| 189 |
| 190 /** |
| 191 * HeapSnapshotEdge represents a directed connection between heap |
| 192 * graph nodes: from retaners to retained nodes. |
| 193 */ |
| 194 class V8EXPORT HeapGraphEdge { |
| 195 public: |
| 196 enum Type { |
| 197 CONTEXT_VARIABLE = 0, // A variable from a function context. |
| 198 ELEMENT = 1, // An element of an array. |
| 199 PROPERTY = 2 // A named object property. |
| 200 }; |
| 201 |
| 202 /** Returns edge type (see HeapGraphEdge::Type). */ |
| 203 Type GetType() const; |
| 204 |
| 205 /** |
| 206 * Returns edge name. This can be a variable name, an element index, or |
| 207 * a property name. |
| 208 */ |
| 209 Handle<Value> GetName() const; |
| 210 |
| 211 /** Returns origin node. */ |
| 212 const HeapGraphNode* GetFromNode() const; |
| 213 |
| 214 /** Returns destination node. */ |
| 215 const HeapGraphNode* GetToNode() const; |
| 216 }; |
| 217 |
| 218 |
| 219 class V8EXPORT HeapGraphPath { |
| 220 public: |
| 221 /** Returns the number of edges in the path. */ |
| 222 int GetEdgesCount() const; |
| 223 |
| 224 /** Returns an edge from the path. */ |
| 225 const HeapGraphEdge* GetEdge(int index) const; |
| 226 |
| 227 /** Returns origin node. */ |
| 228 const HeapGraphNode* GetFromNode() const; |
| 229 |
| 230 /** Returns destination node. */ |
| 231 const HeapGraphNode* GetToNode() const; |
| 232 }; |
| 233 |
| 234 |
| 235 /** |
| 236 * HeapGraphNode represents a node in a heap graph. |
| 237 */ |
| 238 class V8EXPORT HeapGraphNode { |
| 239 public: |
| 240 enum Type { |
| 241 INTERNAL = 0, // Internal node, a virtual one, for housekeeping. |
| 242 ARRAY = 1, // An array of elements. |
| 243 STRING = 2, // A string. |
| 244 OBJECT = 3, // A JS object (except for arrays and strings). |
| 245 CODE = 4, // Compiled code. |
| 246 CLOSURE = 5 // Function closure. |
| 247 }; |
| 248 |
| 249 /** Returns node type (see HeapGraphNode::Type). */ |
| 250 Type GetType() const; |
| 251 |
| 252 /** |
| 253 * Returns node name. Depending on node's type this can be the name |
| 254 * of the constructor (for objects), the name of the function (for |
| 255 * closures), string value, or an empty string (for compiled code). |
| 256 */ |
| 257 Handle<String> GetName() const; |
| 258 |
| 259 /** Returns node's own size, in bytes. */ |
| 260 int GetSelfSize() const; |
| 261 |
| 262 /** Returns node's network (self + reachable nodes) size, in bytes. */ |
| 263 int GetTotalSize() const; |
| 264 |
| 265 /** |
| 266 * Returns node's private size, in bytes. That is, the size of memory |
| 267 * that will be reclaimed having this node collected. |
| 268 */ |
| 269 int GetPrivateSize() const; |
| 270 |
| 271 /** Returns child nodes count of the node. */ |
| 272 int GetChildrenCount() const; |
| 273 |
| 274 /** Retrieves a child by index. */ |
| 275 const HeapGraphEdge* GetChild(int index) const; |
| 276 |
| 277 /** Returns retainer nodes count of the node. */ |
| 278 int GetRetainersCount() const; |
| 279 |
| 280 /** Returns a retainer by index. */ |
| 281 const HeapGraphEdge* GetRetainer(int index) const; |
| 282 |
| 283 /** Returns the number of simple retaining paths from the root to the node. */ |
| 284 int GetRetainingPathsCount() const; |
| 285 |
| 286 /** Returns a retaining path by index. */ |
| 287 const HeapGraphPath* GetRetainingPath(int index) const; |
| 288 }; |
| 289 |
| 290 |
| 291 /** |
| 292 * HeapSnapshots record the state of the JS heap at some moment. |
| 293 */ |
| 294 class V8EXPORT HeapSnapshot { |
| 295 public: |
| 296 /** Returns heap snapshot UID (assigned by the profiler.) */ |
| 297 unsigned GetUid() const; |
| 298 |
| 299 /** Returns heap snapshot title. */ |
| 300 Handle<String> GetTitle() const; |
| 301 |
| 302 /** Returns the root node of the heap graph. */ |
| 303 const HeapGraphNode* GetHead() const; |
| 304 }; |
| 305 |
| 306 |
| 307 /** |
| 308 * Interface for controlling heap profiling. |
| 309 */ |
| 310 class V8EXPORT HeapProfiler { |
| 311 public: |
| 312 /** Returns the number of snapshots taken. */ |
| 313 static int GetSnapshotsCount(); |
| 314 |
| 315 /** Returns a snapshot by index. */ |
| 316 static const HeapSnapshot* GetSnapshot(int index); |
| 317 |
| 318 /** Returns a profile by uid. */ |
| 319 static const HeapSnapshot* FindSnapshot(unsigned uid); |
| 320 |
| 321 /** Takes a heap snapshot and returns it. Title may be an empty string. */ |
| 322 static const HeapSnapshot* TakeSnapshot(Handle<String> title); |
| 323 }; |
| 324 |
| 325 |
187 } // namespace v8 | 326 } // namespace v8 |
188 | 327 |
189 | 328 |
190 #undef V8EXPORT | 329 #undef V8EXPORT |
191 | 330 |
192 | 331 |
193 #endif // V8_V8_PROFILER_H_ | 332 #endif // V8_V8_PROFILER_H_ |
OLD | NEW |