hotspot/src/share/vm/gc/parallel/psOldGen.cpp
changeset 46619 a3919f5e8d2b
parent 37073 c39d0903390b
child 46625 edefffab74e2
equal deleted inserted replaced
46618:d503911aa948 46619:a3919f5e8d2b
   227   if (bytes == 0) {
   227   if (bytes == 0) {
   228     return;
   228     return;
   229   }
   229   }
   230   MutexLocker x(ExpandHeap_lock);
   230   MutexLocker x(ExpandHeap_lock);
   231   const size_t alignment = virtual_space()->alignment();
   231   const size_t alignment = virtual_space()->alignment();
   232   size_t aligned_bytes  = align_size_up(bytes, alignment);
   232   size_t aligned_bytes  = align_up(bytes, alignment);
   233   size_t aligned_expand_bytes = align_size_up(MinHeapDeltaBytes, alignment);
   233   size_t aligned_expand_bytes = align_up(MinHeapDeltaBytes, alignment);
   234 
   234 
   235   if (UseNUMA) {
   235   if (UseNUMA) {
   236     // With NUMA we use round-robin page allocation for the old gen. Expand by at least
   236     // With NUMA we use round-robin page allocation for the old gen. Expand by at least
   237     // providing a page per lgroup. Alignment is larger or equal to the page size.
   237     // providing a page per lgroup. Alignment is larger or equal to the page size.
   238     aligned_expand_bytes = MAX2(aligned_expand_bytes, alignment * os::numa_get_groups_num());
   238     aligned_expand_bytes = MAX2(aligned_expand_bytes, alignment * os::numa_get_groups_num());
   242     // return true with the implication that and expansion was done when it
   242     // return true with the implication that and expansion was done when it
   243     // was not.  A call to expand implies a best effort to expand by "bytes"
   243     // was not.  A call to expand implies a best effort to expand by "bytes"
   244     // but not a guarantee.  Align down to give a best effort.  This is likely
   244     // but not a guarantee.  Align down to give a best effort.  This is likely
   245     // the most that the generation can expand since it has some capacity to
   245     // the most that the generation can expand since it has some capacity to
   246     // start with.
   246     // start with.
   247     aligned_bytes = align_size_down(bytes, alignment);
   247     aligned_bytes = align_down(bytes, alignment);
   248   }
   248   }
   249 
   249 
   250   bool success = false;
   250   bool success = false;
   251   if (aligned_expand_bytes > aligned_bytes) {
   251   if (aligned_expand_bytes > aligned_bytes) {
   252     success = expand_by(aligned_expand_bytes);
   252     success = expand_by(aligned_expand_bytes);
   316 
   316 
   317 void PSOldGen::shrink(size_t bytes) {
   317 void PSOldGen::shrink(size_t bytes) {
   318   assert_lock_strong(ExpandHeap_lock);
   318   assert_lock_strong(ExpandHeap_lock);
   319   assert_locked_or_safepoint(Heap_lock);
   319   assert_locked_or_safepoint(Heap_lock);
   320 
   320 
   321   size_t size = align_size_down(bytes, virtual_space()->alignment());
   321   size_t size = align_down(bytes, virtual_space()->alignment());
   322   if (size > 0) {
   322   if (size > 0) {
   323     assert_lock_strong(ExpandHeap_lock);
   323     assert_lock_strong(ExpandHeap_lock);
   324     virtual_space()->shrink_by(bytes);
   324     virtual_space()->shrink_by(bytes);
   325     post_resize();
   325     post_resize();
   326 
   326 
   341   }
   341   }
   342   // Adjust according to our min and max
   342   // Adjust according to our min and max
   343   new_size = MAX2(MIN2(new_size, gen_size_limit()), min_gen_size());
   343   new_size = MAX2(MIN2(new_size, gen_size_limit()), min_gen_size());
   344 
   344 
   345   assert(gen_size_limit() >= reserved().byte_size(), "max new size problem?");
   345   assert(gen_size_limit() >= reserved().byte_size(), "max new size problem?");
   346   new_size = align_size_up(new_size, alignment);
   346   new_size = align_up(new_size, alignment);
   347 
   347 
   348   const size_t current_size = capacity_in_bytes();
   348   const size_t current_size = capacity_in_bytes();
   349 
   349 
   350   log_trace(gc, ergo)("AdaptiveSizePolicy::old generation size: "
   350   log_trace(gc, ergo)("AdaptiveSizePolicy::old generation size: "
   351     "desired free: " SIZE_FORMAT " used: " SIZE_FORMAT
   351     "desired free: " SIZE_FORMAT " used: " SIZE_FORMAT