/* * Copyright (c) 2020, 2021, 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. *
*/
class outputStream; template <typename T> class JVMTypedFlagLimit;
enumclass JVMFlagConstraintPhase : int { // Will be validated during argument processing (Arguments::parse_argument).
AtParse = 0, // Will be validated inside Threads::create_vm(), right after Arguments::apply_ergo().
AfterErgo = 1, // Will be validated inside universe_init(), right after Metaspace::global_initialize().
AfterMemoryInit = 2
};
// A JVMFlagLimit is created for each JVMFlag that has a range() and/or constraint() in its declaration in // the globals_xxx.hpp file. // // To query the range information of a JVMFlag: // JVMFlagLimit::get_range(JVMFlag*) // JVMFlagLimit::get_range_at(int flag_enum) // If the given flag doesn't have a range, NULL is returned. // // To query the constraint information of a JVMFlag: // JVMFlagLimit::get_constraint(JVMFlag*) // JVMFlagLimit::get_constraint_at(int flag_enum) // If the given flag doesn't have a constraint, NULL is returned.
class JVMFlagLimit { short _constraint_func; char _phase; char _kind;
// Is the current value of each JVM flag within the allowed range (if specified) staticbool check_all_ranges(); void print_range(outputStream* st, const JVMFlag* flag) const;
// Does the current value of each JVM flag satisfy the specified constraint staticbool check_all_constraints(JVMFlagConstraintPhase phase);
// If range/constraint checks fail, print verbose error messages only if we are parsing // arguments from the command-line. Silently ignore any invalid values that are // set programmatically via FLAG_SET_ERGO, etc. staticbool verbose_checks_needed() { return _validating_phase == JVMFlagConstraintPhase::AtParse;
}
template <typename T> class JVMTypedFlagLimit : public JVMFlagLimit { const T _min; const T _max;
public: // dummy - no range or constraint. This object will not be emitted into the .o file // because we declare it as "const" but has no reference to it.
constexpr JVMTypedFlagLimit(int type_enum) :
JVMFlagLimit(0, 0, 0, 0), _min(0), _max(0) {}
// range only
constexpr JVMTypedFlagLimit(int type_enum, T min, T max) :
JVMFlagLimit(type_enum, 0, 0, HAS_RANGE), _min(min), _max(max) {}
// constraint only
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, int phase) :
JVMFlagLimit(type_enum, func, phase, HAS_CONSTRAINT), _min(0), _max(0) {}
// range and constraint
constexpr JVMTypedFlagLimit(int type_enum, T min, T max, ConstraintMarker dummy2, short func, int phase) :
JVMFlagLimit(type_enum, func, phase, HAS_RANGE | HAS_CONSTRAINT), _min(min), _max(max) {}
// constraint and range
constexpr JVMTypedFlagLimit(int type_enum, ConstraintMarker dummy2, short func, int phase, T min, T max) :
JVMFlagLimit(type_enum, func, phase, HAS_RANGE | HAS_CONSTRAINT), _min(min), _max(max) {}
T min() const { return _min; }
T max() const { return _max; }
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.