47 typedef Flag::Error (*CommandLineFlagConstraintFunc_uint64_t)(bool verbose, uint64_t* 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); |
48 typedef Flag::Error (*CommandLineFlagConstraintFunc_size_t)(bool verbose, size_t* value); |
49 typedef Flag::Error (*CommandLineFlagConstraintFunc_double)(bool verbose, double* value); |
49 typedef Flag::Error (*CommandLineFlagConstraintFunc_double)(bool verbose, double* value); |
50 |
50 |
51 class CommandLineFlagConstraint : public CHeapObj<mtInternal> { |
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 (Arguments::parse_argument). |
|
56 AtParse = 0, |
|
57 // Will be validated by CommandLineFlags::check_constraints_of_after_ergo(). |
|
58 AfterErgo = 1, |
|
59 // Will be validated by CommandLineFlags::check_constraints_of_after_memory_init(). |
|
60 AfterMemoryInit = 2 |
|
61 }; |
|
62 |
52 private: |
63 private: |
53 const char* _name; |
64 const char* _name; |
|
65 ConstraintType _validate_type; |
|
66 |
54 public: |
67 public: |
55 // the "name" argument must be a string literal |
68 // the "name" argument must be a string literal |
56 CommandLineFlagConstraint(const char* name) { _name=name; }; |
69 CommandLineFlagConstraint(const char* name, ConstraintType type) { _name=name; _validate_type=type; }; |
57 ~CommandLineFlagConstraint() {}; |
70 ~CommandLineFlagConstraint() {}; |
58 const char* name() { return _name; } |
71 const char* name() const { return _name; } |
|
72 ConstraintType type() const { return _validate_type; } |
59 virtual Flag::Error apply_bool(bool* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; |
73 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; }; |
74 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; }; |
75 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; }; |
76 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; }; |
77 virtual Flag::Error apply_uintx(uintx* value, bool verbose = true) { ShouldNotReachHere(); return Flag::ERR_OTHER; }; |
67 }; |
81 }; |
68 |
82 |
69 class CommandLineFlagConstraintList : public AllStatic { |
83 class CommandLineFlagConstraintList : public AllStatic { |
70 private: |
84 private: |
71 static GrowableArray<CommandLineFlagConstraint*>* _constraints; |
85 static GrowableArray<CommandLineFlagConstraint*>* _constraints; |
|
86 // Latest constraint validation type. |
|
87 static CommandLineFlagConstraint::ConstraintType _validating_type; |
72 public: |
88 public: |
73 static void init(); |
89 static void init(); |
74 static int length() { return (_constraints != NULL) ? _constraints->length() : 0; } |
90 static int length() { return (_constraints != NULL) ? _constraints->length() : 0; } |
75 static CommandLineFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; } |
91 static CommandLineFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; } |
76 static CommandLineFlagConstraint* find(const char* name); |
92 static CommandLineFlagConstraint* find_if_needs_check(const char* name); |
77 static void add(CommandLineFlagConstraint* constraint) { _constraints->append(constraint); } |
93 static void add(CommandLineFlagConstraint* constraint) { _constraints->append(constraint); } |
|
94 // True if 'AfterErgo' or later constraint functions are validated. |
|
95 static bool validated_after_ergo() { return _validating_type >= CommandLineFlagConstraint::AfterErgo; }; |
|
96 static bool check_constraints(CommandLineFlagConstraint::ConstraintType type); |
78 }; |
97 }; |
79 |
98 |
80 #endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP */ |
99 #endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTLIST_HPP */ |