comparison src/share/vm/runtime/arguments.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents bb3f6194fedb
children 11fb740ce98f
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
243 JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) }, 243 JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
244 { "UseParallelOldGCDensePrefix", 244 { "UseParallelOldGCDensePrefix",
245 JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) }, 245 JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
246 { "AllowTransitionalJSR292", JDK_Version::jdk(7), JDK_Version::jdk(8) }, 246 { "AllowTransitionalJSR292", JDK_Version::jdk(7), JDK_Version::jdk(8) },
247 { "UseCompressedStrings", JDK_Version::jdk(7), JDK_Version::jdk(8) }, 247 { "UseCompressedStrings", JDK_Version::jdk(7), JDK_Version::jdk(8) },
248 { "CMSPermGenPrecleaningEnabled", JDK_Version::jdk(8), JDK_Version::jdk(9) },
249 { "CMSTriggerPermRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) },
250 { "CMSInitiatingPermOccupancyFraction", JDK_Version::jdk(8), JDK_Version::jdk(9) },
251 { "AdaptivePermSizeWeight", JDK_Version::jdk(8), JDK_Version::jdk(9) },
252 { "PermGenPadding", JDK_Version::jdk(8), JDK_Version::jdk(9) },
253 { "PermMarkSweepDeadRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) },
254 { "PermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) },
255 { "MaxPermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) },
256 { "MinPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) },
257 { "MaxPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) },
258 { "CMSRevisitStackSize", JDK_Version::jdk(8), JDK_Version::jdk(9) },
259 { "PrintRevisitStats", JDK_Version::jdk(8), JDK_Version::jdk(9) },
248 #ifdef PRODUCT 260 #ifdef PRODUCT
249 { "DesiredMethodLimit", 261 { "DesiredMethodLimit",
250 JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) }, 262 JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) },
251 #endif // PRODUCT 263 #endif // PRODUCT
252 { NULL, JDK_Version(0), JDK_Version(0) } 264 { NULL, JDK_Version(0), JDK_Version(0) }
1084 FLAG_SET_DEFAULT(UseParNewGC, false); 1096 FLAG_SET_DEFAULT(UseParNewGC, false);
1085 FLAG_SET_DEFAULT(ParallelGCThreads, 0); 1097 FLAG_SET_DEFAULT(ParallelGCThreads, 0);
1086 } 1098 }
1087 } 1099 }
1088 if (UseParNewGC) { 1100 if (UseParNewGC) {
1089 // CDS doesn't work with ParNew yet
1090 no_shared_spaces();
1091
1092 // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 respectively, 1101 // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 respectively,
1093 // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration 1102 // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration
1094 // we set them to 1024 and 1024. 1103 // we set them to 1024 and 1024.
1095 // See CR 6362902. 1104 // See CR 6362902.
1096 if (FLAG_IS_DEFAULT(YoungPLABSize)) { 1105 if (FLAG_IS_DEFAULT(YoungPLABSize)) {
1330 return true; 1339 return true;
1331 } 1340 }
1332 1341
1333 inline uintx max_heap_for_compressed_oops() { 1342 inline uintx max_heap_for_compressed_oops() {
1334 // Avoid sign flip. 1343 // Avoid sign flip.
1335 if (OopEncodingHeapMax < MaxPermSize + os::vm_page_size()) { 1344 if (OopEncodingHeapMax < ClassMetaspaceSize + os::vm_page_size()) {
1336 return 0; 1345 return 0;
1337 } 1346 }
1338 LP64_ONLY(return OopEncodingHeapMax - MaxPermSize - os::vm_page_size()); 1347 LP64_ONLY(return OopEncodingHeapMax - ClassMetaspaceSize - os::vm_page_size());
1339 NOT_LP64(ShouldNotReachHere(); return 0); 1348 NOT_LP64(ShouldNotReachHere(); return 0);
1340 } 1349 }
1341 1350
1342 bool Arguments::should_auto_select_low_pause_collector() { 1351 bool Arguments::should_auto_select_low_pause_collector() {
1343 if (UseAutoGCSelectPolicy && 1352 if (UseAutoGCSelectPolicy &&
1352 } 1361 }
1353 return false; 1362 return false;
1354 } 1363 }
1355 1364
1356 void Arguments::set_ergonomics_flags() { 1365 void Arguments::set_ergonomics_flags() {
1357 // Parallel GC is not compatible with sharing. If one specifies
1358 // that they want sharing explicitly, do not set ergonomics flags.
1359 if (DumpSharedSpaces || RequireSharedSpaces) {
1360 return;
1361 }
1362 1366
1363 if (os::is_server_class_machine()) { 1367 if (os::is_server_class_machine()) {
1364 // If no other collector is requested explicitly, 1368 // If no other collector is requested explicitly,
1365 // let the VM select the collector based on 1369 // let the VM select the collector based on
1366 // machine class and automatic selection policy. 1370 // machine class and automatic selection policy.
1367 if (!UseSerialGC && 1371 if (!UseSerialGC &&
1368 !UseConcMarkSweepGC && 1372 !UseConcMarkSweepGC &&
1369 !UseG1GC && 1373 !UseG1GC &&
1370 !UseParNewGC && 1374 !UseParNewGC &&
1371 !DumpSharedSpaces &&
1372 FLAG_IS_DEFAULT(UseParallelGC)) { 1375 FLAG_IS_DEFAULT(UseParallelGC)) {
1373 if (should_auto_select_low_pause_collector()) { 1376 if (should_auto_select_low_pause_collector()) {
1374 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true); 1377 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1375 } else { 1378 } else {
1376 FLAG_SET_ERGO(bool, UseParallelGC, true); 1379 FLAG_SET_ERGO(bool, UseParallelGC, true);
1377 } 1380 }
1381 }
1382 // Shared spaces work fine with other GCs but causes bytecode rewriting
1383 // to be disabled, which hurts interpreter performance and decreases
1384 // server performance. On server class machines, keep the default
1385 // off unless it is asked for. Future work: either add bytecode rewriting
1386 // at link time, or rewrite bytecodes in non-shared methods.
1387 if (!DumpSharedSpaces && !RequireSharedSpaces) {
1378 no_shared_spaces(); 1388 no_shared_spaces();
1379 } 1389 }
1380 } 1390 }
1381 1391
1382 #ifndef ZERO 1392 #ifndef ZERO
1400 #endif // _WIN64 1410 #endif // _WIN64
1401 } else { 1411 } else {
1402 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) { 1412 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1403 warning("Max heap size too large for Compressed Oops"); 1413 warning("Max heap size too large for Compressed Oops");
1404 FLAG_SET_DEFAULT(UseCompressedOops, false); 1414 FLAG_SET_DEFAULT(UseCompressedOops, false);
1405 } 1415 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1416 }
1417 }
1418 // UseCompressedOops must be on for UseCompressedKlassPointers to be on.
1419 if (!UseCompressedOops) {
1420 if (UseCompressedKlassPointers) {
1421 warning("UseCompressedKlassPointers requires UseCompressedOops");
1422 }
1423 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1424 } else {
1425 // Turn on UseCompressedKlassPointers too
1426 // The compiler is broken for this so turn it on when the compiler is fixed.
1427 // if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) {
1428 // FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true);
1429 // }
1406 } 1430 }
1407 // Also checks that certain machines are slower with compressed oops 1431 // Also checks that certain machines are slower with compressed oops
1408 // in vm_version initialization code. 1432 // in vm_version initialization code.
1409 #endif // _LP64 1433 #endif // _LP64
1410 #endif // !ZERO 1434 #endif // !ZERO
1441 // Par compact uses lower default values since they are treated as 1465 // Par compact uses lower default values since they are treated as
1442 // minimums. These are different defaults because of the different 1466 // minimums. These are different defaults because of the different
1443 // interpretation and are not ergonomically set. 1467 // interpretation and are not ergonomically set.
1444 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) { 1468 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
1445 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1); 1469 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
1446 }
1447 if (FLAG_IS_DEFAULT(PermMarkSweepDeadRatio)) {
1448 FLAG_SET_DEFAULT(PermMarkSweepDeadRatio, 5);
1449 } 1470 }
1450 } 1471 }
1451 } 1472 }
1452 if (UseNUMA) { 1473 if (UseNUMA) {
1453 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) { 1474 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
1468 Abstract_VM_Version::parallel_worker_threads()); 1489 Abstract_VM_Version::parallel_worker_threads());
1469 if (ParallelGCThreads == 0) { 1490 if (ParallelGCThreads == 0) {
1470 FLAG_SET_DEFAULT(ParallelGCThreads, 1491 FLAG_SET_DEFAULT(ParallelGCThreads,
1471 Abstract_VM_Version::parallel_worker_threads()); 1492 Abstract_VM_Version::parallel_worker_threads());
1472 } 1493 }
1473 no_shared_spaces();
1474 1494
1475 if (FLAG_IS_DEFAULT(MarkStackSize)) { 1495 if (FLAG_IS_DEFAULT(MarkStackSize)) {
1476 FLAG_SET_DEFAULT(MarkStackSize, 128 * TASKQUEUE_SIZE); 1496 FLAG_SET_DEFAULT(MarkStackSize, 128 * TASKQUEUE_SIZE);
1477 } 1497 }
1478 if (PrintGCDetails && Verbose) { 1498 if (PrintGCDetails && Verbose) {
1804 status = false; 1824 status = false;
1805 } 1825 }
1806 1826
1807 status = status && verify_percentage(AdaptiveSizePolicyWeight, 1827 status = status && verify_percentage(AdaptiveSizePolicyWeight,
1808 "AdaptiveSizePolicyWeight"); 1828 "AdaptiveSizePolicyWeight");
1809 status = status && verify_percentage(AdaptivePermSizeWeight, "AdaptivePermSizeWeight");
1810 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance"); 1829 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
1811 status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio"); 1830 status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
1812 status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio"); 1831 status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
1813 1832
1814 if (MinHeapFreeRatio > MaxHeapFreeRatio) { 1833 if (MinHeapFreeRatio > MaxHeapFreeRatio) {
2383 // for testing the compiler; turn off all flags that inhibit compilation 2402 // for testing the compiler; turn off all flags that inhibit compilation
2384 set_mode_flags(_comp); 2403 set_mode_flags(_comp);
2385 2404
2386 // -Xshare:dump 2405 // -Xshare:dump
2387 } else if (match_option(option, "-Xshare:dump", &tail)) { 2406 } else if (match_option(option, "-Xshare:dump", &tail)) {
2388 #ifdef TIERED 2407 #if defined(KERNEL)
2389 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true);
2390 set_mode_flags(_int); // Prevent compilation, which creates objects
2391 #elif defined(COMPILER2)
2392 vm_exit_during_initialization(
2393 "Dumping a shared archive is not supported on the Server JVM.", NULL);
2394 #elif defined(KERNEL)
2395 vm_exit_during_initialization( 2408 vm_exit_during_initialization(
2396 "Dumping a shared archive is not supported on the Kernel JVM.", NULL); 2409 "Dumping a shared archive is not supported on the Kernel JVM.", NULL);
2397 #else 2410 #else
2398 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true); 2411 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true);
2399 set_mode_flags(_int); // Prevent compilation, which creates objects 2412 set_mode_flags(_int); // Prevent compilation, which creates objects
2488 total_memory - (julong)160*M); 2501 total_memory - (julong)160*M);
2489 2502
2490 // Make sure that if we have a lot of memory we cap the 32 bit 2503 // Make sure that if we have a lot of memory we cap the 32 bit
2491 // process space. The 64bit VM version of this function is a nop. 2504 // process space. The 64bit VM version of this function is a nop.
2492 initHeapSize = os::allocatable_physical_memory(initHeapSize); 2505 initHeapSize = os::allocatable_physical_memory(initHeapSize);
2493
2494 // The perm gen is separate but contiguous with the
2495 // object heap (and is reserved with it) so subtract it
2496 // from the heap size.
2497 if (initHeapSize > MaxPermSize) {
2498 initHeapSize = initHeapSize - MaxPermSize;
2499 } else {
2500 warning("AggressiveHeap and MaxPermSize values may conflict");
2501 }
2502 2506
2503 if (FLAG_IS_DEFAULT(MaxHeapSize)) { 2507 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
2504 FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize); 2508 FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize);
2505 FLAG_SET_CMDLINE(uintx, InitialHeapSize, initHeapSize); 2509 FLAG_SET_CMDLINE(uintx, InitialHeapSize, initHeapSize);
2506 // Currently the minimum size and the initial heap sizes are the same. 2510 // Currently the minimum size and the initial heap sizes are the same.
2902 2906
2903 void Arguments::set_shared_spaces_flags() { 2907 void Arguments::set_shared_spaces_flags() {
2904 const bool must_share = DumpSharedSpaces || RequireSharedSpaces; 2908 const bool must_share = DumpSharedSpaces || RequireSharedSpaces;
2905 const bool might_share = must_share || UseSharedSpaces; 2909 const bool might_share = must_share || UseSharedSpaces;
2906 2910
2907 // The string table is part of the shared archive so the size must match. 2911 // CompressedOops cannot be used with CDS. The offsets of oopmaps and
2908 if (!FLAG_IS_DEFAULT(StringTableSize)) { 2912 // static fields are incorrect in the archive. With some more clever
2909 // Disable sharing. 2913 // initialization, this restriction can probably be lifted.
2910 if (must_share) { 2914 // ??? UseLargePages might be okay now
2911 warning("disabling shared archive %s because of non-default " 2915 const bool cannot_share = UseCompressedOops ||
2912 "StringTableSize", DumpSharedSpaces ? "creation" : "use"); 2916 (UseLargePages && FLAG_IS_CMDLINE(UseLargePages));
2913 }
2914 if (might_share) {
2915 FLAG_SET_DEFAULT(DumpSharedSpaces, false);
2916 FLAG_SET_DEFAULT(RequireSharedSpaces, false);
2917 FLAG_SET_DEFAULT(UseSharedSpaces, false);
2918 }
2919 return;
2920 }
2921
2922 // Check whether class data sharing settings conflict with GC, compressed oops
2923 // or page size, and fix them up. Explicit sharing options override other
2924 // settings.
2925 const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode ||
2926 UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC ||
2927 UseCompressedOops || UseLargePages && FLAG_IS_CMDLINE(UseLargePages);
2928 if (cannot_share) { 2917 if (cannot_share) {
2929 if (must_share) { 2918 if (must_share) {
2930 warning("selecting serial gc and disabling large pages %s" 2919 warning("disabling large pages%s"
2931 "because of %s", "" LP64_ONLY("and compressed oops "), 2920 "because of %s", "" LP64_ONLY("and compressed oops "),
2932 DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on"); 2921 DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on");
2933 force_serial_gc();
2934 FLAG_SET_CMDLINE(bool, UseLargePages, false); 2922 FLAG_SET_CMDLINE(bool, UseLargePages, false);
2935 LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false)); 2923 LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false));
2924 LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false));
2936 } else { 2925 } else {
2926 // Prefer compressed oops and large pages to class data sharing
2937 if (UseSharedSpaces && Verbose) { 2927 if (UseSharedSpaces && Verbose) {
2938 warning("turning off use of shared archive because of " 2928 warning("turning off use of shared archive because of large pages%s",
2939 "choice of garbage collector or large pages"); 2929 "" LP64_ONLY(" and/or compressed oops"));
2940 } 2930 }
2941 no_shared_spaces(); 2931 no_shared_spaces();
2942 } 2932 }
2943 } else if (UseLargePages && might_share) { 2933 } else if (UseLargePages && might_share) {
2944 // Disable large pages to allow shared spaces. This is sub-optimal, since 2934 // Disable large pages to allow shared spaces. This is sub-optimal, since
2945 // there may not even be a shared archive to use. 2935 // there may not even be a shared archive to use.
2946 FLAG_SET_DEFAULT(UseLargePages, false); 2936 FLAG_SET_DEFAULT(UseLargePages, false);
2937 }
2938
2939 // Add 2M to any size for SharedReadOnlySize to get around the JPRT setting
2940 if (DumpSharedSpaces && !FLAG_IS_DEFAULT(SharedReadOnlySize)) {
2941 SharedReadOnlySize = 14*M;
2942 }
2943
2944 if (DumpSharedSpaces) {
2945 if (RequireSharedSpaces) {
2946 warning("cannot dump shared archive while using shared archive");
2947 }
2948 UseSharedSpaces = false;
2947 } 2949 }
2948 } 2950 }
2949 2951
2950 // Disable options not supported in this release, with a warning if they 2952 // Disable options not supported in this release, with a warning if they
2951 // were explicitly requested on the command-line 2953 // were explicitly requested on the command-line
3101 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) { 3103 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
3102 warning("forcing ScavengeRootsInCode non-zero because EnableInvokeDynamic is true"); 3104 warning("forcing ScavengeRootsInCode non-zero because EnableInvokeDynamic is true");
3103 } 3105 }
3104 ScavengeRootsInCode = 1; 3106 ScavengeRootsInCode = 1;
3105 } 3107 }
3106 if (!JavaObjectsInPerm && ScavengeRootsInCode == 0) {
3107 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
3108 warning("forcing ScavengeRootsInCode non-zero because JavaObjectsInPerm is false");
3109 }
3110 ScavengeRootsInCode = 1;
3111 }
3112 3108
3113 if (PrintGCDetails) { 3109 if (PrintGCDetails) {
3114 // Turn on -verbose:gc options as well 3110 // Turn on -verbose:gc options as well
3115 PrintGC = true; 3111 PrintGC = true;
3116 } 3112 }
3198 #ifdef CC_INTERP 3194 #ifdef CC_INTERP
3199 // Clear flags not supported by the C++ interpreter 3195 // Clear flags not supported by the C++ interpreter
3200 FLAG_SET_DEFAULT(ProfileInterpreter, false); 3196 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3201 FLAG_SET_DEFAULT(UseBiasedLocking, false); 3197 FLAG_SET_DEFAULT(UseBiasedLocking, false);
3202 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false)); 3198 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false));
3199 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedKlassPointers, false));
3203 #endif // CC_INTERP 3200 #endif // CC_INTERP
3204 3201
3205 #ifdef COMPILER2 3202 #ifdef COMPILER2
3206 if (!UseBiasedLocking || EmitSync != 0) { 3203 if (!UseBiasedLocking || EmitSync != 0) {
3207 UseOptoBiasInlining = false; 3204 UseOptoBiasInlining = false;