hotspot/src/share/vm/gc/shared/collectorPolicy.cpp
changeset 35521 3cb32806ed1d
parent 35492 c8c0273e6b91
child 35864 40e215ce799a
equal deleted inserted replaced
35519:9200162499f7 35521:3cb32806ed1d
   301     }
   301     }
   302   }
   302   }
   303 
   303 
   304   // Make sure NewSize allows an old generation to fit even if set on the command line
   304   // Make sure NewSize allows an old generation to fit even if set on the command line
   305   if (FLAG_IS_CMDLINE(NewSize) && NewSize >= _initial_heap_byte_size) {
   305   if (FLAG_IS_CMDLINE(NewSize) && NewSize >= _initial_heap_byte_size) {
   306     warning("NewSize was set larger than initial heap size, will use initial heap size.");
   306     log_warning(gc, ergo)("NewSize was set larger than initial heap size, will use initial heap size.");
   307     NewSize = bound_minus_alignment(NewSize, _initial_heap_byte_size);
   307     NewSize = bound_minus_alignment(NewSize, _initial_heap_byte_size);
   308   }
   308   }
   309 
   309 
   310   // Now take the actual NewSize into account. We will silently increase NewSize
   310   // Now take the actual NewSize into account. We will silently increase NewSize
   311   // if the user specified a smaller or unaligned value.
   311   // if the user specified a smaller or unaligned value.
   323   if (!FLAG_IS_DEFAULT(MaxNewSize)) {
   323   if (!FLAG_IS_DEFAULT(MaxNewSize)) {
   324     if (MaxNewSize >= MaxHeapSize) {
   324     if (MaxNewSize >= MaxHeapSize) {
   325       // Make sure there is room for an old generation
   325       // Make sure there is room for an old generation
   326       size_t smaller_max_new_size = MaxHeapSize - _gen_alignment;
   326       size_t smaller_max_new_size = MaxHeapSize - _gen_alignment;
   327       if (FLAG_IS_CMDLINE(MaxNewSize)) {
   327       if (FLAG_IS_CMDLINE(MaxNewSize)) {
   328         warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or greater than the entire "
   328         log_warning(gc, ergo)("MaxNewSize (" SIZE_FORMAT "k) is equal to or greater than the entire "
   329                 "heap (" SIZE_FORMAT "k).  A new max generation size of " SIZE_FORMAT "k will be used.",
   329                               "heap (" SIZE_FORMAT "k).  A new max generation size of " SIZE_FORMAT "k will be used.",
   330                 MaxNewSize/K, MaxHeapSize/K, smaller_max_new_size/K);
   330                               MaxNewSize/K, MaxHeapSize/K, smaller_max_new_size/K);
   331       }
   331       }
   332       FLAG_SET_ERGO(size_t, MaxNewSize, smaller_max_new_size);
   332       FLAG_SET_ERGO(size_t, MaxNewSize, smaller_max_new_size);
   333       if (NewSize > MaxNewSize) {
   333       if (NewSize > MaxNewSize) {
   334         FLAG_SET_ERGO(size_t, NewSize, MaxNewSize);
   334         FLAG_SET_ERGO(size_t, NewSize, MaxNewSize);
   335         _initial_young_size = NewSize;
   335         _initial_young_size = NewSize;
   344 
   344 
   345   if (NewSize > MaxNewSize) {
   345   if (NewSize > MaxNewSize) {
   346     // At this point this should only happen if the user specifies a large NewSize and/or
   346     // At this point this should only happen if the user specifies a large NewSize and/or
   347     // a small (but not too small) MaxNewSize.
   347     // a small (but not too small) MaxNewSize.
   348     if (FLAG_IS_CMDLINE(MaxNewSize)) {
   348     if (FLAG_IS_CMDLINE(MaxNewSize)) {
   349       warning("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). "
   349       log_warning(gc, ergo)("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). "
   350               "A new max generation size of " SIZE_FORMAT "k will be used.",
   350                             "A new max generation size of " SIZE_FORMAT "k will be used.",
   351               NewSize/K, MaxNewSize/K, NewSize/K);
   351                             NewSize/K, MaxNewSize/K, NewSize/K);
   352     }
   352     }
   353     FLAG_SET_ERGO(size_t, MaxNewSize, NewSize);
   353     FLAG_SET_ERGO(size_t, MaxNewSize, NewSize);
   354     _max_young_size = MaxNewSize;
   354     _max_young_size = MaxNewSize;
   355   }
   355   }
   356 
   356 
   514     // If the user has explicitly set an OldSize that is inconsistent
   514     // If the user has explicitly set an OldSize that is inconsistent
   515     // with other command line flags, issue a warning.
   515     // with other command line flags, issue a warning.
   516     // The generation minimums and the overall heap minimum should
   516     // The generation minimums and the overall heap minimum should
   517     // be within one generation alignment.
   517     // be within one generation alignment.
   518     if (_initial_old_size > _max_old_size) {
   518     if (_initial_old_size > _max_old_size) {
   519       warning("Inconsistency between maximum heap size and maximum "
   519       log_warning(gc, ergo)("Inconsistency between maximum heap size and maximum "
   520           "generation sizes: using maximum heap = " SIZE_FORMAT
   520                             "generation sizes: using maximum heap = " SIZE_FORMAT
   521           " -XX:OldSize flag is being ignored",
   521                             ", -XX:OldSize flag is being ignored",
   522           _max_heap_byte_size);
   522                             _max_heap_byte_size);
   523       _initial_old_size = _max_old_size;
   523       _initial_old_size = _max_old_size;
   524     }
   524     }
   525 
   525 
   526     _min_old_size = MIN2(_initial_old_size, _min_heap_byte_size - _min_young_size);
   526     _min_old_size = MIN2(_initial_old_size, _min_heap_byte_size - _min_young_size);
   527   }
   527   }
   529   // The initial generation sizes should match the initial heap size,
   529   // The initial generation sizes should match the initial heap size,
   530   // if not issue a warning and resize the generations. This behavior
   530   // if not issue a warning and resize the generations. This behavior
   531   // differs from JDK8 where the generation sizes have higher priority
   531   // differs from JDK8 where the generation sizes have higher priority
   532   // than the initial heap size.
   532   // than the initial heap size.
   533   if ((_initial_old_size + _initial_young_size) != _initial_heap_byte_size) {
   533   if ((_initial_old_size + _initial_young_size) != _initial_heap_byte_size) {
   534     warning("Inconsistency between generation sizes and heap size, resizing "
   534     log_warning(gc, ergo)("Inconsistency between generation sizes and heap size, resizing "
   535             "the generations to fit the heap.");
   535                           "the generations to fit the heap.");
   536 
   536 
   537     size_t desired_young_size = _initial_heap_byte_size - _initial_old_size;
   537     size_t desired_young_size = _initial_heap_byte_size - _initial_old_size;
   538     if (_initial_heap_byte_size < _initial_old_size) {
   538     if (_initial_heap_byte_size < _initial_old_size) {
   539       // Old want all memory, use minimum for young and rest for old
   539       // Old want all memory, use minimum for young and rest for old
   540       _initial_young_size = _min_young_size;
   540       _initial_young_size = _min_young_size;
   695     }
   695     }
   696 
   696 
   697     // Give a warning if we seem to be looping forever.
   697     // Give a warning if we seem to be looping forever.
   698     if ((QueuedAllocationWarningCount > 0) &&
   698     if ((QueuedAllocationWarningCount > 0) &&
   699         (try_count % QueuedAllocationWarningCount == 0)) {
   699         (try_count % QueuedAllocationWarningCount == 0)) {
   700           warning("GenCollectorPolicy::mem_allocate_work retries %d times \n\t"
   700           log_warning(gc, ergo)("GenCollectorPolicy::mem_allocate_work retries %d times,"
   701                   " size=" SIZE_FORMAT " %s", try_count, size, is_tlab ? "(TLAB)" : "");
   701                                 " size=" SIZE_FORMAT " %s", try_count, size, is_tlab ? "(TLAB)" : "");
   702     }
   702     }
   703   }
   703   }
   704 }
   704 }
   705 
   705 
   706 HeapWord* GenCollectorPolicy::expand_heap_and_allocate(size_t size,
   706 HeapWord* GenCollectorPolicy::expand_heap_and_allocate(size_t size,
   868       return op.result();
   868       return op.result();
   869     }
   869     }
   870     loop_count++;
   870     loop_count++;
   871     if ((QueuedAllocationWarningCount > 0) &&
   871     if ((QueuedAllocationWarningCount > 0) &&
   872         (loop_count % QueuedAllocationWarningCount == 0)) {
   872         (loop_count % QueuedAllocationWarningCount == 0)) {
   873       warning("satisfy_failed_metadata_allocation() retries %d times \n\t"
   873       log_warning(gc, ergo)("satisfy_failed_metadata_allocation() retries %d times,"
   874               " size=" SIZE_FORMAT, loop_count, word_size);
   874                             " size=" SIZE_FORMAT, loop_count, word_size);
   875     }
   875     }
   876   } while (true);  // Until a GC is done
   876   } while (true);  // Until a GC is done
   877 }
   877 }
   878 
   878 
   879 // Return true if any of the following is true:
   879 // Return true if any of the following is true: