2015-06-18 14:39:38 -05:00
|
|
|
/*
|
2018-02-26 09:34:12 +01:00
|
|
|
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
2015-06-18 14:39:38 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.hpp"
|
2015-10-05 14:56:19 -07:00
|
|
|
#include "gc/shared/collectedHeap.hpp"
|
|
|
|
#include "gc/shared/collectorPolicy.hpp"
|
2018-04-26 11:19:05 -05:00
|
|
|
#include "gc/shared/jvmFlagConstraintsGC.hpp"
|
2018-04-10 12:17:16 +02:00
|
|
|
#include "gc/shared/plab.hpp"
|
2015-10-05 14:56:19 -07:00
|
|
|
#include "gc/shared/threadLocalAllocBuffer.hpp"
|
2015-06-18 14:39:38 -05:00
|
|
|
#include "runtime/arguments.hpp"
|
2018-04-26 11:19:05 -05:00
|
|
|
#include "runtime/flags/jvmFlagRangeList.hpp"
|
2015-06-18 14:39:38 -05:00
|
|
|
#include "runtime/globals.hpp"
|
2015-10-05 14:56:19 -07:00
|
|
|
#include "runtime/globals_extension.hpp"
|
2015-12-04 15:24:14 -08:00
|
|
|
#include "runtime/thread.inline.hpp"
|
2017-07-05 11:33:17 +02:00
|
|
|
#include "utilities/align.hpp"
|
2015-06-18 14:39:38 -05:00
|
|
|
#include "utilities/defaultStream.hpp"
|
2018-04-10 12:17:16 +02:00
|
|
|
#include "utilities/macros.hpp"
|
2015-06-18 14:39:38 -05:00
|
|
|
#if INCLUDE_ALL_GCS
|
2018-04-26 11:19:05 -05:00
|
|
|
#include "gc/cms/jvmFlagConstraintsCMS.hpp"
|
|
|
|
#include "gc/g1/jvmFlagConstraintsG1.hpp"
|
|
|
|
#include "gc/parallel/jvmFlagConstraintsParallel.hpp"
|
2018-04-10 12:17:16 +02:00
|
|
|
#endif
|
2015-06-18 14:39:38 -05:00
|
|
|
#ifdef COMPILER1
|
|
|
|
#include "c1/c1_globals.hpp"
|
|
|
|
#endif // COMPILER1
|
|
|
|
#ifdef COMPILER2
|
|
|
|
#include "opto/c2_globals.hpp"
|
|
|
|
#endif // COMPILER2
|
|
|
|
|
2015-10-05 14:56:19 -07:00
|
|
|
// Some flags that have default values that indicate that the
|
|
|
|
// JVM should automatically determine an appropriate value
|
|
|
|
// for that flag. In those cases it is only appropriate for the
|
|
|
|
// constraint checking to be done if the user has specified the
|
|
|
|
// value(s) of the flag(s) on the command line. In the constraint
|
|
|
|
// checking functions, FLAG_IS_CMDLINE() is used to check if
|
|
|
|
// the flag has been set by the user and so should be checked.
|
|
|
|
|
|
|
|
// As ParallelGCThreads differs among GC modes, we need constraint function.
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
|
|
|
|
JVMFlag::Error status = JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
|
|
|
|
#if INCLUDE_ALL_GCS
|
2018-04-10 12:17:16 +02:00
|
|
|
status = ParallelGCThreadsConstraintFuncParallel(value, verbose);
|
2018-04-26 11:19:05 -05:00
|
|
|
if (status != JVMFlag::SUCCESS) {
|
2018-04-10 12:17:16 +02:00
|
|
|
return status;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
2018-04-10 12:17:16 +02:00
|
|
|
|
|
|
|
status = ParallelGCThreadsConstraintFuncCMS(value, verbose);
|
2018-04-26 11:19:05 -05:00
|
|
|
if (status != JVMFlag::SUCCESS) {
|
2018-04-10 12:17:16 +02:00
|
|
|
return status;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
#endif
|
2018-04-10 12:17:16 +02:00
|
|
|
|
2015-10-05 14:56:19 -07:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
// As ConcGCThreads should be smaller than ParallelGCThreads,
|
|
|
|
// we need constraint function.
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
// CMS and G1 GCs use ConcGCThreads.
|
|
|
|
if ((UseConcMarkSweepGC || UseG1GC) && (value > ParallelGCThreads)) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"ConcGCThreads (" UINT32_FORMAT ") must be "
|
|
|
|
"less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n",
|
|
|
|
value, ParallelGCThreads);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
#endif
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
|
2015-07-27 13:56:26 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2016-04-01 09:45:50 -07:00
|
|
|
if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value < PLAB::min_size())) {
|
2015-08-13 17:17:56 -05:00
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"%s (" SIZE_FORMAT ") must be "
|
|
|
|
"greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
|
|
|
|
name, value, PLAB::min_size());
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
|
2015-07-27 13:56:26 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2016-04-01 09:45:50 -07:00
|
|
|
if ((UseConcMarkSweepGC || UseG1GC || UseParallelGC) && (value > PLAB::max_size())) {
|
2015-08-13 17:17:56 -05:00
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"%s (" SIZE_FORMAT ") must be "
|
2015-08-31 11:51:29 -07:00
|
|
|
"less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
|
2015-09-02 14:00:46 +02:00
|
|
|
name, value, PLAB::max_size());
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
static JVMFlag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
|
|
|
|
JVMFlag::Error status = MinPLABSizeBounds(name, value, verbose);
|
2015-10-05 14:56:19 -07:00
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
if (status == JVMFlag::SUCCESS) {
|
2015-08-13 17:17:56 -05:00
|
|
|
return MaxPLABSizeBounds(name, value, verbose);
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
2015-10-05 14:56:19 -07:00
|
|
|
return status;
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) {
|
2015-08-13 17:17:56 -05:00
|
|
|
return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose);
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
|
|
|
|
JVMFlag::Error status = JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
|
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
if (UseConcMarkSweepGC) {
|
2018-04-10 12:17:16 +02:00
|
|
|
return OldPLABSizeConstraintFuncCMS(value, verbose);
|
2015-10-05 14:56:19 -07:00
|
|
|
} else {
|
|
|
|
status = MinMaxPLABSizeBounds("OldPLABSize", value, verbose);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
|
2015-08-13 17:17:56 -05:00
|
|
|
if (value > MaxHeapFreeRatio) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MinHeapFreeRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
|
|
|
|
value, MaxHeapFreeRatio);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-06-18 14:39:38 -05:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
|
2015-08-13 17:17:56 -05:00
|
|
|
if (value < MinHeapFreeRatio) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MaxHeapFreeRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
|
|
|
|
value, MinHeapFreeRatio);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-06-18 14:39:38 -05:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
static JVMFlag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, intx softRef, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
if ((softRef > 0) && ((maxHeap / M) > (max_uintx / softRef))) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"Desired lifetime of SoftReferences cannot be expressed correctly. "
|
|
|
|
"MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB "
|
|
|
|
"(" INTX_FORMAT ") is too large\n",
|
|
|
|
maxHeap, softRef);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
return CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(MaxHeapSize, value, verbose);
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) {
|
2018-04-10 12:17:16 +02:00
|
|
|
if (value > MarkStackSizeMax) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MarkStackSize (" SIZE_FORMAT ") must be "
|
|
|
|
"less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n",
|
|
|
|
value, MarkStackSizeMax);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2018-04-10 12:17:16 +02:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2018-04-10 12:17:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
|
2015-08-13 17:17:56 -05:00
|
|
|
if (value > MaxMetaspaceFreeRatio) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
|
|
|
|
value, MaxMetaspaceFreeRatio);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-06-18 14:39:38 -05:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
|
2015-08-13 17:17:56 -05:00
|
|
|
if (value < MinMetaspaceFreeRatio) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
|
|
|
|
value, MinMetaspaceFreeRatio);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-06-18 14:39:38 -05:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose);
|
|
|
|
if (status != JVMFlag::SUCCESS) {
|
2018-04-10 12:17:16 +02:00
|
|
|
return status;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
#endif
|
2018-04-10 12:17:16 +02:00
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose);
|
|
|
|
if (status != JVMFlag::SUCCESS) {
|
2018-04-10 12:17:16 +02:00
|
|
|
return status;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// MaxTenuringThreshold=0 means NeverTenure=false && AlwaysTenure=true
|
|
|
|
if ((value == 0) && (NeverTenure || !AlwaysTenure)) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MaxTenuringThreshold (0) should match to NeverTenure=false "
|
|
|
|
"&& AlwaysTenure=true. But we have NeverTenure=%s "
|
|
|
|
"AlwaysTenure=%s\n",
|
|
|
|
NeverTenure ? "true" : "false",
|
|
|
|
AlwaysTenure ? "true" : "false");
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose);
|
|
|
|
if (status != JVMFlag::SUCCESS) {
|
2018-04-10 12:17:16 +02:00
|
|
|
return status;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose);
|
|
|
|
if (status != JVMFlag::SUCCESS) {
|
2018-04-10 12:17:16 +02:00
|
|
|
return status;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
#endif
|
2018-04-10 12:17:16 +02:00
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
|
2017-07-04 15:58:10 +02:00
|
|
|
size_t aligned_max = align_down(max_uintx/2, Metaspace::reserve_alignment_words());
|
2015-10-05 14:56:19 -07:00
|
|
|
if (value > aligned_max) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be "
|
|
|
|
"less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
|
|
|
|
value, aligned_max);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2017-07-04 15:58:10 +02:00
|
|
|
// To avoid an overflow by 'align_up(value, alignment)'.
|
2018-04-26 11:19:05 -05:00
|
|
|
static JVMFlag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) {
|
2015-12-04 15:24:14 -08:00
|
|
|
size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
|
|
|
|
if (value > aligned_max) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"%s (" SIZE_FORMAT ") must be "
|
|
|
|
"less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
|
|
|
|
name, value, aligned_max);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-12-04 15:24:14 -08:00
|
|
|
}
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-12-04 15:24:14 -08:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
size_t heap_alignment;
|
|
|
|
|
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
if (UseG1GC) {
|
2018-04-10 12:17:16 +02:00
|
|
|
// For G1 GC, we don't know until G1CollectorPolicy is created.
|
|
|
|
heap_alignment = MaxSizeForHeapAlignmentG1();
|
2015-10-05 14:56:19 -07:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
heap_alignment = CollectorPolicy::compute_heap_alignment();
|
|
|
|
}
|
|
|
|
|
2015-12-04 15:24:14 -08:00
|
|
|
return MaxSizeForAlignment(name, value, heap_alignment, verbose);
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
|
|
|
|
JVMFlag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
|
2015-10-05 14:56:19 -07:00
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
if (status == JVMFlag::SUCCESS) {
|
2015-10-05 14:56:19 -07:00
|
|
|
status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
|
2015-12-04 15:24:14 -08:00
|
|
|
// If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value.
|
|
|
|
// Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx.
|
|
|
|
if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. "
|
|
|
|
"Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n",
|
|
|
|
value, MaxHeapSize, max_uintx);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-12-04 15:24:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
|
|
|
|
if (status != JVMFlag::SUCCESS) {
|
2018-04-10 12:17:16 +02:00
|
|
|
return status;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
2018-04-10 12:17:16 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
// At least, alignment reserve area is needed.
|
|
|
|
if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MinTLABSize (" SIZE_FORMAT ") must be "
|
|
|
|
"greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n",
|
|
|
|
value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
2016-03-18 21:01:28 -07:00
|
|
|
if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MinTLABSize (" SIZE_FORMAT ") must be "
|
|
|
|
"less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n",
|
|
|
|
value, ThreadLocalAllocBuffer::max_size() * HeapWordSize);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2016-03-18 21:01:28 -07:00
|
|
|
}
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error TLABSizeConstraintFunc(size_t value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
// Skip for default value of zero which means set ergonomically.
|
|
|
|
if (FLAG_IS_CMDLINE(TLABSize)) {
|
|
|
|
if (value < MinTLABSize) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"TLABSize (" SIZE_FORMAT ") must be "
|
|
|
|
"greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n",
|
|
|
|
value, MinTLABSize);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"TLABSize (" SIZE_FORMAT ") must be "
|
|
|
|
"less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n",
|
|
|
|
value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize));
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
}
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
|
2015-12-04 15:24:14 -08:00
|
|
|
// We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
|
|
|
|
// so AfterMemoryInit type is enough to check.
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
|
2015-12-04 15:24:14 -08:00
|
|
|
if (UseTLAB) {
|
|
|
|
size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit();
|
|
|
|
|
|
|
|
// Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'.
|
|
|
|
if (refill_waste_limit > (max_uintx - value)) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"TLABWasteIncrement (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n",
|
|
|
|
value, (max_uintx - refill_waste_limit));
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-12-04 15:24:14 -08:00
|
|
|
}
|
|
|
|
}
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-12-04 15:24:14 -08:00
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
if (FLAG_IS_CMDLINE(SurvivorRatio) &&
|
|
|
|
(value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"SurvivorRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n",
|
|
|
|
value,
|
|
|
|
(MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()));
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
if (value > MaxMetaspaceSize) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MetaspaceSize (" SIZE_FORMAT ") must be "
|
|
|
|
"less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n",
|
|
|
|
value, MaxMetaspaceSize);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-10-05 14:56:19 -07:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-10-05 14:56:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
|
2015-10-05 14:56:19 -07:00
|
|
|
if (value < MetaspaceSize) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MaxMetaspaceSize (" SIZE_FORMAT ") must be "
|
|
|
|
"greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n",
|
|
|
|
value, MaxMetaspaceSize);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-06-18 14:39:38 -05:00
|
|
|
} else {
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-26 11:19:05 -05:00
|
|
|
JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
|
2015-08-13 17:17:56 -05:00
|
|
|
if (value != 0) {
|
|
|
|
if (!is_power_of_2(value)) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
|
|
|
|
"power of 2\n",
|
|
|
|
value);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
2015-08-13 17:17:56 -05:00
|
|
|
if (value < ObjectAlignmentInBytes) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
|
|
|
|
"greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
|
|
|
|
value, ObjectAlignmentInBytes);
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::VIOLATES_CONSTRAINT;
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
}
|
2018-04-26 11:19:05 -05:00
|
|
|
return JVMFlag::SUCCESS;
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|