comparison src/share/vm/runtime/arguments.cpp @ 17798:f040cf9fc9c0

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