34 #include "gc/shared/referenceProcessor.hpp"
35 #include "gc/shared/taskqueue.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_ALL_GCS
55 #include "gc/cms/compactibleFreeListSpace.hpp"
56 #include "gc/g1/g1CollectedHeap.inline.hpp"
57 #include "gc/parallel/parallelScavengeHeap.hpp"
58 #endif // INCLUDE_ALL_GCS
59
60 // Note: This is a special bug reporting site for the JVM
61 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp"
62 #define DEFAULT_JAVA_LAUNCHER "generic"
63
64 #define UNSUPPORTED_GC_OPTION(gc) \
65 do { \
66 if (gc) { \
67 if (FLAG_IS_CMDLINE(gc)) { \
68 warning(#gc " is not supported in this VM. Using Serial GC."); \
69 } \
70 FLAG_SET_DEFAULT(gc, false); \
71 } \
72 } while(0)
73
197
198 // Following are JVMTI agent writable properties.
199 // Properties values are set to NULL and they are
200 // os specific they are initialized in os::init_system_properties_values().
201 _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true);
202 _java_library_path = new SystemProperty("java.library.path", NULL, true);
203 _java_home = new SystemProperty("java.home", NULL, true);
204 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true);
205
206 _java_class_path = new SystemProperty("java.class.path", "", true);
207
208 // Add to System Property list.
209 PropertyList_add(&_system_properties, _sun_boot_library_path);
210 PropertyList_add(&_system_properties, _java_library_path);
211 PropertyList_add(&_system_properties, _java_home);
212 PropertyList_add(&_system_properties, _java_class_path);
213 PropertyList_add(&_system_properties, _sun_boot_class_path);
214
215 // Set OS specific system properties values
216 os::init_system_properties_values();
217 }
218
219 // Update/Initialize System properties after JDK version number is known
220 void Arguments::init_version_specific_system_properties() {
221 enum { bufsz = 16 };
222 char buffer[bufsz];
223 const char* spec_vendor = "Sun Microsystems Inc.";
224 uint32_t spec_version = 0;
225
226 spec_vendor = "Oracle Corporation";
227 spec_version = JDK_Version::current().major_version();
228 jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
229
230 PropertyList_add(&_system_properties,
231 new SystemProperty("java.vm.specification.vendor", spec_vendor, false));
232 PropertyList_add(&_system_properties,
233 new SystemProperty("java.vm.specification.version", buffer, false));
234 PropertyList_add(&_system_properties,
235 new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false));
236 }
1079 UseOnStackReplacement = false;
1080 break;
1081 case _mixed:
1082 // same as default
1083 break;
1084 case _comp:
1085 UseInterpreter = false;
1086 BackgroundCompilation = false;
1087 ClipInlining = false;
1088 // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
1089 // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
1090 // compile a level 4 (C2) and then continue executing it.
1091 if (TieredCompilation) {
1092 Tier3InvokeNotifyFreqLog = 0;
1093 Tier4InvocationThreshold = 0;
1094 }
1095 break;
1096 }
1097 }
1098
1099 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS
1100 // Conflict: required to use shared spaces (-Xshare:on), but
1101 // incompatible command line options were chosen.
1102
1103 static void no_shared_spaces(const char* message) {
1104 if (RequireSharedSpaces) {
1105 jio_fprintf(defaultStream::error_stream(),
1106 "Class data sharing is inconsistent with other specified options.\n");
1107 vm_exit_during_initialization("Unable to use shared archive.", message);
1108 } else {
1109 FLAG_SET_DEFAULT(UseSharedSpaces, false);
1110 }
1111 }
1112 #endif
1113
1114 // Returns threshold scaled with the value of scale.
1115 // If scale < 0.0, threshold is returned without scaling.
1116 intx Arguments::scaled_compile_threshold(intx threshold, double scale) {
1117 if (scale == 1.0 || scale < 0.0) {
1118 return threshold;
1119 } else {
1539 FLAG_SET_ERGO(bool, UseParallelGC, true);
1540 #else
1541 FLAG_SET_ERGO(bool, UseG1GC, true);
1542 #endif
1543 }
1544 } else {
1545 FLAG_SET_ERGO(bool, UseSerialGC, true);
1546 }
1547 }
1548
1549 void Arguments::select_gc() {
1550 if (!gc_selected()) {
1551 select_gc_ergonomically();
1552 guarantee(gc_selected(), "No GC selected");
1553 }
1554 }
1555
1556 void Arguments::set_ergonomics_flags() {
1557 select_gc();
1558
1559 #ifdef COMPILER2
1560 // Shared spaces work fine with other GCs but causes bytecode rewriting
1561 // to be disabled, which hurts interpreter performance and decreases
1562 // server performance. When -server is specified, keep the default off
1563 // unless it is asked for. Future work: either add bytecode rewriting
1564 // at link time, or rewrite bytecodes in non-shared methods.
1565 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1566 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1567 no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1568 }
1569 #endif
1570
1571 set_conservative_max_heap_alignment();
1572
1573 #ifndef ZERO
1574 #ifdef _LP64
1575 set_use_compressed_oops();
1576
1577 // set_use_compressed_klass_ptrs() must be called after calling
1578 // set_use_compressed_oops().
1579 set_use_compressed_klass_ptrs();
1626 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
1627 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
1628 }
1629 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
1630 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
1631 }
1632 }
1633
1634 if (UseParallelOldGC) {
1635 // Par compact uses lower default values since they are treated as
1636 // minimums. These are different defaults because of the different
1637 // interpretation and are not ergonomically set.
1638 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
1639 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
1640 }
1641 }
1642 }
1643
1644 void Arguments::set_g1_gc_flags() {
1645 assert(UseG1GC, "Error");
1646 #ifdef COMPILER1
1647 FastTLABRefill = false;
1648 #endif
1649 FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
1650 if (ParallelGCThreads == 0) {
1651 assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0.");
1652 vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL);
1653 }
1654
1655 #if INCLUDE_ALL_GCS
1656 if (G1ConcRefinementThreads == 0) {
1657 FLAG_SET_DEFAULT(G1ConcRefinementThreads, ParallelGCThreads);
1658 }
1659 #endif
1660
1661 // MarkStackSize will be set (if it hasn't been set by the user)
1662 // when concurrent marking is initialized.
1663 // Its value will be based upon the number of parallel marking threads.
1664 // But we do set the maximum mark stack size here.
1665 if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1666 FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
2113 // Note: only executed in non-PRODUCT mode
2114 if (!UseAsyncConcMarkSweepGC &&
2115 (ExplicitGCInvokesConcurrent ||
2116 ExplicitGCInvokesConcurrentAndUnloadsClasses)) {
2117 jio_fprintf(defaultStream::error_stream(),
2118 "error: +ExplicitGCInvokesConcurrent[AndUnloadsClasses] conflicts"
2119 " with -UseAsyncConcMarkSweepGC");
2120 status = false;
2121 }
2122
2123 if (PrintNMTStatistics) {
2124 #if INCLUDE_NMT
2125 if (MemTracker::tracking_level() == NMT_off) {
2126 #endif // INCLUDE_NMT
2127 warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
2128 PrintNMTStatistics = false;
2129 #if INCLUDE_NMT
2130 }
2131 #endif
2132 }
2133
2134 // Check lower bounds of the code cache
2135 // Template Interpreter code is approximately 3X larger in debug builds.
2136 uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
2137 if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
2138 jio_fprintf(defaultStream::error_stream(),
2139 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
2140 os::vm_page_size()/K);
2141 status = false;
2142 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
2143 jio_fprintf(defaultStream::error_stream(),
2144 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
2145 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
2146 status = false;
2147 } else if (ReservedCodeCacheSize < min_code_cache_size) {
2148 jio_fprintf(defaultStream::error_stream(),
2149 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
2150 min_code_cache_size/K);
2151 status = false;
2152 } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) {
3248 memcpy(dirpath, path, tmp_end - path);
3249 dirpath[tmp_end - path] = '\0';
3250 if (has_jar_files(dirpath)) {
3251 nonEmptyDirs++;
3252 jio_fprintf(defaultStream::output_stream(),
3253 "Non-empty directory: %s\n", dirpath);
3254 }
3255 FREE_C_HEAP_ARRAY(char, dirpath);
3256 path = tmp_end + 1;
3257 }
3258 }
3259 return nonEmptyDirs;
3260 }
3261
3262 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
3263 // check if the default lib/endorsed directory exists; if so, error
3264 char path[JVM_MAXPATHLEN];
3265 const char* fileSep = os::file_separator();
3266 sprintf(path, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
3267
3268 if (CheckEndorsedAndExtDirs) {
3269 int nonEmptyDirs = 0;
3270 // check endorsed directory
3271 nonEmptyDirs += check_non_empty_dirs(path);
3272 // check the extension directories
3273 nonEmptyDirs += check_non_empty_dirs(Arguments::get_ext_dirs());
3274 if (nonEmptyDirs > 0) {
3275 return JNI_ERR;
3276 }
3277 }
3278
3279 DIR* dir = os::opendir(path);
3280 if (dir != NULL) {
3281 jio_fprintf(defaultStream::output_stream(),
3282 "<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
3283 "in modular form will be supported via the concept of upgradeable modules.\n");
3284 os::closedir(dir);
3285 return JNI_ERR;
3286 }
3287
3306 // java_compiler() true means set to "NONE" or empty.
3307 if (java_compiler() && !xdebug_mode()) {
3308 // For backwards compatibility, we switch to interpreted mode if
3309 // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3310 // not specified.
3311 set_mode_flags(_int);
3312 }
3313
3314 // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
3315 // but like -Xint, leave compilation thresholds unaffected.
3316 // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
3317 if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
3318 set_mode_flags(_int);
3319 }
3320
3321 // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
3322 if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
3323 FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold);
3324 }
3325
3326 #ifndef COMPILER2
3327 // Don't degrade server performance for footprint
3328 if (FLAG_IS_DEFAULT(UseLargePages) &&
3329 MaxHeapSize < LargePageHeapSizeThreshold) {
3330 // No need for large granularity pages w/small heaps.
3331 // Note that large pages are enabled/disabled for both the
3332 // Java heap and the code cache.
3333 FLAG_SET_DEFAULT(UseLargePages, false);
3334 }
3335
3336 #else
3337 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
3338 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
3339 }
3340 #endif
3341
3342 #ifndef TIERED
3343 // Tiered compilation is undefined.
3344 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
3345 #endif
3346
3347 // If we are running in a headless jre, force java.awt.headless property
3348 // to be true unless the property has already been set.
3349 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3350 if (os::is_headless_jre()) {
3351 const char* headless = Arguments::get_property("java.awt.headless");
3352 if (headless == NULL) {
3353 const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
3354 if (headless_env == NULL) {
3355 if (!add_property("java.awt.headless=true")) {
3356 return JNI_ENOMEM;
3862 set_heap_size();
3863
3864 ArgumentsExt::set_gc_specific_flags();
3865
3866 // Initialize Metaspace flags and alignments
3867 Metaspace::ergo_initialize();
3868
3869 // Set bytecode rewriting flags
3870 set_bytecode_flags();
3871
3872 // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled
3873 set_aggressive_opts_flags();
3874
3875 // Turn off biased locking for locking debug mode flags,
3876 // which are subtly different from each other but neither works with
3877 // biased locking
3878 if (UseHeavyMonitors
3879 #ifdef COMPILER1
3880 || !UseFastLocking
3881 #endif // COMPILER1
3882 ) {
3883 if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) {
3884 // flag set to true on command line; warn the user that they
3885 // can't enable biased locking here
3886 warning("Biased Locking is not supported with locking debug flags"
3887 "; ignoring UseBiasedLocking flag." );
3888 }
3889 UseBiasedLocking = false;
3890 }
3891
3892 #ifdef ZERO
3893 // Clear flags not supported on zero.
3894 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3895 FLAG_SET_DEFAULT(UseBiasedLocking, false);
3896 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false));
3897 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedClassPointers, false));
3898 #endif // CC_INTERP
3899
3900 #ifdef COMPILER2
3901 if (!EliminateLocks) {
|
34 #include "gc/shared/referenceProcessor.hpp"
35 #include "gc/shared/taskqueue.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
55 #include "jvmci/jvmciRuntime.hpp"
56 #endif
57 #if INCLUDE_ALL_GCS
58 #include "gc/cms/compactibleFreeListSpace.hpp"
59 #include "gc/g1/g1CollectedHeap.inline.hpp"
60 #include "gc/parallel/parallelScavengeHeap.hpp"
61 #endif // INCLUDE_ALL_GCS
62
63 // Note: This is a special bug reporting site for the JVM
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
200
201 // Following are JVMTI agent writable properties.
202 // Properties values are set to NULL and they are
203 // os specific they are initialized in os::init_system_properties_values().
204 _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true);
205 _java_library_path = new SystemProperty("java.library.path", NULL, true);
206 _java_home = new SystemProperty("java.home", NULL, true);
207 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true);
208
209 _java_class_path = new SystemProperty("java.class.path", "", true);
210
211 // Add to System Property list.
212 PropertyList_add(&_system_properties, _sun_boot_library_path);
213 PropertyList_add(&_system_properties, _java_library_path);
214 PropertyList_add(&_system_properties, _java_home);
215 PropertyList_add(&_system_properties, _java_class_path);
216 PropertyList_add(&_system_properties, _sun_boot_class_path);
217
218 // Set OS specific system properties values
219 os::init_system_properties_values();
220
221 JVMCI_ONLY(JVMCIRuntime::parse_properties(&_system_properties);)
222 }
223
224 // Update/Initialize System properties after JDK version number is known
225 void Arguments::init_version_specific_system_properties() {
226 enum { bufsz = 16 };
227 char buffer[bufsz];
228 const char* spec_vendor = "Sun Microsystems Inc.";
229 uint32_t spec_version = 0;
230
231 spec_vendor = "Oracle Corporation";
232 spec_version = JDK_Version::current().major_version();
233 jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
234
235 PropertyList_add(&_system_properties,
236 new SystemProperty("java.vm.specification.vendor", spec_vendor, false));
237 PropertyList_add(&_system_properties,
238 new SystemProperty("java.vm.specification.version", buffer, false));
239 PropertyList_add(&_system_properties,
240 new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false));
241 }
1084 UseOnStackReplacement = false;
1085 break;
1086 case _mixed:
1087 // same as default
1088 break;
1089 case _comp:
1090 UseInterpreter = false;
1091 BackgroundCompilation = false;
1092 ClipInlining = false;
1093 // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
1094 // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
1095 // compile a level 4 (C2) and then continue executing it.
1096 if (TieredCompilation) {
1097 Tier3InvokeNotifyFreqLog = 0;
1098 Tier4InvocationThreshold = 0;
1099 }
1100 break;
1101 }
1102 }
1103
1104 #if defined(COMPILER2) || INCLUDE_JVMCI || defined(_LP64) || !INCLUDE_CDS
1105 // Conflict: required to use shared spaces (-Xshare:on), but
1106 // incompatible command line options were chosen.
1107
1108 static void no_shared_spaces(const char* message) {
1109 if (RequireSharedSpaces) {
1110 jio_fprintf(defaultStream::error_stream(),
1111 "Class data sharing is inconsistent with other specified options.\n");
1112 vm_exit_during_initialization("Unable to use shared archive.", message);
1113 } else {
1114 FLAG_SET_DEFAULT(UseSharedSpaces, false);
1115 }
1116 }
1117 #endif
1118
1119 // Returns threshold scaled with the value of scale.
1120 // If scale < 0.0, threshold is returned without scaling.
1121 intx Arguments::scaled_compile_threshold(intx threshold, double scale) {
1122 if (scale == 1.0 || scale < 0.0) {
1123 return threshold;
1124 } else {
1544 FLAG_SET_ERGO(bool, UseParallelGC, true);
1545 #else
1546 FLAG_SET_ERGO(bool, UseG1GC, true);
1547 #endif
1548 }
1549 } else {
1550 FLAG_SET_ERGO(bool, UseSerialGC, true);
1551 }
1552 }
1553
1554 void Arguments::select_gc() {
1555 if (!gc_selected()) {
1556 select_gc_ergonomically();
1557 guarantee(gc_selected(), "No GC selected");
1558 }
1559 }
1560
1561 void Arguments::set_ergonomics_flags() {
1562 select_gc();
1563
1564 #if defined(COMPILER2) || INCLUDE_JVMCI
1565 // Shared spaces work fine with other GCs but causes bytecode rewriting
1566 // to be disabled, which hurts interpreter performance and decreases
1567 // server performance. When -server is specified, keep the default off
1568 // unless it is asked for. Future work: either add bytecode rewriting
1569 // at link time, or rewrite bytecodes in non-shared methods.
1570 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1571 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1572 no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1573 }
1574 #endif
1575
1576 set_conservative_max_heap_alignment();
1577
1578 #ifndef ZERO
1579 #ifdef _LP64
1580 set_use_compressed_oops();
1581
1582 // set_use_compressed_klass_ptrs() must be called after calling
1583 // set_use_compressed_oops().
1584 set_use_compressed_klass_ptrs();
1631 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
1632 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
1633 }
1634 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
1635 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
1636 }
1637 }
1638
1639 if (UseParallelOldGC) {
1640 // Par compact uses lower default values since they are treated as
1641 // minimums. These are different defaults because of the different
1642 // interpretation and are not ergonomically set.
1643 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
1644 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
1645 }
1646 }
1647 }
1648
1649 void Arguments::set_g1_gc_flags() {
1650 assert(UseG1GC, "Error");
1651 #if defined(COMPILER1) || INCLUDE_JVMCI
1652 FastTLABRefill = false;
1653 #endif
1654 FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
1655 if (ParallelGCThreads == 0) {
1656 assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "The default value for ParallelGCThreads should not be 0.");
1657 vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL);
1658 }
1659
1660 #if INCLUDE_ALL_GCS
1661 if (G1ConcRefinementThreads == 0) {
1662 FLAG_SET_DEFAULT(G1ConcRefinementThreads, ParallelGCThreads);
1663 }
1664 #endif
1665
1666 // MarkStackSize will be set (if it hasn't been set by the user)
1667 // when concurrent marking is initialized.
1668 // Its value will be based upon the number of parallel marking threads.
1669 // But we do set the maximum mark stack size here.
1670 if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1671 FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
2118 // Note: only executed in non-PRODUCT mode
2119 if (!UseAsyncConcMarkSweepGC &&
2120 (ExplicitGCInvokesConcurrent ||
2121 ExplicitGCInvokesConcurrentAndUnloadsClasses)) {
2122 jio_fprintf(defaultStream::error_stream(),
2123 "error: +ExplicitGCInvokesConcurrent[AndUnloadsClasses] conflicts"
2124 " with -UseAsyncConcMarkSweepGC");
2125 status = false;
2126 }
2127
2128 if (PrintNMTStatistics) {
2129 #if INCLUDE_NMT
2130 if (MemTracker::tracking_level() == NMT_off) {
2131 #endif // INCLUDE_NMT
2132 warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
2133 PrintNMTStatistics = false;
2134 #if INCLUDE_NMT
2135 }
2136 #endif
2137 }
2138 #if INCLUDE_JVMCI
2139 if (EnableJVMCI) {
2140 if (!ScavengeRootsInCode) {
2141 warning("forcing ScavengeRootsInCode non-zero because JVMCI is enabled");
2142 ScavengeRootsInCode = 1;
2143 }
2144 if (FLAG_IS_DEFAULT(TypeProfileLevel)) {
2145 TypeProfileLevel = 0;
2146 }
2147 if (UseJVMCICompiler) {
2148 if (FLAG_IS_DEFAULT(TypeProfileWidth)) {
2149 TypeProfileWidth = 8;
2150 }
2151 }
2152 }
2153 #endif
2154
2155 // Check lower bounds of the code cache
2156 // Template Interpreter code is approximately 3X larger in debug builds.
2157 uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
2158 if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
2159 jio_fprintf(defaultStream::error_stream(),
2160 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
2161 os::vm_page_size()/K);
2162 status = false;
2163 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
2164 jio_fprintf(defaultStream::error_stream(),
2165 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
2166 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
2167 status = false;
2168 } else if (ReservedCodeCacheSize < min_code_cache_size) {
2169 jio_fprintf(defaultStream::error_stream(),
2170 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
2171 min_code_cache_size/K);
2172 status = false;
2173 } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) {
3269 memcpy(dirpath, path, tmp_end - path);
3270 dirpath[tmp_end - path] = '\0';
3271 if (has_jar_files(dirpath)) {
3272 nonEmptyDirs++;
3273 jio_fprintf(defaultStream::output_stream(),
3274 "Non-empty directory: %s\n", dirpath);
3275 }
3276 FREE_C_HEAP_ARRAY(char, dirpath);
3277 path = tmp_end + 1;
3278 }
3279 }
3280 return nonEmptyDirs;
3281 }
3282
3283 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
3284 // check if the default lib/endorsed directory exists; if so, error
3285 char path[JVM_MAXPATHLEN];
3286 const char* fileSep = os::file_separator();
3287 sprintf(path, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
3288
3289 #if INCLUDE_JVMCI
3290 if (EnableJVMCI) {
3291 // Append lib/jvmci/*.jar to boot class path
3292 char jvmciDir[JVM_MAXPATHLEN];
3293 const char* fileSep = os::file_separator();
3294 jio_snprintf(jvmciDir, sizeof(jvmciDir), "%s%slib%sjvmci", Arguments::get_java_home(), fileSep, fileSep);
3295 DIR* dir = os::opendir(jvmciDir);
3296 if (dir != NULL) {
3297 struct dirent *entry;
3298 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(jvmciDir), mtInternal);
3299 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
3300 const char* name = entry->d_name;
3301 const char* ext = name + strlen(name) - 4;
3302 if (ext > name && strcmp(ext, ".jar") == 0) {
3303 char fileName[JVM_MAXPATHLEN];
3304 jio_snprintf(fileName, sizeof(fileName), "%s%s%s", jvmciDir, fileSep, name);
3305 scp_p->add_suffix(fileName);
3306 scp_assembly_required = true;
3307 }
3308 }
3309 FREE_C_HEAP_ARRAY(char, dbuf);
3310 os::closedir(dir);
3311 }
3312 }
3313 #endif // INCLUDE_JVMCI
3314
3315 if (CheckEndorsedAndExtDirs) {
3316 int nonEmptyDirs = 0;
3317 // check endorsed directory
3318 nonEmptyDirs += check_non_empty_dirs(path);
3319 // check the extension directories
3320 nonEmptyDirs += check_non_empty_dirs(Arguments::get_ext_dirs());
3321 if (nonEmptyDirs > 0) {
3322 return JNI_ERR;
3323 }
3324 }
3325
3326 DIR* dir = os::opendir(path);
3327 if (dir != NULL) {
3328 jio_fprintf(defaultStream::output_stream(),
3329 "<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
3330 "in modular form will be supported via the concept of upgradeable modules.\n");
3331 os::closedir(dir);
3332 return JNI_ERR;
3333 }
3334
3353 // java_compiler() true means set to "NONE" or empty.
3354 if (java_compiler() && !xdebug_mode()) {
3355 // For backwards compatibility, we switch to interpreted mode if
3356 // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3357 // not specified.
3358 set_mode_flags(_int);
3359 }
3360
3361 // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
3362 // but like -Xint, leave compilation thresholds unaffected.
3363 // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
3364 if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
3365 set_mode_flags(_int);
3366 }
3367
3368 // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
3369 if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
3370 FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold);
3371 }
3372
3373 #if !defined(COMPILER2) && !INCLUDE_JVMCI
3374 // Don't degrade server performance for footprint
3375 if (FLAG_IS_DEFAULT(UseLargePages) &&
3376 MaxHeapSize < LargePageHeapSizeThreshold) {
3377 // No need for large granularity pages w/small heaps.
3378 // Note that large pages are enabled/disabled for both the
3379 // Java heap and the code cache.
3380 FLAG_SET_DEFAULT(UseLargePages, false);
3381 }
3382
3383 #elif defined(COMPILER2)
3384 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
3385 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
3386 }
3387 #endif
3388
3389 #ifndef TIERED
3390 // Tiered compilation is undefined.
3391 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
3392 #endif
3393
3394 // If we are running in a headless jre, force java.awt.headless property
3395 // to be true unless the property has already been set.
3396 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
3397 if (os::is_headless_jre()) {
3398 const char* headless = Arguments::get_property("java.awt.headless");
3399 if (headless == NULL) {
3400 const char *headless_env = ::getenv("JAVA_AWT_HEADLESS");
3401 if (headless_env == NULL) {
3402 if (!add_property("java.awt.headless=true")) {
3403 return JNI_ENOMEM;
3909 set_heap_size();
3910
3911 ArgumentsExt::set_gc_specific_flags();
3912
3913 // Initialize Metaspace flags and alignments
3914 Metaspace::ergo_initialize();
3915
3916 // Set bytecode rewriting flags
3917 set_bytecode_flags();
3918
3919 // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled
3920 set_aggressive_opts_flags();
3921
3922 // Turn off biased locking for locking debug mode flags,
3923 // which are subtly different from each other but neither works with
3924 // biased locking
3925 if (UseHeavyMonitors
3926 #ifdef COMPILER1
3927 || !UseFastLocking
3928 #endif // COMPILER1
3929 #if INCLUDE_JVMCI
3930 || !JVMCIUseFastLocking
3931 #endif
3932 ) {
3933 if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) {
3934 // flag set to true on command line; warn the user that they
3935 // can't enable biased locking here
3936 warning("Biased Locking is not supported with locking debug flags"
3937 "; ignoring UseBiasedLocking flag." );
3938 }
3939 UseBiasedLocking = false;
3940 }
3941
3942 #ifdef ZERO
3943 // Clear flags not supported on zero.
3944 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3945 FLAG_SET_DEFAULT(UseBiasedLocking, false);
3946 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false));
3947 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedClassPointers, false));
3948 #endif // CC_INTERP
3949
3950 #ifdef COMPILER2
3951 if (!EliminateLocks) {
|