< prev index next >

src/share/vm/runtime/commandLineFlagConstraintList.cpp

Print this page

        

*** 37,47 **** class CommandLineFlagConstraint_bool : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_bool _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_bool(const char* name, CommandLineFlagConstraintFunc_bool func) : CommandLineFlagConstraint(name) { _constraint=func; } Flag::Error apply_bool(bool* value, bool verbose) { return _constraint(verbose, value); --- 37,49 ---- class CommandLineFlagConstraint_bool : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_bool _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_bool(const char* name, ! CommandLineFlagConstraintFunc_bool func, ! ConstraintType type) : CommandLineFlagConstraint(name, type) { _constraint=func; } Flag::Error apply_bool(bool* value, bool verbose) { return _constraint(verbose, value);
*** 51,61 **** class CommandLineFlagConstraint_int : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_int _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_int(const char* name, CommandLineFlagConstraintFunc_int func) : CommandLineFlagConstraint(name) { _constraint=func; } Flag::Error apply_int(int* value, bool verbose) { return _constraint(verbose, value); --- 53,65 ---- class CommandLineFlagConstraint_int : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_int _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_int(const char* name, ! CommandLineFlagConstraintFunc_int func, ! ConstraintType type) : CommandLineFlagConstraint(name, type) { _constraint=func; } Flag::Error apply_int(int* value, bool verbose) { return _constraint(verbose, value);
*** 65,75 **** class CommandLineFlagConstraint_intx : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_intx _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_intx(const char* name, CommandLineFlagConstraintFunc_intx func) : CommandLineFlagConstraint(name) { _constraint=func; } Flag::Error apply_intx(intx* value, bool verbose) { return _constraint(verbose, value); --- 69,81 ---- class CommandLineFlagConstraint_intx : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_intx _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_intx(const char* name, ! CommandLineFlagConstraintFunc_intx func, ! ConstraintType type) : CommandLineFlagConstraint(name, type) { _constraint=func; } Flag::Error apply_intx(intx* value, bool verbose) { return _constraint(verbose, value);
*** 79,89 **** class CommandLineFlagConstraint_uint : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_uint _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_uint(const char* name, CommandLineFlagConstraintFunc_uint func) : CommandLineFlagConstraint(name) { _constraint=func; } Flag::Error apply_uint(uint* value, bool verbose) { return _constraint(verbose, value); --- 85,97 ---- class CommandLineFlagConstraint_uint : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_uint _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_uint(const char* name, ! CommandLineFlagConstraintFunc_uint func, ! ConstraintType type) : CommandLineFlagConstraint(name, type) { _constraint=func; } Flag::Error apply_uint(uint* value, bool verbose) { return _constraint(verbose, value);
*** 93,103 **** class CommandLineFlagConstraint_uintx : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_uintx _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_uintx(const char* name, CommandLineFlagConstraintFunc_uintx func) : CommandLineFlagConstraint(name) { _constraint=func; } Flag::Error apply_uintx(uintx* value, bool verbose) { return _constraint(verbose, value); --- 101,113 ---- class CommandLineFlagConstraint_uintx : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_uintx _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_uintx(const char* name, ! CommandLineFlagConstraintFunc_uintx func, ! ConstraintType type) : CommandLineFlagConstraint(name, type) { _constraint=func; } Flag::Error apply_uintx(uintx* value, bool verbose) { return _constraint(verbose, value);
*** 107,117 **** class CommandLineFlagConstraint_uint64_t : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_uint64_t _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_uint64_t(const char* name, CommandLineFlagConstraintFunc_uint64_t func) : CommandLineFlagConstraint(name) { _constraint=func; } Flag::Error apply_uint64_t(uint64_t* value, bool verbose) { return _constraint(verbose, value); --- 117,129 ---- class CommandLineFlagConstraint_uint64_t : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_uint64_t _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_uint64_t(const char* name, ! CommandLineFlagConstraintFunc_uint64_t func, ! ConstraintType type) : CommandLineFlagConstraint(name, type) { _constraint=func; } Flag::Error apply_uint64_t(uint64_t* value, bool verbose) { return _constraint(verbose, value);
*** 121,131 **** class CommandLineFlagConstraint_size_t : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_size_t _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_size_t(const char* name, CommandLineFlagConstraintFunc_size_t func) : CommandLineFlagConstraint(name) { _constraint=func; } Flag::Error apply_size_t(size_t* value, bool verbose) { return _constraint(verbose, value); --- 133,145 ---- class CommandLineFlagConstraint_size_t : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_size_t _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_size_t(const char* name, ! CommandLineFlagConstraintFunc_size_t func, ! ConstraintType type) : CommandLineFlagConstraint(name, type) { _constraint=func; } Flag::Error apply_size_t(size_t* value, bool verbose) { return _constraint(verbose, value);
*** 135,145 **** class CommandLineFlagConstraint_double : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_double _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_double(const char* name, CommandLineFlagConstraintFunc_double func) : CommandLineFlagConstraint(name) { _constraint=func; } Flag::Error apply_double(double* value, bool verbose) { return _constraint(verbose, value); --- 149,161 ---- class CommandLineFlagConstraint_double : public CommandLineFlagConstraint { CommandLineFlagConstraintFunc_double _constraint; public: // the "name" argument must be a string literal ! CommandLineFlagConstraint_double(const char* name, ! CommandLineFlagConstraintFunc_double func, ! ConstraintType type) : CommandLineFlagConstraint(name, type) { _constraint=func; } Flag::Error apply_double(double* value, bool verbose) { return _constraint(verbose, value);
*** 159,192 **** void emit_constraint_uintx(const char* /*name*/) { /* NOP */ } void emit_constraint_uint64_t(const char* /*name*/) { /* NOP */ } void emit_constraint_size_t(const char* /*name*/) { /* NOP */ } void emit_constraint_double(const char* /*name*/) { /* NOP */ } // CommandLineFlagConstraint emitting code functions if function argument is provided ! void emit_constraint_bool(const char* name, CommandLineFlagConstraintFunc_bool func) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_bool(name, func)); } ! void emit_constraint_int(const char* name, CommandLineFlagConstraintFunc_int func) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_int(name, func)); } ! void emit_constraint_intx(const char* name, CommandLineFlagConstraintFunc_intx func) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_intx(name, func)); } ! void emit_constraint_uint(const char* name, CommandLineFlagConstraintFunc_uint func) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint(name, func)); } ! void emit_constraint_uintx(const char* name, CommandLineFlagConstraintFunc_uintx func) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uintx(name, func)); } ! void emit_constraint_uint64_t(const char* name, CommandLineFlagConstraintFunc_uint64_t func) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint64_t(name, func)); } ! void emit_constraint_size_t(const char* name, CommandLineFlagConstraintFunc_size_t func) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_size_t(name, func)); } ! void emit_constraint_double(const char* name, CommandLineFlagConstraintFunc_double func) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_double(name, func)); } // Generate code to call emit_constraint_xxx function #define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_COMMERCIAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name --- 175,225 ---- void emit_constraint_uintx(const char* /*name*/) { /* NOP */ } void emit_constraint_uint64_t(const char* /*name*/) { /* NOP */ } void emit_constraint_size_t(const char* /*name*/) { /* NOP */ } void emit_constraint_double(const char* /*name*/) { /* NOP */ } + CommandLineFlagConstraint::ConstraintType CommandLineFlagConstraint::change_to_enum(const char* type) { + static const char* const anytime_str = "Anytime"; + static const char* const afterParse_str = "AfterParse"; + static const char* const afterMemoryInit_str = "AfterMemoryInit"; + + if (strncmp(type, afterParse_str, 10) == 0) { + return CommandLineFlagConstraint::AfterParse; + } else if (strncmp(type, afterMemoryInit_str, 15) == 0) { + return CommandLineFlagConstraint::AfterMemoryInit; + } else if (strncmp(type, anytime_str, 7) == 0) { + return CommandLineFlagConstraint::Anytime; + } else { + ShouldNotReachHere(); + return CommandLineFlagConstraint::AfterMemoryInit; + } + } + // CommandLineFlagConstraint emitting code functions if function argument is provided ! void emit_constraint_bool(const char* name, CommandLineFlagConstraintFunc_bool func, const char* type) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_bool(name, func, CommandLineFlagConstraint::change_to_enum(type))); } ! void emit_constraint_int(const char* name, CommandLineFlagConstraintFunc_int func, const char* type) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_int(name, func, CommandLineFlagConstraint::change_to_enum(type))); } ! void emit_constraint_intx(const char* name, CommandLineFlagConstraintFunc_intx func, const char* type) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_intx(name, func, CommandLineFlagConstraint::change_to_enum(type))); } ! void emit_constraint_uint(const char* name, CommandLineFlagConstraintFunc_uint func, const char* type) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint(name, func, CommandLineFlagConstraint::change_to_enum(type))); } ! void emit_constraint_uintx(const char* name, CommandLineFlagConstraintFunc_uintx func, const char* type) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uintx(name, func, CommandLineFlagConstraint::change_to_enum(type))); } ! void emit_constraint_uint64_t(const char* name, CommandLineFlagConstraintFunc_uint64_t func, const char* type) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint64_t(name, func, CommandLineFlagConstraint::change_to_enum(type))); } ! void emit_constraint_size_t(const char* name, CommandLineFlagConstraintFunc_size_t func, const char* type) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_size_t(name, func, CommandLineFlagConstraint::change_to_enum(type))); } ! void emit_constraint_double(const char* name, CommandLineFlagConstraintFunc_double func, const char* type) { ! CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_double(name, func, CommandLineFlagConstraint::change_to_enum(type))); } // Generate code to call emit_constraint_xxx function #define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_COMMERCIAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
*** 199,213 **** #define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name // Generate func argument to pass into emit_constraint_xxx functions ! #define EMIT_CONSTRAINT_CHECK(func) , func // the "name" argument must be a string literal #define INITIAL_CONTRAINTS_SIZE 16 GrowableArray<CommandLineFlagConstraint*>* CommandLineFlagConstraintList::_constraints = NULL; // Check the ranges of all flags that have them or print them out and exit if requested void CommandLineFlagConstraintList::init(void) { _constraints = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<CommandLineFlagConstraint*>(INITIAL_CONTRAINTS_SIZE, true); --- 232,247 ---- #define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name #define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name // Generate func argument to pass into emit_constraint_xxx functions ! #define EMIT_CONSTRAINT_CHECK(func, type) , func, #type // the "name" argument must be a string literal #define INITIAL_CONTRAINTS_SIZE 16 GrowableArray<CommandLineFlagConstraint*>* CommandLineFlagConstraintList::_constraints = NULL; + CommandLineFlagConstraint::ConstraintType CommandLineFlagConstraintList::_validationType = CommandLineFlagConstraint::Anytime; // Check the ranges of all flags that have them or print them out and exit if requested void CommandLineFlagConstraintList::init(void) { _constraints = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<CommandLineFlagConstraint*>(INITIAL_CONTRAINTS_SIZE, true);
*** 271,285 **** IGNORE_RANGE, EMIT_CONSTRAINT_CHECK)); #endif // INCLUDE_ALL_GCS } ! CommandLineFlagConstraint* CommandLineFlagConstraintList::find(const char* name) { CommandLineFlagConstraint* found = NULL; for (int i=0; i<length(); i++) { CommandLineFlagConstraint* constraint = at(i); ! if (strcmp(constraint->name(), name) == 0) { found = constraint; break; } } return found; --- 305,321 ---- IGNORE_RANGE, EMIT_CONSTRAINT_CHECK)); #endif // INCLUDE_ALL_GCS } ! // Find constraints by name and return only if found constraint's type is equal or lower than current validating type. ! CommandLineFlagConstraint* CommandLineFlagConstraintList::find_if_validated(const char* name) { CommandLineFlagConstraint* found = NULL; for (int i=0; i<length(); i++) { CommandLineFlagConstraint* constraint = at(i); ! if ((strcmp(constraint->name(), name) == 0) && ! (constraint->type() <= _validationType)) { found = constraint; break; } } return found;
< prev index next >