1555 }
1556 #endif // INCLUDE_ALL_GCS
1557 _conservative_max_heap_alignment = MAX4(heap_alignment,
1558 (size_t)os::vm_allocation_granularity(),
1559 os::max_page_size(),
1560 CollectorPolicy::compute_heap_alignment());
1561 }
1562
1563 void Arguments::select_gc_ergonomically() {
1564 if (os::is_server_class_machine()) {
1565 if (should_auto_select_low_pause_collector()) {
1566 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1567 } else {
1568 FLAG_SET_ERGO(bool, UseParallelGC, true);
1569 }
1570 }
1571 }
1572
1573 void Arguments::select_gc() {
1574 if (!gc_selected()) {
1575 ArgumentsExt::select_gc_ergonomically();
1576 }
1577 }
1578
1579 void Arguments::set_ergonomics_flags() {
1580 select_gc();
1581
1582 #ifdef COMPILER2
1583 // Shared spaces work fine with other GCs but causes bytecode rewriting
1584 // to be disabled, which hurts interpreter performance and decreases
1585 // server performance. When -server is specified, keep the default off
1586 // unless it is asked for. Future work: either add bytecode rewriting
1587 // at link time, or rewrite bytecodes in non-shared methods.
1588 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1589 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1590 no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1591 }
1592 #endif
1593
1594 set_conservative_max_heap_alignment();
1595
2050 return true;
2051 }
2052
2053 bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) {
2054 if (!is_percentage(max_heap_free_ratio)) {
2055 err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100");
2056 return false;
2057 }
2058 if (max_heap_free_ratio < MinHeapFreeRatio) {
2059 err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
2060 "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio,
2061 MinHeapFreeRatio);
2062 return false;
2063 }
2064 // This does not set the flag itself, but stores the value in a safe place for later usage.
2065 _max_heap_free_ratio = max_heap_free_ratio;
2066 return true;
2067 }
2068
2069 // Check consistency of GC selection
2070 bool Arguments::check_gc_consistency_user() {
2071 check_gclog_consistency();
2072 bool status = true;
2073 // Ensure that the user has not selected conflicting sets
2074 // of collectors. [Note: this check is merely a user convenience;
2075 // collectors over-ride each other so that only a non-conflicting
2076 // set is selected; however what the user gets is not what they
2077 // may have expected from the combination they asked for. It's
2078 // better to reduce user confusion by not allowing them to
2079 // select conflicting combinations.
2080 uint i = 0;
2081 if (UseSerialGC) i++;
2082 if (UseConcMarkSweepGC || UseParNewGC) i++;
2083 if (UseParallelGC || UseParallelOldGC) i++;
2084 if (UseG1GC) i++;
2085 if (i > 1) {
2086 jio_fprintf(defaultStream::error_stream(),
2087 "Conflicting collector combinations in option list; "
2088 "please refer to the release notes for the combinations "
2089 "allowed\n");
2090 status = false;
2216 MarkSweepAlwaysCompactCount = 1; // Move objects every gc.
2217 }
2218
2219 if (UseParallelOldGC && ParallelOldGCSplitALot) {
2220 // Settings to encourage splitting.
2221 if (!FLAG_IS_CMDLINE(NewRatio)) {
2222 FLAG_SET_CMDLINE(uintx, NewRatio, 2);
2223 }
2224 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) {
2225 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
2226 }
2227 }
2228
2229 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
2230 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit");
2231 if (GCTimeLimit == 100) {
2232 // Turn off gc-overhead-limit-exceeded checks
2233 FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
2234 }
2235
2236 status = status && check_gc_consistency_user();
2237 status = status && check_stack_pages();
2238
2239 if (CMSIncrementalMode) {
2240 if (!UseConcMarkSweepGC) {
2241 jio_fprintf(defaultStream::error_stream(),
2242 "error: invalid argument combination.\n"
2243 "The CMS collector (-XX:+UseConcMarkSweepGC) must be "
2244 "selected in order\nto use CMSIncrementalMode.\n");
2245 status = false;
2246 } else {
2247 status = status && verify_percentage(CMSIncrementalDutyCycle,
2248 "CMSIncrementalDutyCycle");
2249 status = status && verify_percentage(CMSIncrementalDutyCycleMin,
2250 "CMSIncrementalDutyCycleMin");
2251 status = status && verify_percentage(CMSIncrementalSafetyFactor,
2252 "CMSIncrementalSafetyFactor");
2253 status = status && verify_percentage(CMSIncrementalOffset,
2254 "CMSIncrementalOffset");
2255 status = status && verify_percentage(CMSExpAvgFactor,
2256 "CMSExpAvgFactor");
3989 }
3990 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
3991 warning("Shared spaces are not supported in this VM");
3992 FLAG_SET_DEFAULT(UseSharedSpaces, false);
3993 FLAG_SET_DEFAULT(PrintSharedSpaces, false);
3994 }
3995 no_shared_spaces("CDS Disabled");
3996 #endif // INCLUDE_CDS
3997
3998 return JNI_OK;
3999 }
4000
4001 jint Arguments::apply_ergo() {
4002
4003 // Set flags based on ergonomics.
4004 set_ergonomics_flags();
4005
4006 set_shared_spaces_flags();
4007
4008 // Check the GC selections again.
4009 if (!ArgumentsExt::check_gc_consistency_ergo()) {
4010 return JNI_EINVAL;
4011 }
4012
4013 if (TieredCompilation) {
4014 set_tiered_flags();
4015 } else {
4016 // Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup.
4017 if (CompilationPolicyChoice >= 2) {
4018 vm_exit_during_initialization(
4019 "Incompatible compilation policy selected", NULL);
4020 }
4021 }
4022 // Set NmethodSweepFraction after the size of the code cache is adapted (in case of tiered)
4023 if (FLAG_IS_DEFAULT(NmethodSweepFraction)) {
4024 FLAG_SET_DEFAULT(NmethodSweepFraction, 1 + ReservedCodeCacheSize / (16 * M));
4025 }
4026
4027
4028 // Set heap size based on available physical memory
4029 set_heap_size();
|
1555 }
1556 #endif // INCLUDE_ALL_GCS
1557 _conservative_max_heap_alignment = MAX4(heap_alignment,
1558 (size_t)os::vm_allocation_granularity(),
1559 os::max_page_size(),
1560 CollectorPolicy::compute_heap_alignment());
1561 }
1562
1563 void Arguments::select_gc_ergonomically() {
1564 if (os::is_server_class_machine()) {
1565 if (should_auto_select_low_pause_collector()) {
1566 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1567 } else {
1568 FLAG_SET_ERGO(bool, UseParallelGC, true);
1569 }
1570 }
1571 }
1572
1573 void Arguments::select_gc() {
1574 if (!gc_selected()) {
1575 select_gc_ergonomically();
1576 }
1577 }
1578
1579 void Arguments::set_ergonomics_flags() {
1580 select_gc();
1581
1582 #ifdef COMPILER2
1583 // Shared spaces work fine with other GCs but causes bytecode rewriting
1584 // to be disabled, which hurts interpreter performance and decreases
1585 // server performance. When -server is specified, keep the default off
1586 // unless it is asked for. Future work: either add bytecode rewriting
1587 // at link time, or rewrite bytecodes in non-shared methods.
1588 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1589 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1590 no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on.");
1591 }
1592 #endif
1593
1594 set_conservative_max_heap_alignment();
1595
2050 return true;
2051 }
2052
2053 bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio) {
2054 if (!is_percentage(max_heap_free_ratio)) {
2055 err_msg.print("MaxHeapFreeRatio must have a value between 0 and 100");
2056 return false;
2057 }
2058 if (max_heap_free_ratio < MinHeapFreeRatio) {
2059 err_msg.print("MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
2060 "equal to MinHeapFreeRatio (" UINTX_FORMAT ")", max_heap_free_ratio,
2061 MinHeapFreeRatio);
2062 return false;
2063 }
2064 // This does not set the flag itself, but stores the value in a safe place for later usage.
2065 _max_heap_free_ratio = max_heap_free_ratio;
2066 return true;
2067 }
2068
2069 // Check consistency of GC selection
2070 bool Arguments::check_gc_consistency() {
2071 check_gclog_consistency();
2072 bool status = true;
2073 // Ensure that the user has not selected conflicting sets
2074 // of collectors. [Note: this check is merely a user convenience;
2075 // collectors over-ride each other so that only a non-conflicting
2076 // set is selected; however what the user gets is not what they
2077 // may have expected from the combination they asked for. It's
2078 // better to reduce user confusion by not allowing them to
2079 // select conflicting combinations.
2080 uint i = 0;
2081 if (UseSerialGC) i++;
2082 if (UseConcMarkSweepGC || UseParNewGC) i++;
2083 if (UseParallelGC || UseParallelOldGC) i++;
2084 if (UseG1GC) i++;
2085 if (i > 1) {
2086 jio_fprintf(defaultStream::error_stream(),
2087 "Conflicting collector combinations in option list; "
2088 "please refer to the release notes for the combinations "
2089 "allowed\n");
2090 status = false;
2216 MarkSweepAlwaysCompactCount = 1; // Move objects every gc.
2217 }
2218
2219 if (UseParallelOldGC && ParallelOldGCSplitALot) {
2220 // Settings to encourage splitting.
2221 if (!FLAG_IS_CMDLINE(NewRatio)) {
2222 FLAG_SET_CMDLINE(uintx, NewRatio, 2);
2223 }
2224 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) {
2225 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
2226 }
2227 }
2228
2229 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
2230 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit");
2231 if (GCTimeLimit == 100) {
2232 // Turn off gc-overhead-limit-exceeded checks
2233 FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
2234 }
2235
2236 status = status && check_gc_consistency();
2237 status = status && check_stack_pages();
2238
2239 if (CMSIncrementalMode) {
2240 if (!UseConcMarkSweepGC) {
2241 jio_fprintf(defaultStream::error_stream(),
2242 "error: invalid argument combination.\n"
2243 "The CMS collector (-XX:+UseConcMarkSweepGC) must be "
2244 "selected in order\nto use CMSIncrementalMode.\n");
2245 status = false;
2246 } else {
2247 status = status && verify_percentage(CMSIncrementalDutyCycle,
2248 "CMSIncrementalDutyCycle");
2249 status = status && verify_percentage(CMSIncrementalDutyCycleMin,
2250 "CMSIncrementalDutyCycleMin");
2251 status = status && verify_percentage(CMSIncrementalSafetyFactor,
2252 "CMSIncrementalSafetyFactor");
2253 status = status && verify_percentage(CMSIncrementalOffset,
2254 "CMSIncrementalOffset");
2255 status = status && verify_percentage(CMSExpAvgFactor,
2256 "CMSExpAvgFactor");
3989 }
3990 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) {
3991 warning("Shared spaces are not supported in this VM");
3992 FLAG_SET_DEFAULT(UseSharedSpaces, false);
3993 FLAG_SET_DEFAULT(PrintSharedSpaces, false);
3994 }
3995 no_shared_spaces("CDS Disabled");
3996 #endif // INCLUDE_CDS
3997
3998 return JNI_OK;
3999 }
4000
4001 jint Arguments::apply_ergo() {
4002
4003 // Set flags based on ergonomics.
4004 set_ergonomics_flags();
4005
4006 set_shared_spaces_flags();
4007
4008 // Check the GC selections again.
4009 if (!check_gc_consistency()) {
4010 return JNI_EINVAL;
4011 }
4012
4013 if (TieredCompilation) {
4014 set_tiered_flags();
4015 } else {
4016 // Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup.
4017 if (CompilationPolicyChoice >= 2) {
4018 vm_exit_during_initialization(
4019 "Incompatible compilation policy selected", NULL);
4020 }
4021 }
4022 // Set NmethodSweepFraction after the size of the code cache is adapted (in case of tiered)
4023 if (FLAG_IS_DEFAULT(NmethodSweepFraction)) {
4024 FLAG_SET_DEFAULT(NmethodSweepFraction, 1 + ReservedCodeCacheSize / (16 * M));
4025 }
4026
4027
4028 // Set heap size based on available physical memory
4029 set_heap_size();
|