--- old/src/share/vm/runtime/globals.cpp 2015-07-20 12:40:23.519901756 -0700 +++ new/src/share/vm/runtime/globals.cpp 2015-07-20 12:40:23.275901748 -0700 @@ -770,7 +770,7 @@ 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); + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { status = constraint->apply_bool(new_value, verbose); } @@ -789,7 +789,7 @@ Flag* result = Flag::find_flag(name, len); if (result == NULL) return Flag::INVALID_FLAG; if (!result->is_bool()) return Flag::WRONG_FORMAT; - Flag::Error check = apply_constraint_and_check_range_bool(name, value, !CommandLineFlags::finishedInitializing()); + Flag::Error check = apply_constraint_and_check_range_bool(name, value, !CommandLineFlagConstraintList::validated_after_ergo()); if (check != Flag::SUCCESS) return check; bool old_value = result->get_bool(); trace_flag_changed(name, old_value, *value, origin); @@ -817,7 +817,7 @@ range_status = range->check_int(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { constraint_status = constraint->apply_int(new_value, verbose); } @@ -836,7 +836,7 @@ Flag* result = Flag::find_flag(name, len); if (result == NULL) return Flag::INVALID_FLAG; if (!result->is_int()) return Flag::WRONG_FORMAT; - Flag::Error check = apply_constraint_and_check_range_int(name, value, !CommandLineFlags::finishedInitializing()); + Flag::Error check = apply_constraint_and_check_range_int(name, value, !CommandLineFlagConstraintList::validated_after_ergo()); if (check != Flag::SUCCESS) return check; int old_value = result->get_int(); trace_flag_changed(name, old_value, *value, origin); @@ -862,7 +862,7 @@ range_status = range->check_uint(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { constraint_status = constraint->apply_uint(new_value, verbose); } @@ -881,7 +881,7 @@ Flag* result = Flag::find_flag(name, len); if (result == NULL) return Flag::INVALID_FLAG; if (!result->is_uint()) return Flag::WRONG_FORMAT; - Flag::Error check = apply_constraint_and_check_range_uint(name, value, !CommandLineFlags::finishedInitializing()); + Flag::Error check = apply_constraint_and_check_range_uint(name, value, !CommandLineFlagConstraintList::validated_after_ergo()); if (check != Flag::SUCCESS) return check; uint old_value = result->get_uint(); trace_flag_changed(name, old_value, *value, origin); @@ -915,7 +915,7 @@ range_status = range->check_intx(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { constraint_status = constraint->apply_intx(new_value, verbose); } @@ -926,7 +926,7 @@ Flag* result = Flag::find_flag(name, len); if (result == NULL) return Flag::INVALID_FLAG; if (!result->is_intx()) return Flag::WRONG_FORMAT; - Flag::Error check = apply_constraint_and_check_range_intx(name, value, !CommandLineFlags::finishedInitializing()); + Flag::Error check = apply_constraint_and_check_range_intx(name, value, !CommandLineFlagConstraintList::validated_after_ergo()); if (check != Flag::SUCCESS) return check; intx old_value = result->get_intx(); trace_flag_changed(name, old_value, *value, origin); @@ -962,7 +962,7 @@ range_status = range->check_uintx(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { constraint_status = constraint->apply_uintx(new_value, verbose); } @@ -973,7 +973,7 @@ Flag* result = Flag::find_flag(name, len); if (result == NULL) return Flag::INVALID_FLAG; if (!result->is_uintx()) return Flag::WRONG_FORMAT; - Flag::Error check = apply_constraint_and_check_range_uintx(name, value, !CommandLineFlags::finishedInitializing()); + Flag::Error check = apply_constraint_and_check_range_uintx(name, value, !CommandLineFlagConstraintList::validated_after_ergo()); if (check != Flag::SUCCESS) return check; uintx old_value = result->get_uintx(); trace_flag_changed(name, old_value, *value, origin); @@ -1009,7 +1009,7 @@ range_status = range->check_uint64_t(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { constraint_status = constraint->apply_uint64_t(new_value, verbose); } @@ -1020,7 +1020,7 @@ Flag* result = Flag::find_flag(name, len); if (result == NULL) return Flag::INVALID_FLAG; if (!result->is_uint64_t()) return Flag::WRONG_FORMAT; - Flag::Error check = apply_constraint_and_check_range_uint64_t(name, value, !CommandLineFlags::finishedInitializing()); + Flag::Error check = apply_constraint_and_check_range_uint64_t(name, value, !CommandLineFlagConstraintList::validated_after_ergo()); if (check != Flag::SUCCESS) return check; uint64_t old_value = result->get_uint64_t(); trace_flag_changed(name, old_value, *value, origin); @@ -1056,7 +1056,7 @@ range_status = range->check_size_t(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { constraint_status = constraint->apply_size_t(new_value, verbose); } @@ -1067,7 +1067,7 @@ Flag* result = Flag::find_flag(name, len); if (result == NULL) return Flag::INVALID_FLAG; if (!result->is_size_t()) return Flag::WRONG_FORMAT; - Flag::Error check = apply_constraint_and_check_range_size_t(name, value, !CommandLineFlags::finishedInitializing()); + Flag::Error check = apply_constraint_and_check_range_size_t(name, value, !CommandLineFlagConstraintList::validated_after_ergo()); if (check != Flag::SUCCESS) return check; size_t old_value = result->get_size_t(); trace_flag_changed(name, old_value, *value, origin); @@ -1103,7 +1103,7 @@ range_status = range->check_double(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { constraint_status = constraint->apply_double(new_value, verbose); } @@ -1114,7 +1114,7 @@ Flag* result = Flag::find_flag(name, len); if (result == NULL) return Flag::INVALID_FLAG; if (!result->is_double()) return Flag::WRONG_FORMAT; - Flag::Error check = apply_constraint_and_check_range_double(name, value, !CommandLineFlags::finishedInitializing()); + Flag::Error check = apply_constraint_and_check_range_double(name, value, !CommandLineFlagConstraintList::validated_after_ergo()); if (check != Flag::SUCCESS) return check; double old_value = result->get_double(); trace_flag_changed(name, old_value, *value, origin); @@ -1127,7 +1127,7 @@ 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()); + Flag::Error check = apply_constraint_and_check_range_double(faddr->_name, &value); if (check != Flag::SUCCESS) return check; trace_flag_changed(faddr->_name, faddr->get_double(), value, origin); faddr->set_double(value); @@ -1210,12 +1210,9 @@ FREE_C_HEAP_ARRAY(Flag*, array); } -bool CommandLineFlags::_finished_initializing = false; - -bool CommandLineFlags::check_all_ranges_and_constraints() { - -//#define PRINT_RANGES_AND_CONSTRAINTS_SIZES -#ifdef PRINT_RANGES_AND_CONSTRAINTS_SIZES +bool CommandLineFlags::check_ranges() { +//#define PRINT_RANGES_SIZES +#ifdef PRINT_RANGES_SIZES { size_t size_ranges = sizeof(CommandLineFlagRangeList); for (int i=0; iname(); + 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; + } + } + } + return status; +} + +// Check constraints for specific constraint type. +static bool check_constraints(CommandLineFlagConstraint::ConstraintType constraint_type) { +//#define PRINT_CONSTRAINTS_SIZES +#ifdef PRINT_CONSTRAINTS_SIZES { size_t size_constraints = sizeof(CommandLineFlagConstraintList); for (int i=0; iname(); - 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; itype()) continue; const char*name = constraint->name(); Flag* flag = Flag::find_flag(name, strlen(name), true, true); if (flag != NULL) { @@ -1327,12 +1334,27 @@ } } } + return status; +} + +// Check constraints and do post work of 'AfterErgo'. +bool CommandLineFlags::check_constraints_of_after_ergo() { + CommandLineFlagConstraintList::set_validating_type(CommandLineFlagConstraint::AfterErgo); + + bool status = check_constraints(CommandLineFlagConstraint::AfterErgo); - Arguments::post_final_range_and_constraint_check(status); + Arguments::post_after_ergo_constraint_check(status); return status; } +// Check constraints of 'AfterMemoryInit'. +bool CommandLineFlags::check_constraints_of_after_memory_init() { + CommandLineFlagConstraintList::set_validating_type(CommandLineFlagConstraint::AfterMemoryInit); + + return check_constraints(CommandLineFlagConstraint::AfterMemoryInit); +} + #ifndef PRODUCT void CommandLineFlags::verify() {