V8 Project
v8::internal::StatisticsExtension Class Reference

#include <statistics-extension.h>

+ Inheritance diagram for v8::internal::StatisticsExtension:
+ Collaboration diagram for v8::internal::StatisticsExtension:

Public Member Functions

 StatisticsExtension ()
 
virtual v8::Handle< v8::FunctionTemplateGetNativeFunctionTemplate (v8::Isolate *isolate, v8::Handle< v8::String > name)
 
- Public Member Functions inherited from v8::Extension
 Extension (const char *name, const char *source=0, int dep_count=0, const char **deps=0, int source_length=-1)
 
virtual ~Extension ()
 
const char * name () const
 
size_t source_length () const
 
const String::ExternalOneByteStringResourcesource () const
 
int dependency_count ()
 
const char ** dependencies ()
 
void set_auto_enable (bool value)
 
bool auto_enable ()
 

Static Public Member Functions

static void GetCounters (const v8::FunctionCallbackInfo< v8::Value > &args)
 

Static Private Attributes

static const char *const kSource
 

Detailed Description

Definition at line 13 of file statistics-extension.h.

Constructor & Destructor Documentation

◆ StatisticsExtension()

v8::internal::StatisticsExtension::StatisticsExtension ( )
inline

Definition at line 15 of file statistics-extension.h.

15 : v8::Extension("v8/statistics", kSource) {}
Ignore.
Definition: v8.h:4008

Member Function Documentation

◆ GetCounters()

void v8::internal::StatisticsExtension::GetCounters ( const v8::FunctionCallbackInfo< v8::Value > &  args)
static

Definition at line 50 of file statistics-extension.cc.

51  {
52  Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate());
53  Heap* heap = isolate->heap();
54 
55  if (args.Length() > 0) { // GC if first argument evaluates to true.
56  if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) {
57  heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension");
58  }
59  }
60 
61  Counters* counters = isolate->counters();
63 
64 #define ADD_COUNTER(name, caption) \
65  AddCounter(args.GetIsolate(), result, counters->name(), #name);
66 
69 #undef ADD_COUNTER
70 #define ADD_COUNTER(name) \
71  AddCounter(args.GetIsolate(), result, counters->count_of_##name(), \
72  "count_of_" #name); \
73  AddCounter(args.GetIsolate(), result, counters->size_of_##name(), \
74  "size_of_" #name);
75 
77 #undef ADD_COUNTER
78 #define ADD_COUNTER(name) \
79  AddCounter(args.GetIsolate(), result, counters->count_of_CODE_TYPE_##name(), \
80  "count_of_CODE_TYPE_" #name); \
81  AddCounter(args.GetIsolate(), result, counters->size_of_CODE_TYPE_##name(), \
82  "size_of_CODE_TYPE_" #name);
83 
85 #undef ADD_COUNTER
86 #define ADD_COUNTER(name) \
87  AddCounter(args.GetIsolate(), result, \
88  counters->count_of_FIXED_ARRAY_##name(), \
89  "count_of_FIXED_ARRAY_" #name); \
90  AddCounter(args.GetIsolate(), result, \
91  counters->size_of_FIXED_ARRAY_##name(), \
92  "size_of_FIXED_ARRAY_" #name);
93 
95 #undef ADD_COUNTER
96 
97  AddNumber(args.GetIsolate(), result, isolate->memory_allocator()->Size(),
98  "total_committed_bytes");
99  AddNumber(args.GetIsolate(), result, heap->new_space()->Size(),
100  "new_space_live_bytes");
101  AddNumber(args.GetIsolate(), result, heap->new_space()->Available(),
102  "new_space_available_bytes");
103  AddNumber(args.GetIsolate(), result, heap->new_space()->CommittedMemory(),
104  "new_space_commited_bytes");
105  AddNumber(args.GetIsolate(), result, heap->old_pointer_space()->Size(),
106  "old_pointer_space_live_bytes");
107  AddNumber(args.GetIsolate(), result, heap->old_pointer_space()->Available(),
108  "old_pointer_space_available_bytes");
109  AddNumber(args.GetIsolate(), result,
110  heap->old_pointer_space()->CommittedMemory(),
111  "old_pointer_space_commited_bytes");
112  AddNumber(args.GetIsolate(), result, heap->old_data_space()->Size(),
113  "old_data_space_live_bytes");
114  AddNumber(args.GetIsolate(), result, heap->old_data_space()->Available(),
115  "old_data_space_available_bytes");
116  AddNumber(args.GetIsolate(), result,
117  heap->old_data_space()->CommittedMemory(),
118  "old_data_space_commited_bytes");
119  AddNumber(args.GetIsolate(), result, heap->code_space()->Size(),
120  "code_space_live_bytes");
121  AddNumber(args.GetIsolate(), result, heap->code_space()->Available(),
122  "code_space_available_bytes");
123  AddNumber(args.GetIsolate(), result, heap->code_space()->CommittedMemory(),
124  "code_space_commited_bytes");
125  AddNumber(args.GetIsolate(), result, heap->cell_space()->Size(),
126  "cell_space_live_bytes");
127  AddNumber(args.GetIsolate(), result, heap->cell_space()->Available(),
128  "cell_space_available_bytes");
129  AddNumber(args.GetIsolate(), result, heap->cell_space()->CommittedMemory(),
130  "cell_space_commited_bytes");
131  AddNumber(args.GetIsolate(), result, heap->property_cell_space()->Size(),
132  "property_cell_space_live_bytes");
133  AddNumber(args.GetIsolate(), result, heap->property_cell_space()->Available(),
134  "property_cell_space_available_bytes");
135  AddNumber(args.GetIsolate(), result,
136  heap->property_cell_space()->CommittedMemory(),
137  "property_cell_space_commited_bytes");
138  AddNumber(args.GetIsolate(), result, heap->lo_space()->Size(),
139  "lo_space_live_bytes");
140  AddNumber(args.GetIsolate(), result, heap->lo_space()->Available(),
141  "lo_space_available_bytes");
142  AddNumber(args.GetIsolate(), result, heap->lo_space()->CommittedMemory(),
143  "lo_space_commited_bytes");
144  AddNumber64(args.GetIsolate(), result,
145  heap->amount_of_external_allocated_memory(),
146  "amount_of_external_allocated_memory");
147  args.GetReturnValue().Set(result);
148 }
ReturnValue< T > GetReturnValue() const
Definition: v8.h:6348
Isolate * GetIsolate() const
Definition: v8.h:6342
int Length() const
Definition: v8.h:6360
A light-weight stack-allocated object handle.
Definition: v8.h:334
static Local< Object > New(Isolate *isolate)
Definition: api.cc:5610
static const int kNoGCFlags
Definition: heap.h:716
#define STATS_COUNTER_LIST_1(SC)
Definition: counters.h:380
#define STATS_COUNTER_LIST_2(SC)
Definition: counters.h:433
static void AddNumber64(v8::Isolate *isolate, v8::Local< v8::Object > object, int64_t value, const char *name)
static void AddNumber(v8::Isolate *isolate, v8::Local< v8::Object > object, intptr_t value, const char *name)
#define INSTANCE_TYPE_LIST(V)
Definition: objects.h:339
#define CODE_KIND_LIST(V)
Definition: objects.h:4950
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V)
Definition: objects.h:800
#define ADD_COUNTER(name, caption)

References ADD_COUNTER, v8::internal::AddNumber(), v8::internal::AddNumber64(), v8::internal::Heap::amount_of_external_allocated_memory(), v8::internal::PagedSpace::Available(), v8::internal::NewSpace::Available(), v8::internal::LargeObjectSpace::Available(), v8::internal::Heap::cell_space(), CODE_KIND_LIST, v8::internal::Heap::code_space(), v8::internal::Heap::CollectAllGarbage(), v8::internal::PagedSpace::CommittedMemory(), v8::internal::NewSpace::CommittedMemory(), v8::internal::LargeObjectSpace::CommittedMemory(), v8::internal::Isolate::counters(), FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST, v8::FunctionCallbackInfo< T >::GetIsolate(), v8::FunctionCallbackInfo< T >::GetReturnValue(), v8::internal::Isolate::heap(), INSTANCE_TYPE_LIST, v8::internal::Heap::kNoGCFlags, v8::FunctionCallbackInfo< T >::Length(), v8::internal::Heap::lo_space(), v8::internal::Isolate::memory_allocator(), v8::Object::New(), v8::internal::Heap::new_space(), v8::internal::Heap::old_data_space(), v8::internal::Heap::old_pointer_space(), v8::internal::Heap::property_cell_space(), v8::internal::MemoryAllocator::Size(), v8::internal::PagedSpace::Size(), v8::internal::NewSpace::Size(), v8::internal::LargeObjectSpace::Size(), STATS_COUNTER_LIST_1, and STATS_COUNTER_LIST_2.

Referenced by GetNativeFunctionTemplate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNativeFunctionTemplate()

v8::Handle< v8::FunctionTemplate > v8::internal::StatisticsExtension::GetNativeFunctionTemplate ( v8::Isolate isolate,
v8::Handle< v8::String name 
)
virtual

Reimplemented from v8::Extension.

Definition at line 14 of file statistics-extension.cc.

16  {
17  DCHECK(strcmp(*v8::String::Utf8Value(str), "getV8Statistics") == 0);
19 }
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >(), int length=0)
Creates a function template.
Definition: api.cc:904
Converts an object to a UTF-8-encoded character array.
Definition: v8.h:2048
static void GetCounters(const v8::FunctionCallbackInfo< v8::Value > &args)
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, GetCounters(), and v8::FunctionTemplate::New().

+ Here is the call graph for this function:

Member Data Documentation

◆ kSource

const char *const v8::internal::StatisticsExtension::kSource
staticprivate
Initial value:
=
"native function getV8Statistics();"

Definition at line 22 of file statistics-extension.h.


The documentation for this class was generated from the following files: