hotspot/src/share/vm/runtime/arguments.cpp
changeset 22555 ea32f6c51d08
parent 22551 9bf46d16dcc6
child 22556 a17351e8c2c2
child 22763 ac261a7c84b3
equal deleted inserted replaced
22554:a19b9cf9ffa8 22555:ea32f6c51d08
  1567     jio_fprintf(defaultStream::error_stream(),
  1567     jio_fprintf(defaultStream::error_stream(),
  1568         "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
  1568         "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
  1569     vm_exit(1);
  1569     vm_exit(1);
  1570   }
  1570   }
  1571 
  1571 
       
  1572   if (UseAdaptiveSizePolicy) {
       
  1573     // We don't want to limit adaptive heap sizing's freedom to adjust the heap
       
  1574     // unless the user actually sets these flags.
       
  1575     if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
       
  1576       FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
       
  1577     }
       
  1578     if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
       
  1579       FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
       
  1580     }
       
  1581   }
  1572 
  1582 
  1573   // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
  1583   // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
  1574   // SurvivorRatio has been set, reset their default values to SurvivorRatio +
  1584   // SurvivorRatio has been set, reset their default values to SurvivorRatio +
  1575   // 2.  By doing this we make SurvivorRatio also work for Parallel Scavenger.
  1585   // 2.  By doing this we make SurvivorRatio also work for Parallel Scavenger.
  1576   // See CR 6362902 for details.
  1586   // See CR 6362902 for details.
  1842               name, val, min);
  1852               name, val, min);
  1843   return false;
  1853   return false;
  1844 }
  1854 }
  1845 
  1855 
  1846 bool Arguments::verify_percentage(uintx value, const char* name) {
  1856 bool Arguments::verify_percentage(uintx value, const char* name) {
  1847   if (value <= 100) {
  1857   if (is_percentage(value)) {
  1848     return true;
  1858     return true;
  1849   }
  1859   }
  1850   jio_fprintf(defaultStream::error_stream(),
  1860   jio_fprintf(defaultStream::error_stream(),
  1851               "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
  1861               "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
  1852               name, value);
  1862               name, value);
  1928       }
  1938       }
  1929     }
  1939     }
  1930     return false;
  1940     return false;
  1931   }
  1941   }
  1932   return count_p < 2 && count_t < 2;
  1942   return count_p < 2 && count_t < 2;
       
  1943 }
       
  1944 
       
  1945 bool Arguments::verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio) {
       
  1946   if (!is_percentage(min_heap_free_ratio)) {
       
  1947     err_msg.print("MinHeapFreeRatio must have a value between 0 and 100");
       
  1948     return false;
       
  1949   }
       
  1950   if (min_heap_free_ratio > MaxHeapFreeRatio) {
       
  1951     err_msg.print("MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
       
  1952                   "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")", min_heap_free_ratio,
       
  1953                   MaxHeapFreeRatio);
       
  1954     return false;
       
  1955   }
       
  1956   return true;
       
  1957 }
       
  1958 
       
  1959 bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) {
       
  1960   if (!is_percentage(max_heap_free_ratio)) {
       
  1961     err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100");
       
  1962     return false;
       
  1963   }
       
  1964   if (max_heap_free_ratio < MinHeapFreeRatio) {
       
  1965     err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
       
  1966                   "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio,
       
  1967                   MinHeapFreeRatio);
       
  1968     return false;
       
  1969   }
       
  1970   return true;
  1933 }
  1971 }
  1934 
  1972 
  1935 // Check consistency of GC selection
  1973 // Check consistency of GC selection
  1936 bool Arguments::check_gc_consistency() {
  1974 bool Arguments::check_gc_consistency() {
  1937   check_gclog_consistency();
  1975   check_gclog_consistency();
  2035   }
  2073   }
  2036 
  2074 
  2037   status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
  2075   status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
  2038                               "AdaptiveSizePolicyWeight");
  2076                               "AdaptiveSizePolicyWeight");
  2039   status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
  2077   status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
  2040   status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
       
  2041   status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
       
  2042 
  2078 
  2043   // Divide by bucket size to prevent a large size from causing rollover when
  2079   // Divide by bucket size to prevent a large size from causing rollover when
  2044   // calculating amount of memory needed to be allocated for the String table.
  2080   // calculating amount of memory needed to be allocated for the String table.
  2045   status = status && verify_interval(StringTableSize, minimumStringTableSize,
  2081   status = status && verify_interval(StringTableSize, minimumStringTableSize,
  2046     (max_uintx / StringTable::bucket_size()), "StringTable size");
  2082     (max_uintx / StringTable::bucket_size()), "StringTable size");
  2047 
  2083 
  2048   status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
  2084   status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
  2049     (max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
  2085     (max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
  2050 
  2086 
  2051   if (MinHeapFreeRatio > MaxHeapFreeRatio) {
  2087   {
  2052     jio_fprintf(defaultStream::error_stream(),
  2088     // Using "else if" below to avoid printing two error messages if min > max.
  2053                 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
  2089     // This will also prevent us from reporting both min>100 and max>100 at the
  2054                 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
  2090     // same time, but that is less annoying than printing two identical errors IMHO.
  2055                 MinHeapFreeRatio, MaxHeapFreeRatio);
  2091     FormatBuffer<80> err_msg("");
  2056     status = false;
  2092     if (!verify_MinHeapFreeRatio(err_msg, MinHeapFreeRatio)) {
  2057   }
  2093       jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
  2058   // Keeping the heap 100% free is hard ;-) so limit it to 99%.
  2094       status = false;
  2059   MinHeapFreeRatio = MIN2(MinHeapFreeRatio, (uintx) 99);
  2095     } else if (!verify_MaxHeapFreeRatio(err_msg, MaxHeapFreeRatio)) {
       
  2096       jio_fprintf(defaultStream::error_stream(), "%s\n", err_msg.buffer());
       
  2097       status = false;
       
  2098     }
       
  2099   }
  2060 
  2100 
  2061   // Min/MaxMetaspaceFreeRatio
  2101   // Min/MaxMetaspaceFreeRatio
  2062   status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
  2102   status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
  2063   status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
  2103   status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
  2064 
  2104 
  2687       FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
  2727       FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
  2688     // Xmaxf
  2728     // Xmaxf
  2689     } else if (match_option(option, "-Xmaxf", &tail)) {
  2729     } else if (match_option(option, "-Xmaxf", &tail)) {
  2690       char* err;
  2730       char* err;
  2691       int maxf = (int)(strtod(tail, &err) * 100);
  2731       int maxf = (int)(strtod(tail, &err) * 100);
  2692       if (*err != '\0' || maxf < 0 || maxf > 100) {
  2732       if (*err != '\0' || *tail == '\0' || maxf < 0 || maxf > 100) {
  2693         jio_fprintf(defaultStream::error_stream(),
  2733         jio_fprintf(defaultStream::error_stream(),
  2694                     "Bad max heap free percentage size: %s\n",
  2734                     "Bad max heap free percentage size: %s\n",
  2695                     option->optionString);
  2735                     option->optionString);
  2696         return JNI_EINVAL;
  2736         return JNI_EINVAL;
  2697       } else {
  2737       } else {
  2699       }
  2739       }
  2700     // Xminf
  2740     // Xminf
  2701     } else if (match_option(option, "-Xminf", &tail)) {
  2741     } else if (match_option(option, "-Xminf", &tail)) {
  2702       char* err;
  2742       char* err;
  2703       int minf = (int)(strtod(tail, &err) * 100);
  2743       int minf = (int)(strtod(tail, &err) * 100);
  2704       if (*err != '\0' || minf < 0 || minf > 100) {
  2744       if (*err != '\0' || *tail == '\0' || minf < 0 || minf > 100) {
  2705         jio_fprintf(defaultStream::error_stream(),
  2745         jio_fprintf(defaultStream::error_stream(),
  2706                     "Bad min heap free percentage size: %s\n",
  2746                     "Bad min heap free percentage size: %s\n",
  2707                     option->optionString);
  2747                     option->optionString);
  2708         return JNI_EINVAL;
  2748         return JNI_EINVAL;
  2709       } else {
  2749       } else {
  3644 
  3684 
  3645 #if INCLUDE_ALL_GCS
  3685 #if INCLUDE_ALL_GCS
  3646   // Set per-collector flags
  3686   // Set per-collector flags
  3647   if (UseParallelGC || UseParallelOldGC) {
  3687   if (UseParallelGC || UseParallelOldGC) {
  3648     set_parallel_gc_flags();
  3688     set_parallel_gc_flags();
  3649   } else if (UseConcMarkSweepGC) { // should be done before ParNew check below
  3689   } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
  3650     set_cms_and_parnew_gc_flags();
  3690     set_cms_and_parnew_gc_flags();
  3651   } else if (UseParNewGC) {  // skipped if CMS is set above
  3691   } else if (UseParNewGC) {  // Skipped if CMS is set above
  3652     set_parnew_gc_flags();
  3692     set_parnew_gc_flags();
  3653   } else if (UseG1GC) {
  3693   } else if (UseG1GC) {
  3654     set_g1_gc_flags();
  3694     set_g1_gc_flags();
  3655   }
  3695   }
  3656   check_deprecated_gcs();
  3696   check_deprecated_gcs();
  3659     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
  3699     if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
  3660       warning("If the number of processors is expected to increase from one, then"
  3700       warning("If the number of processors is expected to increase from one, then"
  3661               " you should configure the number of parallel GC threads appropriately"
  3701               " you should configure the number of parallel GC threads appropriately"
  3662               " using -XX:ParallelGCThreads=N");
  3702               " using -XX:ParallelGCThreads=N");
  3663     }
  3703     }
       
  3704   }
       
  3705   if (MinHeapFreeRatio == 100) {
       
  3706     // Keeping the heap 100% free is hard ;-) so limit it to 99%.
       
  3707     FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99);
  3664   }
  3708   }
  3665 #else // INCLUDE_ALL_GCS
  3709 #else // INCLUDE_ALL_GCS
  3666   assert(verify_serial_gc_flags(), "SerialGC unset");
  3710   assert(verify_serial_gc_flags(), "SerialGC unset");
  3667 #endif // INCLUDE_ALL_GCS
  3711 #endif // INCLUDE_ALL_GCS
  3668 
  3712