--- a/hotspot/src/share/vm/runtime/arguments.cpp Wed Jan 15 07:20:04 2014 -0800
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Jan 29 23:17:05 2014 +0100
@@ -1569,6 +1569,16 @@
vm_exit(1);
}
+ if (UseAdaptiveSizePolicy) {
+ // We don't want to limit adaptive heap sizing's freedom to adjust the heap
+ // unless the user actually sets these flags.
+ if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
+ FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
+ }
+ if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
+ FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
+ }
+ }
// If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
// SurvivorRatio has been set, reset their default values to SurvivorRatio +
@@ -1844,7 +1854,7 @@
}
bool Arguments::verify_percentage(uintx value, const char* name) {
- if (value <= 100) {
+ if (is_percentage(value)) {
return true;
}
jio_fprintf(defaultStream::error_stream(),
@@ -1932,6 +1942,34 @@
return count_p < 2 && count_t < 2;
}
+bool Arguments::verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio) {
+ if (!is_percentage(min_heap_free_ratio)) {
+ err_msg.print("MinHeapFreeRatio must have a value between 0 and 100");
+ return false;
+ }
+ if (min_heap_free_ratio > MaxHeapFreeRatio) {
+ err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
+ "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio,
+ MaxHeapFreeRatio);
+ return false;
+ }
+ return true;
+}
+
+bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) {
+ if (!is_percentage(max_heap_free_ratio)) {
+ err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100");
+ return false;
+ }
+ if (max_heap_free_ratio < MinHeapFreeRatio) {
+ err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
+ "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio,
+ MinHeapFreeRatio);
+ return false;
+ }
+ return true;
+}
+
// Check consistency of GC selection
bool Arguments::check_gc_consistency() {
check_gclog_consistency();
@@ -2037,8 +2075,6 @@
status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
"AdaptiveSizePolicyWeight");
status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
- status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
- status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
// Divide by bucket size to prevent a large size from causing rollover when
// calculating amount of memory needed to be allocated for the String table.
@@ -2048,15 +2084,19 @@
status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
(max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
- if (MinHeapFreeRatio > MaxHeapFreeRatio) {
- jio_fprintf(defaultStream::error_stream(),
- "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
- "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
- MinHeapFreeRatio, MaxHeapFreeRatio);
- status = false;
+ {
+ // Using "else if" below to avoid printing two error messages if min > max.
+ // This will also prevent us from reporting both min>100 and max>100 at the
+ // same time, but that is less annoying than printing two identical errors IMHO.
+ FormatBuffer<80> err_msg("");
+ if (!verify_MinHeapFreeRatio(err_msg, MinHeapFreeRatio)) {
+ jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
+ status = false;
+ } else if (!verify_MaxHeapFreeRatio(err_msg, MaxHeapFreeRatio)) {
+ jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
+ status = false;
+ }
}
- // Keeping the heap 100% free is hard ;-) so limit it to 99%.
- MinHeapFreeRatio = MIN2(MinHeapFreeRatio, (uintx) 99);
// Min/MaxMetaspaceFreeRatio
status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
@@ -2689,7 +2729,7 @@
} else if (match_option(option, "-Xmaxf", &tail)) {
char* err;
int maxf = (int)(strtod(tail, &err) * 100);
- if (*err != '\0' || maxf < 0 || maxf > 100) {
+ if (*err != '\0' || *tail == '\0' || maxf < 0 || maxf > 100) {
jio_fprintf(defaultStream::error_stream(),
"Bad max heap free percentage size: %s\n",
option->optionString);
@@ -2701,7 +2741,7 @@
} else if (match_option(option, "-Xminf", &tail)) {
char* err;
int minf = (int)(strtod(tail, &err) * 100);
- if (*err != '\0' || minf < 0 || minf > 100) {
+ if (*err != '\0' || *tail == '\0' || minf < 0 || minf > 100) {
jio_fprintf(defaultStream::error_stream(),
"Bad min heap free percentage size: %s\n",
option->optionString);
@@ -3646,9 +3686,9 @@
// Set per-collector flags
if (UseParallelGC || UseParallelOldGC) {
set_parallel_gc_flags();
- } else if (UseConcMarkSweepGC) { // should be done before ParNew check below
+ } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
set_cms_and_parnew_gc_flags();
- } else if (UseParNewGC) { // skipped if CMS is set above
+ } else if (UseParNewGC) { // Skipped if CMS is set above
set_parnew_gc_flags();
} else if (UseG1GC) {
set_g1_gc_flags();
@@ -3662,6 +3702,10 @@
" using -XX:ParallelGCThreads=N");
}
}
+ if (MinHeapFreeRatio == 100) {
+ // Keeping the heap 100% free is hard ;-) so limit it to 99%.
+ FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
+ }
#else // INCLUDE_ALL_GCS
assert(verify_serial_gc_flags(), "SerialGC unset");
#endif // INCLUDE_ALL_GCS