< prev index next >

src/share/vm/runtime/globals.cpp

Print this page

        

*** 768,778 **** } } 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; } --- 768,778 ---- } } 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_if_validated(name); if (constraint != NULL) { status = constraint->apply_bool(new_value, verbose); } return status; }
*** 787,797 **** 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 Flag::INVALID_FLAG; if (!result->is_bool()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_bool(name, value, !CommandLineFlags::finishedInitializing()); if (check != Flag::SUCCESS) return check; bool old_value = result->get_bool(); trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin); result->set_bool(*value); *value = old_value; --- 787,797 ---- 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 Flag::INVALID_FLAG; if (!result->is_bool()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_bool(name, value, !CommandLineFlagConstraintList::validatedAfterParse()); if (check != Flag::SUCCESS) return check; bool old_value = result->get_bool(); trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin); result->set_bool(*value); *value = old_value;
*** 815,825 **** CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { range_status = range->check_int(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; ! CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); if (constraint != NULL) { constraint_status = constraint->apply_int(new_value, verbose); } return get_status_error(range_status, constraint_status); } --- 815,825 ---- CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { range_status = range->check_int(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; ! CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_validated(name); if (constraint != NULL) { constraint_status = constraint->apply_int(new_value, verbose); } return get_status_error(range_status, constraint_status); }
*** 834,844 **** Flag::Error CommandLineFlags::intAtPut(const char* name, size_t len, int* value, Flag::Flags origin) { 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()); if (check != Flag::SUCCESS) return check; int old_value = result->get_int(); trace_flag_changed<EventIntFlagChanged, s4>(name, old_value, *value, origin); result->set_int(*value); *value = old_value; --- 834,844 ---- Flag::Error CommandLineFlags::intAtPut(const char* name, size_t len, int* value, Flag::Flags origin) { 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, !CommandLineFlagConstraintList::validatedAfterParse()); if (check != Flag::SUCCESS) return check; int old_value = result->get_int(); trace_flag_changed<EventIntFlagChanged, s4>(name, old_value, *value, origin); result->set_int(*value); *value = old_value;
*** 860,870 **** CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { range_status = range->check_uint(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; ! CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); if (constraint != NULL) { constraint_status = constraint->apply_uint(new_value, verbose); } return get_status_error(range_status, constraint_status); } --- 860,870 ---- CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { range_status = range->check_uint(*new_value, verbose); } Flag::Error constraint_status = Flag::SUCCESS; ! CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_validated(name); if (constraint != NULL) { constraint_status = constraint->apply_uint(new_value, verbose); } return get_status_error(range_status, constraint_status); }
*** 879,889 **** Flag::Error CommandLineFlags::uintAtPut(const char* name, size_t len, uint* value, Flag::Flags origin) { 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()); if (check != Flag::SUCCESS) return check; uint old_value = result->get_uint(); trace_flag_changed<EventUnsignedIntFlagChanged, u4>(name, old_value, *value, origin); result->set_uint(*value); *value = old_value; --- 879,889 ---- Flag::Error CommandLineFlags::uintAtPut(const char* name, size_t len, uint* value, Flag::Flags origin) { 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, !CommandLineFlagConstraintList::validatedAfterParse()); if (check != Flag::SUCCESS) return check; uint old_value = result->get_uint(); trace_flag_changed<EventUnsignedIntFlagChanged, u4>(name, old_value, *value, origin); result->set_uint(*value); *value = old_value;
*** 913,934 **** 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); } 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 Flag::INVALID_FLAG; if (!result->is_intx()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_intx(name, value, !CommandLineFlags::finishedInitializing()); if (check != Flag::SUCCESS) return check; intx old_value = result->get_intx(); trace_flag_changed<EventLongFlagChanged, intx>(name, old_value, *value, origin); result->set_intx(*value); *value = old_value; --- 913,934 ---- 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_if_validated(name); if (constraint != NULL) { constraint_status = constraint->apply_intx(new_value, verbose); } return get_status_error(range_status, constraint_status); } 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 Flag::INVALID_FLAG; if (!result->is_intx()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_intx(name, value, !CommandLineFlagConstraintList::validatedAfterParse()); if (check != Flag::SUCCESS) return check; intx old_value = result->get_intx(); trace_flag_changed<EventLongFlagChanged, intx>(name, old_value, *value, origin); result->set_intx(*value); *value = old_value;
*** 960,981 **** 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 Flag::INVALID_FLAG; if (!result->is_uintx()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_uintx(name, value, !CommandLineFlags::finishedInitializing()); if (check != Flag::SUCCESS) return check; uintx old_value = result->get_uintx(); trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); result->set_uintx(*value); *value = old_value; --- 960,981 ---- 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_if_validated(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 Flag::INVALID_FLAG; if (!result->is_uintx()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_uintx(name, value, !CommandLineFlagConstraintList::validatedAfterParse()); if (check != Flag::SUCCESS) return check; uintx old_value = result->get_uintx(); trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); result->set_uintx(*value); *value = old_value;
*** 1007,1028 **** 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 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()); if (check != Flag::SUCCESS) return check; uint64_t old_value = result->get_uint64_t(); trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); result->set_uint64_t(*value); *value = old_value; --- 1007,1028 ---- 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_if_validated(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 Flag::INVALID_FLAG; if (!result->is_uint64_t()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_uint64_t(name, value, !CommandLineFlagConstraintList::validatedAfterParse()); if (check != Flag::SUCCESS) return check; uint64_t old_value = result->get_uint64_t(); trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); result->set_uint64_t(*value); *value = old_value;
*** 1054,1075 **** 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 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()); if (check != Flag::SUCCESS) return check; size_t old_value = result->get_size_t(); trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); result->set_size_t(*value); *value = old_value; --- 1054,1075 ---- 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_if_validated(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 Flag::INVALID_FLAG; if (!result->is_size_t()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_size_t(name, value, !CommandLineFlagConstraintList::validatedAfterParse()); if (check != Flag::SUCCESS) return check; size_t old_value = result->get_size_t(); trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); result->set_size_t(*value); *value = old_value;
*** 1101,1122 **** 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); } 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 Flag::INVALID_FLAG; if (!result->is_double()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_double(name, value, !CommandLineFlags::finishedInitializing()); if (check != Flag::SUCCESS) return check; double old_value = result->get_double(); trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin); result->set_double(*value); *value = old_value; --- 1101,1122 ---- 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_if_validated(name); if (constraint != NULL) { constraint_status = constraint->apply_double(new_value, verbose); } return get_status_error(range_status, constraint_status); } 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 Flag::INVALID_FLAG; if (!result->is_double()) return Flag::WRONG_FORMAT; ! Flag::Error check = apply_constraint_and_check_range_double(name, value, !CommandLineFlagConstraintList::validatedAfterParse()); if (check != Flag::SUCCESS) return check; double old_value = result->get_double(); trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin); result->set_double(*value); *value = old_value;
*** 1125,1135 **** } 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()); 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; --- 1125,1135 ---- } 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); 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;
*** 1208,1220 **** } out->cr(); 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 { size_t size_ranges = sizeof(CommandLineFlagRangeList); --- 1208,1253 ---- } out->cr(); FREE_C_HEAP_ARRAY(Flag*, array); } ! // Check constraints for specific constraint type. ! static bool check_constraints(CommandLineFlagConstraint::ConstraintType constraint_type) { ! bool status = true; ! ! for (int i=0; i<CommandLineFlagConstraintList::length(); i++) { ! CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::at(i); ! if (constraint_type != constraint->type()) continue; ! 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; ! } ! } ! } ! ! return status; ! } ! bool CommandLineFlags::check_ranges_and_constraints_of_after_parse() { //#define PRINT_RANGES_AND_CONSTRAINTS_SIZES #ifdef PRINT_RANGES_AND_CONSTRAINTS_SIZES { size_t size_ranges = sizeof(CommandLineFlagRangeList);
*** 1273,1284 **** 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); --- 1306,1318 ---- fprintf(stderr, "Size of %d constraints: " SIZE_FORMAT " bytes\n", CommandLineFlagConstraintList::length(), size_constraints); } #endif // PRINT_RANGES_AND_CONSTRAINTS_SIZES ! CommandLineFlagConstraintList::setValidatingType(CommandLineFlagConstraint::AfterParse); + // Check ranges. 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);
*** 1299,1340 **** 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"); } --- 1333,1358 ---- double value = flag->get_double(); if (range->check_double(value, true) != Flag::SUCCESS) status = false; } } } ! ! // Check constraints of 'AfterParse'. ! status = check_constraints(CommandLineFlagConstraint::AfterParse); Arguments::post_final_range_and_constraint_check(status); return status; } + + bool CommandLineFlags::check_constraints_of_after_memory_init() { + CommandLineFlagConstraintList::setValidatingType(CommandLineFlagConstraint::AfterMemoryInit); + + return check_constraints(CommandLineFlagConstraint::AfterMemoryInit); + } + #ifndef PRODUCT void CommandLineFlags::verify() { assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict"); }
< prev index next >