--- old/src/share/vm/runtime/globals.cpp 2015-06-16 15:48:04.000000000 -0500 +++ new/src/share/vm/runtime/globals.cpp 2015-06-16 15:48:04.000000000 -0500 @@ -348,7 +348,7 @@ #define FORMAT_BUFFER_LEN 16 PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL -void Flag::print_on(outputStream* st, bool printRanges, bool withComments) { +void Flag::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; @@ -654,7 +654,7 @@ // Found a matching entry. // Don't report notproduct and develop flags in product builds. if (current->is_constant_in_binary()) { - return (return_flag == true ? current : NULL); + return (return_flag ? current : NULL); } // Report locked flags only if allowed. if (!(current->is_unlocked() || current->is_unlocker())) { @@ -758,6 +758,16 @@ e.commit(); } +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); @@ -801,18 +811,17 @@ } static Flag::Error apply_constraint_and_check_range_int(const char* name, int* new_value, bool verbose = true) { - Flag::Error status = Flag::SUCCESS; + Flag::Error range_status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - status = range->check_int(*new_value, verbose); + range_status = range->check_int(*new_value, verbose); } - if (status == Flag::SUCCESS) { - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); - if (constraint != NULL) { - status = constraint->apply_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 status; + return get_status_error(range_status, constraint_status); } Flag::Error CommandLineFlags::intAt(const char* name, size_t len, int* value, bool allow_locked, bool return_flag) { @@ -847,18 +856,17 @@ } static Flag::Error apply_constraint_and_check_range_uint(const char* name, uint* new_value, bool verbose = true) { - Flag::Error status = Flag::SUCCESS; + Flag::Error range_status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - status = range->check_uint(*new_value, verbose); + range_status = range->check_uint(*new_value, verbose); } - if (status == Flag::SUCCESS) { - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); - if (constraint != NULL) { - status = constraint->apply_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 status; + return get_status_error(range_status, constraint_status); } Flag::Error CommandLineFlags::uintAt(const char* name, size_t len, uint* value, bool allow_locked, bool return_flag) { @@ -901,18 +909,17 @@ } static Flag::Error apply_constraint_and_check_range_intx(const char* name, intx* new_value, bool verbose = true) { - Flag::Error status = Flag::SUCCESS; + Flag::Error range_status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - status = range->check_intx(*new_value, verbose); + range_status = range->check_intx(*new_value, verbose); } - if (status == Flag::SUCCESS) { - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); - if (constraint != NULL) { - status = constraint->apply_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 status; + return get_status_error(range_status, constraint_status); } Flag::Error CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) { @@ -949,18 +956,17 @@ } static Flag::Error apply_constraint_and_check_range_uintx(const char* name, uintx* new_value, bool verbose = true) { - Flag::Error status = Flag::SUCCESS; + Flag::Error range_status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - status = range->check_uintx(*new_value, verbose); + range_status = range->check_uintx(*new_value, verbose); } - if (status == Flag::SUCCESS) { - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); - if (constraint != NULL) { - status = constraint->apply_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 status; + return get_status_error(range_status, constraint_status); } Flag::Error CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) { @@ -997,18 +1003,17 @@ } static Flag::Error apply_constraint_and_check_range_uint64_t(const char* name, uint64_t* new_value, bool verbose = true) { - Flag::Error status = Flag::SUCCESS; + Flag::Error range_status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - status = range->check_uint64_t(*new_value, verbose); + range_status = range->check_uint64_t(*new_value, verbose); } - if (status == Flag::SUCCESS) { - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); - if (constraint != NULL) { - status = constraint->apply_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 status; + 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) { @@ -1045,18 +1050,17 @@ } static Flag::Error apply_constraint_and_check_range_size_t(const char* name, size_t* new_value, bool verbose = true) { - Flag::Error status = Flag::SUCCESS; + Flag::Error range_status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - status = range->check_size_t(*new_value, verbose); + range_status = range->check_size_t(*new_value, verbose); } - if (status == Flag::SUCCESS) { - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); - if (constraint != NULL) { - status = constraint->apply_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 status; + 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) { @@ -1093,18 +1097,17 @@ } static Flag::Error apply_constraint_and_check_range_double(const char* name, double* new_value, bool verbose = true) { - Flag::Error status = Flag::SUCCESS; + Flag::Error range_status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - status = range->check_double(*new_value, verbose); + range_status = range->check_double(*new_value, verbose); } - if (status == Flag::SUCCESS) { - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find(name); - if (constraint != NULL) { - status = constraint->apply_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 status; + return get_status_error(range_status, constraint_status); } Flag::Error CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) { @@ -1175,79 +1178,12 @@ 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 @@ -1277,6 +1213,7 @@ bool CommandLineFlags::_finished_initializing = false; bool CommandLineFlags::check_all_ranges_and_constraints() { + //#define PRINT_RANGES_AND_CONSTRAINTS_SIZES #ifdef PRINT_RANGES_AND_CONSTRAINTS_SIZES { @@ -1392,7 +1329,7 @@ } Arguments::post_final_range_and_constraint_check(status); - + return status; } @@ -1422,7 +1359,7 @@ qsort(array, length, sizeof(Flag*), compare_flags); // Print - if (printRanges == false) { + if (!printRanges) { out->print_cr("[Global flags]"); } else { out->print_cr("[Global flags ranges]"); @@ -1433,7 +1370,7 @@ #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); + array[i]->print_on(out, withComments, printRanges); } } FREE_C_HEAP_ARRAY(Flag*, array);