OLD | NEW |
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/heap/heap.h" | 5 #include "src/heap/heap.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 return new_space_->Capacity() + OldGenerationCapacity(); | 185 return new_space_->Capacity() + OldGenerationCapacity(); |
186 } | 186 } |
187 | 187 |
188 intptr_t Heap::OldGenerationCapacity() { | 188 intptr_t Heap::OldGenerationCapacity() { |
189 if (!HasBeenSetUp()) return 0; | 189 if (!HasBeenSetUp()) return 0; |
190 | 190 |
191 return old_space_->Capacity() + code_space_->Capacity() + | 191 return old_space_->Capacity() + code_space_->Capacity() + |
192 map_space_->Capacity() + lo_space_->SizeOfObjects(); | 192 map_space_->Capacity() + lo_space_->SizeOfObjects(); |
193 } | 193 } |
194 | 194 |
195 | 195 size_t Heap::CommittedOldGenerationMemory() { |
196 intptr_t Heap::CommittedOldGenerationMemory() { | |
197 if (!HasBeenSetUp()) return 0; | 196 if (!HasBeenSetUp()) return 0; |
198 | 197 |
199 return old_space_->CommittedMemory() + code_space_->CommittedMemory() + | 198 return old_space_->CommittedMemory() + code_space_->CommittedMemory() + |
200 map_space_->CommittedMemory() + lo_space_->Size(); | 199 map_space_->CommittedMemory() + lo_space_->Size(); |
201 } | 200 } |
202 | 201 |
203 | 202 size_t Heap::CommittedMemory() { |
204 intptr_t Heap::CommittedMemory() { | |
205 if (!HasBeenSetUp()) return 0; | 203 if (!HasBeenSetUp()) return 0; |
206 | 204 |
207 return new_space_->CommittedMemory() + CommittedOldGenerationMemory(); | 205 return new_space_->CommittedMemory() + CommittedOldGenerationMemory(); |
208 } | 206 } |
209 | 207 |
210 | 208 |
211 size_t Heap::CommittedPhysicalMemory() { | 209 size_t Heap::CommittedPhysicalMemory() { |
212 if (!HasBeenSetUp()) return 0; | 210 if (!HasBeenSetUp()) return 0; |
213 | 211 |
214 return new_space_->CommittedPhysicalMemory() + | 212 return new_space_->CommittedPhysicalMemory() + |
215 old_space_->CommittedPhysicalMemory() + | 213 old_space_->CommittedPhysicalMemory() + |
216 code_space_->CommittedPhysicalMemory() + | 214 code_space_->CommittedPhysicalMemory() + |
217 map_space_->CommittedPhysicalMemory() + | 215 map_space_->CommittedPhysicalMemory() + |
218 lo_space_->CommittedPhysicalMemory(); | 216 lo_space_->CommittedPhysicalMemory(); |
219 } | 217 } |
220 | 218 |
221 | 219 size_t Heap::CommittedMemoryExecutable() { |
222 intptr_t Heap::CommittedMemoryExecutable() { | |
223 if (!HasBeenSetUp()) return 0; | 220 if (!HasBeenSetUp()) return 0; |
224 | 221 |
225 return memory_allocator()->SizeExecutable(); | 222 return static_cast<size_t>(memory_allocator()->SizeExecutable()); |
226 } | 223 } |
227 | 224 |
228 | 225 |
229 void Heap::UpdateMaximumCommitted() { | 226 void Heap::UpdateMaximumCommitted() { |
230 if (!HasBeenSetUp()) return; | 227 if (!HasBeenSetUp()) return; |
231 | 228 |
232 intptr_t current_committed_memory = CommittedMemory(); | 229 const size_t current_committed_memory = CommittedMemory(); |
233 if (current_committed_memory > maximum_committed_) { | 230 if (current_committed_memory > maximum_committed_) { |
234 maximum_committed_ = current_committed_memory; | 231 maximum_committed_ = current_committed_memory; |
235 } | 232 } |
236 } | 233 } |
237 | 234 |
238 | 235 |
239 intptr_t Heap::Available() { | 236 intptr_t Heap::Available() { |
240 if (!HasBeenSetUp()) return 0; | 237 if (!HasBeenSetUp()) return 0; |
241 | 238 |
242 intptr_t total = 0; | 239 intptr_t total = 0; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 void Heap::PrintShortHeapStatistics() { | 322 void Heap::PrintShortHeapStatistics() { |
326 if (!FLAG_trace_gc_verbose) return; | 323 if (!FLAG_trace_gc_verbose) return; |
327 PrintIsolate(isolate_, "Memory allocator, used: %6" V8PRIdPTR | 324 PrintIsolate(isolate_, "Memory allocator, used: %6" V8PRIdPTR |
328 " KB, available: %6" V8PRIdPTR " KB\n", | 325 " KB, available: %6" V8PRIdPTR " KB\n", |
329 memory_allocator()->Size() / KB, | 326 memory_allocator()->Size() / KB, |
330 memory_allocator()->Available() / KB); | 327 memory_allocator()->Available() / KB); |
331 PrintIsolate(isolate_, "New space, used: %6" V8PRIdPTR | 328 PrintIsolate(isolate_, "New space, used: %6" V8PRIdPTR |
332 " KB" | 329 " KB" |
333 ", available: %6" V8PRIdPTR | 330 ", available: %6" V8PRIdPTR |
334 " KB" | 331 " KB" |
335 ", committed: %6" V8PRIdPTR " KB\n", | 332 ", committed: %6zu KB\n", |
336 new_space_->Size() / KB, new_space_->Available() / KB, | 333 new_space_->Size() / KB, new_space_->Available() / KB, |
337 new_space_->CommittedMemory() / KB); | 334 new_space_->CommittedMemory() / KB); |
338 PrintIsolate(isolate_, "Old space, used: %6" V8PRIdPTR | 335 PrintIsolate(isolate_, "Old space, used: %6" V8PRIdPTR |
339 " KB" | 336 " KB" |
340 ", available: %6" V8PRIdPTR | 337 ", available: %6" V8PRIdPTR |
341 " KB" | 338 " KB" |
342 ", committed: %6" V8PRIdPTR " KB\n", | 339 ", committed: %6zu KB\n", |
343 old_space_->SizeOfObjects() / KB, old_space_->Available() / KB, | 340 old_space_->SizeOfObjects() / KB, old_space_->Available() / KB, |
344 old_space_->CommittedMemory() / KB); | 341 old_space_->CommittedMemory() / KB); |
345 PrintIsolate(isolate_, "Code space, used: %6" V8PRIdPTR | 342 PrintIsolate(isolate_, "Code space, used: %6" V8PRIdPTR |
346 " KB" | 343 " KB" |
347 ", available: %6" V8PRIdPTR | 344 ", available: %6" V8PRIdPTR |
348 " KB" | 345 " KB" |
349 ", committed: %6" V8PRIdPTR " KB\n", | 346 ", committed: %6zu KB\n", |
350 code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, | 347 code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, |
351 code_space_->CommittedMemory() / KB); | 348 code_space_->CommittedMemory() / KB); |
352 PrintIsolate(isolate_, "Map space, used: %6" V8PRIdPTR | 349 PrintIsolate(isolate_, "Map space, used: %6" V8PRIdPTR |
353 " KB" | 350 " KB" |
354 ", available: %6" V8PRIdPTR | 351 ", available: %6" V8PRIdPTR |
355 " KB" | 352 " KB" |
356 ", committed: %6" V8PRIdPTR " KB\n", | 353 ", committed: %6zu KB\n", |
357 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, | 354 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, |
358 map_space_->CommittedMemory() / KB); | 355 map_space_->CommittedMemory() / KB); |
359 PrintIsolate(isolate_, "Large object space, used: %6" V8PRIdPTR | 356 PrintIsolate(isolate_, "Large object space, used: %6" V8PRIdPTR |
360 " KB" | 357 " KB" |
361 ", available: %6" V8PRIdPTR | 358 ", available: %6" V8PRIdPTR |
362 " KB" | 359 " KB" |
363 ", committed: %6" V8PRIdPTR " KB\n", | 360 ", committed: %6zu KB\n", |
364 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, | 361 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, |
365 lo_space_->CommittedMemory() / KB); | 362 lo_space_->CommittedMemory() / KB); |
366 PrintIsolate(isolate_, "All spaces, used: %6" V8PRIdPTR | 363 PrintIsolate(isolate_, "All spaces, used: %6" V8PRIdPTR |
367 " KB" | 364 " KB" |
368 ", available: %6" V8PRIdPTR | 365 ", available: %6" V8PRIdPTR |
369 " KB" | 366 " KB" |
370 ", committed: %6" V8PRIdPTR " KB\n", | 367 ", committed: %6zu KB\n", |
371 this->SizeOfObjects() / KB, this->Available() / KB, | 368 this->SizeOfObjects() / KB, this->Available() / KB, |
372 this->CommittedMemory() / KB); | 369 this->CommittedMemory() / KB); |
373 PrintIsolate(isolate_, "External memory reported: %6" V8PRIdPTR " KB\n", | 370 PrintIsolate(isolate_, "External memory reported: %6" V8PRIdPTR " KB\n", |
374 static_cast<intptr_t>(external_memory_ / KB)); | 371 static_cast<intptr_t>(external_memory_ / KB)); |
375 PrintIsolate(isolate_, "Total time spent in GC : %.1f ms\n", | 372 PrintIsolate(isolate_, "Total time spent in GC : %.1f ms\n", |
376 total_gc_time_ms_); | 373 total_gc_time_ms_); |
377 } | 374 } |
378 | 375 |
379 // TODO(1238405): Combine the infrastructure for --heap-stats and | 376 // TODO(1238405): Combine the infrastructure for --heap-stats and |
380 // --log-gc to avoid the complicated preprocessor and flag testing. | 377 // --log-gc to avoid the complicated preprocessor and flag testing. |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 ? GCTracer::Scope::MC_EXTERNAL_PROLOGUE | 1299 ? GCTracer::Scope::MC_EXTERNAL_PROLOGUE |
1303 : GCTracer::Scope::SCAVENGER_EXTERNAL_PROLOGUE); | 1300 : GCTracer::Scope::SCAVENGER_EXTERNAL_PROLOGUE); |
1304 VMState<EXTERNAL> state(isolate_); | 1301 VMState<EXTERNAL> state(isolate_); |
1305 HandleScope handle_scope(isolate_); | 1302 HandleScope handle_scope(isolate_); |
1306 CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags); | 1303 CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags); |
1307 } | 1304 } |
1308 } | 1305 } |
1309 | 1306 |
1310 EnsureFromSpaceIsCommitted(); | 1307 EnsureFromSpaceIsCommitted(); |
1311 | 1308 |
1312 int start_new_space_size = Heap::new_space()->SizeAsInt(); | 1309 int start_new_space_size = static_cast<int>(Heap::new_space()->Size()); |
1313 | 1310 |
1314 if (IsHighSurvivalRate()) { | 1311 if (IsHighSurvivalRate()) { |
1315 // We speed up the incremental marker if it is running so that it | 1312 // We speed up the incremental marker if it is running so that it |
1316 // does not fall behind the rate of promotion, which would cause a | 1313 // does not fall behind the rate of promotion, which would cause a |
1317 // constantly growing old space. | 1314 // constantly growing old space. |
1318 incremental_marking()->NotifyOfHighPromotionRate(); | 1315 incremental_marking()->NotifyOfHighPromotionRate(); |
1319 } | 1316 } |
1320 | 1317 |
1321 { | 1318 { |
1322 Heap::PretenuringScope pretenuring_scope(this); | 1319 Heap::PretenuringScope pretenuring_scope(this); |
(...skipping 3837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5160 memcpy(buffer + copied, trace_ring_buffer_, ring_buffer_end_); | 5157 memcpy(buffer + copied, trace_ring_buffer_, ring_buffer_end_); |
5161 } | 5158 } |
5162 | 5159 |
5163 | 5160 |
5164 bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); } | 5161 bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); } |
5165 | 5162 |
5166 | 5163 |
5167 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { | 5164 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { |
5168 *stats->start_marker = HeapStats::kStartMarker; | 5165 *stats->start_marker = HeapStats::kStartMarker; |
5169 *stats->end_marker = HeapStats::kEndMarker; | 5166 *stats->end_marker = HeapStats::kEndMarker; |
5170 *stats->new_space_size = new_space_->SizeAsInt(); | 5167 *stats->new_space_size = new_space_->Size(); |
5171 *stats->new_space_capacity = new_space_->Capacity(); | 5168 *stats->new_space_capacity = new_space_->Capacity(); |
5172 *stats->old_space_size = old_space_->SizeOfObjects(); | 5169 *stats->old_space_size = old_space_->SizeOfObjects(); |
5173 *stats->old_space_capacity = old_space_->Capacity(); | 5170 *stats->old_space_capacity = old_space_->Capacity(); |
5174 *stats->code_space_size = code_space_->SizeOfObjects(); | 5171 *stats->code_space_size = code_space_->SizeOfObjects(); |
5175 *stats->code_space_capacity = code_space_->Capacity(); | 5172 *stats->code_space_capacity = code_space_->Capacity(); |
5176 *stats->map_space_size = map_space_->SizeOfObjects(); | 5173 *stats->map_space_size = map_space_->SizeOfObjects(); |
5177 *stats->map_space_capacity = map_space_->Capacity(); | 5174 *stats->map_space_capacity = map_space_->Capacity(); |
5178 *stats->lo_space_size = lo_space_->Size(); | 5175 *stats->lo_space_size = lo_space_->Size(); |
5179 isolate_->global_handles()->RecordStats(stats); | 5176 isolate_->global_handles()->RecordStats(stats); |
5180 *stats->memory_allocator_size = memory_allocator()->Size(); | 5177 *stats->memory_allocator_size = memory_allocator()->Size(); |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6467 } | 6464 } |
6468 | 6465 |
6469 | 6466 |
6470 // static | 6467 // static |
6471 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6468 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6472 return StaticVisitorBase::GetVisitorId(map); | 6469 return StaticVisitorBase::GetVisitorId(map); |
6473 } | 6470 } |
6474 | 6471 |
6475 } // namespace internal | 6472 } // namespace internal |
6476 } // namespace v8 | 6473 } // namespace v8 |
OLD | NEW |