< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




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



  53 #if INCLUDE_ALL_GCS
  54 #include "gc/cms/compactibleFreeListSpace.hpp"
  55 #include "gc/g1/g1CollectedHeap.inline.hpp"
  56 #include "gc/parallel/parallelScavengeHeap.hpp"
  57 #endif // INCLUDE_ALL_GCS
  58 
  59 // Note: This is a special bug reporting site for the JVM
  60 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  61 #define DEFAULT_JAVA_LAUNCHER  "generic"
  62 
  63 #define UNSUPPORTED_GC_OPTION(gc)                                     \
  64 do {                                                                  \
  65   if (gc) {                                                           \
  66     if (FLAG_IS_CMDLINE(gc)) {                                        \
  67       warning(#gc " is not supported in this VM.  Using Serial GC."); \
  68     }                                                                 \
  69     FLAG_SET_DEFAULT(gc, false);                                      \
  70   }                                                                   \
  71 } while(0)
  72 


 196 
 197   // Following are JVMTI agent writable properties.
 198   // Properties values are set to NULL and they are
 199   // os specific they are initialized in os::init_system_properties_values().
 200   _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL,  true);
 201   _java_library_path = new SystemProperty("java.library.path", NULL,  true);
 202   _java_home =  new SystemProperty("java.home", NULL,  true);
 203   _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL,  true);
 204 
 205   _java_class_path = new SystemProperty("java.class.path", "",  true);
 206 
 207   // Add to System Property list.
 208   PropertyList_add(&_system_properties, _sun_boot_library_path);
 209   PropertyList_add(&_system_properties, _java_library_path);
 210   PropertyList_add(&_system_properties, _java_home);
 211   PropertyList_add(&_system_properties, _java_class_path);
 212   PropertyList_add(&_system_properties, _sun_boot_class_path);
 213 
 214   // Set OS specific system properties values
 215   os::init_system_properties_values();


 216 }
 217 
 218 // Update/Initialize System properties after JDK version number is known
 219 void Arguments::init_version_specific_system_properties() {
 220   enum { bufsz = 16 };
 221   char buffer[bufsz];
 222   const char* spec_vendor = "Oracle Corporation";
 223   uint32_t spec_version = JDK_Version::current().major_version();
 224 
 225   jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
 226 
 227   PropertyList_add(&_system_properties,
 228       new SystemProperty("java.vm.specification.vendor",  spec_vendor, false));
 229   PropertyList_add(&_system_properties,
 230       new SystemProperty("java.vm.specification.version", buffer, false));
 231   PropertyList_add(&_system_properties,
 232       new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(),  false));
 233 }
 234 
 235 /*


1357     UseOnStackReplacement    = false;
1358     break;
1359   case _mixed:
1360     // same as default
1361     break;
1362   case _comp:
1363     UseInterpreter           = false;
1364     BackgroundCompilation    = false;
1365     ClipInlining             = false;
1366     // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
1367     // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
1368     // compile a level 4 (C2) and then continue executing it.
1369     if (TieredCompilation) {
1370       Tier3InvokeNotifyFreqLog = 0;
1371       Tier4InvocationThreshold = 0;
1372     }
1373     break;
1374   }
1375 }
1376 
1377 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS
1378 // Conflict: required to use shared spaces (-Xshare:on), but
1379 // incompatible command line options were chosen.
1380 
1381 static void no_shared_spaces(const char* message) {
1382   if (RequireSharedSpaces) {
1383     jio_fprintf(defaultStream::error_stream(),
1384       "Class data sharing is inconsistent with other specified options.\n");
1385     vm_exit_during_initialization("Unable to use shared archive.", message);
1386   } else {
1387     FLAG_SET_DEFAULT(UseSharedSpaces, false);
1388   }
1389 }
1390 #endif
1391 
1392 // Returns threshold scaled with the value of scale.
1393 // If scale < 0.0, threshold is returned without scaling.
1394 intx Arguments::scaled_compile_threshold(intx threshold, double scale) {
1395   if (scale == 1.0 || scale < 0.0) {
1396     return threshold;
1397   } else {


1817       FLAG_SET_ERGO(bool, UseParallelGC, true);
1818 #else
1819       FLAG_SET_ERGO(bool, UseG1GC, true);
1820 #endif
1821     }
1822   } else {
1823     FLAG_SET_ERGO(bool, UseSerialGC, true);
1824   }
1825 }
1826 
1827 void Arguments::select_gc() {
1828   if (!gc_selected()) {
1829     select_gc_ergonomically();
1830     guarantee(gc_selected(), "No GC selected");
1831   }
1832 }
1833 
1834 void Arguments::set_ergonomics_flags() {
1835   select_gc();
1836 
1837 #ifdef COMPILER2
1838   // Shared spaces work fine with other GCs but causes bytecode rewriting
1839   // to be disabled, which hurts interpreter performance and decreases
1840   // server performance.  When -server is specified, keep the default off
1841   // unless it is asked for.  Future work: either add bytecode rewriting
1842   // at link time, or rewrite bytecodes in non-shared methods.
1843   if (!DumpSharedSpaces && !RequireSharedSpaces &&
1844       (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1845     no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1846   }
1847 #endif
1848 
1849   set_conservative_max_heap_alignment();
1850 
1851 #ifndef ZERO
1852 #ifdef _LP64
1853   set_use_compressed_oops();
1854 
1855   // set_use_compressed_klass_ptrs() must be called after calling
1856   // set_use_compressed_oops().
1857   set_use_compressed_klass_ptrs();


1901     if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
1902        FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
1903     }
1904     if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
1905       FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
1906     }
1907   }
1908 
1909   if (UseParallelOldGC) {
1910     // Par compact uses lower default values since they are treated as
1911     // minimums.  These are different defaults because of the different
1912     // interpretation and are not ergonomically set.
1913     if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
1914       FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
1915     }
1916   }
1917 }
1918 
1919 void Arguments::set_g1_gc_flags() {
1920   assert(UseG1GC, "Error");
1921 #ifdef COMPILER1
1922   FastTLABRefill = false;
1923 #endif
1924   FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
1925   if (ParallelGCThreads == 0) {
1926     assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0.");
1927     vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL);
1928   }
1929 
1930 #if INCLUDE_ALL_GCS
1931   if (G1ConcRefinementThreads == 0) {
1932     FLAG_SET_DEFAULT(G1ConcRefinementThreads, ParallelGCThreads);
1933   }
1934 #endif
1935 
1936   // MarkStackSize will be set (if it hasn't been set by the user)
1937   // when concurrent marking is initialized.
1938   // Its value will be based upon the number of parallel marking threads.
1939   // But we do set the maximum mark stack size here.
1940   if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1941     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);


2478   // Note: only executed in non-PRODUCT mode
2479   if (!UseAsyncConcMarkSweepGC &&
2480       (ExplicitGCInvokesConcurrent ||
2481        ExplicitGCInvokesConcurrentAndUnloadsClasses)) {
2482     jio_fprintf(defaultStream::error_stream(),
2483                 "error: +ExplicitGCInvokesConcurrent[AndUnloadsClasses] conflicts"
2484                 " with -UseAsyncConcMarkSweepGC");
2485     status = false;
2486   }
2487 
2488   if (PrintNMTStatistics) {
2489 #if INCLUDE_NMT
2490     if (MemTracker::tracking_level() == NMT_off) {
2491 #endif // INCLUDE_NMT
2492       warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
2493       PrintNMTStatistics = false;
2494 #if INCLUDE_NMT
2495     }
2496 #endif
2497   }
















2498 
2499   // Check lower bounds of the code cache
2500   // Template Interpreter code is approximately 3X larger in debug builds.
2501   uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
2502   if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
2503     jio_fprintf(defaultStream::error_stream(),
2504                 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
2505                 os::vm_page_size()/K);
2506     status = false;
2507   } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
2508     jio_fprintf(defaultStream::error_stream(),
2509                 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
2510                 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
2511     status = false;
2512   } else if (ReservedCodeCacheSize < min_code_cache_size) {
2513     jio_fprintf(defaultStream::error_stream(),
2514                 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
2515                 min_code_cache_size/K);
2516     status = false;
2517   } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) {


3446       memcpy(dirpath, path, tmp_end - path);
3447       dirpath[tmp_end - path] = '\0';
3448       if (has_jar_files(dirpath)) {
3449         nonEmptyDirs++;
3450         jio_fprintf(defaultStream::output_stream(),
3451           "Non-empty directory: %s\n", dirpath);
3452       }
3453       FREE_C_HEAP_ARRAY(char, dirpath);
3454       path = tmp_end + 1;
3455     }
3456   }
3457   return nonEmptyDirs;
3458 }
3459 
3460 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
3461   // check if the default lib/endorsed directory exists; if so, error
3462   char path[JVM_MAXPATHLEN];
3463   const char* fileSep = os::file_separator();
3464   sprintf(path, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
3465 































3466   if (CheckEndorsedAndExtDirs) {
3467     int nonEmptyDirs = 0;
3468     // check endorsed directory
3469     nonEmptyDirs += check_non_empty_dirs(path);
3470     // check the extension directories
3471     nonEmptyDirs += check_non_empty_dirs(Arguments::get_ext_dirs());
3472     if (nonEmptyDirs > 0) {
3473       return JNI_ERR;
3474     }
3475   }
3476 
3477   DIR* dir = os::opendir(path);
3478   if (dir != NULL) {
3479     jio_fprintf(defaultStream::output_stream(),
3480       "<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
3481       "in modular form will be supported via the concept of upgradeable modules.\n");
3482     os::closedir(dir);
3483     return JNI_ERR;
3484   }
3485 


3504   // java_compiler() true means set to "NONE" or empty.
3505   if (java_compiler() && !xdebug_mode()) {
3506     // For backwards compatibility, we switch to interpreted mode if
3507     // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3508     // not specified.
3509     set_mode_flags(_int);
3510   }
3511 
3512   // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
3513   // but like -Xint, leave compilation thresholds unaffected.
3514   // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
3515   if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
3516     set_mode_flags(_int);
3517   }
3518 
3519   // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
3520   if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
3521     FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold);
3522   }
3523 
3524 #ifndef COMPILER2
3525   // Don't degrade server performance for footprint
3526   if (FLAG_IS_DEFAULT(UseLargePages) &&
3527       MaxHeapSize < LargePageHeapSizeThreshold) {
3528     // No need for large granularity pages w/small heaps.
3529     // Note that large pages are enabled/disabled for both the
3530     // Java heap and the code cache.
3531     FLAG_SET_DEFAULT(UseLargePages, false);
3532   }
3533 
3534 #else
3535   if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
3536     FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
3537   }
3538 #endif
3539 
3540 #ifndef TIERED
3541   // Tiered compilation is undefined.
3542   UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
3543 #endif
3544 
3545   // If we are running in a headless jre, force java.awt.headless property
3546   // to be true unless the property has already been set.
3547   // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3548   if (os::is_headless_jre()) {
3549     const char* headless = Arguments::get_property("java.awt.headless");
3550     if (headless == NULL) {
3551       const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
3552       if (headless_env == NULL) {
3553         if (!add_property("java.awt.headless=true")) {
3554           return JNI_ENOMEM;


4262 
4263   // Initialize Metaspace flags and alignments
4264   Metaspace::ergo_initialize();
4265 
4266   // Set bytecode rewriting flags
4267   set_bytecode_flags();
4268 
4269   // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled
4270   jint code = set_aggressive_opts_flags();
4271   if (code != JNI_OK) {
4272     return code;
4273   }
4274 
4275   // Turn off biased locking for locking debug mode flags,
4276   // which are subtly different from each other but neither works with
4277   // biased locking
4278   if (UseHeavyMonitors
4279 #ifdef COMPILER1
4280       || !UseFastLocking
4281 #endif // COMPILER1



4282     ) {
4283     if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) {
4284       // flag set to true on command line; warn the user that they
4285       // can't enable biased locking here
4286       warning("Biased Locking is not supported with locking debug flags"
4287               "; ignoring UseBiasedLocking flag." );
4288     }
4289     UseBiasedLocking = false;
4290   }
4291 
4292 #ifdef ZERO
4293   // Clear flags not supported on zero.
4294   FLAG_SET_DEFAULT(ProfileInterpreter, false);
4295   FLAG_SET_DEFAULT(UseBiasedLocking, false);
4296   LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false));
4297   LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedClassPointers, false));
4298 #endif // CC_INTERP
4299 
4300 #ifdef COMPILER2
4301   if (!EliminateLocks) {




  33 #include "gc/shared/referenceProcessor.hpp"
  34 #include "gc/shared/taskqueue.hpp"
  35 #include "memory/allocation.inline.hpp"
  36 #include "memory/universe.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "prims/jvmtiExport.hpp"
  39 #include "runtime/arguments.hpp"
  40 #include "runtime/arguments_ext.hpp"
  41 #include "runtime/commandLineFlagConstraintList.hpp"
  42 #include "runtime/commandLineFlagRangeList.hpp"
  43 #include "runtime/globals.hpp"
  44 #include "runtime/globals_extension.hpp"
  45 #include "runtime/java.hpp"
  46 #include "runtime/os.hpp"
  47 #include "runtime/vm_version.hpp"
  48 #include "services/management.hpp"
  49 #include "services/memTracker.hpp"
  50 #include "utilities/defaultStream.hpp"
  51 #include "utilities/macros.hpp"
  52 #include "utilities/stringUtils.hpp"
  53 #if INCLUDE_JVMCI
  54 #include "jvmci/jvmciRuntime.hpp"
  55 #endif
  56 #if INCLUDE_ALL_GCS
  57 #include "gc/cms/compactibleFreeListSpace.hpp"
  58 #include "gc/g1/g1CollectedHeap.inline.hpp"
  59 #include "gc/parallel/parallelScavengeHeap.hpp"
  60 #endif // INCLUDE_ALL_GCS
  61 
  62 // Note: This is a special bug reporting site for the JVM
  63 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
  64 #define DEFAULT_JAVA_LAUNCHER  "generic"
  65 
  66 #define UNSUPPORTED_GC_OPTION(gc)                                     \
  67 do {                                                                  \
  68   if (gc) {                                                           \
  69     if (FLAG_IS_CMDLINE(gc)) {                                        \
  70       warning(#gc " is not supported in this VM.  Using Serial GC."); \
  71     }                                                                 \
  72     FLAG_SET_DEFAULT(gc, false);                                      \
  73   }                                                                   \
  74 } while(0)
  75 


 199 
 200   // Following are JVMTI agent writable properties.
 201   // Properties values are set to NULL and they are
 202   // os specific they are initialized in os::init_system_properties_values().
 203   _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL,  true);
 204   _java_library_path = new SystemProperty("java.library.path", NULL,  true);
 205   _java_home =  new SystemProperty("java.home", NULL,  true);
 206   _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL,  true);
 207 
 208   _java_class_path = new SystemProperty("java.class.path", "",  true);
 209 
 210   // Add to System Property list.
 211   PropertyList_add(&_system_properties, _sun_boot_library_path);
 212   PropertyList_add(&_system_properties, _java_library_path);
 213   PropertyList_add(&_system_properties, _java_home);
 214   PropertyList_add(&_system_properties, _java_class_path);
 215   PropertyList_add(&_system_properties, _sun_boot_class_path);
 216 
 217   // Set OS specific system properties values
 218   os::init_system_properties_values();
 219 
 220   JVMCI_ONLY(JVMCIRuntime::init_system_properties(&_system_properties);)
 221 }
 222 
 223 // Update/Initialize System properties after JDK version number is known
 224 void Arguments::init_version_specific_system_properties() {
 225   enum { bufsz = 16 };
 226   char buffer[bufsz];
 227   const char* spec_vendor = "Oracle Corporation";
 228   uint32_t spec_version = JDK_Version::current().major_version();
 229 
 230   jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
 231 
 232   PropertyList_add(&_system_properties,
 233       new SystemProperty("java.vm.specification.vendor",  spec_vendor, false));
 234   PropertyList_add(&_system_properties,
 235       new SystemProperty("java.vm.specification.version", buffer, false));
 236   PropertyList_add(&_system_properties,
 237       new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(),  false));
 238 }
 239 
 240 /*


1362     UseOnStackReplacement    = false;
1363     break;
1364   case _mixed:
1365     // same as default
1366     break;
1367   case _comp:
1368     UseInterpreter           = false;
1369     BackgroundCompilation    = false;
1370     ClipInlining             = false;
1371     // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
1372     // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
1373     // compile a level 4 (C2) and then continue executing it.
1374     if (TieredCompilation) {
1375       Tier3InvokeNotifyFreqLog = 0;
1376       Tier4InvocationThreshold = 0;
1377     }
1378     break;
1379   }
1380 }
1381 
1382 #if defined(COMPILER2) || INCLUDE_JVMCI || defined(_LP64) || !INCLUDE_CDS
1383 // Conflict: required to use shared spaces (-Xshare:on), but
1384 // incompatible command line options were chosen.
1385 
1386 static void no_shared_spaces(const char* message) {
1387   if (RequireSharedSpaces) {
1388     jio_fprintf(defaultStream::error_stream(),
1389       "Class data sharing is inconsistent with other specified options.\n");
1390     vm_exit_during_initialization("Unable to use shared archive.", message);
1391   } else {
1392     FLAG_SET_DEFAULT(UseSharedSpaces, false);
1393   }
1394 }
1395 #endif
1396 
1397 // Returns threshold scaled with the value of scale.
1398 // If scale < 0.0, threshold is returned without scaling.
1399 intx Arguments::scaled_compile_threshold(intx threshold, double scale) {
1400   if (scale == 1.0 || scale < 0.0) {
1401     return threshold;
1402   } else {


1822       FLAG_SET_ERGO(bool, UseParallelGC, true);
1823 #else
1824       FLAG_SET_ERGO(bool, UseG1GC, true);
1825 #endif
1826     }
1827   } else {
1828     FLAG_SET_ERGO(bool, UseSerialGC, true);
1829   }
1830 }
1831 
1832 void Arguments::select_gc() {
1833   if (!gc_selected()) {
1834     select_gc_ergonomically();
1835     guarantee(gc_selected(), "No GC selected");
1836   }
1837 }
1838 
1839 void Arguments::set_ergonomics_flags() {
1840   select_gc();
1841 
1842 #if defined(COMPILER2) || INCLUDE_JVMCI
1843   // Shared spaces work fine with other GCs but causes bytecode rewriting
1844   // to be disabled, which hurts interpreter performance and decreases
1845   // server performance.  When -server is specified, keep the default off
1846   // unless it is asked for.  Future work: either add bytecode rewriting
1847   // at link time, or rewrite bytecodes in non-shared methods.
1848   if (!DumpSharedSpaces && !RequireSharedSpaces &&
1849       (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1850     no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1851   }
1852 #endif
1853 
1854   set_conservative_max_heap_alignment();
1855 
1856 #ifndef ZERO
1857 #ifdef _LP64
1858   set_use_compressed_oops();
1859 
1860   // set_use_compressed_klass_ptrs() must be called after calling
1861   // set_use_compressed_oops().
1862   set_use_compressed_klass_ptrs();


1906     if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
1907        FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
1908     }
1909     if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
1910       FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
1911     }
1912   }
1913 
1914   if (UseParallelOldGC) {
1915     // Par compact uses lower default values since they are treated as
1916     // minimums.  These are different defaults because of the different
1917     // interpretation and are not ergonomically set.
1918     if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
1919       FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
1920     }
1921   }
1922 }
1923 
1924 void Arguments::set_g1_gc_flags() {
1925   assert(UseG1GC, "Error");
1926 #if defined(COMPILER1) || INCLUDE_JVMCI
1927   FastTLABRefill = false;
1928 #endif
1929   FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
1930   if (ParallelGCThreads == 0) {
1931     assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0.");
1932     vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL);
1933   }
1934 
1935 #if INCLUDE_ALL_GCS
1936   if (G1ConcRefinementThreads == 0) {
1937     FLAG_SET_DEFAULT(G1ConcRefinementThreads, ParallelGCThreads);
1938   }
1939 #endif
1940 
1941   // MarkStackSize will be set (if it hasn't been set by the user)
1942   // when concurrent marking is initialized.
1943   // Its value will be based upon the number of parallel marking threads.
1944   // But we do set the maximum mark stack size here.
1945   if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1946     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);


2483   // Note: only executed in non-PRODUCT mode
2484   if (!UseAsyncConcMarkSweepGC &&
2485       (ExplicitGCInvokesConcurrent ||
2486        ExplicitGCInvokesConcurrentAndUnloadsClasses)) {
2487     jio_fprintf(defaultStream::error_stream(),
2488                 "error: +ExplicitGCInvokesConcurrent[AndUnloadsClasses] conflicts"
2489                 " with -UseAsyncConcMarkSweepGC");
2490     status = false;
2491   }
2492 
2493   if (PrintNMTStatistics) {
2494 #if INCLUDE_NMT
2495     if (MemTracker::tracking_level() == NMT_off) {
2496 #endif // INCLUDE_NMT
2497       warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
2498       PrintNMTStatistics = false;
2499 #if INCLUDE_NMT
2500     }
2501 #endif
2502   }
2503 #if INCLUDE_JVMCI
2504   if (EnableJVMCI) {
2505     if (!ScavengeRootsInCode) {
2506       warning("forcing ScavengeRootsInCode non-zero because JVMCI is enabled");
2507       ScavengeRootsInCode = 1;
2508     }
2509     if (FLAG_IS_DEFAULT(TypeProfileLevel)) {
2510       TypeProfileLevel = 0;
2511     }
2512     if (UseJVMCICompiler) {
2513       if (FLAG_IS_DEFAULT(TypeProfileWidth)) {
2514         TypeProfileWidth = 8;
2515       }
2516     }
2517   }
2518 #endif
2519 
2520   // Check lower bounds of the code cache
2521   // Template Interpreter code is approximately 3X larger in debug builds.
2522   uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
2523   if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
2524     jio_fprintf(defaultStream::error_stream(),
2525                 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
2526                 os::vm_page_size()/K);
2527     status = false;
2528   } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
2529     jio_fprintf(defaultStream::error_stream(),
2530                 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
2531                 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
2532     status = false;
2533   } else if (ReservedCodeCacheSize < min_code_cache_size) {
2534     jio_fprintf(defaultStream::error_stream(),
2535                 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
2536                 min_code_cache_size/K);
2537     status = false;
2538   } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) {


3467       memcpy(dirpath, path, tmp_end - path);
3468       dirpath[tmp_end - path] = '\0';
3469       if (has_jar_files(dirpath)) {
3470         nonEmptyDirs++;
3471         jio_fprintf(defaultStream::output_stream(),
3472           "Non-empty directory: %s\n", dirpath);
3473       }
3474       FREE_C_HEAP_ARRAY(char, dirpath);
3475       path = tmp_end + 1;
3476     }
3477   }
3478   return nonEmptyDirs;
3479 }
3480 
3481 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
3482   // check if the default lib/endorsed directory exists; if so, error
3483   char path[JVM_MAXPATHLEN];
3484   const char* fileSep = os::file_separator();
3485   sprintf(path, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
3486 
3487 #if INCLUDE_JVMCI
3488   jint res = JVMCIRuntime::save_options(_system_properties);
3489   if (res != JNI_OK) {
3490     return res;
3491   }
3492 
3493   if (EnableJVMCI) {
3494     // Append lib/jvmci/*.jar to boot class path
3495     char jvmciDir[JVM_MAXPATHLEN];
3496     const char* fileSep = os::file_separator();
3497     jio_snprintf(jvmciDir, sizeof(jvmciDir), "%s%slib%sjvmci", Arguments::get_java_home(), fileSep, fileSep);
3498     DIR* dir = os::opendir(jvmciDir);
3499     if (dir != NULL) {
3500       struct dirent *entry;
3501       char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(jvmciDir), mtInternal);
3502       while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
3503         const char* name = entry->d_name;
3504         const char* ext = name + strlen(name) - 4;
3505         if (ext > name && strcmp(ext, ".jar") == 0) {
3506           char fileName[JVM_MAXPATHLEN];
3507           jio_snprintf(fileName, sizeof(fileName), "%s%s%s", jvmciDir, fileSep, name);
3508           scp_p->add_suffix(fileName);
3509           scp_assembly_required = true;
3510         }
3511       }
3512       FREE_C_HEAP_ARRAY(char, dbuf);
3513       os::closedir(dir);
3514     }
3515   }
3516 #endif // INCLUDE_JVMCI
3517 
3518   if (CheckEndorsedAndExtDirs) {
3519     int nonEmptyDirs = 0;
3520     // check endorsed directory
3521     nonEmptyDirs += check_non_empty_dirs(path);
3522     // check the extension directories
3523     nonEmptyDirs += check_non_empty_dirs(Arguments::get_ext_dirs());
3524     if (nonEmptyDirs > 0) {
3525       return JNI_ERR;
3526     }
3527   }
3528 
3529   DIR* dir = os::opendir(path);
3530   if (dir != NULL) {
3531     jio_fprintf(defaultStream::output_stream(),
3532       "<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
3533       "in modular form will be supported via the concept of upgradeable modules.\n");
3534     os::closedir(dir);
3535     return JNI_ERR;
3536   }
3537 


3556   // java_compiler() true means set to "NONE" or empty.
3557   if (java_compiler() && !xdebug_mode()) {
3558     // For backwards compatibility, we switch to interpreted mode if
3559     // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3560     // not specified.
3561     set_mode_flags(_int);
3562   }
3563 
3564   // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
3565   // but like -Xint, leave compilation thresholds unaffected.
3566   // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
3567   if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
3568     set_mode_flags(_int);
3569   }
3570 
3571   // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
3572   if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
3573     FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold);
3574   }
3575 
3576 #if !defined(COMPILER2) && !INCLUDE_JVMCI
3577   // Don't degrade server performance for footprint
3578   if (FLAG_IS_DEFAULT(UseLargePages) &&
3579       MaxHeapSize < LargePageHeapSizeThreshold) {
3580     // No need for large granularity pages w/small heaps.
3581     // Note that large pages are enabled/disabled for both the
3582     // Java heap and the code cache.
3583     FLAG_SET_DEFAULT(UseLargePages, false);
3584   }
3585 
3586 #elif defined(COMPILER2)
3587   if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
3588     FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
3589   }
3590 #endif
3591 
3592 #ifndef TIERED
3593   // Tiered compilation is undefined.
3594   UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
3595 #endif
3596 
3597   // If we are running in a headless jre, force java.awt.headless property
3598   // to be true unless the property has already been set.
3599   // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3600   if (os::is_headless_jre()) {
3601     const char* headless = Arguments::get_property("java.awt.headless");
3602     if (headless == NULL) {
3603       const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
3604       if (headless_env == NULL) {
3605         if (!add_property("java.awt.headless=true")) {
3606           return JNI_ENOMEM;


4314 
4315   // Initialize Metaspace flags and alignments
4316   Metaspace::ergo_initialize();
4317 
4318   // Set bytecode rewriting flags
4319   set_bytecode_flags();
4320 
4321   // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled
4322   jint code = set_aggressive_opts_flags();
4323   if (code != JNI_OK) {
4324     return code;
4325   }
4326 
4327   // Turn off biased locking for locking debug mode flags,
4328   // which are subtly different from each other but neither works with
4329   // biased locking
4330   if (UseHeavyMonitors
4331 #ifdef COMPILER1
4332       || !UseFastLocking
4333 #endif // COMPILER1
4334 #if INCLUDE_JVMCI
4335       || !JVMCIUseFastLocking
4336 #endif
4337     ) {
4338     if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) {
4339       // flag set to true on command line; warn the user that they
4340       // can't enable biased locking here
4341       warning("Biased Locking is not supported with locking debug flags"
4342               "; ignoring UseBiasedLocking flag." );
4343     }
4344     UseBiasedLocking = false;
4345   }
4346 
4347 #ifdef ZERO
4348   // Clear flags not supported on zero.
4349   FLAG_SET_DEFAULT(ProfileInterpreter, false);
4350   FLAG_SET_DEFAULT(UseBiasedLocking, false);
4351   LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false));
4352   LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedClassPointers, false));
4353 #endif // CC_INTERP
4354 
4355 #ifdef COMPILER2
4356   if (!EliminateLocks) {


< prev index next >