v8  3.11.10(node0.8.26)
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) && defined(V8_SHARED)
54 #define V8EXPORT __attribute__ ((visibility("default")))
55 #else // defined(__GNUC__) && (__GNUC__ >= 4)
56 #define V8EXPORT
57 #endif // defined(__GNUC__) && (__GNUC__ >= 4)
58 
59 #endif // _WIN32
60 
61 
65 namespace v8 {
66 
67 typedef uint32_t SnapshotObjectId;
68 
73  public:
75  Handle<String> GetFunctionName() const;
76 
78  Handle<String> GetScriptResourceName() const;
79 
84  int GetLineNumber() const;
85 
90  double GetTotalTime() const;
91 
96  double GetSelfTime() const;
97 
99  double GetTotalSamplesCount() const;
100 
102  double GetSelfSamplesCount() const;
103 
105  unsigned GetCallUid() const;
106 
108  int GetChildrenCount() const;
109 
111  const CpuProfileNode* GetChild(int index) const;
112 
113  static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
114 };
115 
116 
123  public:
125  unsigned GetUid() const;
126 
128  Handle<String> GetTitle() const;
129 
131  const CpuProfileNode* GetBottomUpRoot() const;
132 
134  const CpuProfileNode* GetTopDownRoot() const;
135 
144  void Delete();
145 };
146 
147 
152  public:
166  static int GetProfilesCount();
167 
169  static const CpuProfile* GetProfile(
170  int index,
171  Handle<Value> security_token = Handle<Value>());
172 
174  static const CpuProfile* FindProfile(
175  unsigned uid,
176  Handle<Value> security_token = Handle<Value>());
177 
186  static void StartProfiling(Handle<String> title);
187 
192  static const CpuProfile* StopProfiling(
193  Handle<String> title,
194  Handle<Value> security_token = Handle<Value>());
195 
201  static void DeleteAllProfiles();
202 };
203 
204 
205 class HeapGraphNode;
206 
207 
213  public:
214  enum Type {
215  kContextVariable = 0, // A variable from a function context.
216  kElement = 1, // An element of an array.
217  kProperty = 2, // A named object property.
218  kInternal = 3, // A link that can't be accessed from JS,
219  // thus, its name isn't a real property name
220  // (e.g. parts of a ConsString).
221  kHidden = 4, // A link that is needed for proper sizes
222  // calculation, but may be hidden from user.
223  kShortcut = 5, // A link that must not be followed during
224  // sizes calculation.
225  kWeak = 6 // A weak reference (ignored by the GC).
226  };
227 
229  Type GetType() const;
230 
235  Handle<Value> GetName() const;
236 
238  const HeapGraphNode* GetFromNode() const;
239 
241  const HeapGraphNode* GetToNode() const;
242 };
243 
244 
249  public:
250  enum Type {
251  kHidden = 0, // Hidden node, may be filtered when shown to user.
252  kArray = 1, // An array of elements.
253  kString = 2, // A string.
254  kObject = 3, // A JS object (except for arrays and strings).
255  kCode = 4, // Compiled code.
256  kClosure = 5, // Function closure.
257  kRegExp = 6, // RegExp.
258  kHeapNumber = 7, // Number stored in the heap.
259  kNative = 8, // Native object (not from V8 heap).
260  kSynthetic = 9 // Synthetic object, usualy used for grouping
261  // snapshot items together.
262  };
263 
265  Type GetType() const;
266 
272  Handle<String> GetName() const;
273 
278  SnapshotObjectId GetId() const;
279 
281  int GetSelfSize() const;
282 
289  int GetRetainedSize() const;
290 
292  int GetChildrenCount() const;
293 
295  const HeapGraphEdge* GetChild(int index) const;
296 
298  int GetRetainersCount() const;
299 
301  const HeapGraphEdge* GetRetainer(int index) const;
302 
307  const HeapGraphNode* GetDominatorNode() const;
308 
313  Handle<Value> GetHeapValue() const;
314 };
315 
316 
321  public:
322  enum Type {
323  kFull = 0 // Heap snapshot with all instances and references.
324  };
326  kJSON = 0 // See format description near 'Serialize' method.
327  };
328 
330  Type GetType() const;
331 
333  unsigned GetUid() const;
334 
336  Handle<String> GetTitle() const;
337 
339  const HeapGraphNode* GetRoot() const;
340 
342  const HeapGraphNode* GetNodeById(SnapshotObjectId id) const;
343 
345  int GetNodesCount() const;
346 
348  const HeapGraphNode* GetNode(int index) const;
349 
351  SnapshotObjectId GetMaxSnapshotJSObjectId() const;
352 
358  void Delete();
359 
386  void Serialize(OutputStream* stream, SerializationFormat format) const;
387 };
388 
389 
390 class RetainedObjectInfo;
391 
396  public:
403  typedef RetainedObjectInfo* (*WrapperInfoCallback)
404  (uint16_t class_id, Handle<Value> wrapper);
405 
407  static int GetSnapshotsCount();
408 
410  static const HeapSnapshot* GetSnapshot(int index);
411 
413  static const HeapSnapshot* FindSnapshot(unsigned uid);
414 
419  static SnapshotObjectId GetSnapshotObjectId(Handle<Value> value);
420 
426  static const SnapshotObjectId kUnknownObjectId = 0;
427 
432  static const HeapSnapshot* TakeSnapshot(
433  Handle<String> title,
435  ActivityControl* control = NULL);
436 
442  static void StartHeapObjectsTracking();
443 
456  static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
457 
463  static void StopHeapObjectsTracking();
464 
469  static void DeleteAllSnapshots();
470 
472  static void DefineWrapperClass(
473  uint16_t class_id,
474  WrapperInfoCallback callback);
475 
481  static const uint16_t kPersistentHandleNoClassId = 0;
482 
484  static int GetPersistentHandleCount();
485 
487  static size_t GetMemorySizeUsedByProfiler();
488 };
489 
490 
515 class V8EXPORT RetainedObjectInfo { // NOLINT
516  public:
518  virtual void Dispose() = 0;
519 
521  virtual bool IsEquivalent(RetainedObjectInfo* other) = 0;
522 
527  virtual intptr_t GetHash() = 0;
528 
533  virtual const char* GetLabel() = 0;
534 
544  virtual const char* GetGroupLabel() { return GetLabel(); }
545 
550  virtual intptr_t GetElementCount() { return -1; }
551 
553  virtual intptr_t GetSizeInBytes() { return -1; }
554 
555  protected:
557  virtual ~RetainedObjectInfo() {}
558 
559  private:
561  RetainedObjectInfo& operator=(const RetainedObjectInfo&);
562 };
563 
564 
570  HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
571  : index(index), count(count), size(size) { }
572  uint32_t index; // Index of the time interval that was changed.
573  uint32_t count; // New value of count field for the interval with this index.
574  uint32_t size; // New value of size field for the interval with this index.
575 };
576 
577 
578 } // namespace v8
579 
580 
581 #undef V8EXPORT
582 
583 
584 #endif // V8_V8_PROFILER_H_
unsigned short uint16_t
Definition: unicode.cc:46
static const int kNoLineNumberInfo
Definition: v8.h:747
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 trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt 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 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size)
Definition: v8-profiler.h:570
virtual ~RetainedObjectInfo()
Definition: v8-profiler.h:557
#define V8EXPORT
Definition: v8-profiler.h:56
uint32_t SnapshotObjectId
Definition: v8-profiler.h:67
virtual intptr_t GetElementCount()
Definition: v8-profiler.h:550
virtual intptr_t GetSizeInBytes()
Definition: v8-profiler.h:553
virtual const char * GetGroupLabel()
Definition: v8-profiler.h:544
FlagType type() const
Definition: flags.cc:1358