Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @ 3976:d912b598c6c3
7091032: G1: assert failure when NewRatio is used
Summary: The desired min / max heap sizes are miscalculated at initialization when NewRatio is used. The changeset also includes an additional small change to turn a print statement into a warning.
Reviewed-by: johnc, jmasa, ysr, brutisso
author | tonyp |
---|---|
date | Wed, 21 Sep 2011 13:36:37 -0400 |
parents | f1b4e0e0bdad |
children | 4dfb2df418f2 |
comparison
equal
deleted
inserted
replaced
3975:1847b501ae74 | 3976:d912b598c6c3 |
---|---|
457 // TwoGenerationCollectorPolicy class. This is similar to what | 457 // TwoGenerationCollectorPolicy class. This is similar to what |
458 // ParallelScavenge does with its GenerationSizer class (see | 458 // ParallelScavenge does with its GenerationSizer class (see |
459 // ParallelScavengeHeap::initialize()). We might change this in the | 459 // ParallelScavengeHeap::initialize()). We might change this in the |
460 // future, but it's a good start. | 460 // future, but it's a good start. |
461 class G1YoungGenSizer : public TwoGenerationCollectorPolicy { | 461 class G1YoungGenSizer : public TwoGenerationCollectorPolicy { |
462 private: | |
463 size_t size_to_region_num(size_t byte_size) { | |
464 return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes); | |
465 } | |
462 | 466 |
463 public: | 467 public: |
464 G1YoungGenSizer() { | 468 G1YoungGenSizer() { |
465 initialize_flags(); | 469 initialize_flags(); |
466 initialize_size_info(); | 470 initialize_size_info(); |
467 } | |
468 size_t size_to_region_num(size_t byte_size) { | |
469 return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes); | |
470 } | 471 } |
471 size_t min_young_region_num() { | 472 size_t min_young_region_num() { |
472 return size_to_region_num(_min_gen0_size); | 473 return size_to_region_num(_min_gen0_size); |
473 } | 474 } |
474 size_t initial_young_region_num() { | 475 size_t initial_young_region_num() { |
499 _min_desired_young_length = sizer.min_young_region_num(); | 500 _min_desired_young_length = sizer.min_young_region_num(); |
500 _max_desired_young_length = sizer.max_young_region_num(); | 501 _max_desired_young_length = sizer.max_young_region_num(); |
501 | 502 |
502 if (FLAG_IS_CMDLINE(NewRatio)) { | 503 if (FLAG_IS_CMDLINE(NewRatio)) { |
503 if (FLAG_IS_CMDLINE(NewSize) || FLAG_IS_CMDLINE(MaxNewSize)) { | 504 if (FLAG_IS_CMDLINE(NewSize) || FLAG_IS_CMDLINE(MaxNewSize)) { |
504 gclog_or_tty->print_cr("-XX:NewSize and -XX:MaxNewSize overrides -XX:NewRatio"); | 505 warning("-XX:NewSize and -XX:MaxNewSize override -XX:NewRatio"); |
505 } else { | 506 } else { |
506 // Treat NewRatio as a fixed size that is only recalculated when the heap size changes | 507 // Treat NewRatio as a fixed size that is only recalculated when the heap size changes |
507 size_t heap_regions = sizer.size_to_region_num(_g1->n_regions()); | 508 update_young_list_size_using_newratio(_g1->n_regions()); |
508 update_young_list_size_using_newratio(heap_regions); | |
509 _using_new_ratio_calculations = true; | 509 _using_new_ratio_calculations = true; |
510 } | 510 } |
511 } | 511 } |
512 | 512 |
513 // GenCollectorPolicy guarantees that min <= initial <= max. | 513 // GenCollectorPolicy guarantees that min <= initial <= max. |