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

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

Issue 2490523003: [heap] Use size_t for heap and space counters. (Closed)
Patch Set: more fixes Created 4 years, 1 month 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
« no previous file with comments | « no previous file | src/heap/gc-tracer.cc » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/extensions/statistics-extension.h" 5 #include "src/extensions/statistics-extension.h"
6 6
7 #include "src/counters.h" 7 #include "src/counters.h"
8 #include "src/heap/heap-inl.h" 8 #include "src/heap/heap-inl.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 10
(...skipping 17 matching lines...) Expand all
28 const char* name) { 28 const char* name) {
29 if (counter->Enabled()) { 29 if (counter->Enabled()) {
30 object->Set(isolate->GetCurrentContext(), 30 object->Set(isolate->GetCurrentContext(),
31 v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal) 31 v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal)
32 .ToLocalChecked(), 32 .ToLocalChecked(),
33 v8::Number::New(isolate, *counter->GetInternalPointer())) 33 v8::Number::New(isolate, *counter->GetInternalPointer()))
34 .FromJust(); 34 .FromJust();
35 } 35 }
36 } 36 }
37 37
38 static void AddNumber(v8::Isolate* isolate, 38 static void AddNumber(v8::Isolate* isolate, v8::Local<v8::Object> object,
39 v8::Local<v8::Object> object, 39 double value, const char* name) {
40 intptr_t value, 40 object
41 const char* name) { 41 ->Set(isolate->GetCurrentContext(),
42 object->Set(isolate->GetCurrentContext(), 42 v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal)
43 v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal) 43 .ToLocalChecked(),
44 .ToLocalChecked(), 44 v8::Number::New(isolate, value))
45 v8::Number::New(isolate, static_cast<double>(value))).FromJust(); 45 .FromJust();
46 } 46 }
47 47
48 48
49 static void AddNumber64(v8::Isolate* isolate, 49 static void AddNumber64(v8::Isolate* isolate,
50 v8::Local<v8::Object> object, 50 v8::Local<v8::Object> object,
51 int64_t value, 51 int64_t value,
52 const char* name) { 52 const char* name) {
53 object->Set(isolate->GetCurrentContext(), 53 object->Set(isolate->GetCurrentContext(),
54 v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal) 54 v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal)
55 .ToLocalChecked(), 55 .ToLocalChecked(),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADD_COUNTER) 105 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADD_COUNTER)
106 #undef ADD_COUNTER 106 #undef ADD_COUNTER
107 }; // End counter_list array. 107 }; // End counter_list array.
108 108
109 for (size_t i = 0; i < arraysize(counter_list); i++) { 109 for (size_t i = 0; i < arraysize(counter_list); i++) {
110 AddCounter(args.GetIsolate(), result, counter_list[i].counter, 110 AddCounter(args.GetIsolate(), result, counter_list[i].counter,
111 counter_list[i].name); 111 counter_list[i].name);
112 } 112 }
113 113
114 struct StatisticNumber { 114 struct StatisticNumber {
115 intptr_t number; 115 size_t number;
116 const char* name; 116 const char* name;
117 }; 117 };
118 118
119 const StatisticNumber numbers[] = { 119 const StatisticNumber numbers[] = {
120 {static_cast<intptr_t>(heap->memory_allocator()->Size()), 120 {heap->memory_allocator()->Size(), "total_committed_bytes"},
121 "total_committed_bytes"},
122 {heap->new_space()->Size(), "new_space_live_bytes"}, 121 {heap->new_space()->Size(), "new_space_live_bytes"},
123 {heap->new_space()->Available(), "new_space_available_bytes"}, 122 {heap->new_space()->Available(), "new_space_available_bytes"},
124 {static_cast<intptr_t>(heap->new_space()->CommittedMemory()), 123 {heap->new_space()->CommittedMemory(), "new_space_commited_bytes"},
125 "new_space_commited_bytes"},
126 {heap->old_space()->Size(), "old_space_live_bytes"}, 124 {heap->old_space()->Size(), "old_space_live_bytes"},
127 {heap->old_space()->Available(), "old_space_available_bytes"}, 125 {heap->old_space()->Available(), "old_space_available_bytes"},
128 {static_cast<intptr_t>(heap->old_space()->CommittedMemory()), 126 {heap->old_space()->CommittedMemory(), "old_space_commited_bytes"},
129 "old_space_commited_bytes"},
130 {heap->code_space()->Size(), "code_space_live_bytes"}, 127 {heap->code_space()->Size(), "code_space_live_bytes"},
131 {heap->code_space()->Available(), "code_space_available_bytes"}, 128 {heap->code_space()->Available(), "code_space_available_bytes"},
132 {static_cast<intptr_t>(heap->code_space()->CommittedMemory()), 129 {heap->code_space()->CommittedMemory(), "code_space_commited_bytes"},
133 "code_space_commited_bytes"},
134 {heap->lo_space()->Size(), "lo_space_live_bytes"}, 130 {heap->lo_space()->Size(), "lo_space_live_bytes"},
135 {heap->lo_space()->Available(), "lo_space_available_bytes"}, 131 {heap->lo_space()->Available(), "lo_space_available_bytes"},
136 {static_cast<intptr_t>(heap->lo_space()->CommittedMemory()), 132 {heap->lo_space()->CommittedMemory(), "lo_space_commited_bytes"},
137 "lo_space_commited_bytes"},
138 }; 133 };
139 134
140 for (size_t i = 0; i < arraysize(numbers); i++) { 135 for (size_t i = 0; i < arraysize(numbers); i++) {
141 AddNumber(args.GetIsolate(), result, numbers[i].number, numbers[i].name); 136 AddNumber(args.GetIsolate(), result, numbers[i].number, numbers[i].name);
142 } 137 }
143 138
144 AddNumber64(args.GetIsolate(), result, heap->external_memory(), 139 AddNumber64(args.GetIsolate(), result, heap->external_memory(),
145 "amount_of_external_allocated_memory"); 140 "amount_of_external_allocated_memory");
146 args.GetReturnValue().Set(result); 141 args.GetReturnValue().Set(result);
147 142
(...skipping 16 matching lines...) Expand all
164 } 159 }
165 160
166 AddNumber(args.GetIsolate(), result, reloc_info_total, 161 AddNumber(args.GetIsolate(), result, reloc_info_total,
167 "reloc_info_total_size"); 162 "reloc_info_total_size");
168 AddNumber(args.GetIsolate(), result, source_position_table_total, 163 AddNumber(args.GetIsolate(), result, source_position_table_total,
169 "source_position_table_total_size"); 164 "source_position_table_total_size");
170 } 165 }
171 166
172 } // namespace internal 167 } // namespace internal
173 } // namespace v8 168 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/gc-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698