--- /dev/null 2019-11-19 22:05:02.069813242 -0800 +++ new/src/hotspot/share/runtime/flags/jvmFlag.inline.hpp 2020-04-05 21:36:01.308581272 -0700 @@ -0,0 +1,131 @@ +/* + * Copyright (c) 1997, 2020, 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. + * + */ + +#ifndef SHARE_RUNTIME_FLAGS_JVMFLAG_INLINE_HPP +#define SHARE_RUNTIME_FLAGS_JVMFLAG_INLINE_HPP + +#include "runtime/flags/jvmFlag.hpp" +#include "utilities/ostream.hpp" + +// We are calling printf with a non-literal format string indexed from print_formats[] +PRAGMA_DIAG_PUSH +PRAGMA_FORMAT_NONLITERAL_IGNORED + +template +inline void JVMFlag::print_range_helper(outputStream* st, T min, T max) const { + assert(print_formats[type()].type == type(), "must be"); + const char* fmt = JVMFlag::print_formats[type()].print_range_format; + assert(fmt != NULL, "no range check for bool or ccstr"); + st->print(fmt, min, max); +} + +template +inline void JVMFlag::print_range_error(T new_value, T min, T max, bool verbose) const { + assert(print_formats[type()].type == type(), "must be"); + const char* fmt = print_formats[type()].range_error_format; + assert(fmt != NULL, "no range check for bool or ccstr"); + JVMFlag::printError(verbose, fmt, type_string(), name(), new_value, min, max); +} + +PRAGMA_DIAG_POP + +// ---- Macros for defining VM flags in *globals.cpp files ----- + + +// NOTE: each of the XXX_FLAG macros has a 6th required argument "docs". +// However, for __VA_ARGS__ craziness, this arg is not explicitly specified. + +// Meta-information for PRODUCT_FLAG is stored in ProductFlag +#define DEFN_PRODUCT_FLAG_COMMON(name) \ + ProductFlag FLAG_##name(FLAG_TYPE_NAME_##name(), XSTR(name), FLAG_ATTR(FLAG_ATTR_##name()), &name, FLAG_DOCS_##name()) + +#define DEFN_PRODUCT_FLAG(name) \ + FLAG_TYPE_##name name = FLAG_DEFVAL_##name(); \ + DEFN_PRODUCT_FLAG_COMMON(name) + +#define DEFN_PRODUCT_FLAG_PD(name) \ + FLAG_TYPE_##name name = pd_##name; \ + DEFN_PRODUCT_FLAG_COMMON(name) + +#ifdef PRODUCT +// In product builds, information for DEVELOP_FLAG is stored in +// DevelopFlag. + +#define DEFN_DEVELOP_FLAG_COMMON(name) \ + DevelopFlag FLAG_##name(FLAG_TYPE_NAME_##name(), XSTR(name), FLAG_ATTR(FLAG_ATTR_##name()), &name) + +#define DEFN_DEVELOP_FLAG(name) \ + DEFN_DEVELOP_FLAG_COMMON(name) + +#define DEFN_DEVELOP_FLAG_PD(name) \ + DEFN_DEVELOP_FLAG_COMMON(name) + +// In product builds, NOTPROD_FLAGs are not visible at all.. +// We add a harmless typedef here to allow using the NOTPROD_FLAG macro with +// a trailing ";" in xxx_globals.flags.hpp +#define DEFN_NOTPROD_FLAG(name) \ + typedef int __unused2__##name + +#else +// !defined(PRODUCT) + +// In develop builds, NOTPROD_FLAG and DEVELOP_FLAG are equivalent to PRODUCT_FLAG +#define DEFN_NOTPROD_FLAG(name) DEFN_PRODUCT_FLAG(name) +#define DEFN_DEVELOP_FLAG(name) DEFN_PRODUCT_FLAG(name) +#define DEFN_DEVELOP_FLAG_PD(name) DEFN_PRODUCT_FLAG_PD(name) + +#endif // PRODUCT + +// ---- Macros for implementing VM flags constraints in *globals.cpp files ----- + +#define DEFN_PRODUCT_RANGE(name) \ + JVMFlagRange FLAG_RANGE_##name(&FLAG_##name, FLAG_MIN_##name(), FLAG_MAX_##name()) + +#define DEFN_PRODUCT_CONSTRAINT(name) \ + JVMFlagConstraint \ + FLAG_CONSTRAINT_##name(&FLAG_##name, FLAG_CONSTRAINT_FUNC_##name(), FLAG_CONSTRAINT_PHASE_##name()) + +#define DEFN_PRODUCT_CUSTOM_RANGE(name) \ + FLAG_RANGE_TYPE_##name FLAG_RANGE_##name(&FLAG_##name) + +#ifdef PRODUCT +#define DEFN_DEVELOP_RANGE(name) typedef int __unused5__##name +#define DEFN_DEVELOP_CONSTRAINT(name) typedef int __unused6__##name + +#define DEFN_NOTPROD_RANGE(name) typedef int __unused7__##name +#define DEFN_NOTPROD_CONSTRAINT(name) typedef int __unused8__##name + + +#else +// !defined(PRODUCT) + +#define DEFN_DEVELOP_RANGE(name) DEFN_PRODUCT_RANGE(name) +#define DEFN_DEVELOP_CONSTRAINT(name) DEFN_PRODUCT_CONSTRAINT(name) + +#define DEFN_NOTPROD_RANGE(name) DEFN_PRODUCT_RANGE(name) +#define DEFN_NOTPROD_CONSTRAINT(name) DEFN_PRODUCT_CONSTRAINT(name) + +#endif + +#endif // SHARE_RUNTIME_FLAGS_JVMFLAG_INLINE_HPP