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

Side by Side Diff: src/heap/heap.cc

Issue 1869433004: Fix printf formats (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address review comments. Created 4 years, 8 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
« no previous file with comments | « src/heap/gc-tracer.cc ('k') | src/heap/mark-compact.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/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
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 4065 matching lines...) Expand 10 before | Expand all | Expand 10 after
4476 } 4474 }
4477 4475
4478 4476
4479 // This function expects that NewSpace's allocated objects histogram is 4477 // This function expects that NewSpace's allocated objects histogram is
4480 // populated (via a call to CollectStatistics or else as a side effect of a 4478 // populated (via a call to CollectStatistics or else as a side effect of a
4481 // just-completed scavenge collection). 4479 // just-completed scavenge collection).
4482 void Heap::ReportHeapStatistics(const char* title) { 4480 void Heap::ReportHeapStatistics(const char* title) {
4483 USE(title); 4481 USE(title);
4484 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", title, 4482 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", title,
4485 gc_count_); 4483 gc_count_);
4486 PrintF("old_generation_allocation_limit_ %" V8_PTR_PREFIX "d\n", 4484 PrintF("old_generation_allocation_limit_ %" V8PRIdPTR "\n",
4487 old_generation_allocation_limit_); 4485 old_generation_allocation_limit_);
4488 4486
4489 PrintF("\n"); 4487 PrintF("\n");
4490 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); 4488 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_));
4491 isolate_->global_handles()->PrintStats(); 4489 isolate_->global_handles()->PrintStats();
4492 PrintF("\n"); 4490 PrintF("\n");
4493 4491
4494 PrintF("Heap statistics : "); 4492 PrintF("Heap statistics : ");
4495 memory_allocator()->ReportStatistics(); 4493 memory_allocator()->ReportStatistics();
4496 PrintF("To space : "); 4494 PrintF("To space : ");
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
5143 } 5141 }
5144 5142
5145 if (FLAG_heap_growing_percent > 0) { 5143 if (FLAG_heap_growing_percent > 0) {
5146 factor = 1.0 + FLAG_heap_growing_percent / 100.0; 5144 factor = 1.0 + FLAG_heap_growing_percent / 100.0;
5147 } 5145 }
5148 5146
5149 old_generation_allocation_limit_ = 5147 old_generation_allocation_limit_ =
5150 CalculateOldGenerationAllocationLimit(factor, old_gen_size); 5148 CalculateOldGenerationAllocationLimit(factor, old_gen_size);
5151 5149
5152 if (FLAG_trace_gc_verbose) { 5150 if (FLAG_trace_gc_verbose) {
5153 PrintIsolate(isolate_, "Grow: old size: %" V8_PTR_PREFIX 5151 PrintIsolate(isolate_, "Grow: old size: %" V8PRIdPTR
5154 "d KB, new limit: %" V8_PTR_PREFIX "d KB (%.1f)\n", 5152 " KB, new limit: %" V8PRIdPTR " KB (%.1f)\n",
5155 old_gen_size / KB, old_generation_allocation_limit_ / KB, 5153 old_gen_size / KB, old_generation_allocation_limit_ / KB,
5156 factor); 5154 factor);
5157 } 5155 }
5158 } 5156 }
5159 5157
5160 5158
5161 void Heap::DampenOldGenerationAllocationLimit(intptr_t old_gen_size, 5159 void Heap::DampenOldGenerationAllocationLimit(intptr_t old_gen_size,
5162 double gc_speed, 5160 double gc_speed,
5163 double mutator_speed) { 5161 double mutator_speed) {
5164 double factor = HeapGrowingFactor(gc_speed, mutator_speed); 5162 double factor = HeapGrowingFactor(gc_speed, mutator_speed);
5165 intptr_t limit = CalculateOldGenerationAllocationLimit(factor, old_gen_size); 5163 intptr_t limit = CalculateOldGenerationAllocationLimit(factor, old_gen_size);
5166 if (limit < old_generation_allocation_limit_) { 5164 if (limit < old_generation_allocation_limit_) {
5167 if (FLAG_trace_gc_verbose) { 5165 if (FLAG_trace_gc_verbose) {
5168 PrintIsolate(isolate_, "Dampen: old size: %" V8_PTR_PREFIX 5166 PrintIsolate(isolate_,
5169 "d KB, old limit: %" V8_PTR_PREFIX 5167 "Dampen: old size: %" V8PRIdPTR " KB, old limit: %" V8PRIdPTR
5170 "d KB, " 5168 " KB, "
5171 "new limit: %" V8_PTR_PREFIX "d KB (%.1f)\n", 5169 "new limit: %" V8PRIdPTR " KB (%.1f)\n",
5172 old_gen_size / KB, old_generation_allocation_limit_ / KB, 5170 old_gen_size / KB, old_generation_allocation_limit_ / KB,
5173 limit / KB, factor); 5171 limit / KB, factor);
5174 } 5172 }
5175 old_generation_allocation_limit_ = limit; 5173 old_generation_allocation_limit_ = limit;
5176 } 5174 }
5177 } 5175 }
5178 5176
5179 5177
5180 void Heap::EnableInlineAllocation() { 5178 void Heap::EnableInlineAllocation() {
5181 if (!inline_allocation_disabled_) return; 5179 if (!inline_allocation_disabled_) return;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
5386 5384
5387 UpdateMaximumCommitted(); 5385 UpdateMaximumCommitted();
5388 5386
5389 if (FLAG_print_cumulative_gc_stat) { 5387 if (FLAG_print_cumulative_gc_stat) {
5390 PrintF("\n"); 5388 PrintF("\n");
5391 PrintF("gc_count=%d ", gc_count_); 5389 PrintF("gc_count=%d ", gc_count_);
5392 PrintF("mark_sweep_count=%d ", ms_count_); 5390 PrintF("mark_sweep_count=%d ", ms_count_);
5393 PrintF("max_gc_pause=%.1f ", get_max_gc_pause()); 5391 PrintF("max_gc_pause=%.1f ", get_max_gc_pause());
5394 PrintF("total_gc_time=%.1f ", total_gc_time_ms_); 5392 PrintF("total_gc_time=%.1f ", total_gc_time_ms_);
5395 PrintF("min_in_mutator=%.1f ", get_min_in_mutator()); 5393 PrintF("min_in_mutator=%.1f ", get_min_in_mutator());
5396 PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", get_max_alive_after_gc()); 5394 PrintF("max_alive_after_gc=%" V8PRIdPTR " ", get_max_alive_after_gc());
5397 PrintF("total_marking_time=%.1f ", tracer()->cumulative_marking_duration()); 5395 PrintF("total_marking_time=%.1f ", tracer()->cumulative_marking_duration());
5398 PrintF("total_sweeping_time=%.1f ", 5396 PrintF("total_sweeping_time=%.1f ",
5399 tracer()->cumulative_sweeping_duration()); 5397 tracer()->cumulative_sweeping_duration());
5400 PrintF("\n\n"); 5398 PrintF("\n\n");
5401 } 5399 }
5402 5400
5403 if (FLAG_print_max_heap_committed) { 5401 if (FLAG_print_max_heap_committed) {
5404 PrintF("\n"); 5402 PrintF("\n");
5405 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", 5403 PrintF("maximum_committed_by_heap=%" V8PRIdPTR " ",
5406 MaximumCommittedMemory()); 5404 MaximumCommittedMemory());
5407 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", 5405 PrintF("maximum_committed_by_new_space=%" V8PRIdPTR " ",
5408 new_space_.MaximumCommittedMemory()); 5406 new_space_.MaximumCommittedMemory());
5409 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", 5407 PrintF("maximum_committed_by_old_space=%" V8PRIdPTR " ",
5410 old_space_->MaximumCommittedMemory()); 5408 old_space_->MaximumCommittedMemory());
5411 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", 5409 PrintF("maximum_committed_by_code_space=%" V8PRIdPTR " ",
5412 code_space_->MaximumCommittedMemory()); 5410 code_space_->MaximumCommittedMemory());
5413 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", 5411 PrintF("maximum_committed_by_map_space=%" V8PRIdPTR " ",
5414 map_space_->MaximumCommittedMemory()); 5412 map_space_->MaximumCommittedMemory());
5415 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", 5413 PrintF("maximum_committed_by_lo_space=%" V8PRIdPTR " ",
5416 lo_space_->MaximumCommittedMemory()); 5414 lo_space_->MaximumCommittedMemory());
5417 PrintF("\n\n"); 5415 PrintF("\n\n");
5418 } 5416 }
5419 5417
5420 if (FLAG_verify_predictable) { 5418 if (FLAG_verify_predictable) {
5421 PrintAlloctionsHash(); 5419 PrintAlloctionsHash();
5422 } 5420 }
5423 5421
5424 new_space()->RemoveAllocationObserver(idle_scavenge_observer_); 5422 new_space()->RemoveAllocationObserver(idle_scavenge_observer_);
5425 delete idle_scavenge_observer_; 5423 delete idle_scavenge_observer_;
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
6437 } 6435 }
6438 6436
6439 6437
6440 // static 6438 // static
6441 int Heap::GetStaticVisitorIdForMap(Map* map) { 6439 int Heap::GetStaticVisitorIdForMap(Map* map) {
6442 return StaticVisitorBase::GetVisitorId(map); 6440 return StaticVisitorBase::GetVisitorId(map);
6443 } 6441 }
6444 6442
6445 } // namespace internal 6443 } // namespace internal
6446 } // namespace v8 6444 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/gc-tracer.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698