< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoader.hpp"
  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/symbolTable.hpp"
  30 #include "code/codeCacheExtensions.hpp"
  31 #include "gc/shared/cardTableRS.hpp"
  32 #include "gc/shared/genCollectedHeap.hpp"
  33 #include "gc/shared/referenceProcessor.hpp"
  34 #include "gc/shared/taskqueue.hpp"

  35 #include "logging/logConfiguration.hpp"
  36 #include "memory/allocation.inline.hpp"
  37 #include "memory/universe.inline.hpp"
  38 #include "oops/oop.inline.hpp"
  39 #include "prims/jvmtiExport.hpp"
  40 #include "runtime/arguments.hpp"
  41 #include "runtime/arguments_ext.hpp"
  42 #include "runtime/commandLineFlagConstraintList.hpp"
  43 #include "runtime/commandLineFlagRangeList.hpp"
  44 #include "runtime/globals.hpp"
  45 #include "runtime/globals_extension.hpp"
  46 #include "runtime/java.hpp"
  47 #include "runtime/os.hpp"
  48 #include "runtime/vm_version.hpp"
  49 #include "services/management.hpp"
  50 #include "services/memTracker.hpp"
  51 #include "utilities/defaultStream.hpp"
  52 #include "utilities/macros.hpp"
  53 #include "utilities/stringUtils.hpp"
  54 #if INCLUDE_JVMCI


  64 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  65 #define DEFAULT_JAVA_LAUNCHER  "generic"
  66 
  67 #define UNSUPPORTED_GC_OPTION(gc)                                     \
  68 do {                                                                  \
  69   if (gc) {                                                           \
  70     if (FLAG_IS_CMDLINE(gc)) {                                        \
  71       warning(#gc " is not supported in this VM.  Using Serial GC."); \
  72     }                                                                 \
  73     FLAG_SET_DEFAULT(gc, false);                                      \
  74   }                                                                   \
  75 } while(0)
  76 
  77 char*  Arguments::_jvm_flags_file               = NULL;
  78 char** Arguments::_jvm_flags_array              = NULL;
  79 int    Arguments::_num_jvm_flags                = 0;
  80 char** Arguments::_jvm_args_array               = NULL;
  81 int    Arguments::_num_jvm_args                 = 0;
  82 char*  Arguments::_java_command                 = NULL;
  83 SystemProperty* Arguments::_system_properties   = NULL;
  84 const char*  Arguments::_gc_log_filename        = NULL;
  85 bool   Arguments::_has_profile                  = false;
  86 size_t Arguments::_conservative_max_heap_alignment = 0;
  87 size_t Arguments::_min_heap_size                = 0;
  88 Arguments::Mode Arguments::_mode                = _mixed;
  89 bool   Arguments::_java_compiler                = false;
  90 bool   Arguments::_xdebug_mode                  = false;
  91 const char*  Arguments::_java_vendor_url_bug    = DEFAULT_VENDOR_URL_BUG;
  92 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  93 int    Arguments::_sun_java_launcher_pid        = -1;
  94 bool   Arguments::_sun_java_launcher_is_altjvm  = false;
  95 
  96 // These parameters are reset in method parse_vm_init_args()
  97 bool   Arguments::_AlwaysCompileLoopMethods     = AlwaysCompileLoopMethods;
  98 bool   Arguments::_UseOnStackReplacement        = UseOnStackReplacement;
  99 bool   Arguments::_BackgroundCompilation        = BackgroundCompilation;
 100 bool   Arguments::_ClipInlining                 = ClipInlining;
 101 intx   Arguments::_Tier3InvokeNotifyFreqLog     = Tier3InvokeNotifyFreqLog;
 102 intx   Arguments::_Tier4InvocationThreshold     = Tier4InvocationThreshold;
 103 
 104 char*  Arguments::SharedArchivePath             = NULL;


1600   const size_t preferred_max_new_size_unaligned =
1601     MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads));
1602   size_t preferred_max_new_size =
1603     align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
1604 
1605   // Unless explicitly requested otherwise, size young gen
1606   // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1607 
1608   // If either MaxNewSize or NewRatio is set on the command line,
1609   // assume the user is trying to set the size of the young gen.
1610   if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1611 
1612     // Set MaxNewSize to our calculated preferred_max_new_size unless
1613     // NewSize was set on the command line and it is larger than
1614     // preferred_max_new_size.
1615     if (!FLAG_IS_DEFAULT(NewSize)) {   // NewSize explicitly set at command-line
1616       FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
1617     } else {
1618       FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
1619     }
1620     if (PrintGCDetails && Verbose) {
1621       // Too early to use gclog_or_tty
1622       tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
1623     }
1624 
1625     // Code along this path potentially sets NewSize and OldSize
1626     if (PrintGCDetails && Verbose) {
1627       // Too early to use gclog_or_tty
1628       tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT
1629            " initial_heap_size:  " SIZE_FORMAT
1630            " max_heap: " SIZE_FORMAT,
1631            min_heap_size(), InitialHeapSize, max_heap);
1632     }
1633     size_t min_new = preferred_max_new_size;
1634     if (FLAG_IS_CMDLINE(NewSize)) {
1635       min_new = NewSize;
1636     }
1637     if (max_heap > min_new && min_heap_size() > min_new) {
1638       // Unless explicitly requested otherwise, make young gen
1639       // at least min_new, and at most preferred_max_new_size.
1640       if (FLAG_IS_DEFAULT(NewSize)) {
1641         FLAG_SET_ERGO(size_t, NewSize, MAX2(NewSize, min_new));
1642         FLAG_SET_ERGO(size_t, NewSize, MIN2(preferred_max_new_size, NewSize));
1643         if (PrintGCDetails && Verbose) {
1644           // Too early to use gclog_or_tty
1645           tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
1646         }
1647       }
1648       // Unless explicitly requested otherwise, size old gen
1649       // so it's NewRatio x of NewSize.
1650       if (FLAG_IS_DEFAULT(OldSize)) {
1651         if (max_heap > NewSize) {
1652           FLAG_SET_ERGO(size_t, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
1653           if (PrintGCDetails && Verbose) {
1654             // Too early to use gclog_or_tty
1655             tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
1656           }
1657         }
1658       }
1659     }
1660   }
1661   // Unless explicitly requested otherwise, definitely
1662   // promote all objects surviving "tenuring_default" scavenges.
1663   if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
1664       FLAG_IS_DEFAULT(SurvivorRatio)) {
1665     FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
1666   }
1667   // If we decided above (or user explicitly requested)
1668   // `promote all' (via MaxTenuringThreshold := 0),
1669   // prefer minuscule survivor spaces so as not to waste
1670   // space for (non-existent) survivors
1671   if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
1672     FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
1673   }
1674 
1675   // OldPLABSize is interpreted in CMS as not the size of the PLAB in words,
1676   // but rather the number of free blocks of a given size that are used when


1680       // OldPLAB sizing manually turned off: Use a larger default setting,
1681       // unless it was manually specified. This is because a too-low value
1682       // will slow down scavenges.
1683       FLAG_SET_ERGO(size_t, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166
1684     } else {
1685       FLAG_SET_DEFAULT(OldPLABSize, CFLS_LAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
1686     }
1687   }
1688 
1689   // If either of the static initialization defaults have changed, note this
1690   // modification.
1691   if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
1692     CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight);
1693   }
1694 
1695   if (!ClassUnloading) {
1696     FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
1697     FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
1698   }
1699 
1700   if (PrintGCDetails && Verbose) {
1701     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1702       (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1703     tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1704   }
1705 }
1706 #endif // INCLUDE_ALL_GCS
1707 
1708 void set_object_alignment() {
1709   // Object alignment.
1710   assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2");
1711   MinObjAlignmentInBytes     = ObjectAlignmentInBytes;
1712   assert(MinObjAlignmentInBytes >= HeapWordsPerLong * HeapWordSize, "ObjectAlignmentInBytes value is too small");
1713   MinObjAlignment            = MinObjAlignmentInBytes / HeapWordSize;
1714   assert(MinObjAlignmentInBytes == MinObjAlignment * HeapWordSize, "ObjectAlignmentInBytes value is incorrect");
1715   MinObjAlignmentInBytesMask = MinObjAlignmentInBytes - 1;
1716 
1717   LogMinObjAlignmentInBytes  = exact_log2(ObjectAlignmentInBytes);
1718   LogMinObjAlignment         = LogMinObjAlignmentInBytes - LogHeapWordSize;
1719 
1720   // Oop encoding heap max
1721   OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
1722 
1723   if (SurvivorAlignmentInBytes == 0) {
1724     SurvivorAlignmentInBytes = ObjectAlignmentInBytes;


1731 }
1732 
1733 size_t Arguments::max_heap_for_compressed_oops() {
1734   // Avoid sign flip.
1735   assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1736   // We need to fit both the NULL page and the heap into the memory budget, while
1737   // keeping alignment constraints of the heap. To guarantee the latter, as the
1738   // NULL page is located before the heap, we pad the NULL page to the conservative
1739   // maximum alignment that the GC may ever impose upon the heap.
1740   size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
1741                                                         _conservative_max_heap_alignment);
1742 
1743   LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1744   NOT_LP64(ShouldNotReachHere(); return 0);
1745 }
1746 
1747 bool Arguments::should_auto_select_low_pause_collector() {
1748   if (UseAutoGCSelectPolicy &&
1749       !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1750       (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1751     if (PrintGCDetails) {
1752       // Cannot use gclog_or_tty yet.
1753       tty->print_cr("Automatic selection of the low pause collector"
1754        " based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
1755     }
1756     return true;
1757   }
1758   return false;
1759 }
1760 
1761 void Arguments::set_use_compressed_oops() {
1762 #ifndef ZERO
1763 #ifdef _LP64
1764   // MaxHeapSize is not set up properly at this point, but
1765   // the only value that can override MaxHeapSize if we are
1766   // to use UseCompressedOops is InitialHeapSize.
1767   size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
1768 
1769   if (max_heap_size <= max_heap_for_compressed_oops()) {
1770 #if !defined(COMPILER1) || defined(TIERED)
1771     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1772       FLAG_SET_ERGO(bool, UseCompressedOops, true);
1773     }
1774 #endif
1775   } else {


1957 #endif
1958 
1959   // MarkStackSize will be set (if it hasn't been set by the user)
1960   // when concurrent marking is initialized.
1961   // Its value will be based upon the number of parallel marking threads.
1962   // But we do set the maximum mark stack size here.
1963   if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1964     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1965   }
1966 
1967   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1968     // In G1, we want the default GC overhead goal to be higher than
1969     // say in PS. So we set it here to 10%. Otherwise the heap might
1970     // be expanded more aggressively than we would like it to. In
1971     // fact, even 10% seems to not be high enough in some cases
1972     // (especially small GC stress tests that the main thing they do
1973     // is allocation). We might consider increase it further.
1974     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1975   }
1976 
1977   if (PrintGCDetails && Verbose) {
1978     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1979       (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1980     tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1981   }
1982 }
1983 
1984 #if !INCLUDE_ALL_GCS
1985 #ifdef ASSERT
1986 static bool verify_serial_gc_flags() {
1987   return (UseSerialGC &&
1988         !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1989           UseParallelGC || UseParallelOldGC));
1990 }
1991 #endif // ASSERT
1992 #endif // INCLUDE_ALL_GCS
1993 
1994 void Arguments::set_gc_specific_flags() {
1995 #if INCLUDE_ALL_GCS
1996   // Set per-collector flags
1997   if (UseParallelGC || UseParallelOldGC) {
1998     set_parallel_gc_flags();
1999   } else if (UseConcMarkSweepGC) {
2000     set_cms_and_parnew_gc_flags();
2001   } else if (UseG1GC) {


2073         }
2074       }
2075 
2076       if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
2077         // Heap should be above HeapBaseMinAddress to get zero based compressed oops
2078         // but it should be not less than default MaxHeapSize.
2079         max_coop_heap -= HeapBaseMinAddress;
2080       }
2081       reasonable_max = MIN2(reasonable_max, max_coop_heap);
2082     }
2083     reasonable_max = limit_by_allocatable_memory(reasonable_max);
2084 
2085     if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
2086       // An initial heap size was specified on the command line,
2087       // so be sure that the maximum size is consistent.  Done
2088       // after call to limit_by_allocatable_memory because that
2089       // method might reduce the allocation size.
2090       reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
2091     }
2092 
2093     if (PrintGCDetails && Verbose) {
2094       // Cannot use gclog_or_tty yet.
2095       tty->print_cr("  Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
2096     }
2097     FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
2098   }
2099 
2100   // If the minimum or initial heap_size have not been set or requested to be set
2101   // ergonomically, set them accordingly.
2102   if (InitialHeapSize == 0 || min_heap_size() == 0) {
2103     julong reasonable_minimum = (julong)(OldSize + NewSize);
2104 
2105     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
2106 
2107     reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
2108 
2109     if (InitialHeapSize == 0) {
2110       julong reasonable_initial = phys_mem / InitialRAMFraction;
2111 
2112       reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
2113       reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
2114 
2115       reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
2116 
2117       if (PrintGCDetails && Verbose) {
2118         // Cannot use gclog_or_tty yet.
2119         tty->print_cr("  Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
2120       }
2121       FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
2122     }
2123     // If the minimum heap size has not been set (via -Xms),
2124     // synchronize with InitialHeapSize to avoid errors with the default value.
2125     if (min_heap_size() == 0) {
2126       set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
2127       if (PrintGCDetails && Verbose) {
2128         // Cannot use gclog_or_tty yet.
2129         tty->print_cr("  Minimum heap size " SIZE_FORMAT, min_heap_size());
2130       }
2131     }
2132   }
2133 }
2134 
2135 // This option inspects the machine and attempts to set various
2136 // parameters to be optimal for long-running, memory allocation
2137 // intensive jobs.  It is intended for machines with large
2138 // amounts of cpu and memory.
2139 jint Arguments::set_aggressive_heap_flags() {
2140   // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
2141   // VM, but we may not be able to represent the total physical memory
2142   // available (like having 8gb of memory on a box but using a 32bit VM).
2143   // Thus, we need to make sure we're using a julong for intermediate
2144   // calculations.
2145   julong initHeapSize;
2146   julong total_memory = os::physical_memory();
2147 
2148   if (total_memory < (julong) 256 * M) {
2149     jio_fprintf(defaultStream::error_stream(),
2150             "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");


2313     set_java_compiler(true);    // "-Djava.compiler[=...]" most recently seen.
2314   }
2315 }
2316 
2317 void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) {
2318   _sun_java_launcher = os::strdup_check_oom(launcher);
2319 }
2320 
2321 bool Arguments::created_by_java_launcher() {
2322   assert(_sun_java_launcher != NULL, "property must have value");
2323   return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
2324 }
2325 
2326 bool Arguments::sun_java_launcher_is_altjvm() {
2327   return _sun_java_launcher_is_altjvm;
2328 }
2329 
2330 //===========================================================================================================
2331 // Parsing of main arguments
2332 
2333 // check if do gclog rotation
2334 // +UseGCLogFileRotation is a must,
2335 // no gc log rotation when log file not supplied or
2336 // NumberOfGCLogFiles is 0
2337 void check_gclog_consistency() {
2338   if (UseGCLogFileRotation) {
2339     if ((Arguments::gc_log_filename() == NULL) || (NumberOfGCLogFiles == 0)) {
2340       jio_fprintf(defaultStream::output_stream(),
2341                   "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files>\n"
2342                   "where num_of_file > 0\n"
2343                   "GC log rotation is turned off\n");
2344       UseGCLogFileRotation = false;
2345     }
2346   }
2347 
2348   if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
2349     if (FLAG_SET_CMDLINE(size_t, GCLogFileSize, 8*K) == Flag::SUCCESS) {
2350       jio_fprintf(defaultStream::output_stream(),
2351                 "GCLogFileSize changed to minimum 8K\n");
2352     }
2353   }
2354 }
2355 
2356 // This function is called for -Xloggc:<filename>, it can be used
2357 // to check if a given file name(or string) conforms to the following
2358 // specification:
2359 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
2360 // %p and %t only allowed once. We only limit usage of filename not path
2361 bool is_filename_valid(const char *file_name) {
2362   const char* p = file_name;
2363   char file_sep = os::file_separator()[0];
2364   const char* cp;
2365   // skip prefix path
2366   for (cp = file_name; *cp != '\0'; cp++) {
2367     if (*cp == '/' || *cp == file_sep) {
2368       p = cp + 1;
2369     }
2370   }
2371 
2372   int count_p = 0;
2373   int count_t = 0;
2374   while (*p != '\0') {
2375     if ((*p >= '0' && *p <= '9') ||
2376         (*p >= 'A' && *p <= 'Z') ||
2377         (*p >= 'a' && *p <= 'z') ||
2378          *p == '-'               ||
2379          *p == '_'               ||
2380          *p == '.') {
2381        p++;
2382        continue;
2383     }
2384     if (*p == '%') {
2385       if(*(p + 1) == 'p') {
2386         p += 2;
2387         count_p ++;
2388         continue;
2389       }
2390       if (*(p + 1) == 't') {
2391         p += 2;
2392         count_t ++;
2393         continue;
2394       }
2395     }
2396     return false;
2397   }
2398   return count_p < 2 && count_t < 2;
2399 }
2400 
2401 // Check consistency of GC selection
2402 bool Arguments::check_gc_consistency() {
2403   check_gclog_consistency();
2404   // Ensure that the user has not selected conflicting sets
2405   // of collectors.
2406   uint i = 0;
2407   if (UseSerialGC)                       i++;
2408   if (UseConcMarkSweepGC)                i++;
2409   if (UseParallelGC || UseParallelOldGC) i++;
2410   if (UseG1GC)                           i++;
2411   if (i > 1) {
2412     jio_fprintf(defaultStream::error_stream(),
2413                 "Conflicting collector combinations in option list; "
2414                 "please refer to the release notes for the combinations "
2415                 "allowed\n");
2416     return false;
2417   }
2418 
2419   if (UseConcMarkSweepGC && !UseParNewGC) {
2420     jio_fprintf(defaultStream::error_stream(),
2421         "It is not possible to combine the DefNew young collector with the CMS collector.\n");
2422     return false;
2423   }


2733         !match_option(option, "-Dsun.java.launcher", &tail)) {
2734 
2735         // add all jvm options to the jvm_args string. This string
2736         // is used later to set the java.vm.args PerfData string constant.
2737         // the -Djava.class.path and the -Dsun.java.command options are
2738         // omitted from jvm_args string as each have their own PerfData
2739         // string constant object.
2740         build_jvm_args(option->optionString);
2741     }
2742 
2743     // -verbose:[class/gc/jni]
2744     if (match_option(option, "-verbose", &tail)) {
2745       if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
2746         if (FLAG_SET_CMDLINE(bool, TraceClassLoading, true) != Flag::SUCCESS) {
2747           return JNI_EINVAL;
2748         }
2749         if (FLAG_SET_CMDLINE(bool, TraceClassUnloading, true) != Flag::SUCCESS) {
2750           return JNI_EINVAL;
2751         }
2752       } else if (!strcmp(tail, ":gc")) {
2753         if (FLAG_SET_CMDLINE(bool, PrintGC, true) != Flag::SUCCESS) {

2754           return JNI_EINVAL;
2755         }
2756       } else if (!strcmp(tail, ":jni")) {
2757         if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) {
2758           return JNI_EINVAL;
2759         }
2760       }
2761     // -da / -ea / -disableassertions / -enableassertions
2762     // These accept an optional class/package name separated by a colon, e.g.,
2763     // -da:java.lang.Thread.
2764     } else if (match_option(option, user_assertion_options, &tail, true)) {
2765       bool enable = option->optionString[1] == 'e';     // char after '-' is 'e'
2766       if (*tail == '\0') {
2767         JavaAssertions::setUserClassDefault(enable);
2768       } else {
2769         assert(*tail == ':', "bogus match by match_option()");
2770         JavaAssertions::addOption(tail + 1, enable);
2771       }
2772     // -dsa / -esa / -disablesystemassertions / -enablesystemassertions
2773     } else if (match_option(option, system_assertion_options, &tail, false)) {


3166         if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) {
3167           return JNI_EINVAL;
3168         }
3169       } else if (strcmp(tail, ":none") == 0) {
3170         if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != Flag::SUCCESS) {
3171           return JNI_EINVAL;
3172         }
3173         if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != Flag::SUCCESS) {
3174           return JNI_EINVAL;
3175         }
3176       } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
3177         return JNI_EINVAL;
3178       }
3179     // -Xdebug
3180     } else if (match_option(option, "-Xdebug")) {
3181       // note this flag has been used, then ignore
3182       set_xdebug_mode(true);
3183     // -Xnoagent
3184     } else if (match_option(option, "-Xnoagent")) {
3185       // For compatibility with classic. HotSpot refuses to load the old style agent.dll.
3186     } else if (match_option(option, "-Xloggc:", &tail)) {
3187       // Redirect GC output to the file. -Xloggc:<filename>
3188       // ostream_init_log(), when called will use this filename
3189       // to initialize a fileStream.
3190       _gc_log_filename = os::strdup_check_oom(tail);
3191      if (!is_filename_valid(_gc_log_filename)) {
3192        jio_fprintf(defaultStream::output_stream(),
3193                   "Invalid file name for use with -Xloggc: Filename can only contain the "
3194                   "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n"
3195                   "Note %%p or %%t can only be used once\n", _gc_log_filename);
3196         return JNI_EINVAL;
3197       }
3198       if (FLAG_SET_CMDLINE(bool, PrintGC, true) != Flag::SUCCESS) {
3199         return JNI_EINVAL;
3200       }
3201       if (FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true) != Flag::SUCCESS) {
3202         return JNI_EINVAL;
3203       }
3204     } else if (match_option(option, "-Xlog", &tail)) {
3205       bool ret = false;
3206       if (strcmp(tail, ":help") == 0) {
3207         LogConfiguration::print_command_line_help(defaultStream::output_stream());
3208         vm_exit(0);
3209       } else if (strcmp(tail, ":disable") == 0) {
3210         LogConfiguration::disable_logging();
3211         ret = true;
3212       } else if (*tail == '\0') {
3213         ret = LogConfiguration::parse_command_line_arguments();
3214         assert(ret, "-Xlog without arguments should never fail to parse");
3215       } else if (*tail == ':') {
3216         ret = LogConfiguration::parse_command_line_arguments(tail + 1);
3217       }
3218       if (ret == false) {
3219         jio_fprintf(defaultStream::error_stream(),
3220                     "Invalid -Xlog option '-Xlog%s'\n",
3221                     tail);
3222         return JNI_EINVAL;
3223       }


4186 
4187   ArgumentsExt::report_unsupported_options();
4188 
4189 #ifndef PRODUCT
4190   if (TraceBytecodesAt != 0) {
4191     TraceBytecodes = true;
4192   }
4193   if (CountCompiledCalls) {
4194     if (UseCounterDecay) {
4195       warning("UseCounterDecay disabled because CountCalls is set");
4196       UseCounterDecay = false;
4197     }
4198   }
4199 #endif // PRODUCT
4200 
4201   if (ScavengeRootsInCode == 0) {
4202     if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
4203       warning("Forcing ScavengeRootsInCode non-zero");
4204     }
4205     ScavengeRootsInCode = 1;
4206   }
4207 
4208   if (PrintGCDetails) {
4209     // Turn on -verbose:gc options as well
4210     PrintGC = true;
4211   }
4212 
4213   // Set object alignment values.
4214   set_object_alignment();
4215 
4216 #if !INCLUDE_ALL_GCS
4217   force_serial_gc();
4218 #endif // INCLUDE_ALL_GCS
4219 #if !INCLUDE_CDS
4220   if (DumpSharedSpaces || RequireSharedSpaces) {
4221     jio_fprintf(defaultStream::error_stream(),
4222       "Shared spaces are not supported in this VM\n");
4223     return JNI_ERR;
4224   }
4225   if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
4226     warning("Shared spaces are not supported in this VM");
4227     FLAG_SET_DEFAULT(UseSharedSpaces, false);
4228     FLAG_SET_DEFAULT(PrintSharedSpaces, false);
4229   }
4230   no_shared_spaces("CDS Disabled");




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoader.hpp"
  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/symbolTable.hpp"
  30 #include "code/codeCacheExtensions.hpp"
  31 #include "gc/shared/cardTableRS.hpp"
  32 #include "gc/shared/genCollectedHeap.hpp"
  33 #include "gc/shared/referenceProcessor.hpp"
  34 #include "gc/shared/taskqueue.hpp"
  35 #include "logging/log.hpp"
  36 #include "logging/logConfiguration.hpp"
  37 #include "memory/allocation.inline.hpp"
  38 #include "memory/universe.inline.hpp"
  39 #include "oops/oop.inline.hpp"
  40 #include "prims/jvmtiExport.hpp"
  41 #include "runtime/arguments.hpp"
  42 #include "runtime/arguments_ext.hpp"
  43 #include "runtime/commandLineFlagConstraintList.hpp"
  44 #include "runtime/commandLineFlagRangeList.hpp"
  45 #include "runtime/globals.hpp"
  46 #include "runtime/globals_extension.hpp"
  47 #include "runtime/java.hpp"
  48 #include "runtime/os.hpp"
  49 #include "runtime/vm_version.hpp"
  50 #include "services/management.hpp"
  51 #include "services/memTracker.hpp"
  52 #include "utilities/defaultStream.hpp"
  53 #include "utilities/macros.hpp"
  54 #include "utilities/stringUtils.hpp"
  55 #if INCLUDE_JVMCI


  65 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  66 #define DEFAULT_JAVA_LAUNCHER  "generic"
  67 
  68 #define UNSUPPORTED_GC_OPTION(gc)                                     \
  69 do {                                                                  \
  70   if (gc) {                                                           \
  71     if (FLAG_IS_CMDLINE(gc)) {                                        \
  72       warning(#gc " is not supported in this VM.  Using Serial GC."); \
  73     }                                                                 \
  74     FLAG_SET_DEFAULT(gc, false);                                      \
  75   }                                                                   \
  76 } while(0)
  77 
  78 char*  Arguments::_jvm_flags_file               = NULL;
  79 char** Arguments::_jvm_flags_array              = NULL;
  80 int    Arguments::_num_jvm_flags                = 0;
  81 char** Arguments::_jvm_args_array               = NULL;
  82 int    Arguments::_num_jvm_args                 = 0;
  83 char*  Arguments::_java_command                 = NULL;
  84 SystemProperty* Arguments::_system_properties   = NULL;

  85 bool   Arguments::_has_profile                  = false;
  86 size_t Arguments::_conservative_max_heap_alignment = 0;
  87 size_t Arguments::_min_heap_size                = 0;
  88 Arguments::Mode Arguments::_mode                = _mixed;
  89 bool   Arguments::_java_compiler                = false;
  90 bool   Arguments::_xdebug_mode                  = false;
  91 const char*  Arguments::_java_vendor_url_bug    = DEFAULT_VENDOR_URL_BUG;
  92 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
  93 int    Arguments::_sun_java_launcher_pid        = -1;
  94 bool   Arguments::_sun_java_launcher_is_altjvm  = false;
  95 
  96 // These parameters are reset in method parse_vm_init_args()
  97 bool   Arguments::_AlwaysCompileLoopMethods     = AlwaysCompileLoopMethods;
  98 bool   Arguments::_UseOnStackReplacement        = UseOnStackReplacement;
  99 bool   Arguments::_BackgroundCompilation        = BackgroundCompilation;
 100 bool   Arguments::_ClipInlining                 = ClipInlining;
 101 intx   Arguments::_Tier3InvokeNotifyFreqLog     = Tier3InvokeNotifyFreqLog;
 102 intx   Arguments::_Tier4InvocationThreshold     = Tier4InvocationThreshold;
 103 
 104 char*  Arguments::SharedArchivePath             = NULL;


1600   const size_t preferred_max_new_size_unaligned =
1601     MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads));
1602   size_t preferred_max_new_size =
1603     align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
1604 
1605   // Unless explicitly requested otherwise, size young gen
1606   // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1607 
1608   // If either MaxNewSize or NewRatio is set on the command line,
1609   // assume the user is trying to set the size of the young gen.
1610   if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1611 
1612     // Set MaxNewSize to our calculated preferred_max_new_size unless
1613     // NewSize was set on the command line and it is larger than
1614     // preferred_max_new_size.
1615     if (!FLAG_IS_DEFAULT(NewSize)) {   // NewSize explicitly set at command-line
1616       FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
1617     } else {
1618       FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
1619     }
1620     log_trace(gc, heap)("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);



1621 
1622     // Code along this path potentially sets NewSize and OldSize
1623     log_trace(gc, heap)("CMS set min_heap_size: " SIZE_FORMAT " initial_heap_size:  " SIZE_FORMAT " max_heap: " SIZE_FORMAT,




1624                         min_heap_size(), InitialHeapSize, max_heap);

1625     size_t min_new = preferred_max_new_size;
1626     if (FLAG_IS_CMDLINE(NewSize)) {
1627       min_new = NewSize;
1628     }
1629     if (max_heap > min_new && min_heap_size() > min_new) {
1630       // Unless explicitly requested otherwise, make young gen
1631       // at least min_new, and at most preferred_max_new_size.
1632       if (FLAG_IS_DEFAULT(NewSize)) {
1633         FLAG_SET_ERGO(size_t, NewSize, MAX2(NewSize, min_new));
1634         FLAG_SET_ERGO(size_t, NewSize, MIN2(preferred_max_new_size, NewSize));
1635         log_trace(gc, heap)("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);



1636       }
1637       // Unless explicitly requested otherwise, size old gen
1638       // so it's NewRatio x of NewSize.
1639       if (FLAG_IS_DEFAULT(OldSize)) {
1640         if (max_heap > NewSize) {
1641           FLAG_SET_ERGO(size_t, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
1642           log_trace(gc, heap)("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);



1643         }
1644       }
1645     }
1646   }
1647   // Unless explicitly requested otherwise, definitely
1648   // promote all objects surviving "tenuring_default" scavenges.
1649   if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
1650       FLAG_IS_DEFAULT(SurvivorRatio)) {
1651     FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
1652   }
1653   // If we decided above (or user explicitly requested)
1654   // `promote all' (via MaxTenuringThreshold := 0),
1655   // prefer minuscule survivor spaces so as not to waste
1656   // space for (non-existent) survivors
1657   if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
1658     FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
1659   }
1660 
1661   // OldPLABSize is interpreted in CMS as not the size of the PLAB in words,
1662   // but rather the number of free blocks of a given size that are used when


1666       // OldPLAB sizing manually turned off: Use a larger default setting,
1667       // unless it was manually specified. This is because a too-low value
1668       // will slow down scavenges.
1669       FLAG_SET_ERGO(size_t, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166
1670     } else {
1671       FLAG_SET_DEFAULT(OldPLABSize, CFLS_LAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
1672     }
1673   }
1674 
1675   // If either of the static initialization defaults have changed, note this
1676   // modification.
1677   if (!FLAG_IS_DEFAULT(OldPLABSize) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
1678     CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight);
1679   }
1680 
1681   if (!ClassUnloading) {
1682     FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
1683     FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
1684   }
1685 
1686   log_trace(gc)("MarkStackSize: %uk  MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1687   log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);



1688 }
1689 #endif // INCLUDE_ALL_GCS
1690 
1691 void set_object_alignment() {
1692   // Object alignment.
1693   assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2");
1694   MinObjAlignmentInBytes     = ObjectAlignmentInBytes;
1695   assert(MinObjAlignmentInBytes >= HeapWordsPerLong * HeapWordSize, "ObjectAlignmentInBytes value is too small");
1696   MinObjAlignment            = MinObjAlignmentInBytes / HeapWordSize;
1697   assert(MinObjAlignmentInBytes == MinObjAlignment * HeapWordSize, "ObjectAlignmentInBytes value is incorrect");
1698   MinObjAlignmentInBytesMask = MinObjAlignmentInBytes - 1;
1699 
1700   LogMinObjAlignmentInBytes  = exact_log2(ObjectAlignmentInBytes);
1701   LogMinObjAlignment         = LogMinObjAlignmentInBytes - LogHeapWordSize;
1702 
1703   // Oop encoding heap max
1704   OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
1705 
1706   if (SurvivorAlignmentInBytes == 0) {
1707     SurvivorAlignmentInBytes = ObjectAlignmentInBytes;


1714 }
1715 
1716 size_t Arguments::max_heap_for_compressed_oops() {
1717   // Avoid sign flip.
1718   assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1719   // We need to fit both the NULL page and the heap into the memory budget, while
1720   // keeping alignment constraints of the heap. To guarantee the latter, as the
1721   // NULL page is located before the heap, we pad the NULL page to the conservative
1722   // maximum alignment that the GC may ever impose upon the heap.
1723   size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
1724                                                         _conservative_max_heap_alignment);
1725 
1726   LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1727   NOT_LP64(ShouldNotReachHere(); return 0);
1728 }
1729 
1730 bool Arguments::should_auto_select_low_pause_collector() {
1731   if (UseAutoGCSelectPolicy &&
1732       !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1733       (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1734     log_trace(gc)("Automatic selection of the low pause collector based on pause goal of %d (ms)", (int) MaxGCPauseMillis);




1735     return true;
1736   }
1737   return false;
1738 }
1739 
1740 void Arguments::set_use_compressed_oops() {
1741 #ifndef ZERO
1742 #ifdef _LP64
1743   // MaxHeapSize is not set up properly at this point, but
1744   // the only value that can override MaxHeapSize if we are
1745   // to use UseCompressedOops is InitialHeapSize.
1746   size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
1747 
1748   if (max_heap_size <= max_heap_for_compressed_oops()) {
1749 #if !defined(COMPILER1) || defined(TIERED)
1750     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
1751       FLAG_SET_ERGO(bool, UseCompressedOops, true);
1752     }
1753 #endif
1754   } else {


1936 #endif
1937 
1938   // MarkStackSize will be set (if it hasn't been set by the user)
1939   // when concurrent marking is initialized.
1940   // Its value will be based upon the number of parallel marking threads.
1941   // But we do set the maximum mark stack size here.
1942   if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1943     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
1944   }
1945 
1946   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1947     // In G1, we want the default GC overhead goal to be higher than
1948     // say in PS. So we set it here to 10%. Otherwise the heap might
1949     // be expanded more aggressively than we would like it to. In
1950     // fact, even 10% seems to not be high enough in some cases
1951     // (especially small GC stress tests that the main thing they do
1952     // is allocation). We might consider increase it further.
1953     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1954   }
1955 
1956   log_trace(gc)("MarkStackSize: %uk  MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1957   log_trace(gc)("ConcGCThreads: %u", ConcGCThreads);



1958 }
1959 
1960 #if !INCLUDE_ALL_GCS
1961 #ifdef ASSERT
1962 static bool verify_serial_gc_flags() {
1963   return (UseSerialGC &&
1964         !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1965           UseParallelGC || UseParallelOldGC));
1966 }
1967 #endif // ASSERT
1968 #endif // INCLUDE_ALL_GCS
1969 
1970 void Arguments::set_gc_specific_flags() {
1971 #if INCLUDE_ALL_GCS
1972   // Set per-collector flags
1973   if (UseParallelGC || UseParallelOldGC) {
1974     set_parallel_gc_flags();
1975   } else if (UseConcMarkSweepGC) {
1976     set_cms_and_parnew_gc_flags();
1977   } else if (UseG1GC) {


2049         }
2050       }
2051 
2052       if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
2053         // Heap should be above HeapBaseMinAddress to get zero based compressed oops
2054         // but it should be not less than default MaxHeapSize.
2055         max_coop_heap -= HeapBaseMinAddress;
2056       }
2057       reasonable_max = MIN2(reasonable_max, max_coop_heap);
2058     }
2059     reasonable_max = limit_by_allocatable_memory(reasonable_max);
2060 
2061     if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
2062       // An initial heap size was specified on the command line,
2063       // so be sure that the maximum size is consistent.  Done
2064       // after call to limit_by_allocatable_memory because that
2065       // method might reduce the allocation size.
2066       reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
2067     }
2068 
2069     log_trace(gc, heap)("  Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);



2070     FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
2071   }
2072 
2073   // If the minimum or initial heap_size have not been set or requested to be set
2074   // ergonomically, set them accordingly.
2075   if (InitialHeapSize == 0 || min_heap_size() == 0) {
2076     julong reasonable_minimum = (julong)(OldSize + NewSize);
2077 
2078     reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
2079 
2080     reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
2081 
2082     if (InitialHeapSize == 0) {
2083       julong reasonable_initial = phys_mem / InitialRAMFraction;
2084 
2085       reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
2086       reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
2087 
2088       reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
2089 
2090       log_trace(gc, heap)("  Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);



2091       FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
2092     }
2093     // If the minimum heap size has not been set (via -Xms),
2094     // synchronize with InitialHeapSize to avoid errors with the default value.
2095     if (min_heap_size() == 0) {
2096       set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
2097       log_trace(gc, heap)("  Minimum heap size " SIZE_FORMAT, min_heap_size());



2098     }
2099   }
2100 }
2101 
2102 // This option inspects the machine and attempts to set various
2103 // parameters to be optimal for long-running, memory allocation
2104 // intensive jobs.  It is intended for machines with large
2105 // amounts of cpu and memory.
2106 jint Arguments::set_aggressive_heap_flags() {
2107   // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
2108   // VM, but we may not be able to represent the total physical memory
2109   // available (like having 8gb of memory on a box but using a 32bit VM).
2110   // Thus, we need to make sure we're using a julong for intermediate
2111   // calculations.
2112   julong initHeapSize;
2113   julong total_memory = os::physical_memory();
2114 
2115   if (total_memory < (julong) 256 * M) {
2116     jio_fprintf(defaultStream::error_stream(),
2117             "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");


2280     set_java_compiler(true);    // "-Djava.compiler[=...]" most recently seen.
2281   }
2282 }
2283 
2284 void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) {
2285   _sun_java_launcher = os::strdup_check_oom(launcher);
2286 }
2287 
2288 bool Arguments::created_by_java_launcher() {
2289   assert(_sun_java_launcher != NULL, "property must have value");
2290   return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
2291 }
2292 
2293 bool Arguments::sun_java_launcher_is_altjvm() {
2294   return _sun_java_launcher_is_altjvm;
2295 }
2296 
2297 //===========================================================================================================
2298 // Parsing of main arguments
2299 




































































2300 // Check consistency of GC selection
2301 bool Arguments::check_gc_consistency() {

2302   // Ensure that the user has not selected conflicting sets
2303   // of collectors.
2304   uint i = 0;
2305   if (UseSerialGC)                       i++;
2306   if (UseConcMarkSweepGC)                i++;
2307   if (UseParallelGC || UseParallelOldGC) i++;
2308   if (UseG1GC)                           i++;
2309   if (i > 1) {
2310     jio_fprintf(defaultStream::error_stream(),
2311                 "Conflicting collector combinations in option list; "
2312                 "please refer to the release notes for the combinations "
2313                 "allowed\n");
2314     return false;
2315   }
2316 
2317   if (UseConcMarkSweepGC && !UseParNewGC) {
2318     jio_fprintf(defaultStream::error_stream(),
2319         "It is not possible to combine the DefNew young collector with the CMS collector.\n");
2320     return false;
2321   }


2631         !match_option(option, "-Dsun.java.launcher", &tail)) {
2632 
2633         // add all jvm options to the jvm_args string. This string
2634         // is used later to set the java.vm.args PerfData string constant.
2635         // the -Djava.class.path and the -Dsun.java.command options are
2636         // omitted from jvm_args string as each have their own PerfData
2637         // string constant object.
2638         build_jvm_args(option->optionString);
2639     }
2640 
2641     // -verbose:[class/gc/jni]
2642     if (match_option(option, "-verbose", &tail)) {
2643       if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
2644         if (FLAG_SET_CMDLINE(bool, TraceClassLoading, true) != Flag::SUCCESS) {
2645           return JNI_EINVAL;
2646         }
2647         if (FLAG_SET_CMDLINE(bool, TraceClassUnloading, true) != Flag::SUCCESS) {
2648           return JNI_EINVAL;
2649         }
2650       } else if (!strcmp(tail, ":gc")) {
2651         bool ret = LogConfiguration::parse_log_arguments("stdout", "gc", NULL, NULL, NULL);
2652         if (!ret) {
2653           return JNI_EINVAL;
2654         }
2655       } else if (!strcmp(tail, ":jni")) {
2656         if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) {
2657           return JNI_EINVAL;
2658         }
2659       }
2660     // -da / -ea / -disableassertions / -enableassertions
2661     // These accept an optional class/package name separated by a colon, e.g.,
2662     // -da:java.lang.Thread.
2663     } else if (match_option(option, user_assertion_options, &tail, true)) {
2664       bool enable = option->optionString[1] == 'e';     // char after '-' is 'e'
2665       if (*tail == '\0') {
2666         JavaAssertions::setUserClassDefault(enable);
2667       } else {
2668         assert(*tail == ':', "bogus match by match_option()");
2669         JavaAssertions::addOption(tail + 1, enable);
2670       }
2671     // -dsa / -esa / -disablesystemassertions / -enablesystemassertions
2672     } else if (match_option(option, system_assertion_options, &tail, false)) {


3065         if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true) != Flag::SUCCESS) {
3066           return JNI_EINVAL;
3067         }
3068       } else if (strcmp(tail, ":none") == 0) {
3069         if (FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false) != Flag::SUCCESS) {
3070           return JNI_EINVAL;
3071         }
3072         if (FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false) != Flag::SUCCESS) {
3073           return JNI_EINVAL;
3074         }
3075       } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
3076         return JNI_EINVAL;
3077       }
3078     // -Xdebug
3079     } else if (match_option(option, "-Xdebug")) {
3080       // note this flag has been used, then ignore
3081       set_xdebug_mode(true);
3082     // -Xnoagent
3083     } else if (match_option(option, "-Xnoagent")) {
3084       // For compatibility with classic. HotSpot refuses to load the old style agent.dll.


















3085     } else if (match_option(option, "-Xlog", &tail)) {
3086       bool ret = false;
3087       if (strcmp(tail, ":help") == 0) {
3088         LogConfiguration::print_command_line_help(defaultStream::output_stream());
3089         vm_exit(0);
3090       } else if (strcmp(tail, ":disable") == 0) {
3091         LogConfiguration::disable_logging();
3092         ret = true;
3093       } else if (*tail == '\0') {
3094         ret = LogConfiguration::parse_command_line_arguments();
3095         assert(ret, "-Xlog without arguments should never fail to parse");
3096       } else if (*tail == ':') {
3097         ret = LogConfiguration::parse_command_line_arguments(tail + 1);
3098       }
3099       if (ret == false) {
3100         jio_fprintf(defaultStream::error_stream(),
3101                     "Invalid -Xlog option '-Xlog%s'\n",
3102                     tail);
3103         return JNI_EINVAL;
3104       }


4067 
4068   ArgumentsExt::report_unsupported_options();
4069 
4070 #ifndef PRODUCT
4071   if (TraceBytecodesAt != 0) {
4072     TraceBytecodes = true;
4073   }
4074   if (CountCompiledCalls) {
4075     if (UseCounterDecay) {
4076       warning("UseCounterDecay disabled because CountCalls is set");
4077       UseCounterDecay = false;
4078     }
4079   }
4080 #endif // PRODUCT
4081 
4082   if (ScavengeRootsInCode == 0) {
4083     if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
4084       warning("Forcing ScavengeRootsInCode non-zero");
4085     }
4086     ScavengeRootsInCode = 1;





4087   }
4088 
4089   // Set object alignment values.
4090   set_object_alignment();
4091 
4092 #if !INCLUDE_ALL_GCS
4093   force_serial_gc();
4094 #endif // INCLUDE_ALL_GCS
4095 #if !INCLUDE_CDS
4096   if (DumpSharedSpaces || RequireSharedSpaces) {
4097     jio_fprintf(defaultStream::error_stream(),
4098       "Shared spaces are not supported in this VM\n");
4099     return JNI_ERR;
4100   }
4101   if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
4102     warning("Shared spaces are not supported in this VM");
4103     FLAG_SET_DEFAULT(UseSharedSpaces, false);
4104     FLAG_SET_DEFAULT(PrintSharedSpaces, false);
4105   }
4106   no_shared_spaces("CDS Disabled");


< prev index next >