1376 // since a space lost due to alignment will be greater
1377 // then a saved space from compressed oops.
1378 if ((int)ObjectAlignmentInBytes > 256) {
1379 jio_fprintf(defaultStream::error_stream(),
1380 "error: ObjectAlignmentInBytes=%d must not be greater than 256\n",
1381 (int)ObjectAlignmentInBytes);
1382 return false;
1383 }
1384 // In case page size is very small.
1385 if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
1386 jio_fprintf(defaultStream::error_stream(),
1387 "error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
1388 (int)ObjectAlignmentInBytes, os::vm_page_size());
1389 return false;
1390 }
1391 return true;
1392 }
1393
1394 inline uintx max_heap_for_compressed_oops() {
1395 // Avoid sign flip.
1396 if (OopEncodingHeapMax < ClassMetaspaceSize + os::vm_page_size()) {
1397 return 0;
1398 }
1399 LP64_ONLY(return OopEncodingHeapMax - ClassMetaspaceSize - os::vm_page_size());
1400 NOT_LP64(ShouldNotReachHere(); return 0);
1401 }
1402
1403 bool Arguments::should_auto_select_low_pause_collector() {
1404 if (UseAutoGCSelectPolicy &&
1405 !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1406 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1407 if (PrintGCDetails) {
1408 // Cannot use gclog_or_tty yet.
1409 tty->print_cr("Automatic selection of the low pause collector"
1410 " based on pause goal of %d (ms)", MaxGCPauseMillis);
1411 }
1412 return true;
1413 }
1414 return false;
1415 }
1416
1417 void Arguments::set_use_compressed_oops() {
1418 #ifndef ZERO
1419 #ifdef _LP64
1431 #ifdef _WIN64
1432 if (UseLargePages && UseCompressedOops) {
1433 // Cannot allocate guard pages for implicit checks in indexed addressing
1434 // mode, when large pages are specified on windows.
1435 // This flag could be switched ON if narrow oop base address is set to 0,
1436 // see code in Universe::initialize_heap().
1437 Universe::set_narrow_oop_use_implicit_null_checks(false);
1438 }
1439 #endif // _WIN64
1440 } else {
1441 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1442 warning("Max heap size too large for Compressed Oops");
1443 FLAG_SET_DEFAULT(UseCompressedOops, false);
1444 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1445 }
1446 }
1447 #endif // _LP64
1448 #endif // ZERO
1449 }
1450
1451 void Arguments::set_ergonomics_flags() {
1452
1453 if (os::is_server_class_machine()) {
1454 // If no other collector is requested explicitly,
1455 // let the VM select the collector based on
1456 // machine class and automatic selection policy.
1457 if (!UseSerialGC &&
1458 !UseConcMarkSweepGC &&
1459 !UseG1GC &&
1460 !UseParNewGC &&
1461 FLAG_IS_DEFAULT(UseParallelGC)) {
1462 if (should_auto_select_low_pause_collector()) {
1463 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1464 } else {
1465 FLAG_SET_ERGO(bool, UseParallelGC, true);
1466 }
1467 }
1468 // Shared spaces work fine with other GCs but causes bytecode rewriting
1469 // to be disabled, which hurts interpreter performance and decreases
1470 // server performance. On server class machines, keep the default
1471 // off unless it is asked for. Future work: either add bytecode rewriting
1472 // at link time, or rewrite bytecodes in non-shared methods.
1473 if (!DumpSharedSpaces && !RequireSharedSpaces) {
1474 no_shared_spaces();
1475 }
1476 }
1477
1478 #ifndef ZERO
1479 #ifdef _LP64
1480 set_use_compressed_oops();
1481 // UseCompressedOops must be on for UseCompressedKlassPointers to be on.
1482 if (!UseCompressedOops) {
1483 if (UseCompressedKlassPointers) {
1484 warning("UseCompressedKlassPointers requires UseCompressedOops");
1485 }
1486 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1487 } else {
1488 // Turn on UseCompressedKlassPointers too
1489 if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) {
1490 FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true);
1491 }
1492 // Set the ClassMetaspaceSize to something that will not need to be
1493 // expanded, since it cannot be expanded.
1494 if (UseCompressedKlassPointers) {
1495 if (ClassMetaspaceSize > KlassEncodingMetaspaceMax) {
1496 warning("Class metaspace size is too large for UseCompressedKlassPointers");
1497 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1498 } else if (FLAG_IS_DEFAULT(ClassMetaspaceSize)) {
1499 // 100,000 classes seems like a good size, so 100M assumes around 1K
1500 // per klass. The vtable and oopMap is embedded so we don't have a fixed
1501 // size per klass. Eventually, this will be parameterized because it
1502 // would also be useful to determine the optimal size of the
1503 // systemDictionary.
1504 FLAG_SET_ERGO(uintx, ClassMetaspaceSize, 100*M);
1505 }
1506 }
1507 }
1508 // Also checks that certain machines are slower with compressed oops
1509 // in vm_version initialization code.
1510 #endif // _LP64
1511 #endif // !ZERO
1512 }
1513
1514 void Arguments::set_parallel_gc_flags() {
1515 assert(UseParallelGC || UseParallelOldGC, "Error");
1516 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
1517 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
1518 FLAG_SET_DEFAULT(UseParallelOldGC, true);
1519 }
1520 FLAG_SET_DEFAULT(UseParallelGC, true);
1521
1522 // If no heap maximum was requested explicitly, use some reasonable fraction
1523 // of the physical memory, up to a maximum of 1GB.
1524 FLAG_SET_DEFAULT(ParallelGCThreads,
1525 Abstract_VM_Version::parallel_worker_threads());
1526 if (ParallelGCThreads == 0) {
1527 jio_fprintf(defaultStream::error_stream(),
2136 status = status && verify_min_value(TenuredGenerationSizeSupplementDecay, 1, "TenuredGenerationSizeSupplementDecay");
2137
2138 status = status && verify_min_value(ParGCCardsPerStrideChunk, 1, "ParGCCardsPerStrideChunk");
2139
2140 status = status && verify_min_value(ParallelOldGCSplitInterval, 0, "ParallelOldGCSplitInterval");
2141 }
2142 #endif // INCLUDE_ALL_GCS
2143
2144 status = status && verify_interval(RefDiscoveryPolicy,
2145 ReferenceProcessor::DiscoveryPolicyMin,
2146 ReferenceProcessor::DiscoveryPolicyMax,
2147 "RefDiscoveryPolicy");
2148
2149 // Limit the lower bound of this flag to 1 as it is used in a division
2150 // expression.
2151 status = status && verify_interval(TLABWasteTargetPercent,
2152 1, 100, "TLABWasteTargetPercent");
2153
2154 status = status && verify_object_alignment();
2155
2156 status = status && verify_min_value(ClassMetaspaceSize, 1*M,
2157 "ClassMetaspaceSize");
2158
2159 status = status && verify_interval(MarkStackSizeMax,
2160 1, (max_jint - 1), "MarkStackSizeMax");
2161 status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
2162
2163 status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
2164
2165 status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
2166
2167 status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
2168
2169 status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
2170 status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
2171
2172 status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
2173
2174 status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
2175 status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
2176 status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");
3256 vm_args.options = options;
3257 vm_args.nOptions = i;
3258 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions;
3259
3260 if (PrintVMOptions) {
3261 const char* tail;
3262 for (int i = 0; i < vm_args.nOptions; i++) {
3263 const JavaVMOption *option = vm_args.options + i;
3264 if (match_option(option, "-XX:", &tail)) {
3265 logOption(tail);
3266 }
3267 }
3268 }
3269
3270 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ENVIRON_VAR));
3271 }
3272 return JNI_OK;
3273 }
3274
3275 void Arguments::set_shared_spaces_flags() {
3276 #ifdef _LP64
3277 const bool must_share = DumpSharedSpaces || RequireSharedSpaces;
3278
3279 // CompressedOops cannot be used with CDS. The offsets of oopmaps and
3280 // static fields are incorrect in the archive. With some more clever
3281 // initialization, this restriction can probably be lifted.
3282 if (UseCompressedOops) {
3283 if (must_share) {
3284 warning("disabling compressed oops because of %s",
3285 DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on");
3286 FLAG_SET_CMDLINE(bool, UseCompressedOops, false);
3287 FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false);
3288 } else {
3289 // Prefer compressed oops to class data sharing
3290 if (UseSharedSpaces && Verbose) {
3291 warning("turning off use of shared archive because of compressed oops");
3292 }
3293 no_shared_spaces();
3294 }
3295 }
3296 #endif
3297
3298 if (DumpSharedSpaces) {
3299 if (RequireSharedSpaces) {
3300 warning("cannot dump shared archive while using shared archive");
3301 }
3302 UseSharedSpaces = false;
3303 }
3304 }
3305
3306 #if !INCLUDE_ALL_GCS
3307 static void force_serial_gc() {
3308 FLAG_SET_DEFAULT(UseSerialGC, true);
3309 FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption
3310 UNSUPPORTED_GC_OPTION(UseG1GC);
3311 UNSUPPORTED_GC_OPTION(UseParallelGC);
3312 UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3313 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3314 UNSUPPORTED_GC_OPTION(UseParNewGC);
3315 }
3316 #endif // INCLUDE_ALL_GCS
3317
3318 // Sharing support
3319 // Construct the path to the archive
3320 static char* get_shared_archive_path() {
3321 char *shared_archive_path;
3322 if (SharedArchiveFile == NULL) {
|
1376 // since a space lost due to alignment will be greater
1377 // then a saved space from compressed oops.
1378 if ((int)ObjectAlignmentInBytes > 256) {
1379 jio_fprintf(defaultStream::error_stream(),
1380 "error: ObjectAlignmentInBytes=%d must not be greater than 256\n",
1381 (int)ObjectAlignmentInBytes);
1382 return false;
1383 }
1384 // In case page size is very small.
1385 if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
1386 jio_fprintf(defaultStream::error_stream(),
1387 "error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
1388 (int)ObjectAlignmentInBytes, os::vm_page_size());
1389 return false;
1390 }
1391 return true;
1392 }
1393
1394 inline uintx max_heap_for_compressed_oops() {
1395 // Avoid sign flip.
1396 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1397 LP64_ONLY(return OopEncodingHeapMax - os::vm_page_size());
1398 NOT_LP64(ShouldNotReachHere(); return 0);
1399 }
1400
1401 bool Arguments::should_auto_select_low_pause_collector() {
1402 if (UseAutoGCSelectPolicy &&
1403 !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
1404 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
1405 if (PrintGCDetails) {
1406 // Cannot use gclog_or_tty yet.
1407 tty->print_cr("Automatic selection of the low pause collector"
1408 " based on pause goal of %d (ms)", MaxGCPauseMillis);
1409 }
1410 return true;
1411 }
1412 return false;
1413 }
1414
1415 void Arguments::set_use_compressed_oops() {
1416 #ifndef ZERO
1417 #ifdef _LP64
1429 #ifdef _WIN64
1430 if (UseLargePages && UseCompressedOops) {
1431 // Cannot allocate guard pages for implicit checks in indexed addressing
1432 // mode, when large pages are specified on windows.
1433 // This flag could be switched ON if narrow oop base address is set to 0,
1434 // see code in Universe::initialize_heap().
1435 Universe::set_narrow_oop_use_implicit_null_checks(false);
1436 }
1437 #endif // _WIN64
1438 } else {
1439 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1440 warning("Max heap size too large for Compressed Oops");
1441 FLAG_SET_DEFAULT(UseCompressedOops, false);
1442 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1443 }
1444 }
1445 #endif // _LP64
1446 #endif // ZERO
1447 }
1448
1449
1450 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
1451 // set_use_compressed_oops().
1452 void Arguments::set_use_compressed_klass_ptrs() {
1453 #ifndef ZERO
1454 #ifdef _LP64
1455 // UseCompressedOops must be on for UseCompressedKlassPointers to be on.
1456 if (!UseCompressedOops) {
1457 if (UseCompressedKlassPointers) {
1458 warning("UseCompressedKlassPointers requires UseCompressedOops");
1459 }
1460 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1461 } else {
1462 // Turn on UseCompressedKlassPointers too
1463 if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) {
1464 FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true);
1465 }
1466 // Check the ClassMetaspaceSize to make sure we use compressed klass ptrs.
1467 if (UseCompressedKlassPointers) {
1468 if (ClassMetaspaceSize > KlassEncodingMetaspaceMax) {
1469 warning("Class metaspace size is too large for UseCompressedKlassPointers");
1470 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1471 }
1472 }
1473 }
1474 #endif // _LP64
1475 #endif // !ZERO
1476 }
1477
1478 void Arguments::set_ergonomics_flags() {
1479
1480 if (os::is_server_class_machine()) {
1481 // If no other collector is requested explicitly,
1482 // let the VM select the collector based on
1483 // machine class and automatic selection policy.
1484 if (!UseSerialGC &&
1485 !UseConcMarkSweepGC &&
1486 !UseG1GC &&
1487 !UseParNewGC &&
1488 FLAG_IS_DEFAULT(UseParallelGC)) {
1489 if (should_auto_select_low_pause_collector()) {
1490 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1491 } else {
1492 FLAG_SET_ERGO(bool, UseParallelGC, true);
1493 }
1494 }
1495 // Shared spaces work fine with other GCs but causes bytecode rewriting
1496 // to be disabled, which hurts interpreter performance and decreases
1497 // server performance. On server class machines, keep the default
1498 // off unless it is asked for. Future work: either add bytecode rewriting
1499 // at link time, or rewrite bytecodes in non-shared methods.
1500 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1501 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1502 no_shared_spaces();
1503 }
1504 }
1505
1506 #ifndef ZERO
1507 #ifdef _LP64
1508 set_use_compressed_oops();
1509
1510 // set_use_compressed_klass_ptrs() must be called after calling
1511 // set_use_compressed_oops().
1512 set_use_compressed_klass_ptrs();
1513
1514 // Also checks that certain machines are slower with compressed oops
1515 // in vm_version initialization code.
1516 #endif // _LP64
1517 #endif // !ZERO
1518 }
1519
1520 void Arguments::set_parallel_gc_flags() {
1521 assert(UseParallelGC || UseParallelOldGC, "Error");
1522 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
1523 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
1524 FLAG_SET_DEFAULT(UseParallelOldGC, true);
1525 }
1526 FLAG_SET_DEFAULT(UseParallelGC, true);
1527
1528 // If no heap maximum was requested explicitly, use some reasonable fraction
1529 // of the physical memory, up to a maximum of 1GB.
1530 FLAG_SET_DEFAULT(ParallelGCThreads,
1531 Abstract_VM_Version::parallel_worker_threads());
1532 if (ParallelGCThreads == 0) {
1533 jio_fprintf(defaultStream::error_stream(),
2142 status = status && verify_min_value(TenuredGenerationSizeSupplementDecay, 1, "TenuredGenerationSizeSupplementDecay");
2143
2144 status = status && verify_min_value(ParGCCardsPerStrideChunk, 1, "ParGCCardsPerStrideChunk");
2145
2146 status = status && verify_min_value(ParallelOldGCSplitInterval, 0, "ParallelOldGCSplitInterval");
2147 }
2148 #endif // INCLUDE_ALL_GCS
2149
2150 status = status && verify_interval(RefDiscoveryPolicy,
2151 ReferenceProcessor::DiscoveryPolicyMin,
2152 ReferenceProcessor::DiscoveryPolicyMax,
2153 "RefDiscoveryPolicy");
2154
2155 // Limit the lower bound of this flag to 1 as it is used in a division
2156 // expression.
2157 status = status && verify_interval(TLABWasteTargetPercent,
2158 1, 100, "TLABWasteTargetPercent");
2159
2160 status = status && verify_object_alignment();
2161
2162 status = status && verify_interval(ClassMetaspaceSize, 1*M, 3*G,
2163 "ClassMetaspaceSize");
2164
2165 status = status && verify_interval(MarkStackSizeMax,
2166 1, (max_jint - 1), "MarkStackSizeMax");
2167 status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
2168
2169 status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
2170
2171 status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
2172
2173 status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
2174
2175 status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
2176 status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
2177
2178 status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
2179
2180 status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
2181 status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
2182 status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");
3262 vm_args.options = options;
3263 vm_args.nOptions = i;
3264 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions;
3265
3266 if (PrintVMOptions) {
3267 const char* tail;
3268 for (int i = 0; i < vm_args.nOptions; i++) {
3269 const JavaVMOption *option = vm_args.options + i;
3270 if (match_option(option, "-XX:", &tail)) {
3271 logOption(tail);
3272 }
3273 }
3274 }
3275
3276 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ENVIRON_VAR));
3277 }
3278 return JNI_OK;
3279 }
3280
3281 void Arguments::set_shared_spaces_flags() {
3282 if (DumpSharedSpaces) {
3283 if (RequireSharedSpaces) {
3284 warning("cannot dump shared archive while using shared archive");
3285 }
3286 UseSharedSpaces = false;
3287 #ifdef _LP64
3288 if (!UseCompressedOops || !UseCompressedKlassPointers) {
3289 vm_exit_during_initialization(
3290 "Cannot dump shared archive when UseCompressedOops or UseCompressedKlassPointers is off.", NULL);
3291 }
3292 } else {
3293 // UseCompressedOops and UseCompressedKlassPointers must be on for UseSharedSpaces.
3294 if (!UseCompressedOops || !UseCompressedKlassPointers) {
3295 no_shared_spaces();
3296 }
3297 #endif
3298 }
3299 }
3300
3301 #if !INCLUDE_ALL_GCS
3302 static void force_serial_gc() {
3303 FLAG_SET_DEFAULT(UseSerialGC, true);
3304 FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption
3305 UNSUPPORTED_GC_OPTION(UseG1GC);
3306 UNSUPPORTED_GC_OPTION(UseParallelGC);
3307 UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3308 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3309 UNSUPPORTED_GC_OPTION(UseParNewGC);
3310 }
3311 #endif // INCLUDE_ALL_GCS
3312
3313 // Sharing support
3314 // Construct the path to the archive
3315 static char* get_shared_archive_path() {
3316 char *shared_archive_path;
3317 if (SharedArchiveFile == NULL) {
|