v8  3.14.5(node0.10.28)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
v8-profiler.h
Go to the documentation of this file.
1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27 
28 #ifndef V8_V8_PROFILER_H_
29 #define V8_V8_PROFILER_H_
30 
31 #include "v8.h"
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 
66 namespace v8 {
67 
68 typedef uint32_t SnapshotObjectId;
69 
74  public:
76  Handle<String> GetFunctionName() const;
77 
79  Handle<String> GetScriptResourceName() const;
80 
85  int GetLineNumber() const;
86 
91  double GetTotalTime() const;
92 
97  double GetSelfTime() const;
98 
100  double GetTotalSamplesCount() const;
101 
103  double GetSelfSamplesCount() const;
104 
106  unsigned GetCallUid() const;
107 
109  int GetChildrenCount() const;
110 
112  const CpuProfileNode* GetChild(int index) const;
113 
114  static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
115 };
116 
117 
124  public:
126  unsigned GetUid() const;
127 
129  Handle<String> GetTitle() const;
130 
132  const CpuProfileNode* GetBottomUpRoot() const;
133 
135  const CpuProfileNode* GetTopDownRoot() const;
136 
145  void Delete();
146 };
147 
148 
153  public:
167  static int GetProfilesCount();
168 
170  static const CpuProfile* GetProfile(
171  int index,
172  Handle<Value> security_token = Handle<Value>());
173 
175  static const CpuProfile* FindProfile(
176  unsigned uid,
177  Handle<Value> security_token = Handle<Value>());
178 
187  static void StartProfiling(Handle<String> title);
188 
193  static const CpuProfile* StopProfiling(
194  Handle<String> title,
195  Handle<Value> security_token = Handle<Value>());
196 
202  static void DeleteAllProfiles();
203 };
204 
205 
206 class HeapGraphNode;
207 
208 
214  public:
215  enum Type {
216  kContextVariable = 0, // A variable from a function context.
217  kElement = 1, // An element of an array.
218  kProperty = 2, // A named object property.
219  kInternal = 3, // A link that can't be accessed from JS,
220  // thus, its name isn't a real property name
221  // (e.g. parts of a ConsString).
222  kHidden = 4, // A link that is needed for proper sizes
223  // calculation, but may be hidden from user.
224  kShortcut = 5, // A link that must not be followed during
225  // sizes calculation.
226  kWeak = 6 // A weak reference (ignored by the GC).
227  };
228 
230  Type GetType() const;
231 
236  Handle<Value> GetName() const;
237 
239  const HeapGraphNode* GetFromNode() const;
240 
242  const HeapGraphNode* GetToNode() const;
243 };
244 
245 
250  public:
251  enum Type {
252  kHidden = 0, // Hidden node, may be filtered when shown to user.
253  kArray = 1, // An array of elements.
254  kString = 2, // A string.
255  kObject = 3, // A JS object (except for arrays and strings).
256  kCode = 4, // Compiled code.
257  kClosure = 5, // Function closure.
258  kRegExp = 6, // RegExp.
259  kHeapNumber = 7, // Number stored in the heap.
260  kNative = 8, // Native object (not from V8 heap).
261  kSynthetic = 9 // Synthetic object, usualy used for grouping
262  // snapshot items together.
263  };
264 
266  Type GetType() const;
267 
273  Handle<String> GetName() const;
274 
279  SnapshotObjectId GetId() const;
280 
282  int GetSelfSize() const;
283 
285  int GetChildrenCount() const;
286 
288  const HeapGraphEdge* GetChild(int index) const;
289 
294  Handle<Value> GetHeapValue() const;
295 };
296 
297 
302  public:
303  enum Type {
304  kFull = 0 // Heap snapshot with all instances and references.
305  };
307  kJSON = 0 // See format description near 'Serialize' method.
308  };
309 
311  Type GetType() const;
312 
314  unsigned GetUid() const;
315 
317  Handle<String> GetTitle() const;
318 
320  const HeapGraphNode* GetRoot() const;
321 
323  const HeapGraphNode* GetNodeById(SnapshotObjectId id) const;
324 
326  int GetNodesCount() const;
327 
329  const HeapGraphNode* GetNode(int index) const;
330 
332  SnapshotObjectId GetMaxSnapshotJSObjectId() const;
333 
339  void Delete();
340 
367  void Serialize(OutputStream* stream, SerializationFormat format) const;
368 };
369 
370 
371 class RetainedObjectInfo;
372 
377  public:
384  typedef RetainedObjectInfo* (*WrapperInfoCallback)
385  (uint16_t class_id, Handle<Value> wrapper);
386 
388  static int GetSnapshotsCount();
389 
391  static const HeapSnapshot* GetSnapshot(int index);
392 
394  static const HeapSnapshot* FindSnapshot(unsigned uid);
395 
400  static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
401 
407  static const SnapshotObjectId kUnknownObjectId = 0;
408 
413  static const HeapSnapshot* TakeSnapshot(
414  Handle<String> title,
416  ActivityControl* control = NULL);
417 
423  static void StartHeapObjectsTracking();
424 
437  static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
438 
444  static void StopHeapObjectsTracking();
445 
450  static void DeleteAllSnapshots();
451 
453  static void DefineWrapperClass(
454  uint16_t class_id,
455  WrapperInfoCallback callback);
456 
462  static const uint16_t kPersistentHandleNoClassId = 0;
463 
465  static int GetPersistentHandleCount();
466 
468  static size_t GetMemorySizeUsedByProfiler();
469 };
470 
471 
496 class V8EXPORT RetainedObjectInfo { // NOLINT
497  public:
499  virtual void Dispose() = 0;
500 
502  virtual bool IsEquivalent(RetainedObjectInfo* other) = 0;
503 
508  virtual intptr_t GetHash() = 0;
509 
514  virtual const char* GetLabel() = 0;
515 
525  virtual const char* GetGroupLabel() { return GetLabel(); }
526 
531  virtual intptr_t GetElementCount() { return -1; }
532 
534  virtual intptr_t GetSizeInBytes() { return -1; }
535 
536  protected:
538  virtual ~RetainedObjectInfo() {}
539 
540  private:
542  RetainedObjectInfo& operator=(const RetainedObjectInfo&);
543 };
544 
545 
551  HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
552  : index(index), count(count), size(size) { }
553  uint32_t index; // Index of the time interval that was changed.
554  uint32_t count; // New value of count field for the interval with this index.
555  uint32_t size; // New value of size field for the interval with this index.
556 };
557 
558 
559 } // namespace v8
560 
561 
562 #undef V8EXPORT
563 
564 
565 #endif // V8_V8_PROFILER_H_
unsigned short uint16_t
Definition: unicode.cc:46
static const int kNoLineNumberInfo
Definition: v8.h:753
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
Definition: v8-profiler.h:551
virtual ~RetainedObjectInfo()
Definition: v8-profiler.h:538
#define V8EXPORT
Definition: v8-profiler.h:57
uint32_t SnapshotObjectId
Definition: v8-profiler.h:68
virtual intptr_t GetElementCount()
Definition: v8-profiler.h:531
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
virtual intptr_t GetSizeInBytes()
Definition: v8-profiler.h:534
virtual const char * GetGroupLabel()
Definition: v8-profiler.h:525