/* * 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. *
*/
virtualvoid range_error(constchar* name, T value, T min, T max, bool verbose) const = 0; virtualvoid print_range_impl(outputStream* st, T min, T max) const = 0;
};
class FlagAccessImpl_int : public RangedFlagAccessImpl<int, EventIntFlagChanged> { public: void range_error(constchar* name, int value, int min, int max, bool verbose) const {
JVMFlag::printError(verbose, "int %s=%d is outside the allowed range " "[ %d ... %d ]\n",
name, value, min, max);
}
JVMFlag::Error typed_check_constraint(void* func, int value, bool verbose) const { return ((JVMFlagConstraintFunc_int)func)(value, verbose);
} void print_range_impl(outputStream* st, int min, int max) const {
st->print("[ %-25d ... %25d ]", min, max);
} void print_default_range(outputStream* st) const {
st->print("[ " INT32_FORMAT_W(-25) " ... " INT32_FORMAT_W(25) " ]", INT_MIN, INT_MAX);
}
};
staticconst FlagAccessImpl* flag_accesss[JVMFlag::NUM_FLAG_TYPES] = {
JVM_FLAG_NON_STRING_TYPES_DO(FLAG_ACCESS_IMPL_ADDR) // ccstr and ccstrlist have special setter
};
inlineconst FlagAccessImpl* JVMFlagAccess::access_impl(const JVMFlag* flag) { int type = flag->type(); int max = (int)(sizeof(flag_accesss)/sizeof(flag_accesss[0]));
assert(type >= 0 && type < max , "sanity");
JVMFlag::Error JVMFlagAccess::set_ccstr(JVMFlag* flag, ccstr* value, JVMFlagOrigin origin) { if (flag == NULL) return JVMFlag::INVALID_FLAG; if (!flag->is_ccstr()) return JVMFlag::WRONG_FORMAT;
ccstr old_value = flag->get_ccstr();
trace_flag_changed<ccstr, EventStringFlagChanged>(flag, old_value, *value, origin); char* new_value = NULL; if (*value != NULL) {
new_value = os::strdup_check_oom(*value);
}
flag->set_ccstr(new_value); if (!flag->is_default() && old_value != NULL) { // Old value is heap allocated so free it.
FREE_C_HEAP_ARRAY(char, old_value);
} // Unlike the other APIs, the old vale is NOT returned, so the caller won't need to free it. // The callers typically don't care what the old value is. // If the caller really wants to know the old value, read it (and make a copy if necessary) // before calling this API.
*value = NULL;
flag->set_origin(origin); return JVMFlag::SUCCESS;
}
// This is called by the FLAG_SET_XXX macros.
JVMFlag::Error JVMFlagAccess::set_or_assert(JVMFlagsEnum flag_enum, int type_enum, void* value, JVMFlagOrigin origin) {
JVMFlag* flag = JVMFlag::flag_from_enum(flag_enum); if (type_enum == JVMFlag::TYPE_ccstr || type_enum == JVMFlag::TYPE_ccstrlist) {
assert(flag->is_ccstr(), "must be"); return set_ccstr(flag, (ccstr*)value, origin);
} else {
assert(flag->type() == type_enum, "wrong flag type"); return set_impl(flag, value, origin);
}
}
// Two special cases where the lower limit of the range is defined by an os:: function call // and cannot be initialized at compile time with constexpr. if (func == (void*)VMPageSizeConstraintFunc) {
uintx min = (uintx)os::vm_page_size();
uintx max = max_uintx;
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.