< prev index next >

src/share/vm/runtime/commandLineFlagConstraintList.hpp

Print this page




  32  * Here we have a mechanism for extracting constraints (as custom functions) for flags,
  33  * which otherwise can not be expressed via simple range check, specified in flag macro tables.
  34  *
  35  * An example of a constraint is "flag1 < flag2" where both flag1 and flag2 can change.
  36  *
  37  * See runtime "runtime/commandLineFlagConstraintsCompiler.hpp",
  38  * "runtime/commandLineFlagConstraintsGC.hpp" and
  39  * "runtime/commandLineFlagConstraintsRuntime.hpp" for the functions themselves.
  40  */
  41 
  42 typedef Flag::Error (*CommandLineFlagConstraintFunc_bool)(bool verbose, bool* value);
  43 typedef Flag::Error (*CommandLineFlagConstraintFunc_int)(bool verbose, int* value);
  44 typedef Flag::Error (*CommandLineFlagConstraintFunc_intx)(bool verbose, intx* value);
  45 typedef Flag::Error (*CommandLineFlagConstraintFunc_uint)(bool verbose, uint* value);
  46 typedef Flag::Error (*CommandLineFlagConstraintFunc_uintx)(bool verbose, uintx* value);
  47 typedef Flag::Error (*CommandLineFlagConstraintFunc_uint64_t)(bool verbose, uint64_t* value);
  48 typedef Flag::Error (*CommandLineFlagConstraintFunc_size_t)(bool verbose, size_t* value);
  49 typedef Flag::Error (*CommandLineFlagConstraintFunc_double)(bool verbose, double* value);
  50 
  51 class CommandLineFlagConstraint : public CHeapObj<mtInternal> {
  52 private:
  53   const char* _name;
  54 public:









  55   // the "name" argument must be a string literal
  56   CommandLineFlagConstraint(const char* name) { _name=name; };
  57   ~CommandLineFlagConstraint() {};
  58   const char* name() { return _name; }

  59   virtual Flag::Error apply_bool(bool* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  60   virtual Flag::Error apply_int(int* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  61   virtual Flag::Error apply_intx(intx* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  62   virtual Flag::Error apply_uint(uint* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  63   virtual Flag::Error apply_uintx(uintx* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  64   virtual Flag::Error apply_uint64_t(uint64_t* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  65   virtual Flag::Error apply_size_t(size_t* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  66   virtual Flag::Error apply_double(double* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };







  67 };
  68 
  69 class CommandLineFlagConstraintList : public AllStatic {
  70 private:
  71   static GrowableArray<CommandLineFlagConstraint*>* _constraints;


  72 public:
  73   static void init();
  74   static int length() { return (_constraints != NULL) ? _constraints->length() : 0; }
  75   static CommandLineFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; }
  76   static CommandLineFlagConstraint* find(const char* name);
  77   static void add(CommandLineFlagConstraint* constraint) { _constraints->append(constraint); }




  78 };
  79 
  80 #endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP */


  32  * Here we have a mechanism for extracting constraints (as custom functions) for flags,
  33  * which otherwise can not be expressed via simple range check, specified in flag macro tables.
  34  *
  35  * An example of a constraint is "flag1 < flag2" where both flag1 and flag2 can change.
  36  *
  37  * See runtime "runtime/commandLineFlagConstraintsCompiler.hpp",
  38  * "runtime/commandLineFlagConstraintsGC.hpp" and
  39  * "runtime/commandLineFlagConstraintsRuntime.hpp" for the functions themselves.
  40  */
  41 
  42 typedef Flag::Error (*CommandLineFlagConstraintFunc_bool)(bool verbose, bool* value);
  43 typedef Flag::Error (*CommandLineFlagConstraintFunc_int)(bool verbose, int* value);
  44 typedef Flag::Error (*CommandLineFlagConstraintFunc_intx)(bool verbose, intx* value);
  45 typedef Flag::Error (*CommandLineFlagConstraintFunc_uint)(bool verbose, uint* value);
  46 typedef Flag::Error (*CommandLineFlagConstraintFunc_uintx)(bool verbose, uintx* value);
  47 typedef Flag::Error (*CommandLineFlagConstraintFunc_uint64_t)(bool verbose, uint64_t* value);
  48 typedef Flag::Error (*CommandLineFlagConstraintFunc_size_t)(bool verbose, size_t* value);
  49 typedef Flag::Error (*CommandLineFlagConstraintFunc_double)(bool verbose, double* value);
  50 
  51 class CommandLineFlagConstraint : public CHeapObj<mtInternal> {


  52 public:
  53   // During VM initialization, constraint validation will be done order of ConstraintType.
  54   enum ConstraintType {
  55     // Will be validated during argument processing.
  56     Anytime         = 0,
  57     // Will be validated by CommandLineFlags::check_ranges_and_constraints_of_after_parse().
  58     AfterParse      = 1,
  59     // Will be validated by CommandLineFlags::check_constraints_of_after_memory_init().
  60     AfterMemoryInit = 2
  61   };
  62   // the "name" argument must be a string literal
  63   CommandLineFlagConstraint(const char* name, ConstraintType type) { _name=name; _validate_type=type; };
  64   ~CommandLineFlagConstraint() {};
  65   const char* name() { return _name; }
  66   ConstraintType type() { return _validate_type; }
  67   virtual Flag::Error apply_bool(bool* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  68   virtual Flag::Error apply_int(int* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  69   virtual Flag::Error apply_intx(intx* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  70   virtual Flag::Error apply_uint(uint* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  71   virtual Flag::Error apply_uintx(uintx* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  72   virtual Flag::Error apply_uint64_t(uint64_t* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  73   virtual Flag::Error apply_size_t(size_t* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  74   virtual Flag::Error apply_double(double* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; };
  75 
  76   // Change a string literal to ConstraintType
  77   static ConstraintType change_to_enum(const char* type);
  78 
  79 private:
  80   const char* _name;
  81   ConstraintType _validate_type;
  82 };
  83 
  84 class CommandLineFlagConstraintList : public AllStatic {
  85 private:
  86   static GrowableArray<CommandLineFlagConstraint*>* _constraints;
  87   // Latest constraint validation type.
  88   static CommandLineFlagConstraint::ConstraintType _validationType;
  89 public:
  90   static void init();
  91   static int length() { return (_constraints != NULL) ? _constraints->length() : 0; }
  92   static CommandLineFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; }
  93   static CommandLineFlagConstraint* find_if_validated(const char* name);
  94   static void add(CommandLineFlagConstraint* constraint) { _constraints->append(constraint); }
  95   // True if 'AfterParse' or later constraint functions are validated.
  96   static bool validatedAfterParse() { return _validationType >= CommandLineFlagConstraint::AfterParse; };
  97   // Set current validation type
  98   static void setValidatingType(CommandLineFlagConstraint::ConstraintType type) { _validationType = type; };
  99 };
 100 
 101 #endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP */
< prev index next >