< prev index next >
src/hotspot/share/runtime/flags/jvmFlag.cpp
Print this page
*** 25,207 ****
#include "precompiled.hpp"
#include "jfr/jfrEvents.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/arguments.hpp"
#include "runtime/flags/jvmFlag.hpp"
! #include "runtime/flags/jvmFlagConstraintList.hpp"
! #include "runtime/flags/jvmFlagRangeList.hpp"
! #include "runtime/globals_extension.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/stringUtils.hpp"
- #define DEFAULT_RANGE_STR_CHUNK_SIZE 64
- static char* create_range_str(const char *fmt, ...) {
- static size_t string_length = DEFAULT_RANGE_STR_CHUNK_SIZE;
- static char* range_string = NEW_C_HEAP_ARRAY(char, string_length, mtLogging);
! int size_needed = 0;
! do {
! va_list args;
! va_start(args, fmt);
! size_needed = jio_vsnprintf(range_string, string_length, fmt, args);
! va_end(args);
!
! if (size_needed < 0) {
! string_length += DEFAULT_RANGE_STR_CHUNK_SIZE;
! range_string = REALLOC_C_HEAP_ARRAY(char, range_string, string_length, mtLogging);
! guarantee(range_string != NULL, "create_range_str string should not be NULL");
! }
! } while (size_needed < 0);
!
! return range_string;
! }
!
! const char* JVMFlag::get_int_default_range_str() {
! return create_range_str("[ " INT32_FORMAT_W(-25) " ... " INT32_FORMAT_W(25) " ]", INT_MIN, INT_MAX);
! }
!
! const char* JVMFlag::get_uint_default_range_str() {
! return create_range_str("[ " UINT32_FORMAT_W(-25) " ... " UINT32_FORMAT_W(25) " ]", 0, UINT_MAX);
! }
!
! const char* JVMFlag::get_intx_default_range_str() {
! return create_range_str("[ " INTX_FORMAT_W(-25) " ... " INTX_FORMAT_W(25) " ]", min_intx, max_intx);
! }
!
! const char* JVMFlag::get_uintx_default_range_str() {
! return create_range_str("[ " UINTX_FORMAT_W(-25) " ... " UINTX_FORMAT_W(25) " ]", 0, max_uintx);
! }
!
! const char* JVMFlag::get_uint64_t_default_range_str() {
! return create_range_str("[ " UINT64_FORMAT_W(-25) " ... " UINT64_FORMAT_W(25) " ]", 0, uint64_t(max_juint));
! }
!
! const char* JVMFlag::get_size_t_default_range_str() {
! return create_range_str("[ " SIZE_FORMAT_W(-25) " ... " SIZE_FORMAT_W(25) " ]", 0, SIZE_MAX);
! }
!
! const char* JVMFlag::get_double_default_range_str() {
! return create_range_str("[ %-25.3f ... %25.3f ]", DBL_MIN, DBL_MAX);
! }
static bool is_product_build() {
#ifdef PRODUCT
return true;
#else
return false;
#endif
}
! bool JVMFlag::is_bool() const {
! return strcmp(_type, "bool") == 0;
! }
!
! bool JVMFlag::is_int() const {
! return strcmp(_type, "int") == 0;
! }
!
! bool JVMFlag::is_uint() const {
! return strcmp(_type, "uint") == 0;
! }
!
! bool JVMFlag::is_intx() const {
! return strcmp(_type, "intx") == 0;
! }
!
! bool JVMFlag::is_uintx() const {
! return strcmp(_type, "uintx") == 0;
! }
!
! bool JVMFlag::is_uint64_t() const {
! return strcmp(_type, "uint64_t") == 0;
! }
!
! bool JVMFlag::is_size_t() const {
! return strcmp(_type, "size_t") == 0;
! }
!
! bool JVMFlag::is_double() const {
! return strcmp(_type, "double") == 0;
! }
!
! bool JVMFlag::is_ccstr() const {
! return strcmp(_type, "ccstr") == 0 || strcmp(_type, "ccstrlist") == 0;
! }
!
! bool JVMFlag::ccstr_accumulates() const {
! return strcmp(_type, "ccstrlist") == 0;
! }
!
! JVMFlag::Flags JVMFlag::get_origin() {
! return Flags(_flags & VALUE_ORIGIN_MASK);
! }
!
! void JVMFlag::set_origin(Flags origin) {
assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity");
! Flags new_origin = Flags((origin == COMMAND_LINE) ? Flags(origin | ORIG_COMMAND_LINE) : origin);
! _flags = Flags((_flags & ~VALUE_ORIGIN_MASK) | new_origin);
! }
!
! bool JVMFlag::is_default() {
! return (get_origin() == DEFAULT);
! }
!
! bool JVMFlag::is_ergonomic() {
! return (get_origin() == ERGONOMIC);
! }
!
! bool JVMFlag::is_command_line() {
! return (_flags & ORIG_COMMAND_LINE) != 0;
! }
!
! void JVMFlag::set_command_line() {
! _flags = Flags(_flags | ORIG_COMMAND_LINE);
! }
!
! bool JVMFlag::is_product() const {
! return (_flags & KIND_PRODUCT) != 0;
! }
!
! bool JVMFlag::is_manageable() const {
! return (_flags & KIND_MANAGEABLE) != 0;
! }
!
! bool JVMFlag::is_diagnostic() const {
! return (_flags & KIND_DIAGNOSTIC) != 0;
! }
!
! bool JVMFlag::is_experimental() const {
! return (_flags & KIND_EXPERIMENTAL) != 0;
! }
!
! bool JVMFlag::is_notproduct() const {
! return (_flags & KIND_NOT_PRODUCT) != 0;
! }
!
! bool JVMFlag::is_develop() const {
! return (_flags & KIND_DEVELOP) != 0;
! }
!
! bool JVMFlag::is_read_write() const {
! return (_flags & KIND_READ_WRITE) != 0;
! }
!
! /**
! * Returns if this flag is a constant in the binary. Right now this is
! * true for notproduct and develop flags in product builds.
! */
! bool JVMFlag::is_constant_in_binary() const {
! #ifdef PRODUCT
! return is_notproduct() || is_develop();
! #else
! return false;
! #endif
}
bool JVMFlag::is_unlocker() const {
! return strcmp(_name, "UnlockDiagnosticVMOptions") == 0 ||
! strcmp(_name, "UnlockExperimentalVMOptions") == 0;
}
bool JVMFlag::is_unlocked() const {
if (is_diagnostic()) {
return UnlockDiagnosticVMOptions;
--- 25,59 ----
#include "precompiled.hpp"
#include "jfr/jfrEvents.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/arguments.hpp"
#include "runtime/flags/jvmFlag.hpp"
! #include "runtime/flags/jvmFlagConstraintsRuntime.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/stringUtils.hpp"
! JVMFlag* JVMFlag::_head = NULL;
! int JVMFlag::_num_flags = 0;
static bool is_product_build() {
#ifdef PRODUCT
return true;
#else
return false;
#endif
}
! void JVMFlag::set_origin(Attr origin) {
assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity");
! int new_origin = (origin == COMMAND_LINE) ? (origin | ORIG_COMMAND_LINE) : origin;
! _attr = (_attr & ~VALUE_ORIGIN_MASK) | new_origin;
}
bool JVMFlag::is_unlocker() const {
! return strcmp(name(), "UnlockDiagnosticVMOptions") == 0 ||
! strcmp(name(), "UnlockExperimentalVMOptions") == 0;
}
bool JVMFlag::is_unlocked() const {
if (is_diagnostic()) {
return UnlockDiagnosticVMOptions;
*** 212,234 ****
return true;
}
void JVMFlag::clear_diagnostic() {
assert(is_diagnostic(), "sanity");
! _flags = Flags(_flags & ~KIND_DIAGNOSTIC);
assert(!is_diagnostic(), "sanity");
}
void JVMFlag::clear_experimental() {
assert(is_experimental(), "sanity");
! _flags = Flags(_flags & ~KIND_EXPERIMENTAL);
assert(!is_experimental(), "sanity");
}
void JVMFlag::set_product() {
assert(!is_product(), "sanity");
! _flags = Flags(_flags | KIND_PRODUCT);
assert(is_product(), "sanity");
}
// Get custom message for this locked flag, or NULL if
// none is available. Returns message type produced.
--- 64,86 ----
return true;
}
void JVMFlag::clear_diagnostic() {
assert(is_diagnostic(), "sanity");
! _attr &= ~DIAGNOSTIC;
assert(!is_diagnostic(), "sanity");
}
void JVMFlag::clear_experimental() {
assert(is_experimental(), "sanity");
! _attr &= ~EXPERIMENTAL;
assert(!is_experimental(), "sanity");
}
void JVMFlag::set_product() {
assert(!is_product(), "sanity");
! _attr |= IS_PRODUCT;
assert(is_product(), "sanity");
}
// Get custom message for this locked flag, or NULL if
// none is available. Returns message type produced.
*** 259,279 ****
return JVMFlag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD;
}
return JVMFlag::NONE;
}
- bool JVMFlag::is_writeable() const {
- return is_manageable() || (is_product() && is_read_write());
- }
-
- // All flags except "manageable" are assumed to be internal flags.
- // Long term, we need to define a mechanism to specify which flags
- // are external/stable and change this function accordingly.
- bool JVMFlag::is_external() const {
- return is_manageable();
- }
-
// Helper function for JVMFlag::print_on().
// Fills current line up to requested position.
// Should the current position already be past the requested position,
// one separator blank is enforced.
void fill_to_pos(outputStream* st, unsigned int req_pos) {
--- 111,120 ----
*** 282,292 ****
} else {
st->print(" "); // enforce blank separation. Previous field too long.
}
}
! void JVMFlag::print_on(outputStream* st, bool withComments, bool printRanges) {
// Don't print notproduct and develop flags in a product build.
if (is_constant_in_binary()) {
return;
}
--- 123,133 ----
} else {
st->print(" "); // enforce blank separation. Previous field too long.
}
}
! void JVMFlag::print_on(outputStream* st, bool withComments, bool printRanges) const {
// Don't print notproduct and develop flags in a product build.
if (is_constant_in_binary()) {
return;
}
*** 338,373 ****
const unsigned int col6_width = 15;
const unsigned int col7_pos = col6_pos + col6_width + col_spacing;
const unsigned int col7_width = 1;
st->fill_to(col1_pos);
! st->print("%*s", col1_width, _type); // right-justified, therefore width is required.
fill_to_pos(st, col2_pos);
st->print("%s", _name);
fill_to_pos(st, col3_pos);
st->print(" ="); // use " =" for proper alignment with multiline ccstr output.
fill_to_pos(st, col4_pos);
! if (is_bool()) {
! st->print("%s", get_bool() ? "true" : "false");
! } else if (is_int()) {
! st->print("%d", get_int());
! } else if (is_uint()) {
! st->print("%u", get_uint());
! } else if (is_intx()) {
! st->print(INTX_FORMAT, get_intx());
! } else if (is_uintx()) {
! st->print(UINTX_FORMAT, get_uintx());
! } else if (is_uint64_t()) {
! st->print(UINT64_FORMAT, get_uint64_t());
! } else if (is_size_t()) {
! st->print(SIZE_FORMAT, get_size_t());
! } else if (is_double()) {
! st->print("%f", get_double());
! } else if (is_ccstr()) {
// Honor <newline> characters in ccstr: print multiple lines.
const char* cp = get_ccstr();
if (cp != NULL) {
const char* eol;
while ((eol = strchr(cp, '\n')) != NULL) {
--- 179,198 ----
const unsigned int col6_width = 15;
const unsigned int col7_pos = col6_pos + col6_width + col_spacing;
const unsigned int col7_width = 1;
st->fill_to(col1_pos);
! st->print("%*s", col1_width, type_string()); // right-justified, therefore width is required.
fill_to_pos(st, col2_pos);
st->print("%s", _name);
fill_to_pos(st, col3_pos);
st->print(" ="); // use " =" for proper alignment with multiline ccstr output.
fill_to_pos(st, col4_pos);
! if (is_ccstr()) {
// Honor <newline> characters in ccstr: print multiple lines.
const char* cp = get_ccstr();
if (cp != NULL) {
const char* eol;
while ((eol = strchr(cp, '\n')) != NULL) {
*** 382,394 ****
fill_to_pos(st, col4_pos);
}
st->print("%s", cp);
}
} else {
! st->print("unhandled type %s", _type);
! st->cr();
! return;
}
fill_to_pos(st, col5_pos);
print_kind(st, col5_width);
--- 207,217 ----
fill_to_pos(st, col4_pos);
}
st->print("%s", cp);
}
} else {
! print_value(st);
}
fill_to_pos(st, col5_pos);
print_kind(st, col5_width);
*** 396,406 ****
print_origin(st, col6_width);
#ifndef PRODUCT
if (withComments) {
fill_to_pos(st, col7_pos);
! st->print("%s", _doc);
}
#endif
st->cr();
} else if (!is_bool() && !is_ccstr()) {
// The command line options -XX:+PrintFlags* cause this function to be called
--- 219,229 ----
print_origin(st, col6_width);
#ifndef PRODUCT
if (withComments) {
fill_to_pos(st, col7_pos);
! st->print("%s", docs());
}
#endif
st->cr();
} else if (!is_bool() && !is_ccstr()) {
// The command line options -XX:+PrintFlags* cause this function to be called
*** 446,533 ****
const unsigned int col6_width = 15;
const unsigned int col7_pos = col6_pos + col6_width + col_spacing;
const unsigned int col7_width = 1;
st->fill_to(col1_pos);
! st->print("%*s", col1_width, _type); // right-justified, therefore width is required.
fill_to_pos(st, col2_pos);
! st->print("%s", _name);
fill_to_pos(st, col4_pos);
! RangeStrFunc func = NULL;
! if (is_int()) {
! func = JVMFlag::get_int_default_range_str;
! } else if (is_uint()) {
! func = JVMFlag::get_uint_default_range_str;
! } else if (is_intx()) {
! func = JVMFlag::get_intx_default_range_str;
! } else if (is_uintx()) {
! func = JVMFlag::get_uintx_default_range_str;
! } else if (is_uint64_t()) {
! func = JVMFlag::get_uint64_t_default_range_str;
! } else if (is_size_t()) {
! func = JVMFlag::get_size_t_default_range_str;
! } else if (is_double()) {
! func = JVMFlag::get_double_default_range_str;
! } else {
! st->print("unhandled type %s", _type);
! st->cr();
! return;
! }
! JVMFlagRangeList::print(st, this, func);
fill_to_pos(st, col5_pos);
print_kind(st, col5_width);
fill_to_pos(st, col6_pos);
print_origin(st, col6_width);
#ifndef PRODUCT
if (withComments) {
fill_to_pos(st, col7_pos);
! st->print("%s", _doc);
}
#endif
st->cr();
}
}
! void JVMFlag::print_kind(outputStream* st, unsigned int width) {
struct Data {
int flag;
const char* name;
};
Data data[] = {
! { KIND_JVMCI, "JVMCI" },
! { KIND_C1, "C1" },
! { KIND_C2, "C2" },
! { KIND_ARCH, "ARCH" },
! { KIND_PLATFORM_DEPENDENT, "pd" },
! { KIND_PRODUCT, "product" },
! { KIND_MANAGEABLE, "manageable" },
! { KIND_DIAGNOSTIC, "diagnostic" },
! { KIND_EXPERIMENTAL, "experimental" },
! { KIND_NOT_PRODUCT, "notproduct" },
! { KIND_DEVELOP, "develop" },
! { KIND_LP64_PRODUCT, "lp64_product" },
! { KIND_READ_WRITE, "rw" },
{ -1, "" }
};
! if ((_flags & KIND_MASK) != 0) {
bool is_first = true;
const size_t buffer_size = 64;
size_t buffer_used = 0;
char kind[buffer_size];
jio_snprintf(kind, buffer_size, "{");
buffer_used++;
for (int i = 0; data[i].flag != -1; i++) {
Data d = data[i];
! if ((_flags & d.flag) != 0) {
if (is_first) {
is_first = false;
} else {
assert(buffer_used + 1 < buffer_size, "Too small buffer");
jio_snprintf(kind + buffer_used, buffer_size - buffer_used, " ");
--- 269,336 ----
const unsigned int col6_width = 15;
const unsigned int col7_pos = col6_pos + col6_width + col_spacing;
const unsigned int col7_width = 1;
st->fill_to(col1_pos);
! st->print("%*s", col1_width, type_string()); // right-justified, therefore width is required.
fill_to_pos(st, col2_pos);
! st->print("%s", name());
fill_to_pos(st, col4_pos);
! print_range(st);
fill_to_pos(st, col5_pos);
print_kind(st, col5_width);
fill_to_pos(st, col6_pos);
print_origin(st, col6_width);
#ifndef PRODUCT
if (withComments) {
fill_to_pos(st, col7_pos);
! st->print("%s", docs());
}
#endif
st->cr();
}
}
! void JVMFlag::print_kind(outputStream* st, unsigned int width) const {
struct Data {
int flag;
const char* name;
};
Data data[] = {
! { JVMCI, "JVMCI" },
! { C1, "C1" },
! { C2, "C2" },
! { ARCH, "ARCH" },
! { PLATFORM_DEPENDENT, "pd" },
! { IS_PRODUCT, "product" },
! { MANAGEABLE, "manageable" },
! { DIAGNOSTIC, "diagnostic" },
! { EXPERIMENTAL, "experimental" },
! { NOT_PRODUCT, "notproduct" },
! { DEVELOP, "develop" },
! { LP64, "lp64_product" },
! { READ_WRITE, "rw" },
{ -1, "" }
};
! if ((_attr & KIND_MASK) != 0) {
bool is_first = true;
const size_t buffer_size = 64;
size_t buffer_used = 0;
char kind[buffer_size];
jio_snprintf(kind, buffer_size, "{");
buffer_used++;
for (int i = 0; data[i].flag != -1; i++) {
Data d = data[i];
! if ((_attr & d.flag) != 0) {
if (is_first) {
is_first = false;
} else {
assert(buffer_used + 1 < buffer_size, "Too small buffer");
jio_snprintf(kind + buffer_used, buffer_size - buffer_used, " ");
*** 543,554 ****
jio_snprintf(kind + buffer_used, buffer_size - buffer_used, "}");
st->print("%*s", width, kind);
}
}
! void JVMFlag::print_origin(outputStream* st, unsigned int width) {
! int origin = _flags & VALUE_ORIGIN_MASK;
st->print("{");
switch(origin) {
case DEFAULT:
st->print("default"); break;
case COMMAND_LINE:
--- 346,357 ----
jio_snprintf(kind + buffer_used, buffer_size - buffer_used, "}");
st->print("%*s", width, kind);
}
}
! void JVMFlag::print_origin(outputStream* st, unsigned int width) const {
! int origin = _attr & VALUE_ORIGIN_MASK;
st->print("{");
switch(origin) {
case DEFAULT:
st->print("default"); break;
case COMMAND_LINE:
*** 558,568 ****
case CONFIG_FILE:
st->print("config file"); break;
case MANAGEMENT:
st->print("management"); break;
case ERGONOMIC:
! if (_flags & ORIG_COMMAND_LINE) {
st->print("command line, ");
}
st->print("ergonomic"); break;
case ATTACH_ON_DEMAND:
st->print("attach"); break;
--- 361,371 ----
case CONFIG_FILE:
st->print("config file"); break;
case MANAGEMENT:
st->print("management"); break;
case ERGONOMIC:
! if (_attr & ORIG_COMMAND_LINE) {
st->print("command line, ");
}
st->print("ergonomic"); break;
case ATTACH_ON_DEMAND:
st->print("attach"); break;
*** 572,600 ****
st->print("jimage"); break;
}
st->print("}");
}
! void JVMFlag::print_as_flag(outputStream* st) {
if (is_bool()) {
st->print("-XX:%s%s", get_bool() ? "+" : "-", _name);
! } else if (is_int()) {
! st->print("-XX:%s=%d", _name, get_int());
! } else if (is_uint()) {
! st->print("-XX:%s=%u", _name, get_uint());
! } else if (is_intx()) {
! st->print("-XX:%s=" INTX_FORMAT, _name, get_intx());
! } else if (is_uintx()) {
! st->print("-XX:%s=" UINTX_FORMAT, _name, get_uintx());
! } else if (is_uint64_t()) {
! st->print("-XX:%s=" UINT64_FORMAT, _name, get_uint64_t());
! } else if (is_size_t()) {
! st->print("-XX:%s=" SIZE_FORMAT, _name, get_size_t());
! } else if (is_double()) {
! st->print("-XX:%s=%f", _name, get_double());
! } else if (is_ccstr()) {
st->print("-XX:%s=", _name);
const char* cp = get_ccstr();
if (cp != NULL) {
// Need to turn embedded '\n's back into separate arguments
// Not so efficient to print one character at a time,
// but the choice is to do the transformation to a buffer
--- 375,521 ----
st->print("jimage"); break;
}
st->print("}");
}
! void JVMFlag::print_attr(outputStream* st, int width) const {
! struct Data {
! int flag;
! const char* name;
! };
!
! Data data[] = {
! { JVMCI, "JVMCI" },
! { C1, "C1" },
! { C2, "C2" },
! { ARCH, "ARCH" },
! { PLATFORM_DEPENDENT, "pd" },
! { IS_PRODUCT, "product" },
! { MANAGEABLE, "manageable" },
! { DIAGNOSTIC, "diagnostic" },
! { EXPERIMENTAL, "experimental" },
! { NOT_PRODUCT, "notproduct" },
! { DEVELOP, "develop" },
! { LP64, "lp64_product" },
! { READ_WRITE, "rw" },
! { -1, "" }
! };
!
! int attr = _attr;
!
! if (attr != 0) {
! bool is_first = true;
! const size_t buffer_size = 64;
! size_t buffer_used = 0;
! char kind[buffer_size];
!
! jio_snprintf(kind, buffer_size, "{");
! buffer_used++;
! for (int i = 0; data[i].flag != -1; i++) {
! Data d = data[i];
! if ((_attr & d.flag) != 0) {
! if (is_first) {
! is_first = false;
! } else {
! assert(buffer_used + 1 < buffer_size, "Too small buffer");
! jio_snprintf(kind + buffer_used, buffer_size - buffer_used, " ");
! buffer_used++;
! }
! size_t length = strlen(d.name);
! assert(buffer_used + length < buffer_size, "Too small buffer");
! jio_snprintf(kind + buffer_used, buffer_size - buffer_used, "%s", d.name);
! buffer_used += length;
! }
! }
! assert(buffer_used + 2 <= buffer_size, "Too small buffer");
! jio_snprintf(kind + buffer_used, buffer_size - buffer_used, "}");
! st->print("%*s", width, kind);
! }
! }
!
! #define DECLARE_TYPE_STRING(t) STR(t),
! static const char* const jvmflag_string_names[] = {
! JVM_FLAG_ALL_TYPES_DO(DECLARE_TYPE_STRING)
! };
!
! const char* JVMFlag::type_string() const {
! assert(type() >= 0 && type() < NUM_TYPES, "sanity");
! if (type() == TYPE_ccstr && _attr & STRINGLIST) {
! return "ccstrlist";
! }
! return jvmflag_string_names[type()];
! }
!
! #define RANGE_FORMAT(type, FMT, RANGE_MIN_FMT, RANGE_MAX_FMT) \
! NOT_PRODUCT_ARG(JVMFlag::TYPE_ ## type) \
! FMT, \
! "%s %s=" FMT " is outside the allowed range [ " FMT " ... " FMT " ]\n", \
! "[ " RANGE_MIN_FMT " ... " RANGE_MAX_FMT " ]"
!
! JVMFlag::PrintFormat JVMFlag::print_formats[] = {
! { NOT_PRODUCT_ARG(JVMFlag::TYPE_bool) "%s", NULL, NULL }, // range not used
! { RANGE_FORMAT(int, "%d", "%-25d", "%25d")},
! { RANGE_FORMAT(uint, "%u", "%-25u", "%25u")},
! { RANGE_FORMAT(intx, INTX_FORMAT, INTX_FORMAT_W(-25), INTX_FORMAT_W(25))},
! { RANGE_FORMAT(uintx, UINTX_FORMAT, UINTX_FORMAT_W(-25), UINTX_FORMAT_W(25))},
! { RANGE_FORMAT(uint64_t, UINT64_FORMAT, UINT64_FORMAT_W(-25), UINT64_FORMAT_W(25))},
! { RANGE_FORMAT(size_t, SIZE_FORMAT, SIZE_FORMAT_W(-25), SIZE_FORMAT_W(25))},
! { RANGE_FORMAT(double, "%f", "%-25.3f", "%25.3f")},
! { NOT_PRODUCT_ARG(JVMFlag::TYPE_ccstr) "%s", NULL, NULL }, // range not used
! };
!
! // We are calling printf with a non-literal format string indexed from print_formats[]
! PRAGMA_DIAG_PUSH
! PRAGMA_FORMAT_NONLITERAL_IGNORED
!
! // This is called when the JVMFlag has constraint function but no range.
! void JVMFlag::print_range_for_constraint(outputStream* st, void* constraint_func) const {
! const char* fmt = print_formats[type()].print_range_format;
! assert(fmt != NULL, "must be");
!
! switch (type()) {
! case TYPE_int: st->print(fmt, INT_MIN, INT_MAX); break;
! case TYPE_uint: st->print(fmt, 0, UINT_MAX); break;
! case TYPE_intx: st->print(fmt, min_intx, max_intx); break;
! case TYPE_uintx: st->print(fmt, 0, max_uintx ); break;
! case TYPE_uint64_t: st->print(fmt, 0, uint64_t(max_juint)); break;
! case TYPE_size_t: st->print(fmt, 0, SIZE_MAX); break;
! case TYPE_double: st->print(fmt, DBL_MIN, DBL_MAX); break;
! default: ShouldNotReachHere();
! }
! }
!
! void JVMFlag::print_value(outputStream* st) const {
! assert(print_formats[type()].type == type(), "must be");
! const char* fmt = print_formats[type()].print_value_format;
! switch (type()) {
! case TYPE_bool: st->print(fmt, get_bool() ? "true" : "false"); break;
! case TYPE_int: st->print(fmt, get_int()); break;
! case TYPE_uint: st->print(fmt, get_uint()); break;
! case TYPE_intx: st->print(fmt, get_intx()); break;
! case TYPE_uintx: st->print(fmt, get_uintx()); break;
! case TYPE_uint64_t: st->print(fmt, get_uint64_t()); break;
! case TYPE_size_t: st->print(fmt, get_size_t()); break;
! case TYPE_double: st->print(fmt, get_double()); break;
! case TYPE_ccstr: st->print(fmt, get_ccstr()); break;
! default: ShouldNotReachHere();
! }
! }
!
! PRAGMA_DIAG_POP
!
! // This is called when the JVMFlag has no range and no constraint function
! void JVMFlag::print_range(outputStream* st) const {
! st->print("[ ... ]");
! }
!
! void JVMFlag::print_as_flag(outputStream* st) const {
if (is_bool()) {
st->print("-XX:%s%s", get_bool() ? "+" : "-", _name);
! } else {
st->print("-XX:%s=", _name);
+ if (is_ccstr()) {
const char* cp = get_ccstr();
if (cp != NULL) {
// Need to turn embedded '\n's back into separate arguments
// Not so efficient to print one character at a time,
// but the choice is to do the transformation to a buffer
*** 609,619 ****
break;
}
}
}
} else {
! ShouldNotReachHere();
}
}
const char* JVMFlag::flag_error_str(JVMFlag::Error error) {
switch (error) {
--- 530,541 ----
break;
}
}
}
} else {
! print_value(st);
! }
}
}
const char* JVMFlag::flag_error_str(JVMFlag::Error error) {
switch (error) {
*** 627,808 ****
case JVMFlag::SUCCESS: return "SUCCESS";
default: ShouldNotReachHere(); return "NULL";
}
}
! // 4991491 do not "optimize out" the was_set false values: omitting them
! // tickles a Microsoft compiler bug causing flagTable to be malformed
!
! #define RUNTIME_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT) },
! #define RUNTIME_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define RUNTIME_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DIAGNOSTIC) },
! #define RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_EXPERIMENTAL) },
! #define RUNTIME_MANAGEABLE_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_MANAGEABLE) },
! #define RUNTIME_PRODUCT_RW_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_READ_WRITE) },
! #define RUNTIME_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DEVELOP) },
! #define RUNTIME_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define RUNTIME_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_NOT_PRODUCT) },
!
! #define JVMCI_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_PRODUCT) },
! #define JVMCI_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define JVMCI_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DIAGNOSTIC) },
! #define JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define JVMCI_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_EXPERIMENTAL) },
! #define JVMCI_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DEVELOP) },
! #define JVMCI_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define JVMCI_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_JVMCI | JVMFlag::KIND_NOT_PRODUCT) },
! #ifdef _LP64
! #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_LP64_PRODUCT) },
! #else
! #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
! #endif // _LP64
! #define C1_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_PRODUCT) },
! #define C1_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define C1_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DIAGNOSTIC) },
! #define C1_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define C1_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DEVELOP) },
! #define C1_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define C1_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C1 | JVMFlag::KIND_NOT_PRODUCT) },
!
! #define C2_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_PRODUCT) },
! #define C2_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_PRODUCT | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define C2_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DIAGNOSTIC) },
! #define C2_PD_DIAGNOSTIC_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DIAGNOSTIC | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define C2_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_EXPERIMENTAL) },
! #define C2_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DEVELOP) },
! #define C2_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_DEVELOP | JVMFlag::KIND_PLATFORM_DEPENDENT) },
! #define C2_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_C2 | JVMFlag::KIND_NOT_PRODUCT) },
!
! #define ARCH_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_PRODUCT) },
! #define ARCH_DIAGNOSTIC_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_DIAGNOSTIC) },
! #define ARCH_EXPERIMENTAL_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_EXPERIMENTAL) },
! #define ARCH_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_DEVELOP) },
! #define ARCH_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), (void*) &name, NOT_PRODUCT_ARG(doc) JVMFlag::Flags(JVMFlag::DEFAULT | JVMFlag::KIND_ARCH | JVMFlag::KIND_NOT_PRODUCT) },
!
! static JVMFlag flagTable[] = {
! VM_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \
! RUNTIME_PD_DEVELOP_FLAG_STRUCT, \
! RUNTIME_PRODUCT_FLAG_STRUCT, \
! RUNTIME_PD_PRODUCT_FLAG_STRUCT, \
! RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \
! RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \
! RUNTIME_EXPERIMENTAL_FLAG_STRUCT, \
! RUNTIME_NOTPRODUCT_FLAG_STRUCT, \
! RUNTIME_MANAGEABLE_FLAG_STRUCT, \
! RUNTIME_PRODUCT_RW_FLAG_STRUCT, \
! RUNTIME_LP64_PRODUCT_FLAG_STRUCT, \
! IGNORE_RANGE, \
! IGNORE_CONSTRAINT)
!
! RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \
! RUNTIME_PD_DEVELOP_FLAG_STRUCT, \
! RUNTIME_PRODUCT_FLAG_STRUCT, \
! RUNTIME_PD_PRODUCT_FLAG_STRUCT, \
! RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \
! RUNTIME_PD_DIAGNOSTIC_FLAG_STRUCT, \
! RUNTIME_NOTPRODUCT_FLAG_STRUCT, \
! IGNORE_RANGE, \
! IGNORE_CONSTRAINT)
! #if INCLUDE_JVMCI
! JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_STRUCT, \
! JVMCI_PD_DEVELOP_FLAG_STRUCT, \
! JVMCI_PRODUCT_FLAG_STRUCT, \
! JVMCI_PD_PRODUCT_FLAG_STRUCT, \
! JVMCI_DIAGNOSTIC_FLAG_STRUCT, \
! JVMCI_PD_DIAGNOSTIC_FLAG_STRUCT, \
! JVMCI_EXPERIMENTAL_FLAG_STRUCT, \
! JVMCI_NOTPRODUCT_FLAG_STRUCT, \
! IGNORE_RANGE, \
! IGNORE_CONSTRAINT)
! #endif // INCLUDE_JVMCI
! #ifdef COMPILER1
! C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, \
! C1_PD_DEVELOP_FLAG_STRUCT, \
! C1_PRODUCT_FLAG_STRUCT, \
! C1_PD_PRODUCT_FLAG_STRUCT, \
! C1_DIAGNOSTIC_FLAG_STRUCT, \
! C1_PD_DIAGNOSTIC_FLAG_STRUCT, \
! C1_NOTPRODUCT_FLAG_STRUCT, \
! IGNORE_RANGE, \
! IGNORE_CONSTRAINT)
! #endif // COMPILER1
! #ifdef COMPILER2
! C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, \
! C2_PD_DEVELOP_FLAG_STRUCT, \
! C2_PRODUCT_FLAG_STRUCT, \
! C2_PD_PRODUCT_FLAG_STRUCT, \
! C2_DIAGNOSTIC_FLAG_STRUCT, \
! C2_PD_DIAGNOSTIC_FLAG_STRUCT, \
! C2_EXPERIMENTAL_FLAG_STRUCT, \
! C2_NOTPRODUCT_FLAG_STRUCT, \
! IGNORE_RANGE, \
! IGNORE_CONSTRAINT)
! #endif // COMPILER2
! ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, \
! ARCH_PRODUCT_FLAG_STRUCT, \
! ARCH_DIAGNOSTIC_FLAG_STRUCT, \
! ARCH_EXPERIMENTAL_FLAG_STRUCT, \
! ARCH_NOTPRODUCT_FLAG_STRUCT, \
! IGNORE_RANGE, \
! IGNORE_CONSTRAINT)
! {0, NULL, NULL}
! };
! JVMFlag* JVMFlag::flags = flagTable;
! size_t JVMFlag::numFlags = (sizeof(flagTable) / sizeof(JVMFlag));
inline bool str_equal(const char* s, size_t s_len, const char* q, size_t q_len) {
if (s_len != q_len) return false;
return memcmp(s, q, q_len) == 0;
}
// Search the flag table for a named flag
JVMFlag* JVMFlag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) {
! for (JVMFlag* current = &flagTable[0]; current->_name != NULL; current++) {
! if (str_equal(current->_name, current->get_name_length(), name, length)) {
// Found a matching entry.
// Don't report notproduct and develop flags in product builds.
! if (current->is_constant_in_binary()) {
! return (return_flag ? current : NULL);
}
// Report locked flags only if allowed.
! if (!(current->is_unlocked() || current->is_unlocker())) {
if (!allow_locked) {
// disable use of locked flags, e.g. diagnostic, experimental,
// etc. until they are explicitly unlocked
return NULL;
}
}
! return current;
}
}
// JVMFlag name is not in the flag table
return NULL;
}
// Get or compute the flag name length
size_t JVMFlag::get_name_length() {
if (_name_len == 0) {
! _name_len = strlen(_name);
}
! return _name_len;
}
JVMFlag* JVMFlag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
float VMOptionsFuzzyMatchSimilarity = 0.7f;
JVMFlag* match = NULL;
float score;
float max_score = -1;
! for (JVMFlag* current = &flagTable[0]; current->_name != NULL; current++) {
! score = StringUtils::similarity(current->_name, strlen(current->_name), name, length);
if (score > max_score) {
max_score = score;
! match = current;
}
}
if (match == NULL) {
return NULL;
--- 549,642 ----
case JVMFlag::SUCCESS: return "SUCCESS";
default: ShouldNotReachHere(); return "NULL";
}
}
! bool JVMFlag::check_all_ranges() {
! bool status = true;
! bool verbose = true;
! JVMFlag* flag;
! JVMFLAG_FOR_EACH(flag) {
! if (flag->check_range(flag->value_addr(), verbose) != JVMFlag::SUCCESS) {
! status = false;
! }
! }
! return status;
! }
! JVMFlag::ConstraintPhase JVMFlag::_constraint_validating_phase = JVMFlag::AtParse;
! const JVMFlag* JVMFlag::_current_checking = NULL;
! bool JVMFlag::check_all_constraints(JVMFlag::ConstraintPhase phase) {
! guarantee(phase > _constraint_validating_phase, "Constraint check is out of order.");
! _constraint_validating_phase = phase;
!
! bool status = true;
! bool verbose = true;
! JVMFlag* flag;
! JVMFLAG_FOR_EACH(flag) {
! if (flag->check_constraint(flag->value_addr(), verbose) != JVMFlag::SUCCESS) {
! status = false;
! }
! }
! return status;
! }
inline bool str_equal(const char* s, size_t s_len, const char* q, size_t q_len) {
if (s_len != q_len) return false;
return memcmp(s, q, q_len) == 0;
}
// Search the flag table for a named flag
JVMFlag* JVMFlag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) {
! JVMFlag* flag;
! char c = name[0];
! JVMFLAG_FOR_EACH(flag) {
! if (c == flag->_name[0] && str_equal(flag->_name, flag->get_name_length(), name, length)) {
// Found a matching entry.
// Don't report notproduct and develop flags in product builds.
! if (flag->is_constant_in_binary()) {
! return (return_flag ? flag : NULL);
}
// Report locked flags only if allowed.
! if (!(flag->is_unlocked() || flag->is_unlocker())) {
if (!allow_locked) {
// disable use of locked flags, e.g. diagnostic, experimental,
// etc. until they are explicitly unlocked
return NULL;
}
}
! return flag;
}
}
// JVMFlag name is not in the flag table
return NULL;
}
// Get or compute the flag name length
size_t JVMFlag::get_name_length() {
if (_name_len == 0) {
! size_t len = strlen(_name);
! assert(len < 0x7fff, "flag name is too long!");
! _name_len = (short)len;
}
! return (size_t)_name_len;
}
JVMFlag* JVMFlag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
float VMOptionsFuzzyMatchSimilarity = 0.7f;
JVMFlag* match = NULL;
float score;
float max_score = -1;
! JVMFlag* flag;
! JVMFLAG_FOR_EACH(flag) {
! score = StringUtils::similarity(flag->name(), strlen(flag->name()), name, length);
if (score > max_score) {
max_score = score;
! match = flag;
}
}
if (match == NULL) {
return NULL;
*** 819,1249 ****
}
return match;
}
! // Returns the address of the index'th element
! JVMFlag* JVMFlagEx::flag_from_enum(JVMFlagsEnum flag) {
! assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
! return &JVMFlag::flags[flag];
! }
!
! bool JVMFlagEx::is_default(JVMFlagsEnum flag) {
! return flag_from_enum(flag)->is_default();
! }
!
! bool JVMFlagEx::is_ergo(JVMFlagsEnum flag) {
! return flag_from_enum(flag)->is_ergonomic();
}
- bool JVMFlagEx::is_cmdline(JVMFlagsEnum flag) {
- return flag_from_enum(flag)->is_command_line();
- }
! void JVMFlagEx::setOnCmdLine(JVMFlagsEnum flag) {
! JVMFlag* faddr = flag_from_enum(flag);
! assert(faddr != NULL, "Unknown flag");
! faddr->set_command_line();
! }
template<class E, class T>
! static void trace_flag_changed(const JVMFlag* flag, const T old_value, const T new_value, const JVMFlag::Flags origin) {
E e;
! e.set_name(flag->_name);
e.set_oldValue(old_value);
e.set_newValue(new_value);
e.set_origin(origin);
e.commit();
}
! static JVMFlag::Error apply_constraint_and_check_range_bool(const JVMFlag* flag, bool new_value, bool verbose) {
! JVMFlag::Error status = JVMFlag::SUCCESS;
! JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
! if (constraint != NULL) {
! status = constraint->apply_bool(new_value, verbose);
! }
! return status;
! }
!
! JVMFlag::Error JVMFlag::boolAt(const JVMFlag* flag, bool* value) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_bool()) return JVMFlag::WRONG_FORMAT;
! *value = flag->get_bool();
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlag::boolAtPut(JVMFlag* flag, bool* value, JVMFlag::Flags origin) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_bool()) return JVMFlag::WRONG_FORMAT;
! JVMFlag::Error check = apply_constraint_and_check_range_bool(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
! if (check != JVMFlag::SUCCESS) return check;
! bool old_value = flag->get_bool();
! trace_flag_changed<EventBooleanFlagChanged, bool>(flag, old_value, *value, origin);
! flag->set_bool(*value);
! *value = old_value;
! flag->set_origin(origin);
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlagEx::boolAtPut(JVMFlagsEnum flag, bool value, JVMFlag::Flags origin) {
! JVMFlag* faddr = flag_from_enum(flag);
! guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
! return JVMFlag::boolAtPut(faddr, &value, origin);
! }
!
! static JVMFlag::Error apply_constraint_and_check_range_int(const JVMFlag* flag, int new_value, bool verbose) {
! JVMFlag::Error status = JVMFlag::SUCCESS;
! JVMFlagRange* range = JVMFlagRangeList::find(flag);
! if (range != NULL) {
! status = range->check_int(new_value, verbose);
! }
! if (status == JVMFlag::SUCCESS) {
! JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
! if (constraint != NULL) {
! status = constraint->apply_int(new_value, verbose);
! }
! }
! return status;
! }
!
! JVMFlag::Error JVMFlag::intAt(const JVMFlag* flag, int* value) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_int()) return JVMFlag::WRONG_FORMAT;
! *value = flag->get_int();
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlag::intAtPut(JVMFlag* flag, int* value, JVMFlag::Flags origin) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_int()) return JVMFlag::WRONG_FORMAT;
! JVMFlag::Error check = apply_constraint_and_check_range_int(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
! if (check != JVMFlag::SUCCESS) return check;
! int old_value = flag->get_int();
! trace_flag_changed<EventIntFlagChanged, s4>(flag, old_value, *value, origin);
! flag->set_int(*value);
! *value = old_value;
! flag->set_origin(origin);
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlagEx::intAtPut(JVMFlagsEnum flag, int value, JVMFlag::Flags origin) {
! JVMFlag* faddr = flag_from_enum(flag);
! guarantee(faddr != NULL && faddr->is_int(), "wrong flag type");
! return JVMFlag::intAtPut(faddr, &value, origin);
! }
!
! static JVMFlag::Error apply_constraint_and_check_range_uint(const JVMFlag* flag, uint new_value, bool verbose) {
! JVMFlag::Error status = JVMFlag::SUCCESS;
! JVMFlagRange* range = JVMFlagRangeList::find(flag);
! if (range != NULL) {
! status = range->check_uint(new_value, verbose);
! }
if (status == JVMFlag::SUCCESS) {
! JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
! if (constraint != NULL) {
! status = constraint->apply_uint(new_value, verbose);
! }
}
return status;
}
! JVMFlag::Error JVMFlag::uintAt(const JVMFlag* flag, uint* value) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_uint()) return JVMFlag::WRONG_FORMAT;
! *value = flag->get_uint();
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlag::uintAtPut(JVMFlag* flag, uint* value, JVMFlag::Flags origin) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_uint()) return JVMFlag::WRONG_FORMAT;
! JVMFlag::Error check = apply_constraint_and_check_range_uint(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
! if (check != JVMFlag::SUCCESS) return check;
! uint old_value = flag->get_uint();
! trace_flag_changed<EventUnsignedIntFlagChanged, u4>(flag, old_value, *value, origin);
! flag->set_uint(*value);
! *value = old_value;
! flag->set_origin(origin);
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlagEx::uintAtPut(JVMFlagsEnum flag, uint value, JVMFlag::Flags origin) {
! JVMFlag* faddr = flag_from_enum(flag);
! guarantee(faddr != NULL && faddr->is_uint(), "wrong flag type");
! return JVMFlag::uintAtPut(faddr, &value, origin);
! }
!
! JVMFlag::Error JVMFlag::intxAt(const JVMFlag* flag, intx* value) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_intx()) return JVMFlag::WRONG_FORMAT;
! *value = flag->get_intx();
! return JVMFlag::SUCCESS;
! }
!
! static JVMFlag::Error apply_constraint_and_check_range_intx(const JVMFlag* flag, intx new_value, bool verbose) {
! JVMFlag::Error status = JVMFlag::SUCCESS;
! JVMFlagRange* range = JVMFlagRangeList::find(flag);
! if (range != NULL) {
! status = range->check_intx(new_value, verbose);
! }
! if (status == JVMFlag::SUCCESS) {
! JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
! if (constraint != NULL) {
! status = constraint->apply_intx(new_value, verbose);
! }
! }
! return status;
! }
!
! JVMFlag::Error JVMFlag::intxAtPut(JVMFlag* flag, intx* value, JVMFlag::Flags origin) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_intx()) return JVMFlag::WRONG_FORMAT;
! JVMFlag::Error check = apply_constraint_and_check_range_intx(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
! if (check != JVMFlag::SUCCESS) return check;
! intx old_value = flag->get_intx();
! trace_flag_changed<EventLongFlagChanged, intx>(flag, old_value, *value, origin);
! flag->set_intx(*value);
! *value = old_value;
! flag->set_origin(origin);
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlagEx::intxAtPut(JVMFlagsEnum flag, intx value, JVMFlag::Flags origin) {
! JVMFlag* faddr = flag_from_enum(flag);
! guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
! return JVMFlag::intxAtPut(faddr, &value, origin);
! }
!
! JVMFlag::Error JVMFlag::uintxAt(const JVMFlag* flag, uintx* value) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_uintx()) return JVMFlag::WRONG_FORMAT;
! *value = flag->get_uintx();
! return JVMFlag::SUCCESS;
! }
!
! static JVMFlag::Error apply_constraint_and_check_range_uintx(const JVMFlag* flag, uintx new_value, bool verbose) {
! JVMFlag::Error status = JVMFlag::SUCCESS;
! JVMFlagRange* range = JVMFlagRangeList::find(flag);
! if (range != NULL) {
! status = range->check_uintx(new_value, verbose);
! }
! if (status == JVMFlag::SUCCESS) {
! JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
! if (constraint != NULL) {
! status = constraint->apply_uintx(new_value, verbose);
}
}
- return status;
- }
! JVMFlag::Error JVMFlag::uintxAtPut(JVMFlag* flag, uintx* value, JVMFlag::Flags origin) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_uintx()) return JVMFlag::WRONG_FORMAT;
! JVMFlag::Error check = apply_constraint_and_check_range_uintx(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
! if (check != JVMFlag::SUCCESS) return check;
! uintx old_value = flag->get_uintx();
! trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
! flag->set_uintx(*value);
! *value = old_value;
! flag->set_origin(origin);
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlagEx::uintxAtPut(JVMFlagsEnum flag, uintx value, JVMFlag::Flags origin) {
! JVMFlag* faddr = flag_from_enum(flag);
! guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
! return JVMFlag::uintxAtPut(faddr, &value, origin);
! }
!
! JVMFlag::Error JVMFlag::uint64_tAt(const JVMFlag* flag, uint64_t* value) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_uint64_t()) return JVMFlag::WRONG_FORMAT;
! *value = flag->get_uint64_t();
! return JVMFlag::SUCCESS;
! }
!
! static JVMFlag::Error apply_constraint_and_check_range_uint64_t(const JVMFlag* flag, uint64_t new_value, bool verbose) {
! JVMFlag::Error status = JVMFlag::SUCCESS;
! JVMFlagRange* range = JVMFlagRangeList::find(flag);
! if (range != NULL) {
! status = range->check_uint64_t(new_value, verbose);
! }
if (status == JVMFlag::SUCCESS) {
! JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
! if (constraint != NULL) {
! status = constraint->apply_uint64_t(new_value, verbose);
! }
! }
! return status;
! }
!
! JVMFlag::Error JVMFlag::uint64_tAtPut(JVMFlag* flag, uint64_t* value, JVMFlag::Flags origin) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_uint64_t()) return JVMFlag::WRONG_FORMAT;
! JVMFlag::Error check = apply_constraint_and_check_range_uint64_t(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
! if (check != JVMFlag::SUCCESS) return check;
! uint64_t old_value = flag->get_uint64_t();
! trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
! flag->set_uint64_t(*value);
! *value = old_value;
flag->set_origin(origin);
- return JVMFlag::SUCCESS;
- }
-
- JVMFlag::Error JVMFlagEx::uint64_tAtPut(JVMFlagsEnum flag, uint64_t value, JVMFlag::Flags origin) {
- JVMFlag* faddr = flag_from_enum(flag);
- guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
- return JVMFlag::uint64_tAtPut(faddr, &value, origin);
- }
-
- JVMFlag::Error JVMFlag::size_tAt(const JVMFlag* flag, size_t* value) {
- if (flag == NULL) return JVMFlag::INVALID_FLAG;
- if (!flag->is_size_t()) return JVMFlag::WRONG_FORMAT;
- *value = flag->get_size_t();
- return JVMFlag::SUCCESS;
- }
-
- static JVMFlag::Error apply_constraint_and_check_range_size_t(const JVMFlag* flag, size_t new_value, bool verbose) {
- JVMFlag::Error status = JVMFlag::SUCCESS;
- JVMFlagRange* range = JVMFlagRangeList::find(flag);
- if (range != NULL) {
- status = range->check_size_t(new_value, verbose);
- }
- if (status == JVMFlag::SUCCESS) {
- JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
- if (constraint != NULL) {
- status = constraint->apply_size_t(new_value, verbose);
- }
}
return status;
}
!
! JVMFlag::Error JVMFlag::size_tAtPut(JVMFlag* flag, size_t* value, JVMFlag::Flags origin) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_size_t()) return JVMFlag::WRONG_FORMAT;
! JVMFlag::Error check = apply_constraint_and_check_range_size_t(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
! if (check != JVMFlag::SUCCESS) return check;
! size_t old_value = flag->get_size_t();
! trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
! flag->set_size_t(*value);
! *value = old_value;
! flag->set_origin(origin);
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlagEx::size_tAtPut(JVMFlagsEnum flag, size_t value, JVMFlag::Flags origin) {
! JVMFlag* faddr = flag_from_enum(flag);
! guarantee(faddr != NULL && faddr->is_size_t(), "wrong flag type");
! return JVMFlag::size_tAtPut(faddr, &value, origin);
! }
!
! JVMFlag::Error JVMFlag::doubleAt(const JVMFlag* flag, double* value) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_double()) return JVMFlag::WRONG_FORMAT;
! *value = flag->get_double();
! return JVMFlag::SUCCESS;
! }
!
! static JVMFlag::Error apply_constraint_and_check_range_double(const JVMFlag* flag, double new_value, bool verbose) {
! JVMFlag::Error status = JVMFlag::SUCCESS;
! JVMFlagRange* range = JVMFlagRangeList::find(flag);
! if (range != NULL) {
! status = range->check_double(new_value, verbose);
}
! if (status == JVMFlag::SUCCESS) {
! JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
! if (constraint != NULL) {
! status = constraint->apply_double(new_value, verbose);
}
- }
- return status;
- }
! JVMFlag::Error JVMFlag::doubleAtPut(JVMFlag* flag, double* value, JVMFlag::Flags origin) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_double()) return JVMFlag::WRONG_FORMAT;
! JVMFlag::Error check = apply_constraint_and_check_range_double(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
! if (check != JVMFlag::SUCCESS) return check;
! double old_value = flag->get_double();
! trace_flag_changed<EventDoubleFlagChanged, double>(flag, old_value, *value, origin);
! flag->set_double(*value);
! *value = old_value;
! flag->set_origin(origin);
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlagEx::doubleAtPut(JVMFlagsEnum flag, double value, JVMFlag::Flags origin) {
! JVMFlag* faddr = flag_from_enum(flag);
! guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
! return JVMFlag::doubleAtPut(faddr, &value, origin);
! }
!
! JVMFlag::Error JVMFlag::ccstrAt(const JVMFlag* flag, ccstr* value) {
! if (flag == NULL) return JVMFlag::INVALID_FLAG;
! if (!flag->is_ccstr()) return JVMFlag::WRONG_FORMAT;
! *value = flag->get_ccstr();
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlag::ccstrAtPut(JVMFlag* flag, ccstr* value, JVMFlag::Flags 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<EventStringFlagChanged, const char*>(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) {
// Prior value is NOT heap allocated, but was a literal constant.
old_value = os::strdup_check_oom(old_value);
}
! *value = old_value;
flag->set_origin(origin);
! return JVMFlag::SUCCESS;
! }
!
! JVMFlag::Error JVMFlagEx::ccstrAtPut(JVMFlagsEnum flag, ccstr value, JVMFlag::Flags origin) {
! JVMFlag* faddr = flag_from_enum(flag);
! guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
! ccstr old_value = faddr->get_ccstr();
! trace_flag_changed<EventStringFlagChanged, const char*>(faddr, old_value, value, origin);
! char* new_value = os::strdup_check_oom(value);
! faddr->set_ccstr(new_value);
! if (!faddr->is_default() && old_value != NULL) {
! // Prior value is heap allocated so free it.
! FREE_C_HEAP_ARRAY(char, old_value);
! }
! faddr->set_origin(origin);
! return JVMFlag::SUCCESS;
}
extern "C" {
static int compare_flags(const void* void_a, const void* void_b) {
! return strcmp((*((JVMFlag**) void_a))->_name, (*((JVMFlag**) void_b))->_name);
}
}
void JVMFlag::printSetFlags(outputStream* out) {
// Print which flags were set on the command line
// note: this method is called before the thread structure is in place
// which means resource allocation cannot be used.
! // The last entry is the null entry.
! const size_t length = JVMFlag::numFlags - 1;
// Sort
JVMFlag** array = NEW_C_HEAP_ARRAY(JVMFlag*, length, mtArguments);
! for (size_t i = 0; i < length; i++) {
! array[i] = &flagTable[i];
}
qsort(array, length, sizeof(JVMFlag*), compare_flags);
// Print
! for (size_t i = 0; i < length; i++) {
if (array[i]->get_origin() /* naked field! */) {
array[i]->print_as_flag(out);
out->print(" ");
}
}
--- 653,784 ----
}
return match;
}
! template <typename T>
! static JVMFlag::Error get_flag(const JVMFlag* flag, JVMFlag::FlagType type, T* value) {
! if (flag == NULL) {
! return JVMFlag::INVALID_FLAG;
! }
! if (flag->type() != type) {
! return JVMFlag::WRONG_FORMAT;
! }
! *value = TypedJVMFlag<T>::cast(flag)->get_value();
! return JVMFlag::SUCCESS;
}
! JVMFlag::Error JVMFlag::boolAt (const JVMFlag* f, bool* v) { return get_flag(f, TYPE_bool, v); }
! JVMFlag::Error JVMFlag::intAt (const JVMFlag* f, int* v) { return get_flag(f, TYPE_int, v); }
! JVMFlag::Error JVMFlag::uintAt (const JVMFlag* f, uint* v) { return get_flag(f, TYPE_uint, v); }
! JVMFlag::Error JVMFlag::intxAt (const JVMFlag* f, intx* v) { return get_flag(f, TYPE_intx, v); }
! JVMFlag::Error JVMFlag::uintxAt (const JVMFlag* f, uintx* v) { return get_flag(f, TYPE_uintx, v); }
! JVMFlag::Error JVMFlag::size_tAt (const JVMFlag* f, size_t* v) { return get_flag(f, TYPE_size_t, v); }
! JVMFlag::Error JVMFlag::uint64_tAt(const JVMFlag* f, uint64_t* v) { return get_flag(f, TYPE_uint64_t, v); }
! JVMFlag::Error JVMFlag::doubleAt (const JVMFlag* f, double* v) { return get_flag(f, TYPE_double, v); }
! JVMFlag::Error JVMFlag::ccstrAt (const JVMFlag* f, ccstr* v) { return get_flag(f, TYPE_ccstr, v); }
template<class E, class T>
! static void trace_flag_changed(const JVMFlag* flag, T old_value, T new_value, JVMFlag::Attr origin) {
E e;
! e.set_name(flag->name());
e.set_oldValue(old_value);
e.set_newValue(new_value);
e.set_origin(origin);
e.commit();
}
! template <typename T>
! JVMFlag::Error ProductFlag<T>::check_new_value(T new_value, JVMFlag::Attr origin) {
! bool verbose = JVMFlag::verbose_checking();
! JVMFlag::Error status = this->check_range((void*)(&new_value), verbose);
if (status == JVMFlag::SUCCESS) {
! JVMFlag::set_current_checking(this);
! status = this->check_constraint((void*)(&new_value), verbose);
! JVMFlag::set_current_checking(NULL);
}
return status;
}
! template <typename T, class TraceEvent, class TraceType>
! static JVMFlag::Error flagAtPut(JVMFlag* f, T new_value, JVMFlag::Attr origin, JVMFlag::FlagType type) {
! if (f == NULL) {
! return JVMFlag::INVALID_FLAG;
}
+ if (f->type() != type) {
+ return JVMFlag::WRONG_FORMAT;
}
! ProductFlag<T>* flag = ProductFlag<T>::cast_non_const(f);
! JVMFlag::Error status = flag->check_new_value(new_value, origin);
if (status == JVMFlag::SUCCESS) {
! trace_flag_changed<TraceEvent, TraceType>(flag, flag->get_value(), new_value, origin);
! flag->write_value(new_value);
flag->set_origin(origin);
}
return status;
}
! JVMFlag::Error JVMFlag::boolAtPut (JVMFlag* f, bool v, JVMFlag::Flags o) { return flagAtPut<bool, EventBooleanFlagChanged, bool>(f, v, o, TYPE_bool);}
! JVMFlag::Error JVMFlag::intAtPut (JVMFlag* f, int v, JVMFlag::Flags o) { return flagAtPut<int, EventIntFlagChanged, s4>(f, v, o, TYPE_int);}
! JVMFlag::Error JVMFlag::uintAtPut (JVMFlag* f, uint v, JVMFlag::Flags o) { return flagAtPut<uint, EventUnsignedIntFlagChanged, u4>(f, v, o, TYPE_uint);}
! JVMFlag::Error JVMFlag::intxAtPut (JVMFlag* f, intx v, JVMFlag::Flags o) { return flagAtPut<intx, EventLongFlagChanged, intx>(f, v, o, TYPE_intx);}
! JVMFlag::Error JVMFlag::uintxAtPut (JVMFlag* f, uintx v, JVMFlag::Flags o) { return flagAtPut<uintx, EventUnsignedLongFlagChanged, u8>(f, v, o, TYPE_uintx);}
! JVMFlag::Error JVMFlag::uint64_tAtPut(JVMFlag* f, uint64_t v, JVMFlag::Flags o) { return flagAtPut<uint64_t, EventUnsignedLongFlagChanged, u8>(f, v, o, TYPE_uint64_t);}
! JVMFlag::Error JVMFlag::size_tAtPut (JVMFlag* f, size_t v, JVMFlag::Flags o) { return flagAtPut<size_t, EventUnsignedLongFlagChanged, u8>(f, v, o, TYPE_size_t);}
! JVMFlag::Error JVMFlag::doubleAtPut (JVMFlag* f, double v, JVMFlag::Flags o) { return flagAtPut<double, EventDoubleFlagChanged, double>(f, v, o, TYPE_double);}
!
! JVMFlag::Error JVMFlag::ccstrAtPut(JVMFlag* f, ccstr* value, JVMFlag::Flags origin) {
! if (f == NULL) {
! return JVMFlag::INVALID_FLAG;
}
! if (!f->is_ccstr()) {
! return JVMFlag::WRONG_FORMAT;
}
! ProductFlag<ccstr> *flag = ProductFlag<ccstr>::cast_non_const(f);
! ccstr old_value = flag->get_value();
trace_flag_changed<EventStringFlagChanged, const char*>(flag, old_value, *value, origin);
char* new_value = NULL;
if (*value != NULL) {
new_value = os::strdup_check_oom(*value);
}
if (flag->is_default() && old_value != NULL) {
// Prior value is NOT heap allocated, but was a literal constant.
old_value = os::strdup_check_oom(old_value);
}
! flag->write_value(new_value);
flag->set_origin(origin);
! *value = old_value;
! return SUCCESS;
}
extern "C" {
static int compare_flags(const void* void_a, const void* void_b) {
! return strcmp((*((JVMFlag**) void_a))->name(), (*((JVMFlag**) void_b))->name());
}
}
void JVMFlag::printSetFlags(outputStream* out) {
// Print which flags were set on the command line
// note: this method is called before the thread structure is in place
// which means resource allocation cannot be used.
! int length = JVMFlag::num_flags();
// Sort
JVMFlag** array = NEW_C_HEAP_ARRAY(JVMFlag*, length, mtArguments);
! JVMFlag* flag;
! int i = 0;
! JVMFLAG_FOR_EACH(flag) {
! array[i++] = flag;
}
qsort(array, length, sizeof(JVMFlag*), compare_flags);
// Print
! for (i = 0; i < length; i++) {
if (array[i]->get_origin() /* naked field! */) {
array[i]->print_as_flag(out);
out->print(" ");
}
}
*** 1263,1301 ****
// Print the flags sorted by name
// Note: This method may be called before the thread structure is in place
// which means resource allocation cannot be used. Also, it may be
// called as part of error reporting, so handle native OOMs gracefully.
! // The last entry is the null entry.
! const size_t length = JVMFlag::numFlags - 1;
// Print
if (!printRanges) {
out->print_cr("[Global flags]");
} else {
out->print_cr("[Global flags ranges]");
}
// Sort
JVMFlag** array = NEW_C_HEAP_ARRAY_RETURN_NULL(JVMFlag*, length, mtArguments);
if (array != NULL) {
! for (size_t i = 0; i < length; i++) {
! array[i] = &flagTable[i];
}
qsort(array, length, sizeof(JVMFlag*), compare_flags);
! for (size_t i = 0; i < length; i++) {
if (array[i]->is_unlocked() && !(skipDefaults && array[i]->is_default())) {
array[i]->print_on(out, withComments, printRanges);
}
}
FREE_C_HEAP_ARRAY(JVMFlag*, array);
} else {
// OOM? Print unsorted.
! for (size_t i = 0; i < length; i++) {
! if (flagTable[i].is_unlocked() && !(skipDefaults && flagTable[i].is_default())) {
! flagTable[i].print_on(out, withComments, printRanges);
}
}
}
}
--- 798,837 ----
// Print the flags sorted by name
// Note: This method may be called before the thread structure is in place
// which means resource allocation cannot be used. Also, it may be
// called as part of error reporting, so handle native OOMs gracefully.
! int length = JVMFlag::num_flags();
! JVMFlag* flag;
// Print
if (!printRanges) {
out->print_cr("[Global flags]");
} else {
out->print_cr("[Global flags ranges]");
}
// Sort
JVMFlag** array = NEW_C_HEAP_ARRAY_RETURN_NULL(JVMFlag*, length, mtArguments);
+ int i = 0;
if (array != NULL) {
! JVMFLAG_FOR_EACH(flag) {
! array[i++] = flag;
}
qsort(array, length, sizeof(JVMFlag*), compare_flags);
! for (i = 0; i < length; i++) {
if (array[i]->is_unlocked() && !(skipDefaults && array[i]->is_default())) {
array[i]->print_on(out, withComments, printRanges);
}
}
FREE_C_HEAP_ARRAY(JVMFlag*, array);
} else {
// OOM? Print unsorted.
! JVMFLAG_FOR_EACH(flag) {
! if (flag->is_unlocked() && !(skipDefaults && flag->is_default())) {
! flag->print_on(out, withComments, printRanges);
}
}
}
}
*** 1305,1309 ****
--- 841,846 ----
va_start(listPointer, msg);
jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
va_end(listPointer);
}
}
+
< prev index next >