< prev index next >

src/hotspot/share/runtime/flags/jvmFlagConstraintList.hpp

Print this page




  30 
  31 /*
  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/flags/jvmFlagConstraintsCompiler.hpp",
  38  * "runtime/flags/jvmFlagConstraintsGC.hpp" and
  39  * "runtime/flags/jvmFlagConstraintsRuntime.hpp" for the functions themselves.
  40  */
  41 
  42 typedef JVMFlag::Error (*JVMFlagConstraintFunc_bool)(bool value, bool verbose);
  43 typedef JVMFlag::Error (*JVMFlagConstraintFunc_int)(int value, bool verbose);
  44 typedef JVMFlag::Error (*JVMFlagConstraintFunc_intx)(intx value, bool verbose);
  45 typedef JVMFlag::Error (*JVMFlagConstraintFunc_uint)(uint value, bool verbose);
  46 typedef JVMFlag::Error (*JVMFlagConstraintFunc_uintx)(uintx value, bool verbose);
  47 typedef JVMFlag::Error (*JVMFlagConstraintFunc_uint64_t)(uint64_t value, bool verbose);
  48 typedef JVMFlag::Error (*JVMFlagConstraintFunc_size_t)(size_t value, bool verbose);
  49 typedef JVMFlag::Error (*JVMFlagConstraintFunc_double)(double value, bool verbose);

  50 
  51 class JVMFlagConstraint : public CHeapObj<mtArguments> {
  52 public:
  53   // During VM initialization, constraint validation will be done order of ConstraintType.
  54   enum ConstraintType {
  55     // Will be validated during argument processing (Arguments::parse_argument).
  56     AtParse         = 0,
  57     // Will be validated inside Threads::create_vm(), right after Arguments::apply_ergo().
  58     AfterErgo       = 1,
  59     // Will be validated inside universe_init(), right after Metaspace::global_initialize().
  60     AfterMemoryInit = 2
  61   };
  62 
  63 protected:
  64   const JVMFlag* const _flag;
  65 
  66 private:
  67   ConstraintType _validate_type;
  68 
  69 public:
  70   // the "name" argument must be a string literal
  71   JVMFlagConstraint(const JVMFlag* flag, ConstraintType type) : _flag(flag), _validate_type(type) {}
  72   ~JVMFlagConstraint() {}
  73   const JVMFlag* flag() const { return _flag; }
  74   ConstraintType type() const { return _validate_type; }
  75   virtual JVMFlag::Error apply(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  76   virtual JVMFlag::Error apply_bool(bool value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  77   virtual JVMFlag::Error apply_int(int value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  78   virtual JVMFlag::Error apply_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  79   virtual JVMFlag::Error apply_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  80   virtual JVMFlag::Error apply_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  81   virtual JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  82   virtual JVMFlag::Error apply_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  83   virtual JVMFlag::Error apply_double(double value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };

  84 };
  85 
  86 class JVMFlagConstraintList : public AllStatic {
  87 private:
  88   static GrowableArray<JVMFlagConstraint*>* _constraints;
  89   // Latest constraint validation type.
  90   static JVMFlagConstraint::ConstraintType _validating_type;
  91 public:
  92   static void init();
  93   static int length() { return (_constraints != NULL) ? _constraints->length() : 0; }
  94   static JVMFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; }
  95   static JVMFlagConstraint* find(const JVMFlag* flag);
  96   static JVMFlagConstraint* find_if_needs_check(const JVMFlag* flag);
  97   static void add(JVMFlagConstraint* constraint) { _constraints->append(constraint); }
  98   // True if 'AfterErgo' or later constraint functions are validated.
  99   static bool validated_after_ergo() { return _validating_type >= JVMFlagConstraint::AfterErgo; };
 100   static bool check_constraints(JVMFlagConstraint::ConstraintType type);
 101 };
 102 
 103 #endif // SHARE_RUNTIME_FLAGS_JVMFLAGCONSTRAINTLIST_HPP


  30 
  31 /*
  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/flags/jvmFlagConstraintsCompiler.hpp",
  38  * "runtime/flags/jvmFlagConstraintsGC.hpp" and
  39  * "runtime/flags/jvmFlagConstraintsRuntime.hpp" for the functions themselves.
  40  */
  41 
  42 typedef JVMFlag::Error (*JVMFlagConstraintFunc_bool)(bool value, bool verbose);
  43 typedef JVMFlag::Error (*JVMFlagConstraintFunc_int)(int value, bool verbose);
  44 typedef JVMFlag::Error (*JVMFlagConstraintFunc_intx)(intx value, bool verbose);
  45 typedef JVMFlag::Error (*JVMFlagConstraintFunc_uint)(uint value, bool verbose);
  46 typedef JVMFlag::Error (*JVMFlagConstraintFunc_uintx)(uintx value, bool verbose);
  47 typedef JVMFlag::Error (*JVMFlagConstraintFunc_uint64_t)(uint64_t value, bool verbose);
  48 typedef JVMFlag::Error (*JVMFlagConstraintFunc_size_t)(size_t value, bool verbose);
  49 typedef JVMFlag::Error (*JVMFlagConstraintFunc_double)(double value, bool verbose);
  50 typedef JVMFlag::Error (*JVMFlagConstraintFunc_ccstrlist)(ccstrlist value, bool verbose);
  51 
  52 class JVMFlagConstraint : public CHeapObj<mtArguments> {
  53 public:
  54   // During VM initialization, constraint validation will be done order of ConstraintType.
  55   enum ConstraintType {
  56     // Will be validated during argument processing (Arguments::parse_argument).
  57     AtParse         = 0,
  58     // Will be validated inside Threads::create_vm(), right after Arguments::apply_ergo().
  59     AfterErgo       = 1,
  60     // Will be validated inside universe_init(), right after Metaspace::global_initialize().
  61     AfterMemoryInit = 2
  62   };
  63 
  64 protected:
  65   const JVMFlag* const _flag;
  66 
  67 private:
  68   ConstraintType _validate_type;
  69 
  70 public:
  71   // the "name" argument must be a string literal
  72   JVMFlagConstraint(const JVMFlag* flag, ConstraintType type) : _flag(flag), _validate_type(type) {}
  73   ~JVMFlagConstraint() {}
  74   const JVMFlag* flag() const { return _flag; }
  75   ConstraintType type() const { return _validate_type; }
  76   virtual JVMFlag::Error apply(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  77   virtual JVMFlag::Error apply_bool(bool value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  78   virtual JVMFlag::Error apply_int(int value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  79   virtual JVMFlag::Error apply_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  80   virtual JVMFlag::Error apply_uint(uint value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  81   virtual JVMFlag::Error apply_uintx(uintx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  82   virtual JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  83   virtual JVMFlag::Error apply_size_t(size_t value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  84   virtual JVMFlag::Error apply_double(double value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  85   virtual JVMFlag::Error apply_ccstrlist(ccstrlist value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
  86 };
  87 
  88 class JVMFlagConstraintList : public AllStatic {
  89 private:
  90   static GrowableArray<JVMFlagConstraint*>* _constraints;
  91   // Latest constraint validation type.
  92   static JVMFlagConstraint::ConstraintType _validating_type;
  93 public:
  94   static void init();
  95   static int length() { return (_constraints != NULL) ? _constraints->length() : 0; }
  96   static JVMFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; }
  97   static JVMFlagConstraint* find(const JVMFlag* flag);
  98   static JVMFlagConstraint* find_if_needs_check(const JVMFlag* flag);
  99   static void add(JVMFlagConstraint* constraint) { _constraints->append(constraint); }
 100   // True if 'AfterErgo' or later constraint functions are validated.
 101   static bool validated_after_ergo() { return _validating_type >= JVMFlagConstraint::AfterErgo; };
 102   static bool check_constraints(JVMFlagConstraint::ConstraintType type);
 103 };
 104 
 105 #endif // SHARE_RUNTIME_FLAGS_JVMFLAGCONSTRAINTLIST_HPP
< prev index next >