Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/extensions/statistics-extension.cc

Issue 148593004: A64: Synchronize with r18084. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/extensions/externalize-string-extension.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 23 matching lines...) Expand all
34 "native function getV8Statistics();"; 34 "native function getV8Statistics();";
35 35
36 36
37 v8::Handle<v8::FunctionTemplate> StatisticsExtension::GetNativeFunction( 37 v8::Handle<v8::FunctionTemplate> StatisticsExtension::GetNativeFunction(
38 v8::Handle<v8::String> str) { 38 v8::Handle<v8::String> str) {
39 ASSERT(strcmp(*v8::String::Utf8Value(str), "getV8Statistics") == 0); 39 ASSERT(strcmp(*v8::String::Utf8Value(str), "getV8Statistics") == 0);
40 return v8::FunctionTemplate::New(StatisticsExtension::GetCounters); 40 return v8::FunctionTemplate::New(StatisticsExtension::GetCounters);
41 } 41 }
42 42
43 43
44 static void AddCounter(v8::Local<v8::Object> object, 44 static void AddCounter(v8::Isolate* isolate,
45 v8::Local<v8::Object> object,
45 StatsCounter* counter, 46 StatsCounter* counter,
46 const char* name) { 47 const char* name) {
47 if (counter->Enabled()) { 48 if (counter->Enabled()) {
48 object->Set(v8::String::New(name), 49 object->Set(v8::String::NewFromUtf8(isolate, name),
49 v8::Number::New(*counter->GetInternalPointer())); 50 v8::Number::New(*counter->GetInternalPointer()));
50 } 51 }
51 } 52 }
52 53
53 static void AddNumber(v8::Local<v8::Object> object, 54 static void AddNumber(v8::Isolate* isolate,
55 v8::Local<v8::Object> object,
54 intptr_t value, 56 intptr_t value,
55 const char* name) { 57 const char* name) {
56 object->Set(v8::String::New(name), 58 object->Set(v8::String::NewFromUtf8(isolate, name),
57 v8::Number::New(static_cast<double>(value))); 59 v8::Number::New(static_cast<double>(value)));
58 } 60 }
59 61
62
63 static void AddNumber64(v8::Isolate* isolate,
64 v8::Local<v8::Object> object,
65 int64_t value,
66 const char* name) {
67 object->Set(v8::String::NewFromUtf8(isolate, name),
68 v8::Number::New(static_cast<double>(value)));
69 }
70
60 71
61 void StatisticsExtension::GetCounters( 72 void StatisticsExtension::GetCounters(
62 const v8::FunctionCallbackInfo<v8::Value>& args) { 73 const v8::FunctionCallbackInfo<v8::Value>& args) {
63 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate()); 74 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate());
64 Heap* heap = isolate->heap(); 75 Heap* heap = isolate->heap();
65 76
66 if (args.Length() > 0) { // GC if first argument evaluates to true. 77 if (args.Length() > 0) { // GC if first argument evaluates to true.
67 if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) { 78 if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) {
68 heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension"); 79 heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension");
69 } 80 }
70 } 81 }
71 82
72 Counters* counters = isolate->counters(); 83 Counters* counters = isolate->counters();
73 v8::Local<v8::Object> result = v8::Object::New(); 84 v8::Local<v8::Object> result = v8::Object::New();
74 85
75 #define ADD_COUNTER(name, caption) \ 86 #define ADD_COUNTER(name, caption) \
76 AddCounter(result, counters->name(), #name); 87 AddCounter(args.GetIsolate(), result, counters->name(), #name);
77 88
78 STATS_COUNTER_LIST_1(ADD_COUNTER) 89 STATS_COUNTER_LIST_1(ADD_COUNTER)
79 STATS_COUNTER_LIST_2(ADD_COUNTER) 90 STATS_COUNTER_LIST_2(ADD_COUNTER)
80 #undef ADD_COUNTER 91 #undef ADD_COUNTER
81 #define ADD_COUNTER(name) \ 92 #define ADD_COUNTER(name) \
82 AddCounter(result, counters->count_of_##name(), "count_of_" #name); \ 93 AddCounter(args.GetIsolate(), result, counters->count_of_##name(), \
83 AddCounter(result, counters->size_of_##name(), "size_of_" #name); 94 "count_of_" #name); \
95 AddCounter(args.GetIsolate(), result, counters->size_of_##name(), \
96 "size_of_" #name);
84 97
85 INSTANCE_TYPE_LIST(ADD_COUNTER) 98 INSTANCE_TYPE_LIST(ADD_COUNTER)
86 #undef ADD_COUNTER 99 #undef ADD_COUNTER
87 #define ADD_COUNTER(name) \ 100 #define ADD_COUNTER(name) \
88 AddCounter(result, counters->count_of_CODE_TYPE_##name(), \ 101 AddCounter(args.GetIsolate(), result, counters->count_of_CODE_TYPE_##name(), \
89 "count_of_CODE_TYPE_" #name); \ 102 "count_of_CODE_TYPE_" #name); \
90 AddCounter(result, counters->size_of_CODE_TYPE_##name(), \ 103 AddCounter(args.GetIsolate(), result, counters->size_of_CODE_TYPE_##name(), \
91 "size_of_CODE_TYPE_" #name); 104 "size_of_CODE_TYPE_" #name);
92 105
93 CODE_KIND_LIST(ADD_COUNTER) 106 CODE_KIND_LIST(ADD_COUNTER)
94 #undef ADD_COUNTER 107 #undef ADD_COUNTER
95 #define ADD_COUNTER(name) \ 108 #define ADD_COUNTER(name) \
96 AddCounter(result, counters->count_of_FIXED_ARRAY_##name(), \ 109 AddCounter(args.GetIsolate(), result, \
97 "count_of_FIXED_ARRAY_" #name); \ 110 counters->count_of_FIXED_ARRAY_##name(), \
98 AddCounter(result, counters->size_of_FIXED_ARRAY_##name(), \ 111 "count_of_FIXED_ARRAY_" #name); \
112 AddCounter(args.GetIsolate(), result, \
113 counters->size_of_FIXED_ARRAY_##name(), \
99 "size_of_FIXED_ARRAY_" #name); 114 "size_of_FIXED_ARRAY_" #name);
100 115
101 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADD_COUNTER) 116 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADD_COUNTER)
102 #undef ADD_COUNTER 117 #undef ADD_COUNTER
103 118
104 AddNumber(result, isolate->memory_allocator()->Size(), 119 AddNumber(args.GetIsolate(), result, isolate->memory_allocator()->Size(),
105 "total_committed_bytes"); 120 "total_committed_bytes");
106 AddNumber(result, heap->new_space()->Size(), 121 AddNumber(args.GetIsolate(), result, heap->new_space()->Size(),
107 "new_space_live_bytes"); 122 "new_space_live_bytes");
108 AddNumber(result, heap->new_space()->Available(), 123 AddNumber(args.GetIsolate(), result, heap->new_space()->Available(),
109 "new_space_available_bytes"); 124 "new_space_available_bytes");
110 AddNumber(result, heap->new_space()->CommittedMemory(), 125 AddNumber(args.GetIsolate(), result, heap->new_space()->CommittedMemory(),
111 "new_space_commited_bytes"); 126 "new_space_commited_bytes");
112 AddNumber(result, heap->old_pointer_space()->Size(), 127 AddNumber(args.GetIsolate(), result, heap->old_pointer_space()->Size(),
113 "old_pointer_space_live_bytes"); 128 "old_pointer_space_live_bytes");
114 AddNumber(result, heap->old_pointer_space()->Available(), 129 AddNumber(args.GetIsolate(), result, heap->old_pointer_space()->Available(),
115 "old_pointer_space_available_bytes"); 130 "old_pointer_space_available_bytes");
116 AddNumber(result, heap->old_pointer_space()->CommittedMemory(), 131 AddNumber(args.GetIsolate(), result,
132 heap->old_pointer_space()->CommittedMemory(),
117 "old_pointer_space_commited_bytes"); 133 "old_pointer_space_commited_bytes");
118 AddNumber(result, heap->old_data_space()->Size(), 134 AddNumber(args.GetIsolate(), result, heap->old_data_space()->Size(),
119 "old_data_space_live_bytes"); 135 "old_data_space_live_bytes");
120 AddNumber(result, heap->old_data_space()->Available(), 136 AddNumber(args.GetIsolate(), result, heap->old_data_space()->Available(),
121 "old_data_space_available_bytes"); 137 "old_data_space_available_bytes");
122 AddNumber(result, heap->old_data_space()->CommittedMemory(), 138 AddNumber(args.GetIsolate(), result,
139 heap->old_data_space()->CommittedMemory(),
123 "old_data_space_commited_bytes"); 140 "old_data_space_commited_bytes");
124 AddNumber(result, heap->code_space()->Size(), 141 AddNumber(args.GetIsolate(), result, heap->code_space()->Size(),
125 "code_space_live_bytes"); 142 "code_space_live_bytes");
126 AddNumber(result, heap->code_space()->Available(), 143 AddNumber(args.GetIsolate(), result, heap->code_space()->Available(),
127 "code_space_available_bytes"); 144 "code_space_available_bytes");
128 AddNumber(result, heap->code_space()->CommittedMemory(), 145 AddNumber(args.GetIsolate(), result, heap->code_space()->CommittedMemory(),
129 "code_space_commited_bytes"); 146 "code_space_commited_bytes");
130 AddNumber(result, heap->cell_space()->Size(), 147 AddNumber(args.GetIsolate(), result, heap->cell_space()->Size(),
131 "cell_space_live_bytes"); 148 "cell_space_live_bytes");
132 AddNumber(result, heap->cell_space()->Available(), 149 AddNumber(args.GetIsolate(), result, heap->cell_space()->Available(),
133 "cell_space_available_bytes"); 150 "cell_space_available_bytes");
134 AddNumber(result, heap->cell_space()->CommittedMemory(), 151 AddNumber(args.GetIsolate(), result, heap->cell_space()->CommittedMemory(),
135 "cell_space_commited_bytes"); 152 "cell_space_commited_bytes");
136 AddNumber(result, heap->property_cell_space()->Size(), 153 AddNumber(args.GetIsolate(), result, heap->property_cell_space()->Size(),
137 "property_cell_space_live_bytes"); 154 "property_cell_space_live_bytes");
138 AddNumber(result, heap->property_cell_space()->Available(), 155 AddNumber(args.GetIsolate(), result, heap->property_cell_space()->Available(),
139 "property_cell_space_available_bytes"); 156 "property_cell_space_available_bytes");
140 AddNumber(result, heap->property_cell_space()->CommittedMemory(), 157 AddNumber(args.GetIsolate(), result,
158 heap->property_cell_space()->CommittedMemory(),
141 "property_cell_space_commited_bytes"); 159 "property_cell_space_commited_bytes");
142 AddNumber(result, heap->lo_space()->Size(), 160 AddNumber(args.GetIsolate(), result, heap->lo_space()->Size(),
143 "lo_space_live_bytes"); 161 "lo_space_live_bytes");
144 AddNumber(result, heap->lo_space()->Available(), 162 AddNumber(args.GetIsolate(), result, heap->lo_space()->Available(),
145 "lo_space_available_bytes"); 163 "lo_space_available_bytes");
146 AddNumber(result, heap->lo_space()->CommittedMemory(), 164 AddNumber(args.GetIsolate(), result, heap->lo_space()->CommittedMemory(),
147 "lo_space_commited_bytes"); 165 "lo_space_commited_bytes");
148 AddNumber(result, heap->amount_of_external_allocated_memory(), 166 AddNumber64(args.GetIsolate(), result,
149 "amount_of_external_allocated_memory"); 167 heap->amount_of_external_allocated_memory(),
168 "amount_of_external_allocated_memory");
150 args.GetReturnValue().Set(result); 169 args.GetReturnValue().Set(result);
151 } 170 }
152 171
153 172
154 void StatisticsExtension::Register() { 173 void StatisticsExtension::Register() {
155 static StatisticsExtension statistics_extension; 174 static StatisticsExtension statistics_extension;
156 static v8::DeclareExtension declaration(&statistics_extension); 175 static v8::DeclareExtension declaration(&statistics_extension);
157 } 176 }
158 177
159 } } // namespace v8::internal 178 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/extensions/externalize-string-extension.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698