src/share/vm/runtime/globals.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/vm/runtime/globals.cpp Wed May 27 10:37:38 2015
--- new/src/share/vm/runtime/globals.cpp Wed May 27 10:37:38 2015
*** 1,7 ****
--- 1,7 ----
/*
! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
! * Copyright (c) 1997, 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.
*** 26,36 ****
--- 26,39 ----
#include "memory/allocation.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/arguments.hpp"
#include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp"
+ #include "runtime/commandLineFlagConstraintList.hpp"
+ #include "runtime/commandLineFlagRangeList.hpp"
#include "runtime/os.hpp"
+ #include "runtime/sharedRuntime.hpp"
#include "trace/tracing.hpp"
#include "utilities/ostream.hpp"
#include "utilities/macros.hpp"
#include "utilities/top.hpp"
#if INCLUDE_ALL_GCS
*** 46,73 ****
--- 49,90 ----
#include "shark/shark_globals.hpp"
#endif
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
- RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
! MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
! MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
! MATERIALIZE_PD_DEVELOPER_FLAG, \
! MATERIALIZE_PRODUCT_FLAG, \
+ MATERIALIZE_PD_PRODUCT_FLAG, \
+ MATERIALIZE_DIAGNOSTIC_FLAG, \
+ MATERIALIZE_EXPERIMENTAL_FLAG, \
MATERIALIZE_NOTPRODUCT_FLAG, \
- MATERIALIZE_MANAGEABLE_FLAG, MATERIALIZE_PRODUCT_RW_FLAG, \
! MATERIALIZE_LP64_PRODUCT_FLAG)
! MATERIALIZE_PRODUCT_RW_FLAG, \
+ MATERIALIZE_LP64_PRODUCT_FLAG, \
+ IGNORE_RANGE, \
+ IGNORE_CONSTRAINT)
+
+ RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \
+ MATERIALIZE_PD_DEVELOPER_FLAG, \
+ MATERIALIZE_PRODUCT_FLAG, \
+ MATERIALIZE_PD_PRODUCT_FLAG, \
+ MATERIALIZE_DIAGNOSTIC_FLAG, \
+ MATERIALIZE_NOTPRODUCT_FLAG, \
+ IGNORE_RANGE, \
+ IGNORE_CONSTRAINT)
! RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
! MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG)
! ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, \
! MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
! MATERIALIZE_NOTPRODUCT_FLAG)
! ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \
! MATERIALIZE_PRODUCT_FLAG, \
+ MATERIALIZE_DIAGNOSTIC_FLAG, \
+ MATERIALIZE_EXPERIMENTAL_FLAG, \
! MATERIALIZE_NOTPRODUCT_FLAG, \
! IGNORE_RANGE, \
! IGNORE_CONSTRAINT)
MATERIALIZE_FLAGS_EXT
static bool is_product_build() {
#ifdef PRODUCT
return true;
#else
return false;
*** 303,339 ****
--- 320,352 ----
// Length of format string (e.g. "%.1234s") for printing ccstr below
#define FORMAT_BUFFER_LEN 16
PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL
! void Flag::print_on(outputStream* st, bool printRanges, bool withComments) {
// Don't print notproduct and develop flags in a product build.
if (is_constant_in_binary()) {
return;
}
+ if (printRanges == false) {
+
st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' '));
if (is_bool()) {
st->print("%-16s", get_bool() ? "true" : "false");
! } else if (is_intx()) {
if (is_intx()) {
st->print("%-16ld", get_intx());
! } else if (is_uintx()) {
if (is_uintx()) {
st->print("%-16lu", get_uintx());
! } else if (is_uint64_t()) {
if (is_uint64_t()) {
st->print("%-16lu", get_uint64_t());
! } else if (is_size_t()) {
if (is_size_t()) {
st->print(SIZE_FORMAT_W(-16), get_size_t());
! } else if (is_double()) {
if (is_double()) {
st->print("%-16f", get_double());
! } else if (is_ccstr()) {
if (is_ccstr()) {
const char* cp = get_ccstr();
if (cp != NULL) {
const char* eol;
while ((eol = strchr(cp, '\n')) != NULL) {
char format_buffer[FORMAT_BUFFER_LEN];
*** 354,369 ****
--- 367,405 ----
}
st->print("%-20s", " ");
print_kind(st);
if (withComments) {
#ifndef PRODUCT
+ if (withComments) {
st->print("%s", _doc);
+ }
#endif
+
+ st->cr();
+
+ } else if ((is_bool() == false) && (is_ccstr() == false)) {
+
+ if (printRanges == true) {
+
+ st->print("%9s %-50s ", _type, _name);
+
+ CommandLineFlagRangeList::print(_name, st, true);
+
+ st->print(" %-20s", " ");
+ print_kind(st);
+
+ #ifndef PRODUCT
+ if (withComments) {
+ st->print("%s", _doc);
}
+ #endif
+
st->cr();
+
+ }
+ }
}
void Flag::print_kind(outputStream* st) {
struct Data {
int flag;
*** 493,517 ****
--- 529,607 ----
#define SHARK_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP) },
#define SHARK_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) },
#define SHARK_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_SHARK | Flag::KIND_NOT_PRODUCT) },
static Flag flagTable[] = {
! RUNTIME_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_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)
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_NOTPRODUCT_FLAG_STRUCT)
! RUNTIME_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \
+ RUNTIME_PD_DEVELOP_FLAG_STRUCT, \
+ RUNTIME_PRODUCT_FLAG_STRUCT, \
+ RUNTIME_PD_PRODUCT_FLAG_STRUCT, \
+ RUNTIME_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_NOTPRODUCT_FLAG_STRUCT, \
+ IGNORE_RANGE, \
+ IGNORE_CONSTRAINT)
#if INCLUDE_ALL_GCS
! G1_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_EXPERIMENTAL_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT, RUNTIME_MANAGEABLE_FLAG_STRUCT, RUNTIME_PRODUCT_RW_FLAG_STRUCT)
! G1_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \
+ RUNTIME_PD_DEVELOP_FLAG_STRUCT, \
+ RUNTIME_PRODUCT_FLAG_STRUCT, \
+ RUNTIME_PD_PRODUCT_FLAG_STRUCT, \
+ RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \
+ RUNTIME_EXPERIMENTAL_FLAG_STRUCT, \
+ RUNTIME_NOTPRODUCT_FLAG_STRUCT, \
+ RUNTIME_MANAGEABLE_FLAG_STRUCT, \
+ RUNTIME_PRODUCT_RW_FLAG_STRUCT, \
+ IGNORE_RANGE, \
+ IGNORE_CONSTRAINT)
#endif // INCLUDE_ALL_GCS
#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_NOTPRODUCT_FLAG_STRUCT)
#endif
! 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_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_EXPERIMENTAL_FLAG_STRUCT, C2_NOTPRODUCT_FLAG_STRUCT)
#endif
! 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_EXPERIMENTAL_FLAG_STRUCT, \
+ C2_NOTPRODUCT_FLAG_STRUCT, \
+ IGNORE_RANGE, \
+ IGNORE_CONSTRAINT)
+ #endif // COMPILER2
#ifdef SHARK
! SHARK_FLAGS(SHARK_DEVELOP_FLAG_STRUCT, SHARK_PD_DEVELOP_FLAG_STRUCT, SHARK_PRODUCT_FLAG_STRUCT, SHARK_PD_PRODUCT_FLAG_STRUCT, SHARK_DIAGNOSTIC_FLAG_STRUCT, SHARK_NOTPRODUCT_FLAG_STRUCT)
#endif
ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, ARCH_PRODUCT_FLAG_STRUCT, ARCH_DIAGNOSTIC_FLAG_STRUCT, ARCH_EXPERIMENTAL_FLAG_STRUCT, ARCH_NOTPRODUCT_FLAG_STRUCT)
! SHARK_FLAGS(SHARK_DEVELOP_FLAG_STRUCT, \
+ SHARK_PD_DEVELOP_FLAG_STRUCT, \
+ SHARK_PRODUCT_FLAG_STRUCT, \
+ SHARK_PD_PRODUCT_FLAG_STRUCT, \
+ SHARK_DIAGNOSTIC_FLAG_STRUCT, \
+ SHARK_NOTPRODUCT_FLAG_STRUCT)
+ #endif // SHARK
+ 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)
FLAGTABLE_EXT
{0, NULL, NULL}
};
Flag* Flag::flags = flagTable;
*** 623,822 ****
--- 713,1040 ----
*value = result->is_command_line();
return true;
}
template<class E, class T>
! static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin) {
{
E e;
e.set_name(name);
e.set_old_value(old_value);
e.set_new_value(new_value);
e.set_origin(origin);
e.commit();
}
! bool CommandLineFlags::boolAt(const char* name, size_t len, bool* value, bool allow_locked, bool return_flag) {
! static Flag::Error get_status_error(Flag::Error status_range, Flag::Error status_constraint) {
+ if (status_range != Flag::SUCCESS) {
+ return status_range;
+ } else if (status_constraint != Flag::SUCCESS) {
+ return status_constraint;
+ } else {
+ return Flag::SUCCESS;
+ }
+ }
+
+ static Flag::Error apply_constraint_and_check_range_bool(const char* name, bool* new_value, bool verbose = true) {
+ Flag::Error status = Flag::SUCCESS;
+ CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name);
+ if (constraint != NULL) {
+ status = constraint->apply_bool(new_value, verbose);
+ }
+ return status;
+ }
+
+ Flag::Error CommandLineFlags::boolAt(const char* name, size_t len, bool* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
! if (result == NULL) return false;
! if (!result->is_bool()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_bool()) return Flag::WRONG_FORMAT;
*value = result->get_bool();
! return true;
! return Flag::SUCCESS;
}
! bool CommandLineFlags::boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin) {
! Flag::Error CommandLineFlags::boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
! if (result == NULL) return false;
! if (!result->is_bool()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_bool()) return Flag::WRONG_FORMAT;
bool old_value = result->get_bool();
+ Flag::Error check = apply_constraint_and_check_range_bool(name, value, (CommandLineFlags::finishedInitializing()==false));
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
result->set_bool(*value);
*value = old_value;
result->set_origin(origin);
! return true;
! return Flag::SUCCESS;
}
! void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
! Flag::Error CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
+ Flag::Error check = apply_constraint_and_check_range_bool(faddr->_name, &value);
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin);
faddr->set_bool(value);
faddr->set_origin(origin);
+ return Flag::SUCCESS;
}
! bool CommandLineFlags::intxAt(const char* name, size_t len, intx* value, bool allow_locked, bool return_flag) {
! Flag::Error CommandLineFlags::intxAt(const char* name, size_t len, intx* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
! if (result == NULL) return false;
! if (!result->is_intx()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_intx()) return Flag::WRONG_FORMAT;
*value = result->get_intx();
! return true;
! return Flag::SUCCESS;
+ }
+
+ static Flag::Error apply_constraint_and_check_range_intx(const char* name, intx* new_value, bool verbose = true) {
+ Flag::Error range_status = Flag::SUCCESS;
+ CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
+ if (range != NULL) {
+ range_status = range->check_intx(*new_value, verbose);
+ }
+
+ Flag::Error constraint_status = Flag::SUCCESS;
+ CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name);
+ if (constraint != NULL) {
+ constraint_status = constraint->apply_intx(new_value, verbose);
+ }
+
+ return get_status_error(range_status, constraint_status);
}
! bool CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) {
! Flag::Error CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
! if (result == NULL) return false;
! if (!result->is_intx()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_intx()) return Flag::WRONG_FORMAT;
intx old_value = result->get_intx();
! trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin);
! Flag::Error check = apply_constraint_and_check_range_intx(name, value, (CommandLineFlags::finishedInitializing()==false));
+ if (check != Flag::SUCCESS) return check;
+ trace_flag_changed<EventLongFlagChanged, intx>(name, old_value, *value, origin);
result->set_intx(*value);
*value = old_value;
result->set_origin(origin);
! return true;
! return Flag::SUCCESS;
}
! void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
! Flag::Error CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
! trace_flag_changed<EventLongFlagChanged, s8>(faddr->_name, faddr->get_intx(), value, origin);
! Flag::Error check = apply_constraint_and_check_range_intx(faddr->_name, &value);
+ if (check != Flag::SUCCESS) return check;
+ trace_flag_changed<EventLongFlagChanged, intx>(faddr->_name, faddr->get_intx(), value, origin);
faddr->set_intx(value);
faddr->set_origin(origin);
+ return Flag::SUCCESS;
}
! bool CommandLineFlags::uintxAt(const char* name, size_t len, uintx* value, bool allow_locked, bool return_flag) {
! Flag::Error CommandLineFlags::uintxAt(const char* name, size_t len, uintx* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
! if (result == NULL) return false;
! if (!result->is_uintx()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_uintx()) return Flag::WRONG_FORMAT;
*value = result->get_uintx();
! return true;
! return Flag::SUCCESS;
}
! bool CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) {
! static Flag::Error apply_constraint_and_check_range_uintx(const char* name, uintx* new_value, bool verbose = true) {
+ Flag::Error range_status = Flag::SUCCESS;
+ CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
+ if (range != NULL) {
+ range_status = range->check_uintx(*new_value, verbose);
+ }
+
+ Flag::Error constraint_status = Flag::SUCCESS;
+ CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name);
+ if (constraint != NULL) {
+ constraint_status = constraint->apply_uintx(new_value, verbose);
+ }
+
+ return get_status_error(range_status, constraint_status);
+ }
+
+ Flag::Error CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
! if (result == NULL) return false;
! if (!result->is_uintx()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_uintx()) return Flag::WRONG_FORMAT;
uintx old_value = result->get_uintx();
+ Flag::Error check = apply_constraint_and_check_range_uintx(name, value, (CommandLineFlags::finishedInitializing()==false));
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
result->set_uintx(*value);
*value = old_value;
result->set_origin(origin);
! return true;
! return Flag::SUCCESS;
}
! void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
! Flag::Error CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
+ Flag::Error check = apply_constraint_and_check_range_uintx(faddr->_name, &value);
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin);
faddr->set_uintx(value);
faddr->set_origin(origin);
+ return Flag::SUCCESS;
}
! bool CommandLineFlags::uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked, bool return_flag) {
! Flag::Error CommandLineFlags::uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
! if (result == NULL) return false;
! if (!result->is_uint64_t()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_uint64_t()) return Flag::WRONG_FORMAT;
*value = result->get_uint64_t();
! return true;
! return Flag::SUCCESS;
}
! bool CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) {
! static Flag::Error apply_constraint_and_check_range_uint64_t(const char* name, uint64_t* new_value, bool verbose = true) {
+ Flag::Error range_status = Flag::SUCCESS;
+ CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
+ if (range != NULL) {
+ range_status = range->check_uint64_t(*new_value, verbose);
+ }
+
+ Flag::Error constraint_status = Flag::SUCCESS;
+ CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name);
+ if (constraint != NULL) {
+ constraint_status = constraint->apply_uint64_t(new_value, verbose);
+ }
+
+ return get_status_error(range_status, constraint_status);
+ }
+
+ Flag::Error CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
! if (result == NULL) return false;
! if (!result->is_uint64_t()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_uint64_t()) return Flag::WRONG_FORMAT;
uint64_t old_value = result->get_uint64_t();
+ Flag::Error check = apply_constraint_and_check_range_uint64_t(name, value, (CommandLineFlags::finishedInitializing()==false));
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
result->set_uint64_t(*value);
*value = old_value;
result->set_origin(origin);
! return true;
! return Flag::SUCCESS;
}
! void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
! Flag::Error CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
+ Flag::Error check = apply_constraint_and_check_range_uint64_t(faddr->_name, &value);
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin);
faddr->set_uint64_t(value);
faddr->set_origin(origin);
+ return Flag::SUCCESS;
}
! bool CommandLineFlags::size_tAt(const char* name, size_t len, size_t* value, bool allow_locked, bool return_flag) {
! Flag::Error CommandLineFlags::size_tAt(const char* name, size_t len, size_t* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
! if (result == NULL) return false;
! if (!result->is_size_t()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_size_t()) return Flag::WRONG_FORMAT;
*value = result->get_size_t();
! return true;
! return Flag::SUCCESS;
}
! bool CommandLineFlags::size_tAtPut(const char* name, size_t len, size_t* value, Flag::Flags origin) {
! static Flag::Error apply_constraint_and_check_range_size_t(const char* name, size_t* new_value, bool verbose = true) {
+ Flag::Error range_status = Flag::SUCCESS;
+ CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
+ if (range != NULL) {
+ range_status = range->check_size_t(*new_value, verbose);
+ }
+
+ Flag::Error constraint_status = Flag::SUCCESS;
+ CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name);
+ if (constraint != NULL) {
+ constraint_status = constraint->apply_size_t(new_value, verbose);
+ }
+
+ return get_status_error(range_status, constraint_status);
+ }
+
+ Flag::Error CommandLineFlags::size_tAtPut(const char* name, size_t len, size_t* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
! if (result == NULL) return false;
! if (!result->is_size_t()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_size_t()) return Flag::WRONG_FORMAT;
size_t old_value = result->get_size_t();
+ Flag::Error check = apply_constraint_and_check_range_size_t(name, value, (CommandLineFlags::finishedInitializing()==false));
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
result->set_size_t(*value);
*value = old_value;
result->set_origin(origin);
! return true;
! return Flag::SUCCESS;
}
! void CommandLineFlagsEx::size_tAtPut(CommandLineFlagWithType flag, size_t value, Flag::Flags origin) {
! Flag::Error CommandLineFlagsEx::size_tAtPut(CommandLineFlagWithType flag, size_t value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_size_t(), "wrong flag type");
+ Flag::Error check = apply_constraint_and_check_range_size_t(faddr->_name, &value);
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_size_t(), value, origin);
faddr->set_size_t(value);
faddr->set_origin(origin);
+ return Flag::SUCCESS;
}
! bool CommandLineFlags::doubleAt(const char* name, size_t len, double* value, bool allow_locked, bool return_flag) {
! Flag::Error CommandLineFlags::doubleAt(const char* name, size_t len, double* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
! if (result == NULL) return false;
! if (!result->is_double()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_double()) return Flag::WRONG_FORMAT;
*value = result->get_double();
! return true;
! return Flag::SUCCESS;
+ }
+
+ static Flag::Error apply_constraint_and_check_range_double(const char* name, double* new_value, bool verbose = true) {
+ Flag::Error range_status = Flag::SUCCESS;
+ CommandLineFlagRange* range = CommandLineFlagRangeList::find(name);
+ if (range != NULL) {
+ range_status = range->check_double(*new_value, verbose);
+ }
+
+ Flag::Error constraint_status = Flag::SUCCESS;
+ CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name);
+ if (constraint != NULL) {
+ constraint_status = constraint->apply_double(new_value, verbose);
+ }
+
+ return get_status_error(range_status, constraint_status);
}
! bool CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) {
! Flag::Error CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
! if (result == NULL) return false;
! if (!result->is_double()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_double()) return Flag::WRONG_FORMAT;
double old_value = result->get_double();
+ Flag::Error check = apply_constraint_and_check_range_double(name, value, (CommandLineFlags::finishedInitializing()==false));
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
result->set_double(*value);
*value = old_value;
result->set_origin(origin);
! return true;
! return Flag::SUCCESS;
}
! void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
! Flag::Error CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
+ Flag::Error check = apply_constraint_and_check_range_double(faddr->_name, &value, (CommandLineFlags::finishedInitializing()==false));
+ if (check != Flag::SUCCESS) return check;
trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin);
faddr->set_double(value);
faddr->set_origin(origin);
+ return Flag::SUCCESS;
}
! bool CommandLineFlags::ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked, bool return_flag) {
! Flag::Error CommandLineFlags::ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
! if (result == NULL) return false;
! if (!result->is_ccstr()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_ccstr()) return Flag::WRONG_FORMAT;
*value = result->get_ccstr();
! return true;
! return Flag::SUCCESS;
}
! bool CommandLineFlags::ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin) {
! Flag::Error CommandLineFlags::ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
! if (result == NULL) return false;
! if (!result->is_ccstr()) return false;
! if (result == NULL) return Flag::INVALID_FLAG;
! if (!result->is_ccstr()) return Flag::WRONG_FORMAT;
ccstr old_value = result->get_ccstr();
trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin);
char* new_value = NULL;
if (*value != NULL) {
new_value = os::strdup_check_oom(*value);
*** 826,839 ****
--- 1044,1057 ----
// Prior value is NOT heap allocated, but was a literal constant.
old_value = os::strdup_check_oom(old_value);
}
*value = old_value;
result->set_origin(origin);
! return true;
! return Flag::SUCCESS;
}
! void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) {
! Flag::Error CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
ccstr old_value = faddr->get_ccstr();
trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin);
char* new_value = os::strdup_check_oom(value);
*** 841,858 ****
--- 1059,1144 ----
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 Flag::SUCCESS;
}
+ //#define PRINT_FLAGS_SORTED_BY_TYPE_THEN_NAMES
+ #ifndef PRINT_FLAGS_SORTED_BY_TYPE_THEN_NAMES
+
extern "C" {
static int compare_flags(const void* void_a, const void* void_b) {
return strcmp((*((Flag**) void_a))->_name, (*((Flag**) void_b))->_name);
}
}
+ #else // PRINT_FLAGS_SORTED_BY_TYPE_THEN_NAMES
+
+ void print_kind(Flag::Flags flags, char* string, int size) {
+ struct Data {
+ int flag;
+ const char* name;
+ };
+
+ Data data[] = {
+ { Flag::KIND_C1, "C1" },
+ { Flag::KIND_C2, "C2" },
+ { Flag::KIND_ARCH, "ARCH" },
+ { Flag::KIND_SHARK, "SHARK" },
+ { Flag::KIND_PLATFORM_DEPENDENT, "pd" },
+ { Flag::KIND_PRODUCT, "product" },
+ { Flag::KIND_MANAGEABLE, "manageable" },
+ { Flag::KIND_DIAGNOSTIC, "diagnostic" },
+ { Flag::KIND_EXPERIMENTAL, "experimental" },
+ { Flag::KIND_COMMERCIAL, "commercial" },
+ { Flag::KIND_NOT_PRODUCT, "notproduct" },
+ { Flag::KIND_DEVELOP, "develop" },
+ { Flag::KIND_LP64_PRODUCT, "lp64_product" },
+ { Flag::KIND_READ_WRITE, "rw" },
+ { -1, "" }
+ };
+
+ if ((flags & Flag::KIND_MASK) != 0) {
+ strncpy(string, "{", size);
+ bool is_first = true;
+
+ 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 {
+ os::strlcat(string, " ", size);
+ }
+ os::strlcat(string, d.name, size);
+ }
+ }
+
+ os::strlcat(string, "}", size);
+ }
+ }
+
+ extern "C" {
+ // by kind, name
+ static int compare_flags(const void* void_a, const void* void_b) {
+ char buf_a[128];
+ print_kind((*((Flag**) void_a))->_flags, &buf_a[0], 127);
+ char buf_b[128];
+ print_kind((*((Flag**) void_b))->_flags, &buf_b[0], 127);
+ int comp_kind = strncmp(buf_a, buf_b, 127);
+ if (comp_kind != 0) {
+ return comp_kind;
+ } else {
+ return strcmp((*((Flag**) void_a))->_name, (*((Flag**) void_b))->_name);
+ }
+ }
+ }
+
+ #endif //PRINT_FLAGS_SORTED_BY_TYPE_THEN_NAMES
+
void CommandLineFlags::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.
*** 875,894 ****
--- 1161,1303 ----
}
out->cr();
FREE_C_HEAP_ARRAY(Flag*, array);
}
#ifndef PRODUCT
+ bool CommandLineFlags::_finished_initializing = false;
+
+ bool CommandLineFlags::check_all_ranges_and_constraints() {
+ //#define PRINT_RANGES_AND_CONSTRAINTS_SIZES
+ #ifdef PRINT_RANGES_AND_CONSTRAINTS_SIZES
+ {
+ size_t size_ranges = sizeof(CommandLineFlagRangeList);
+ for (int i=0; i<CommandLineFlagRangeList::length(); i++) {
+ size_ranges += sizeof(CommandLineFlagRange);
+ CommandLineFlagRange* range = CommandLineFlagRangeList::at(i);
+ const char* name = range->name();
+ Flag* flag = Flag::find_flag(name, strlen(name), true, true);
+ if (flag->is_intx()) {
+ size_ranges += 2*sizeof(intx);
+ size_ranges += sizeof(CommandLineFlagRange*);
+ } else if (flag->is_uintx()) {
+ size_ranges += 2*sizeof(uintx);
+ size_ranges += sizeof(CommandLineFlagRange*);
+ } else if (flag->is_uint64_t()) {
+ size_ranges += 2*sizeof(uint64_t);
+ size_ranges += sizeof(CommandLineFlagRange*);
+ } else if (flag->is_size_t()) {
+ size_ranges += 2*sizeof(size_t);
+ size_ranges += sizeof(CommandLineFlagRange*);
+ } else if (flag->is_double()) {
+ size_ranges += 2*sizeof(double);
+ size_ranges += sizeof(CommandLineFlagRange*);
+ }
+ }
+ fprintf(stderr, "Size of %d ranges: "SIZE_FORMAT" bytes\n",
+ CommandLineFlagRangeList::length(), size_ranges);
+ }
+ {
+ size_t size_constraints = sizeof(CommandLineFlagConstraintList);
+ for (int i=0; i<CommandLineFlagConstraintList::length(); i++) {
+ size_constraints += sizeof(CommandLineFlagConstraint);
+ CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::at(i);
+ const char* name = constraint->name();
+ Flag* flag = Flag::find_flag(name, strlen(name), true, true);
+ if (flag->is_bool()) {
+ size_constraints += sizeof(CommandLineFlagConstraintFunc_bool);
+ size_constraints += sizeof(CommandLineFlagConstraint*);
+ } else if (flag->is_intx()) {
+ size_constraints += sizeof(CommandLineFlagConstraintFunc_intx);
+ size_constraints += sizeof(CommandLineFlagConstraint*);
+ } else if (flag->is_uintx()) {
+ size_constraints += sizeof(CommandLineFlagConstraintFunc_uintx);
+ size_constraints += sizeof(CommandLineFlagConstraint*);
+ } else if (flag->is_uint64_t()) {
+ size_constraints += sizeof(CommandLineFlagConstraintFunc_uint64_t);
+ size_constraints += sizeof(CommandLineFlagConstraint*);
+ } else if (flag->is_size_t()) {
+ size_constraints += sizeof(CommandLineFlagConstraintFunc_size_t);
+ size_constraints += sizeof(CommandLineFlagConstraint*);
+ } else if (flag->is_double()) {
+ size_constraints += sizeof(CommandLineFlagConstraintFunc_double);
+ size_constraints += sizeof(CommandLineFlagConstraint*);
+ }
+ }
+ fprintf(stderr, "Size of %d constraints: "SIZE_FORMAT" bytes\n",
+ CommandLineFlagConstraintList::length(), size_constraints);
+ }
+ #endif // PRINT_RANGES_AND_CONSTRAINTS_SIZES
+
+ _finished_initializing = true;
+
+ bool status = true;
+ for (int i=0; i<CommandLineFlagRangeList::length(); i++) {
+ CommandLineFlagRange* range = CommandLineFlagRangeList::at(i);
+ const char* name = range->name();
+ Flag* flag = Flag::find_flag(name, strlen(name), true, true);
+ if (flag != NULL) {
+ if (flag->is_intx()) {
+ intx value = flag->get_intx();
+ if (range->check_intx(value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_uintx()) {
+ uintx value = flag->get_uintx();
+ if (range->check_uintx(value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_uint64_t()) {
+ uint64_t value = flag->get_uint64_t();
+ if (range->check_uint64_t(value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_size_t()) {
+ size_t value = flag->get_size_t();
+ if (range->check_size_t(value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_double()) {
+ double value = flag->get_double();
+ if (range->check_double(value, true) != Flag::SUCCESS) status = false;
+ }
+ }
+ }
+ for (int i=0; i<CommandLineFlagConstraintList::length(); i++) {
+ CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::at(i);
+ const char*name = constraint->name();
+ Flag* flag = Flag::find_flag(name, strlen(name), true, true);
+ if (flag != NULL) {
+ if (flag->is_bool()) {
+ bool value = flag->get_bool();
+ if (constraint->apply_bool(&value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_intx()) {
+ intx value = flag->get_intx();
+ if (constraint->apply_intx(&value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_uintx()) {
+ uintx value = flag->get_uintx();
+ if (constraint->apply_uintx(&value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_uint64_t()) {
+ uint64_t value = flag->get_uint64_t();
+ if (constraint->apply_uint64_t(&value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_size_t()) {
+ size_t value = flag->get_size_t();
+ if (constraint->apply_size_t(&value, true) != Flag::SUCCESS) status = false;
+ } else if (flag->is_double()) {
+ double value = flag->get_double();
+ if (constraint->apply_double(&value, true) != Flag::SUCCESS) status = false;
+ }
+ }
+ }
+
+ Arguments::post_final_range_and_constraint_check(status);
+ return status;
+ }
+
+ #ifndef PRODUCT
void CommandLineFlags::verify() {
assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict");
}
#endif // PRODUCT
void CommandLineFlags::printFlags(outputStream* out, bool withComments) {
+ #define ONLY_PRINT_PRODUCT_FLAGS
+
+ void CommandLineFlags::printFlags(outputStream* out, bool withComments, bool printRanges) {
// Print the flags sorted by name
// 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.
*** 900,912 ****
--- 1309,1329 ----
array[i] = &flagTable[i];
}
qsort(array, length, sizeof(Flag*), compare_flags);
// Print
+ if (printRanges == false) {
out->print_cr("[Global flags]");
+ } else {
+ out->print_cr("[Global flags ranges]");
+ }
+
for (size_t i = 0; i < length; i++) {
if (array[i]->is_unlocked()) {
array[i]->print_on(out, withComments);
+ #ifdef ONLY_PRINT_PRODUCT_FLAGS
+ if (!array[i]->is_notproduct() && !array[i]->is_develop())
+ #endif // ONLY_PRINT_PRODUCT_FLAGS
+ array[i]->print_on(out, printRanges, withComments);
}
}
FREE_C_HEAP_ARRAY(Flag*, array);
}
src/share/vm/runtime/globals.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File