hotspot/src/share/vm/gc/shared/collectorPolicy.cpp
changeset 35061 be6025ebffea
parent 33212 906b3d079b13
child 35492 c8c0273e6b91
equal deleted inserted replaced
35060:382d0689141c 35061:be6025ebffea
    30 #include "gc/shared/gcPolicyCounters.hpp"
    30 #include "gc/shared/gcPolicyCounters.hpp"
    31 #include "gc/shared/genCollectedHeap.hpp"
    31 #include "gc/shared/genCollectedHeap.hpp"
    32 #include "gc/shared/generationSpec.hpp"
    32 #include "gc/shared/generationSpec.hpp"
    33 #include "gc/shared/space.hpp"
    33 #include "gc/shared/space.hpp"
    34 #include "gc/shared/vmGCOperations.hpp"
    34 #include "gc/shared/vmGCOperations.hpp"
       
    35 #include "logging/log.hpp"
    35 #include "memory/universe.hpp"
    36 #include "memory/universe.hpp"
    36 #include "runtime/arguments.hpp"
    37 #include "runtime/arguments.hpp"
    37 #include "runtime/globals_extension.hpp"
    38 #include "runtime/globals_extension.hpp"
    38 #include "runtime/handles.inline.hpp"
    39 #include "runtime/handles.inline.hpp"
    39 #include "runtime/java.hpp"
    40 #include "runtime/java.hpp"
   135 
   136 
   136   DEBUG_ONLY(CollectorPolicy::assert_flags();)
   137   DEBUG_ONLY(CollectorPolicy::assert_flags();)
   137 }
   138 }
   138 
   139 
   139 void CollectorPolicy::initialize_size_info() {
   140 void CollectorPolicy::initialize_size_info() {
   140   if (PrintGCDetails && Verbose) {
   141   log_debug(gc, heap)("Minimum heap " SIZE_FORMAT "  Initial heap " SIZE_FORMAT "  Maximum heap " SIZE_FORMAT,
   141     gclog_or_tty->print_cr("Minimum heap " SIZE_FORMAT "  Initial heap "
   142                       _min_heap_byte_size, _initial_heap_byte_size, _max_heap_byte_size);
   142       SIZE_FORMAT "  Maximum heap " SIZE_FORMAT,
       
   143       _min_heap_byte_size, _initial_heap_byte_size, _max_heap_byte_size);
       
   144   }
       
   145 
   143 
   146   DEBUG_ONLY(CollectorPolicy::assert_size_info();)
   144   DEBUG_ONLY(CollectorPolicy::assert_size_info();)
   147 }
   145 }
   148 
   146 
   149 bool CollectorPolicy::use_should_clear_all_soft_refs(bool v) {
   147 bool CollectorPolicy::use_should_clear_all_soft_refs(bool v) {
   486       _initial_young_size =
   484       _initial_young_size =
   487         MIN2(_max_young_size, MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize));
   485         MIN2(_max_young_size, MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize));
   488     }
   486     }
   489   }
   487   }
   490 
   488 
   491   if (PrintGCDetails && Verbose) {
   489   log_trace(gc, heap)("1: Minimum young " SIZE_FORMAT "  Initial young " SIZE_FORMAT "  Maximum young " SIZE_FORMAT,
   492     gclog_or_tty->print_cr("1: Minimum young " SIZE_FORMAT "  Initial young "
   490                       _min_young_size, _initial_young_size, _max_young_size);
   493       SIZE_FORMAT "  Maximum young " SIZE_FORMAT,
       
   494       _min_young_size, _initial_young_size, _max_young_size);
       
   495   }
       
   496 
   491 
   497   // At this point the minimum, initial and maximum sizes
   492   // At this point the minimum, initial and maximum sizes
   498   // of the overall heap and of the young generation have been determined.
   493   // of the overall heap and of the young generation have been determined.
   499   // The maximum old size can be determined from the maximum young
   494   // The maximum old size can be determined from the maximum young
   500   // and maximum heap size since no explicit flags exist
   495   // and maximum heap size since no explicit flags exist
   556       // The young generation boundaries allow us to only update the
   551       // The young generation boundaries allow us to only update the
   557       // young generation.
   552       // young generation.
   558       _initial_young_size = desired_young_size;
   553       _initial_young_size = desired_young_size;
   559     }
   554     }
   560 
   555 
   561     if (PrintGCDetails && Verbose) {
   556     log_trace(gc, heap)("2: Minimum young " SIZE_FORMAT "  Initial young " SIZE_FORMAT "  Maximum young " SIZE_FORMAT,
   562       gclog_or_tty->print_cr("2: Minimum young " SIZE_FORMAT "  Initial young "
   557                     _min_young_size, _initial_young_size, _max_young_size);
   563         SIZE_FORMAT "  Maximum young " SIZE_FORMAT,
       
   564         _min_young_size, _initial_young_size, _max_young_size);
       
   565     }
       
   566   }
   558   }
   567 
   559 
   568   // Write back to flags if necessary.
   560   // Write back to flags if necessary.
   569   if (NewSize != _initial_young_size) {
   561   if (NewSize != _initial_young_size) {
   570     FLAG_SET_ERGO(size_t, NewSize, _initial_young_size);
   562     FLAG_SET_ERGO(size_t, NewSize, _initial_young_size);
   576 
   568 
   577   if (OldSize != _initial_old_size) {
   569   if (OldSize != _initial_old_size) {
   578     FLAG_SET_ERGO(size_t, OldSize, _initial_old_size);
   570     FLAG_SET_ERGO(size_t, OldSize, _initial_old_size);
   579   }
   571   }
   580 
   572 
   581   if (PrintGCDetails && Verbose) {
   573   log_trace(gc, heap)("Minimum old " SIZE_FORMAT "  Initial old " SIZE_FORMAT "  Maximum old " SIZE_FORMAT,
   582     gclog_or_tty->print_cr("Minimum old " SIZE_FORMAT "  Initial old "
   574                   _min_old_size, _initial_old_size, _max_old_size);
   583       SIZE_FORMAT "  Maximum old " SIZE_FORMAT,
       
   584       _min_old_size, _initial_old_size, _max_old_size);
       
   585   }
       
   586 
   575 
   587   DEBUG_ONLY(GenCollectorPolicy::assert_size_info();)
   576   DEBUG_ONLY(GenCollectorPolicy::assert_size_info();)
   588 }
   577 }
   589 
   578 
   590 HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size,
   579 HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size,
   618       }
   607       }
   619     }
   608     }
   620     uint gc_count_before;  // Read inside the Heap_lock locked region.
   609     uint gc_count_before;  // Read inside the Heap_lock locked region.
   621     {
   610     {
   622       MutexLocker ml(Heap_lock);
   611       MutexLocker ml(Heap_lock);
   623       if (PrintGC && Verbose) {
   612       log_trace(gc, alloc)("GenCollectorPolicy::mem_allocate_work: attempting locked slow path allocation");
   624         gclog_or_tty->print_cr("GenCollectorPolicy::mem_allocate_work:"
       
   625                                " attempting locked slow path allocation");
       
   626       }
       
   627       // Note that only large objects get a shot at being
   613       // Note that only large objects get a shot at being
   628       // allocated in later generations.
   614       // allocated in later generations.
   629       bool first_only = ! should_try_older_generation_allocation(size);
   615       bool first_only = ! should_try_older_generation_allocation(size);
   630 
   616 
   631       result = gch->attempt_allocation(size, is_tlab, first_only);
   617       result = gch->attempt_allocation(size, is_tlab, first_only);
   755                        false,                     // clear_all_soft_refs
   741                        false,                     // clear_all_soft_refs
   756                        size,                      // size
   742                        size,                      // size
   757                        is_tlab,                   // is_tlab
   743                        is_tlab,                   // is_tlab
   758                        GenCollectedHeap::OldGen); // max_generation
   744                        GenCollectedHeap::OldGen); // max_generation
   759   } else {
   745   } else {
   760     if (Verbose && PrintGCDetails) {
   746     log_trace(gc)(" :: Trying full because partial may fail :: ");
   761       gclog_or_tty->print(" :: Trying full because partial may fail :: ");
       
   762     }
       
   763     // Try a full collection; see delta for bug id 6266275
   747     // Try a full collection; see delta for bug id 6266275
   764     // for the original code and why this has been simplified
   748     // for the original code and why this has been simplified
   765     // with from-space allocation criteria modified and
   749     // with from-space allocation criteria modified and
   766     // such allocation moved out of the safepoint path.
   750     // such allocation moved out of the safepoint path.
   767     gch->do_collection(true,                      // full
   751     gch->do_collection(true,                      // full