1716 // In G1, we want the default GC overhead goal to be higher than
1717 // say in PS. So we set it here to 10%. Otherwise the heap might
1718 // be expanded more aggressively than we would like it to. In
1719 // fact, even 10% seems to not be high enough in some cases
1720 // (especially small GC stress tests that the main thing they do
1721 // is allocation). We might consider increase it further.
1722 FLAG_SET_DEFAULT(GCTimeRatio, 9);
1723 }
1724
1725 if (PrintGCDetails && Verbose) {
1726 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
1727 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1728 tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
1729 }
1730 }
1731
1732 #if !INCLUDE_ALL_GCS
1733 #ifdef ASSERT
1734 static bool verify_serial_gc_flags() {
1735 return (UseSerialGC &&
1736 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1737 UseParallelGC || UseParallelOldGC));
1738 }
1739 #endif // ASSERT
1740 #endif // INCLUDE_ALL_GCS
1741
1742 void Arguments::set_gc_specific_flags() {
1743 #if INCLUDE_ALL_GCS
1744 // Set per-collector flags
1745 if (UseParallelGC || UseParallelOldGC) {
1746 set_parallel_gc_flags();
1747 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
1748 set_cms_and_parnew_gc_flags();
1749 } else if (UseParNewGC) { // Skipped if CMS is set above
1750 set_parnew_gc_flags();
1751 } else if (UseG1GC) {
1752 set_g1_gc_flags();
1753 }
1754 check_deprecated_gcs();
1755 check_deprecated_gc_flags();
1756 if (AssumeMP && !UseSerialGC) {
2130 "Conflicting collector combinations in option list; "
2131 "please refer to the release notes for the combinations "
2132 "allowed\n");
2133 status = false;
2134 }
2135 return status;
2136 }
2137
2138 void Arguments::check_deprecated_gcs() {
2139 if (UseConcMarkSweepGC && !UseParNewGC) {
2140 warning("Using the DefNew young collector with the CMS collector is deprecated "
2141 "and will likely be removed in a future release");
2142 }
2143
2144 if (UseParNewGC && !UseConcMarkSweepGC) {
2145 // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2146 // set up UseSerialGC properly, so that can't be used in the check here.
2147 warning("Using the ParNew young collector with the Serial old collector is deprecated "
2148 "and will likely be removed in a future release");
2149 }
2150
2151 if (CMSIncrementalMode) {
2152 warning("Using incremental CMS is deprecated and will likely be removed in a future release");
2153 }
2154 }
2155
2156 void Arguments::check_deprecated_gc_flags() {
2157 if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) {
2158 warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
2159 "and will likely be removed in future release");
2160 }
2161 if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
2162 warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
2163 "Use MaxRAMFraction instead.");
2164 }
2165 if (FLAG_IS_CMDLINE(UseCMSCompactAtFullCollection)) {
2166 warning("UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.");
2167 }
2168 if (FLAG_IS_CMDLINE(CMSFullGCsBeforeCompaction)) {
2169 warning("CMSFullGCsBeforeCompaction is deprecated and will likely be removed in a future release.");
2170 }
2171 if (FLAG_IS_CMDLINE(UseCMSCollectionPassing)) {
2172 warning("UseCMSCollectionPassing is deprecated and will likely be removed in a future release.");
2173 }
2255 }
2256 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) {
2257 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
2258 }
2259 }
2260
2261 if (!(UseParallelGC || UseParallelOldGC) && FLAG_IS_DEFAULT(ScavengeBeforeFullGC)) {
2262 FLAG_SET_DEFAULT(ScavengeBeforeFullGC, false);
2263 }
2264
2265 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
2266 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit");
2267 if (GCTimeLimit == 100) {
2268 // Turn off gc-overhead-limit-exceeded checks
2269 FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
2270 }
2271
2272 status = status && ArgumentsExt::check_gc_consistency_user();
2273 status = status && check_stack_pages();
2274
2275 if (CMSIncrementalMode) {
2276 if (!UseConcMarkSweepGC) {
2277 jio_fprintf(defaultStream::error_stream(),
2278 "error: invalid argument combination.\n"
2279 "The CMS collector (-XX:+UseConcMarkSweepGC) must be "
2280 "selected in order\nto use CMSIncrementalMode.\n");
2281 status = false;
2282 } else {
2283 status = status && verify_percentage(CMSIncrementalDutyCycle,
2284 "CMSIncrementalDutyCycle");
2285 status = status && verify_percentage(CMSIncrementalDutyCycleMin,
2286 "CMSIncrementalDutyCycleMin");
2287 status = status && verify_percentage(CMSIncrementalSafetyFactor,
2288 "CMSIncrementalSafetyFactor");
2289 status = status && verify_percentage(CMSIncrementalOffset,
2290 "CMSIncrementalOffset");
2291 status = status && verify_percentage(CMSExpAvgFactor,
2292 "CMSExpAvgFactor");
2293 // If it was not set on the command line, set
2294 // CMSInitiatingOccupancyFraction to 1 so icms can initiate cycles early.
2295 if (CMSInitiatingOccupancyFraction < 0) {
2296 FLAG_SET_DEFAULT(CMSInitiatingOccupancyFraction, 1);
2297 }
2298 }
2299 }
2300
2301 // CMS space iteration, which FLSVerifyAllHeapreferences entails,
2302 // insists that we hold the requisite locks so that the iteration is
2303 // MT-safe. For the verification at start-up and shut-down, we don't
2304 // yet have a good way of acquiring and releasing these locks,
2305 // which are not visible at the CollectedHeap level. We want to
2306 // be able to acquire these locks and then do the iteration rather
2307 // than just disable the lock verification. This will be fixed under
2308 // bug 4788986.
2309 if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) {
2310 if (VerifyDuringStartup) {
2311 warning("Heap verification at start-up disabled "
2312 "(due to current incompatibility with FLSVerifyAllHeapReferences)");
2313 VerifyDuringStartup = false; // Disable verification at start-up
2314 }
2315
2316 if (VerifyBeforeExit) {
2317 warning("Heap verification at shutdown disabled "
2318 "(due to current incompatibility with FLSVerifyAllHeapReferences)");
2319 VerifyBeforeExit = false; // Disable verification at shutdown
2812 return JNI_ERR;
2813 }
2814 #endif // !INCLUDE_JVMTI
2815 add_init_agent(name, options, is_absolute_path);
2816 }
2817 // -javaagent
2818 } else if (match_option(option, "-javaagent:", &tail)) {
2819 #if !INCLUDE_JVMTI
2820 jio_fprintf(defaultStream::error_stream(),
2821 "Instrumentation agents are not supported in this VM\n");
2822 return JNI_ERR;
2823 #else
2824 if(tail != NULL) {
2825 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail);
2826 add_init_agent("instrument", options, false);
2827 }
2828 #endif // !INCLUDE_JVMTI
2829 // -Xnoclassgc
2830 } else if (match_option(option, "-Xnoclassgc", &tail)) {
2831 FLAG_SET_CMDLINE(bool, ClassUnloading, false);
2832 // -Xincgc: i-CMS
2833 } else if (match_option(option, "-Xincgc", &tail)) {
2834 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
2835 FLAG_SET_CMDLINE(bool, CMSIncrementalMode, true);
2836 // -Xnoincgc: no i-CMS
2837 } else if (match_option(option, "-Xnoincgc", &tail)) {
2838 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
2839 FLAG_SET_CMDLINE(bool, CMSIncrementalMode, false);
2840 // -Xconcgc
2841 } else if (match_option(option, "-Xconcgc", &tail)) {
2842 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
2843 // -Xnoconcgc
2844 } else if (match_option(option, "-Xnoconcgc", &tail)) {
2845 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
2846 // -Xbatch
2847 } else if (match_option(option, "-Xbatch", &tail)) {
2848 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
2849 // -Xmn for compatibility with other JVM vendors
2850 } else if (match_option(option, "-Xmn", &tail)) {
2851 julong long_initial_young_size = 0;
2852 ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2853 if (errcode != arg_in_range) {
2854 jio_fprintf(defaultStream::error_stream(),
2855 "Invalid initial young generation size: %s\n", option->optionString);
2856 describe_range_error(errcode);
2857 return JNI_EINVAL;
2858 }
2859 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_young_size);
3647 if (RequireSharedSpaces) {
3648 warning("cannot dump shared archive while using shared archive");
3649 }
3650 UseSharedSpaces = false;
3651 #ifdef _LP64
3652 if (!UseCompressedOops || !UseCompressedClassPointers) {
3653 vm_exit_during_initialization(
3654 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3655 }
3656 } else {
3657 if (!UseCompressedOops || !UseCompressedClassPointers) {
3658 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3659 }
3660 #endif
3661 }
3662 }
3663
3664 #if !INCLUDE_ALL_GCS
3665 static void force_serial_gc() {
3666 FLAG_SET_DEFAULT(UseSerialGC, true);
3667 FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption
3668 UNSUPPORTED_GC_OPTION(UseG1GC);
3669 UNSUPPORTED_GC_OPTION(UseParallelGC);
3670 UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3671 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3672 UNSUPPORTED_GC_OPTION(UseParNewGC);
3673 }
3674 #endif // INCLUDE_ALL_GCS
3675
3676 // Sharing support
3677 // Construct the path to the archive
3678 static char* get_shared_archive_path() {
3679 char *shared_archive_path;
3680 if (SharedArchiveFile == NULL) {
3681 char jvm_path[JVM_MAXPATHLEN];
3682 os::jvm_path(jvm_path, sizeof(jvm_path));
3683 char *end = strrchr(jvm_path, *os::file_separator());
3684 if (end != NULL) *end = '\0';
3685 size_t jvm_path_len = strlen(jvm_path);
3686 size_t file_sep_len = strlen(os::file_separator());
3687 shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len +
|
1716 // In G1, we want the default GC overhead goal to be higher than
1717 // say in PS. So we set it here to 10%. Otherwise the heap might
1718 // be expanded more aggressively than we would like it to. In
1719 // fact, even 10% seems to not be high enough in some cases
1720 // (especially small GC stress tests that the main thing they do
1721 // is allocation). We might consider increase it further.
1722 FLAG_SET_DEFAULT(GCTimeRatio, 9);
1723 }
1724
1725 if (PrintGCDetails && Verbose) {
1726 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
1727 (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K));
1728 tty->print_cr("ConcGCThreads: %u", (uint) ConcGCThreads);
1729 }
1730 }
1731
1732 #if !INCLUDE_ALL_GCS
1733 #ifdef ASSERT
1734 static bool verify_serial_gc_flags() {
1735 return (UseSerialGC &&
1736 !(UseParNewGC || (UseConcMarkSweepGC) || UseG1GC ||
1737 UseParallelGC || UseParallelOldGC));
1738 }
1739 #endif // ASSERT
1740 #endif // INCLUDE_ALL_GCS
1741
1742 void Arguments::set_gc_specific_flags() {
1743 #if INCLUDE_ALL_GCS
1744 // Set per-collector flags
1745 if (UseParallelGC || UseParallelOldGC) {
1746 set_parallel_gc_flags();
1747 } else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
1748 set_cms_and_parnew_gc_flags();
1749 } else if (UseParNewGC) { // Skipped if CMS is set above
1750 set_parnew_gc_flags();
1751 } else if (UseG1GC) {
1752 set_g1_gc_flags();
1753 }
1754 check_deprecated_gcs();
1755 check_deprecated_gc_flags();
1756 if (AssumeMP && !UseSerialGC) {
2130 "Conflicting collector combinations in option list; "
2131 "please refer to the release notes for the combinations "
2132 "allowed\n");
2133 status = false;
2134 }
2135 return status;
2136 }
2137
2138 void Arguments::check_deprecated_gcs() {
2139 if (UseConcMarkSweepGC && !UseParNewGC) {
2140 warning("Using the DefNew young collector with the CMS collector is deprecated "
2141 "and will likely be removed in a future release");
2142 }
2143
2144 if (UseParNewGC && !UseConcMarkSweepGC) {
2145 // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
2146 // set up UseSerialGC properly, so that can't be used in the check here.
2147 warning("Using the ParNew young collector with the Serial old collector is deprecated "
2148 "and will likely be removed in a future release");
2149 }
2150 }
2151
2152 void Arguments::check_deprecated_gc_flags() {
2153 if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) {
2154 warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
2155 "and will likely be removed in future release");
2156 }
2157 if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
2158 warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
2159 "Use MaxRAMFraction instead.");
2160 }
2161 if (FLAG_IS_CMDLINE(UseCMSCompactAtFullCollection)) {
2162 warning("UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.");
2163 }
2164 if (FLAG_IS_CMDLINE(CMSFullGCsBeforeCompaction)) {
2165 warning("CMSFullGCsBeforeCompaction is deprecated and will likely be removed in a future release.");
2166 }
2167 if (FLAG_IS_CMDLINE(UseCMSCollectionPassing)) {
2168 warning("UseCMSCollectionPassing is deprecated and will likely be removed in a future release.");
2169 }
2251 }
2252 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) {
2253 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
2254 }
2255 }
2256
2257 if (!(UseParallelGC || UseParallelOldGC) && FLAG_IS_DEFAULT(ScavengeBeforeFullGC)) {
2258 FLAG_SET_DEFAULT(ScavengeBeforeFullGC, false);
2259 }
2260
2261 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
2262 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit");
2263 if (GCTimeLimit == 100) {
2264 // Turn off gc-overhead-limit-exceeded checks
2265 FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
2266 }
2267
2268 status = status && ArgumentsExt::check_gc_consistency_user();
2269 status = status && check_stack_pages();
2270
2271 status = status && verify_percentage(CMSIncrementalSafetyFactor,
2272 "CMSIncrementalSafetyFactor");
2273
2274 // CMS space iteration, which FLSVerifyAllHeapreferences entails,
2275 // insists that we hold the requisite locks so that the iteration is
2276 // MT-safe. For the verification at start-up and shut-down, we don't
2277 // yet have a good way of acquiring and releasing these locks,
2278 // which are not visible at the CollectedHeap level. We want to
2279 // be able to acquire these locks and then do the iteration rather
2280 // than just disable the lock verification. This will be fixed under
2281 // bug 4788986.
2282 if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) {
2283 if (VerifyDuringStartup) {
2284 warning("Heap verification at start-up disabled "
2285 "(due to current incompatibility with FLSVerifyAllHeapReferences)");
2286 VerifyDuringStartup = false; // Disable verification at start-up
2287 }
2288
2289 if (VerifyBeforeExit) {
2290 warning("Heap verification at shutdown disabled "
2291 "(due to current incompatibility with FLSVerifyAllHeapReferences)");
2292 VerifyBeforeExit = false; // Disable verification at shutdown
2785 return JNI_ERR;
2786 }
2787 #endif // !INCLUDE_JVMTI
2788 add_init_agent(name, options, is_absolute_path);
2789 }
2790 // -javaagent
2791 } else if (match_option(option, "-javaagent:", &tail)) {
2792 #if !INCLUDE_JVMTI
2793 jio_fprintf(defaultStream::error_stream(),
2794 "Instrumentation agents are not supported in this VM\n");
2795 return JNI_ERR;
2796 #else
2797 if(tail != NULL) {
2798 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail);
2799 add_init_agent("instrument", options, false);
2800 }
2801 #endif // !INCLUDE_JVMTI
2802 // -Xnoclassgc
2803 } else if (match_option(option, "-Xnoclassgc", &tail)) {
2804 FLAG_SET_CMDLINE(bool, ClassUnloading, false);
2805 // -Xconcgc
2806 } else if (match_option(option, "-Xconcgc", &tail)) {
2807 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
2808 // -Xnoconcgc
2809 } else if (match_option(option, "-Xnoconcgc", &tail)) {
2810 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
2811 // -Xbatch
2812 } else if (match_option(option, "-Xbatch", &tail)) {
2813 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
2814 // -Xmn for compatibility with other JVM vendors
2815 } else if (match_option(option, "-Xmn", &tail)) {
2816 julong long_initial_young_size = 0;
2817 ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
2818 if (errcode != arg_in_range) {
2819 jio_fprintf(defaultStream::error_stream(),
2820 "Invalid initial young generation size: %s\n", option->optionString);
2821 describe_range_error(errcode);
2822 return JNI_EINVAL;
2823 }
2824 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_young_size);
3612 if (RequireSharedSpaces) {
3613 warning("cannot dump shared archive while using shared archive");
3614 }
3615 UseSharedSpaces = false;
3616 #ifdef _LP64
3617 if (!UseCompressedOops || !UseCompressedClassPointers) {
3618 vm_exit_during_initialization(
3619 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3620 }
3621 } else {
3622 if (!UseCompressedOops || !UseCompressedClassPointers) {
3623 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.");
3624 }
3625 #endif
3626 }
3627 }
3628
3629 #if !INCLUDE_ALL_GCS
3630 static void force_serial_gc() {
3631 FLAG_SET_DEFAULT(UseSerialGC, true);
3632 UNSUPPORTED_GC_OPTION(UseG1GC);
3633 UNSUPPORTED_GC_OPTION(UseParallelGC);
3634 UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3635 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3636 UNSUPPORTED_GC_OPTION(UseParNewGC);
3637 }
3638 #endif // INCLUDE_ALL_GCS
3639
3640 // Sharing support
3641 // Construct the path to the archive
3642 static char* get_shared_archive_path() {
3643 char *shared_archive_path;
3644 if (SharedArchiveFile == NULL) {
3645 char jvm_path[JVM_MAXPATHLEN];
3646 os::jvm_path(jvm_path, sizeof(jvm_path));
3647 char *end = strrchr(jvm_path, *os::file_separator());
3648 if (end != NULL) *end = '\0';
3649 size_t jvm_path_len = strlen(jvm_path);
3650 size_t file_sep_len = strlen(os::file_separator());
3651 shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len +
|