2015-06-18 14:39:38 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
|
|
|
* 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"
|
|
|
|
#include "runtime/arguments.hpp"
|
|
|
|
#include "runtime/commandLineFlagConstraintsGC.hpp"
|
2015-08-13 17:17:56 -05:00
|
|
|
#include "runtime/commandLineFlagRangeList.hpp"
|
2015-06-18 14:39:38 -05:00
|
|
|
#include "runtime/globals.hpp"
|
|
|
|
#include "utilities/defaultStream.hpp"
|
|
|
|
|
|
|
|
#if INCLUDE_ALL_GCS
|
|
|
|
#include "gc/g1/g1_globals.hpp"
|
2015-07-27 13:56:26 -07:00
|
|
|
#include "gc/g1/heapRegionBounds.inline.hpp"
|
|
|
|
#include "gc/parallel/parallelScavengeHeap.hpp"
|
|
|
|
#include "gc/shared/plab.hpp"
|
2015-06-18 14:39:38 -05:00
|
|
|
#endif // INCLUDE_ALL_GCS
|
|
|
|
#ifdef COMPILER1
|
|
|
|
#include "c1/c1_globals.hpp"
|
|
|
|
#endif // COMPILER1
|
|
|
|
#ifdef COMPILER2
|
|
|
|
#include "opto/c2_globals.hpp"
|
|
|
|
#endif // COMPILER2
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
static Flag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
|
2015-07-27 13:56:26 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2015-08-13 17:17:56 -05:00
|
|
|
if ((UseConcMarkSweepGC || UseG1GC) && (value < PLAB::min_size())) {
|
|
|
|
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());
|
2015-07-27 13:56:26 -07:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
static Flag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
|
2015-07-27 13:56:26 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2015-08-13 17:17:56 -05:00
|
|
|
if ((UseConcMarkSweepGC || UseG1GC) && (value > PLAB::max_size())) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"%s (" SIZE_FORMAT ") must be "
|
|
|
|
"less than ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
|
|
|
|
name, value, PLAB::min_size());
|
2015-07-27 13:56:26 -07:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
static Flag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
|
|
|
|
if (MinPLABSizeBounds(name, value, verbose) == Flag::SUCCESS) {
|
|
|
|
return MaxPLABSizeBounds(name, value, verbose);
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) {
|
|
|
|
return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose);
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
|
|
|
|
if (value > MaxHeapFreeRatio) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MinHeapFreeRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
|
|
|
|
value, MaxHeapFreeRatio);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
|
|
|
|
if (value < MinHeapFreeRatio) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MaxHeapFreeRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
|
|
|
|
value, MinHeapFreeRatio);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
|
|
|
|
if (value > MaxMetaspaceFreeRatio) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
|
|
|
|
value, MaxMetaspaceFreeRatio);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
|
|
|
|
if (value < MinMetaspaceFreeRatio) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
|
|
|
|
"greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
|
|
|
|
value, MinMetaspaceFreeRatio);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GC workaround for "-XX:+UseConcMarkSweepGC"
|
|
|
|
// which sets InitialTenuringThreshold to 7 but leaves MaxTenuringThreshold remaining at 6
|
|
|
|
// and therefore would invalidate the constraint
|
|
|
|
#define UseConcMarkSweepGCWorkaroundIfNeeded(initial, max) { \
|
|
|
|
if ((initial == 7) && (max == 6)) { \
|
|
|
|
return Flag::SUCCESS; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
|
|
|
|
UseConcMarkSweepGCWorkaroundIfNeeded(value, MaxTenuringThreshold);
|
2015-06-18 14:39:38 -05:00
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
if (value > MaxTenuringThreshold) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"InitialTenuringThreshold (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n",
|
|
|
|
value, MaxTenuringThreshold);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
|
|
|
|
UseConcMarkSweepGCWorkaroundIfNeeded(InitialTenuringThreshold, value);
|
2015-06-18 14:39:38 -05:00
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
if (value < InitialTenuringThreshold) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"MaxTenuringThreshold (" UINTX_FORMAT ") must be "
|
|
|
|
"greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n",
|
|
|
|
value, InitialTenuringThreshold);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_ALL_GCS
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) {
|
|
|
|
if (value > G1MaxNewSizePercent) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"G1NewSizePercent (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n",
|
|
|
|
value, G1MaxNewSizePercent);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) {
|
|
|
|
if (value < G1NewSizePercent) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"G1MaxNewSizePercent (" UINTX_FORMAT ") must be "
|
|
|
|
"greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n",
|
|
|
|
value, G1NewSizePercent);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) {
|
|
|
|
if (value > CMSOldPLABMax) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"CMSOldPLABMin (" SIZE_FORMAT ") must be "
|
|
|
|
"less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n",
|
|
|
|
value, CMSOldPLABMax);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) {
|
|
|
|
if (value <= CMSPrecleanNumerator) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"CMSPrecleanDenominator (" UINTX_FORMAT ") must be "
|
|
|
|
"strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
|
|
|
|
value, CMSPrecleanNumerator);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) {
|
|
|
|
if (value > (CMSPrecleanDenominator - 1)) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"CMSPrecleanNumerator (" UINTX_FORMAT ") must be "
|
|
|
|
"less than or equal to CMSPrecleanDenominator - 1 (" UINTX_FORMAT ")\n",
|
|
|
|
value, CMSPrecleanDenominator - 1);
|
2015-06-18 14:39:38 -05:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
} else {
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
|
|
|
|
if (value != 0) {
|
|
|
|
if (!is_power_of_2(value)) {
|
|
|
|
CommandLineError::print(verbose,
|
|
|
|
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
|
|
|
|
"power of 2\n",
|
|
|
|
value);
|
2015-07-27 13:56:26 -07:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
|
|
|
}
|
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);
|
2015-07-27 13:56:26 -07:00
|
|
|
return Flag::VIOLATES_CONSTRAINT;
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return Flag::SUCCESS;
|
|
|
|
}
|