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 4075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4486 } | 4484 } |
4487 | 4485 |
4488 | 4486 |
4489 // This function expects that NewSpace's allocated objects histogram is | 4487 // This function expects that NewSpace's allocated objects histogram is |
4490 // populated (via a call to CollectStatistics or else as a side effect of a | 4488 // populated (via a call to CollectStatistics or else as a side effect of a |
4491 // just-completed scavenge collection). | 4489 // just-completed scavenge collection). |
4492 void Heap::ReportHeapStatistics(const char* title) { | 4490 void Heap::ReportHeapStatistics(const char* title) { |
4493 USE(title); | 4491 USE(title); |
4494 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", title, | 4492 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", title, |
4495 gc_count_); | 4493 gc_count_); |
4496 PrintF("old_generation_allocation_limit_ %" V8_PTR_PREFIX "d\n", | 4494 PrintF("old_generation_allocation_limit_ %" V8PRIdPTR "\n", |
4497 old_generation_allocation_limit_); | 4495 old_generation_allocation_limit_); |
4498 | 4496 |
4499 PrintF("\n"); | 4497 PrintF("\n"); |
4500 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); | 4498 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); |
4501 isolate_->global_handles()->PrintStats(); | 4499 isolate_->global_handles()->PrintStats(); |
4502 PrintF("\n"); | 4500 PrintF("\n"); |
4503 | 4501 |
4504 PrintF("Heap statistics : "); | 4502 PrintF("Heap statistics : "); |
4505 memory_allocator()->ReportStatistics(); | 4503 memory_allocator()->ReportStatistics(); |
4506 PrintF("To space : "); | 4504 PrintF("To space : "); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5153 } | 5151 } |
5154 | 5152 |
5155 if (FLAG_heap_growing_percent > 0) { | 5153 if (FLAG_heap_growing_percent > 0) { |
5156 factor = 1.0 + FLAG_heap_growing_percent / 100.0; | 5154 factor = 1.0 + FLAG_heap_growing_percent / 100.0; |
5157 } | 5155 } |
5158 | 5156 |
5159 old_generation_allocation_limit_ = | 5157 old_generation_allocation_limit_ = |
5160 CalculateOldGenerationAllocationLimit(factor, old_gen_size); | 5158 CalculateOldGenerationAllocationLimit(factor, old_gen_size); |
5161 | 5159 |
5162 if (FLAG_trace_gc_verbose) { | 5160 if (FLAG_trace_gc_verbose) { |
5163 PrintIsolate(isolate_, "Grow: old size: %" V8_PTR_PREFIX | 5161 PrintIsolate(isolate_, "Grow: old size: %" V8PRIdPTR |
5164 "d KB, new limit: %" V8_PTR_PREFIX "d KB (%.1f)\n", | 5162 " KB, new limit: %" V8PRIdPTR " KB (%.1f)\n", |
5165 old_gen_size / KB, old_generation_allocation_limit_ / KB, | 5163 old_gen_size / KB, old_generation_allocation_limit_ / KB, |
5166 factor); | 5164 factor); |
5167 } | 5165 } |
5168 } | 5166 } |
5169 | 5167 |
5170 | 5168 |
5171 void Heap::DampenOldGenerationAllocationLimit(intptr_t old_gen_size, | 5169 void Heap::DampenOldGenerationAllocationLimit(intptr_t old_gen_size, |
5172 double gc_speed, | 5170 double gc_speed, |
5173 double mutator_speed) { | 5171 double mutator_speed) { |
5174 double factor = HeapGrowingFactor(gc_speed, mutator_speed); | 5172 double factor = HeapGrowingFactor(gc_speed, mutator_speed); |
5175 intptr_t limit = CalculateOldGenerationAllocationLimit(factor, old_gen_size); | 5173 intptr_t limit = CalculateOldGenerationAllocationLimit(factor, old_gen_size); |
5176 if (limit < old_generation_allocation_limit_) { | 5174 if (limit < old_generation_allocation_limit_) { |
5177 if (FLAG_trace_gc_verbose) { | 5175 if (FLAG_trace_gc_verbose) { |
5178 PrintIsolate(isolate_, "Dampen: old size: %" V8_PTR_PREFIX | 5176 PrintIsolate(isolate_, |
5179 "d KB, old limit: %" V8_PTR_PREFIX | 5177 "Dampen: old size: %" V8PRIdPTR " KB, old limit: %" V8PRIdPTR |
5180 "d KB, " | 5178 " KB, " |
5181 "new limit: %" V8_PTR_PREFIX "d KB (%.1f)\n", | 5179 "new limit: %" V8PRIdPTR " KB (%.1f)\n", |
5182 old_gen_size / KB, old_generation_allocation_limit_ / KB, | 5180 old_gen_size / KB, old_generation_allocation_limit_ / KB, |
5183 limit / KB, factor); | 5181 limit / KB, factor); |
5184 } | 5182 } |
5185 old_generation_allocation_limit_ = limit; | 5183 old_generation_allocation_limit_ = limit; |
5186 } | 5184 } |
5187 } | 5185 } |
5188 | 5186 |
5189 | 5187 |
5190 void Heap::EnableInlineAllocation() { | 5188 void Heap::EnableInlineAllocation() { |
5191 if (!inline_allocation_disabled_) return; | 5189 if (!inline_allocation_disabled_) return; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5396 | 5394 |
5397 UpdateMaximumCommitted(); | 5395 UpdateMaximumCommitted(); |
5398 | 5396 |
5399 if (FLAG_print_cumulative_gc_stat) { | 5397 if (FLAG_print_cumulative_gc_stat) { |
5400 PrintF("\n"); | 5398 PrintF("\n"); |
5401 PrintF("gc_count=%d ", gc_count_); | 5399 PrintF("gc_count=%d ", gc_count_); |
5402 PrintF("mark_sweep_count=%d ", ms_count_); | 5400 PrintF("mark_sweep_count=%d ", ms_count_); |
5403 PrintF("max_gc_pause=%.1f ", get_max_gc_pause()); | 5401 PrintF("max_gc_pause=%.1f ", get_max_gc_pause()); |
5404 PrintF("total_gc_time=%.1f ", total_gc_time_ms_); | 5402 PrintF("total_gc_time=%.1f ", total_gc_time_ms_); |
5405 PrintF("min_in_mutator=%.1f ", get_min_in_mutator()); | 5403 PrintF("min_in_mutator=%.1f ", get_min_in_mutator()); |
5406 PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", get_max_alive_after_gc()); | 5404 PrintF("max_alive_after_gc=%" V8PRIdPTR " ", get_max_alive_after_gc()); |
5407 PrintF("total_marking_time=%.1f ", tracer()->cumulative_marking_duration()); | 5405 PrintF("total_marking_time=%.1f ", tracer()->cumulative_marking_duration()); |
5408 PrintF("total_sweeping_time=%.1f ", | 5406 PrintF("total_sweeping_time=%.1f ", |
5409 tracer()->cumulative_sweeping_duration()); | 5407 tracer()->cumulative_sweeping_duration()); |
5410 PrintF("\n\n"); | 5408 PrintF("\n\n"); |
5411 } | 5409 } |
5412 | 5410 |
5413 if (FLAG_print_max_heap_committed) { | 5411 if (FLAG_print_max_heap_committed) { |
5414 PrintF("\n"); | 5412 PrintF("\n"); |
5415 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", | 5413 PrintF("maximum_committed_by_heap=%" V8PRIdPTR " ", |
5416 MaximumCommittedMemory()); | 5414 MaximumCommittedMemory()); |
5417 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", | 5415 PrintF("maximum_committed_by_new_space=%" V8PRIdPTR " ", |
5418 new_space_.MaximumCommittedMemory()); | 5416 new_space_.MaximumCommittedMemory()); |
5419 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", | 5417 PrintF("maximum_committed_by_old_space=%" V8PRIdPTR " ", |
5420 old_space_->MaximumCommittedMemory()); | 5418 old_space_->MaximumCommittedMemory()); |
5421 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", | 5419 PrintF("maximum_committed_by_code_space=%" V8PRIdPTR " ", |
5422 code_space_->MaximumCommittedMemory()); | 5420 code_space_->MaximumCommittedMemory()); |
5423 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", | 5421 PrintF("maximum_committed_by_map_space=%" V8PRIdPTR " ", |
5424 map_space_->MaximumCommittedMemory()); | 5422 map_space_->MaximumCommittedMemory()); |
5425 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", | 5423 PrintF("maximum_committed_by_lo_space=%" V8PRIdPTR " ", |
5426 lo_space_->MaximumCommittedMemory()); | 5424 lo_space_->MaximumCommittedMemory()); |
5427 PrintF("\n\n"); | 5425 PrintF("\n\n"); |
5428 } | 5426 } |
5429 | 5427 |
5430 if (FLAG_verify_predictable) { | 5428 if (FLAG_verify_predictable) { |
5431 PrintAlloctionsHash(); | 5429 PrintAlloctionsHash(); |
5432 } | 5430 } |
5433 | 5431 |
5434 new_space()->RemoveAllocationObserver(idle_scavenge_observer_); | 5432 new_space()->RemoveAllocationObserver(idle_scavenge_observer_); |
5435 delete idle_scavenge_observer_; | 5433 delete idle_scavenge_observer_; |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6447 } | 6445 } |
6448 | 6446 |
6449 | 6447 |
6450 // static | 6448 // static |
6451 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6449 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6452 return StaticVisitorBase::GetVisitorId(map); | 6450 return StaticVisitorBase::GetVisitorId(map); |
6453 } | 6451 } |
6454 | 6452 |
6455 } // namespace internal | 6453 } // namespace internal |
6456 } // namespace v8 | 6454 } // namespace v8 |
OLD | NEW |