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/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 new_space_.CollectStatistics(); | 336 new_space_.CollectStatistics(); |
337 new_space_.ReportStatistics(); | 337 new_space_.ReportStatistics(); |
338 new_space_.ClearHistograms(); | 338 new_space_.ClearHistograms(); |
339 } | 339 } |
340 #endif // DEBUG | 340 #endif // DEBUG |
341 } | 341 } |
342 | 342 |
343 | 343 |
344 void Heap::PrintShortHeapStatistics() { | 344 void Heap::PrintShortHeapStatistics() { |
345 if (!FLAG_trace_gc_verbose) return; | 345 if (!FLAG_trace_gc_verbose) return; |
346 PrintIsolate(isolate_, "Memory allocator, used: %6" V8_PTR_PREFIX | 346 PrintIsolate(isolate_, "Memory allocator, used: %6" V8PRIdPTR |
347 "d KB" | 347 " KB, available: %6" V8PRIdPTR " KB\n", |
348 ", available: %6" V8_PTR_PREFIX "d KB\n", | |
349 memory_allocator()->Size() / KB, | 348 memory_allocator()->Size() / KB, |
350 memory_allocator()->Available() / KB); | 349 memory_allocator()->Available() / KB); |
351 PrintIsolate(isolate_, "New space, used: %6" V8_PTR_PREFIX | 350 PrintIsolate(isolate_, "New space, used: %6" V8PRIdPTR |
352 "d KB" | 351 " KB" |
353 ", available: %6" V8_PTR_PREFIX | 352 ", available: %6" V8PRIdPTR |
354 "d KB" | 353 " KB" |
355 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 354 ", committed: %6" V8PRIdPTR " KB\n", |
356 new_space_.Size() / KB, new_space_.Available() / KB, | 355 new_space_.Size() / KB, new_space_.Available() / KB, |
357 new_space_.CommittedMemory() / KB); | 356 new_space_.CommittedMemory() / KB); |
358 PrintIsolate(isolate_, "Old space, used: %6" V8_PTR_PREFIX | 357 PrintIsolate(isolate_, "Old space, used: %6" V8PRIdPTR |
359 "d KB" | 358 " KB" |
360 ", available: %6" V8_PTR_PREFIX | 359 ", available: %6" V8PRIdPTR |
361 "d KB" | 360 " KB" |
362 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 361 ", committed: %6" V8PRIdPTR " KB\n", |
363 old_space_->SizeOfObjects() / KB, old_space_->Available() / KB, | 362 old_space_->SizeOfObjects() / KB, old_space_->Available() / KB, |
364 old_space_->CommittedMemory() / KB); | 363 old_space_->CommittedMemory() / KB); |
365 PrintIsolate(isolate_, "Code space, used: %6" V8_PTR_PREFIX | 364 PrintIsolate(isolate_, "Code space, used: %6" V8PRIdPTR |
366 "d KB" | 365 " KB" |
367 ", available: %6" V8_PTR_PREFIX | 366 ", available: %6" V8PRIdPTR |
368 "d KB" | 367 " KB" |
369 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 368 ", committed: %6" V8PRIdPTR " KB\n", |
370 code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, | 369 code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, |
371 code_space_->CommittedMemory() / KB); | 370 code_space_->CommittedMemory() / KB); |
372 PrintIsolate(isolate_, "Map space, used: %6" V8_PTR_PREFIX | 371 PrintIsolate(isolate_, "Map space, used: %6" V8PRIdPTR |
373 "d KB" | 372 " KB" |
374 ", available: %6" V8_PTR_PREFIX | 373 ", available: %6" V8PRIdPTR |
375 "d KB" | 374 " KB" |
376 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 375 ", committed: %6" V8PRIdPTR " KB\n", |
377 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, | 376 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, |
378 map_space_->CommittedMemory() / KB); | 377 map_space_->CommittedMemory() / KB); |
379 PrintIsolate(isolate_, "Large object space, used: %6" V8_PTR_PREFIX | 378 PrintIsolate(isolate_, "Large object space, used: %6" V8PRIdPTR |
380 "d KB" | 379 " KB" |
381 ", available: %6" V8_PTR_PREFIX | 380 ", available: %6" V8PRIdPTR |
382 "d KB" | 381 " KB" |
383 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 382 ", committed: %6" V8PRIdPTR " KB\n", |
384 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, | 383 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, |
385 lo_space_->CommittedMemory() / KB); | 384 lo_space_->CommittedMemory() / KB); |
386 PrintIsolate(isolate_, "All spaces, used: %6" V8_PTR_PREFIX | 385 PrintIsolate(isolate_, "All spaces, used: %6" V8PRIdPTR |
387 "d KB" | 386 " KB" |
388 ", available: %6" V8_PTR_PREFIX | 387 ", available: %6" V8PRIdPTR |
389 "d KB" | 388 " KB" |
390 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 389 ", committed: %6" V8PRIdPTR " KB\n", |
391 this->SizeOfObjects() / KB, this->Available() / KB, | 390 this->SizeOfObjects() / KB, this->Available() / KB, |
392 this->CommittedMemory() / KB); | 391 this->CommittedMemory() / KB); |
393 PrintIsolate( | 392 PrintIsolate( |
394 isolate_, "External memory reported: %6" V8_PTR_PREFIX "d KB\n", | 393 isolate_, "External memory reported: %6" V8PRIdPTR " KB\n", |
395 static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB)); | 394 static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB)); |
396 PrintIsolate(isolate_, "Total time spent in GC : %.1f ms\n", | 395 PrintIsolate(isolate_, "Total time spent in GC : %.1f ms\n", |
397 total_gc_time_ms_); | 396 total_gc_time_ms_); |
398 } | 397 } |
399 | 398 |
400 | |
401 // TODO(1238405): Combine the infrastructure for --heap-stats and | 399 // TODO(1238405): Combine the infrastructure for --heap-stats and |
402 // --log-gc to avoid the complicated preprocessor and flag testing. | 400 // --log-gc to avoid the complicated preprocessor and flag testing. |
403 void Heap::ReportStatisticsAfterGC() { | 401 void Heap::ReportStatisticsAfterGC() { |
404 // Similar to the before GC, we use some complicated logic to ensure that | 402 // Similar to the before GC, we use some complicated logic to ensure that |
405 // NewSpace statistics are logged exactly once when --log-gc is turned on. | 403 // NewSpace statistics are logged exactly once when --log-gc is turned on. |
406 #if defined(DEBUG) | 404 #if defined(DEBUG) |
407 if (FLAG_heap_stats) { | 405 if (FLAG_heap_stats) { |
408 new_space_.CollectStatistics(); | 406 new_space_.CollectStatistics(); |
409 ReportHeapStatistics("After GC"); | 407 ReportHeapStatistics("After GC"); |
410 } else if (FLAG_log_gc) { | 408 } else if (FLAG_log_gc) { |
(...skipping 4066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4477 } | 4475 } |
4478 | 4476 |
4479 | 4477 |
4480 // This function expects that NewSpace's allocated objects histogram is | 4478 // This function expects that NewSpace's allocated objects histogram is |
4481 // populated (via a call to CollectStatistics or else as a side effect of a | 4479 // populated (via a call to CollectStatistics or else as a side effect of a |
4482 // just-completed scavenge collection). | 4480 // just-completed scavenge collection). |
4483 void Heap::ReportHeapStatistics(const char* title) { | 4481 void Heap::ReportHeapStatistics(const char* title) { |
4484 USE(title); | 4482 USE(title); |
4485 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", title, | 4483 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", title, |
4486 gc_count_); | 4484 gc_count_); |
4487 PrintF("old_generation_allocation_limit_ %" V8_PTR_PREFIX "d\n", | 4485 PrintF("old_generation_allocation_limit_ %" V8PRIdPTR "\n", |
4488 old_generation_allocation_limit_); | 4486 old_generation_allocation_limit_); |
4489 | 4487 |
4490 PrintF("\n"); | 4488 PrintF("\n"); |
4491 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); | 4489 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); |
4492 isolate_->global_handles()->PrintStats(); | 4490 isolate_->global_handles()->PrintStats(); |
4493 PrintF("\n"); | 4491 PrintF("\n"); |
4494 | 4492 |
4495 PrintF("Heap statistics : "); | 4493 PrintF("Heap statistics : "); |
4496 memory_allocator()->ReportStatistics(); | 4494 memory_allocator()->ReportStatistics(); |
4497 PrintF("To space : "); | 4495 PrintF("To space : "); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5144 } | 5142 } |
5145 | 5143 |
5146 if (FLAG_heap_growing_percent > 0) { | 5144 if (FLAG_heap_growing_percent > 0) { |
5147 factor = 1.0 + FLAG_heap_growing_percent / 100.0; | 5145 factor = 1.0 + FLAG_heap_growing_percent / 100.0; |
5148 } | 5146 } |
5149 | 5147 |
5150 old_generation_allocation_limit_ = | 5148 old_generation_allocation_limit_ = |
5151 CalculateOldGenerationAllocationLimit(factor, old_gen_size); | 5149 CalculateOldGenerationAllocationLimit(factor, old_gen_size); |
5152 | 5150 |
5153 if (FLAG_trace_gc_verbose) { | 5151 if (FLAG_trace_gc_verbose) { |
5154 PrintIsolate(isolate_, "Grow: old size: %" V8_PTR_PREFIX | 5152 PrintIsolate(isolate_, "Grow: old size: %" V8PRIdPTR |
5155 "d KB, new limit: %" V8_PTR_PREFIX "d KB (%.1f)\n", | 5153 " KB, new limit: %" V8PRIdPTR " KB (%.1f)\n", |
5156 old_gen_size / KB, old_generation_allocation_limit_ / KB, | 5154 old_gen_size / KB, old_generation_allocation_limit_ / KB, |
5157 factor); | 5155 factor); |
5158 } | 5156 } |
5159 } | 5157 } |
5160 | 5158 |
5161 | 5159 |
5162 void Heap::DampenOldGenerationAllocationLimit(intptr_t old_gen_size, | 5160 void Heap::DampenOldGenerationAllocationLimit(intptr_t old_gen_size, |
5163 double gc_speed, | 5161 double gc_speed, |
5164 double mutator_speed) { | 5162 double mutator_speed) { |
5165 double factor = HeapGrowingFactor(gc_speed, mutator_speed); | 5163 double factor = HeapGrowingFactor(gc_speed, mutator_speed); |
5166 intptr_t limit = CalculateOldGenerationAllocationLimit(factor, old_gen_size); | 5164 intptr_t limit = CalculateOldGenerationAllocationLimit(factor, old_gen_size); |
5167 if (limit < old_generation_allocation_limit_) { | 5165 if (limit < old_generation_allocation_limit_) { |
5168 if (FLAG_trace_gc_verbose) { | 5166 if (FLAG_trace_gc_verbose) { |
5169 PrintIsolate(isolate_, "Dampen: old size: %" V8_PTR_PREFIX | 5167 PrintIsolate(isolate_, |
5170 "d KB, old limit: %" V8_PTR_PREFIX | 5168 "Dampen: old size: %" V8PRIdPTR " KB, old limit: %" V8PRIdPTR |
5171 "d KB, " | 5169 " KB, " |
5172 "new limit: %" V8_PTR_PREFIX "d KB (%.1f)\n", | 5170 "new limit: %" V8PRIdPTR " KB (%.1f)\n", |
5173 old_gen_size / KB, old_generation_allocation_limit_ / KB, | 5171 old_gen_size / KB, old_generation_allocation_limit_ / KB, |
5174 limit / KB, factor); | 5172 limit / KB, factor); |
5175 } | 5173 } |
5176 old_generation_allocation_limit_ = limit; | 5174 old_generation_allocation_limit_ = limit; |
5177 } | 5175 } |
5178 } | 5176 } |
5179 | 5177 |
5180 | 5178 |
5181 void Heap::EnableInlineAllocation() { | 5179 void Heap::EnableInlineAllocation() { |
5182 if (!inline_allocation_disabled_) return; | 5180 if (!inline_allocation_disabled_) return; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5387 | 5385 |
5388 UpdateMaximumCommitted(); | 5386 UpdateMaximumCommitted(); |
5389 | 5387 |
5390 if (FLAG_print_cumulative_gc_stat) { | 5388 if (FLAG_print_cumulative_gc_stat) { |
5391 PrintF("\n"); | 5389 PrintF("\n"); |
5392 PrintF("gc_count=%d ", gc_count_); | 5390 PrintF("gc_count=%d ", gc_count_); |
5393 PrintF("mark_sweep_count=%d ", ms_count_); | 5391 PrintF("mark_sweep_count=%d ", ms_count_); |
5394 PrintF("max_gc_pause=%.1f ", get_max_gc_pause()); | 5392 PrintF("max_gc_pause=%.1f ", get_max_gc_pause()); |
5395 PrintF("total_gc_time=%.1f ", total_gc_time_ms_); | 5393 PrintF("total_gc_time=%.1f ", total_gc_time_ms_); |
5396 PrintF("min_in_mutator=%.1f ", get_min_in_mutator()); | 5394 PrintF("min_in_mutator=%.1f ", get_min_in_mutator()); |
5397 PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", get_max_alive_after_gc()); | 5395 PrintF("max_alive_after_gc=%" V8PRIdPTR " ", get_max_alive_after_gc()); |
5398 PrintF("total_marking_time=%.1f ", tracer()->cumulative_marking_duration()); | 5396 PrintF("total_marking_time=%.1f ", tracer()->cumulative_marking_duration()); |
5399 PrintF("total_sweeping_time=%.1f ", | 5397 PrintF("total_sweeping_time=%.1f ", |
5400 tracer()->cumulative_sweeping_duration()); | 5398 tracer()->cumulative_sweeping_duration()); |
5401 PrintF("\n\n"); | 5399 PrintF("\n\n"); |
5402 } | 5400 } |
5403 | 5401 |
5404 if (FLAG_print_max_heap_committed) { | 5402 if (FLAG_print_max_heap_committed) { |
5405 PrintF("\n"); | 5403 PrintF("\n"); |
5406 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", | 5404 PrintF("maximum_committed_by_heap=%" V8PRIdPTR " ", |
5407 MaximumCommittedMemory()); | 5405 MaximumCommittedMemory()); |
5408 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", | 5406 PrintF("maximum_committed_by_new_space=%" V8PRIdPTR " ", |
5409 new_space_.MaximumCommittedMemory()); | 5407 new_space_.MaximumCommittedMemory()); |
5410 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", | 5408 PrintF("maximum_committed_by_old_space=%" V8PRIdPTR " ", |
5411 old_space_->MaximumCommittedMemory()); | 5409 old_space_->MaximumCommittedMemory()); |
5412 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", | 5410 PrintF("maximum_committed_by_code_space=%" V8PRIdPTR " ", |
5413 code_space_->MaximumCommittedMemory()); | 5411 code_space_->MaximumCommittedMemory()); |
5414 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", | 5412 PrintF("maximum_committed_by_map_space=%" V8PRIdPTR " ", |
5415 map_space_->MaximumCommittedMemory()); | 5413 map_space_->MaximumCommittedMemory()); |
5416 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", | 5414 PrintF("maximum_committed_by_lo_space=%" V8PRIdPTR " ", |
5417 lo_space_->MaximumCommittedMemory()); | 5415 lo_space_->MaximumCommittedMemory()); |
5418 PrintF("\n\n"); | 5416 PrintF("\n\n"); |
5419 } | 5417 } |
5420 | 5418 |
5421 if (FLAG_verify_predictable) { | 5419 if (FLAG_verify_predictable) { |
5422 PrintAlloctionsHash(); | 5420 PrintAlloctionsHash(); |
5423 } | 5421 } |
5424 | 5422 |
5425 new_space()->RemoveAllocationObserver(idle_scavenge_observer_); | 5423 new_space()->RemoveAllocationObserver(idle_scavenge_observer_); |
5426 delete idle_scavenge_observer_; | 5424 delete idle_scavenge_observer_; |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6438 } | 6436 } |
6439 | 6437 |
6440 | 6438 |
6441 // static | 6439 // static |
6442 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6440 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6443 return StaticVisitorBase::GetVisitorId(map); | 6441 return StaticVisitorBase::GetVisitorId(map); |
6444 } | 6442 } |
6445 | 6443 |
6446 } // namespace internal | 6444 } // namespace internal |
6447 } // namespace v8 | 6445 } // namespace v8 |
OLD | NEW |