203 CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_double(name, func, type));
204 }
205
206 // Generate code to call emit_constraint_xxx function
207 #define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
208 #define EMIT_CONSTRAINT_COMMERCIAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
209 #define EMIT_CONSTRAINT_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
210 #define EMIT_CONSTRAINT_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
211 #define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
212 #define EMIT_CONSTRAINT_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
213 #define EMIT_CONSTRAINT_PD_PRODUCT_FLAG(type, name, doc) ); emit_constraint_##type(#name
214 #define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
215 #define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name
216 #define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
217 #define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
218
219 // Generate func argument to pass into emit_constraint_xxx functions
220 #define EMIT_CONSTRAINT_CHECK(func, type) , func, CommandLineFlagConstraint::type
221
222 // the "name" argument must be a string literal
223 #define INITIAL_CONSTRAINTS_SIZE 40
224 GrowableArray<CommandLineFlagConstraint*>* CommandLineFlagConstraintList::_constraints = NULL;
225 CommandLineFlagConstraint::ConstraintType CommandLineFlagConstraintList::_validating_type = CommandLineFlagConstraint::AtParse;
226
227 // Check the ranges of all flags that have them or print them out and exit if requested
228 void CommandLineFlagConstraintList::init(void) {
229 _constraints = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<CommandLineFlagConstraint*>(INITIAL_CONSTRAINTS_SIZE, true);
230
231 emit_constraint_no(NULL RUNTIME_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
232 EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
233 EMIT_CONSTRAINT_PRODUCT_FLAG,
234 EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
235 EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
236 EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
237 EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
238 EMIT_CONSTRAINT_MANAGEABLE_FLAG,
239 EMIT_CONSTRAINT_PRODUCT_RW_FLAG,
240 EMIT_CONSTRAINT_LP64_PRODUCT_FLAG,
241 IGNORE_RANGE,
242 EMIT_CONSTRAINT_CHECK));
243
257 EMIT_CONSTRAINT_PRODUCT_FLAG,
258 EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
259 EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
260 EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
261 IGNORE_RANGE,
262 EMIT_CONSTRAINT_CHECK));
263 #endif // COMPILER1
264
265 #ifdef COMPILER2
266 emit_constraint_no(NULL C2_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
267 EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
268 EMIT_CONSTRAINT_PRODUCT_FLAG,
269 EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
270 EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
271 EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
272 EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
273 IGNORE_RANGE,
274 EMIT_CONSTRAINT_CHECK));
275 #endif // COMPILER2
276
277 #if INCLUDE_ALL_GCS
278 emit_constraint_no(NULL G1_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
279 EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
280 EMIT_CONSTRAINT_PRODUCT_FLAG,
281 EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
282 EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
283 EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
284 EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
285 EMIT_CONSTRAINT_MANAGEABLE_FLAG,
286 EMIT_CONSTRAINT_PRODUCT_RW_FLAG,
287 IGNORE_RANGE,
288 EMIT_CONSTRAINT_CHECK));
289 #endif // INCLUDE_ALL_GCS
290 }
291
292 // Find constraints by name and return only if found constraint's type is equal or lower than current validating type.
293 CommandLineFlagConstraint* CommandLineFlagConstraintList::find_if_needs_check(const char* name) {
294 CommandLineFlagConstraint* found = NULL;
295 for (int i=0; i<length(); i++) {
296 CommandLineFlagConstraint* constraint = at(i);
297 if ((strcmp(constraint->name(), name) == 0) &&
298 (constraint->type() <= _validating_type)) {
299 found = constraint;
300 break;
301 }
302 }
303 return found;
304 }
305
306 // Check constraints for specific constraint type.
307 bool CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::ConstraintType type) {
308 guarantee(type > _validating_type, "Constraint check is out of order.");
309 _validating_type = type;
310
311 bool status = true;
312 for (int i=0; i<length(); i++) {
313 CommandLineFlagConstraint* constraint = at(i);
314 if (type != constraint->type()) continue;
315 const char* name = constraint->name();
316 Flag* flag = Flag::find_flag(name, strlen(name), true, true);
317 // We must check for NULL here as lp64_product flags on 32 bit architecture
318 // can generate constraint check (despite that they are declared as constants),
319 // but they will not be returned by Flag::find_flag()
320 if (flag != NULL) {
321 if (flag->is_bool()) {
322 bool value = flag->get_bool();
323 if (constraint->apply_bool(value, true) != Flag::SUCCESS) status = false;
324 } else if (flag->is_int()) {
325 int value = flag->get_int();
326 if (constraint->apply_int(value, true) != Flag::SUCCESS) status = false;
327 } else if (flag->is_uint()) {
328 uint value = flag->get_uint();
|
203 CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_double(name, func, type));
204 }
205
206 // Generate code to call emit_constraint_xxx function
207 #define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
208 #define EMIT_CONSTRAINT_COMMERCIAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
209 #define EMIT_CONSTRAINT_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
210 #define EMIT_CONSTRAINT_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
211 #define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
212 #define EMIT_CONSTRAINT_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
213 #define EMIT_CONSTRAINT_PD_PRODUCT_FLAG(type, name, doc) ); emit_constraint_##type(#name
214 #define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
215 #define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name
216 #define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
217 #define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
218
219 // Generate func argument to pass into emit_constraint_xxx functions
220 #define EMIT_CONSTRAINT_CHECK(func, type) , func, CommandLineFlagConstraint::type
221
222 // the "name" argument must be a string literal
223 #define INITIAL_CONSTRAINTS_SIZE 16
224 GrowableArray<CommandLineFlagConstraint*>* CommandLineFlagConstraintList::_constraints = NULL;
225 CommandLineFlagConstraint::ConstraintType CommandLineFlagConstraintList::_validating_type = CommandLineFlagConstraint::AtParse;
226
227 // Check the ranges of all flags that have them or print them out and exit if requested
228 void CommandLineFlagConstraintList::init(void) {
229 _constraints = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<CommandLineFlagConstraint*>(INITIAL_CONSTRAINTS_SIZE, true);
230
231 emit_constraint_no(NULL RUNTIME_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
232 EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
233 EMIT_CONSTRAINT_PRODUCT_FLAG,
234 EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
235 EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
236 EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
237 EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
238 EMIT_CONSTRAINT_MANAGEABLE_FLAG,
239 EMIT_CONSTRAINT_PRODUCT_RW_FLAG,
240 EMIT_CONSTRAINT_LP64_PRODUCT_FLAG,
241 IGNORE_RANGE,
242 EMIT_CONSTRAINT_CHECK));
243
257 EMIT_CONSTRAINT_PRODUCT_FLAG,
258 EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
259 EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
260 EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
261 IGNORE_RANGE,
262 EMIT_CONSTRAINT_CHECK));
263 #endif // COMPILER1
264
265 #ifdef COMPILER2
266 emit_constraint_no(NULL C2_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
267 EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
268 EMIT_CONSTRAINT_PRODUCT_FLAG,
269 EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
270 EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
271 EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
272 EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
273 IGNORE_RANGE,
274 EMIT_CONSTRAINT_CHECK));
275 #endif // COMPILER2
276
277 #ifndef INCLUDE_ALL_GCS
278 emit_constraint_no(NULL G1_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
279 EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
280 EMIT_CONSTRAINT_PRODUCT_FLAG,
281 EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
282 EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
283 EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
284 EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
285 EMIT_CONSTRAINT_MANAGEABLE_FLAG,
286 EMIT_CONSTRAINT_PRODUCT_RW_FLAG,
287 IGNORE_RANGE,
288 EMIT_CONSTRAINT_CHECK));
289 #endif // INCLUDE_ALL_GCS
290 }
291
292 // Find constraints by name and return only if found constraint's type is equal or lower than current validating type.
293 CommandLineFlagConstraint* CommandLineFlagConstraintList::find_if_needs_check(const char* name) {
294 CommandLineFlagConstraint* found = NULL;
295 for (int i=0; i<length(); i++) {
296 CommandLineFlagConstraint* constraint = at(i);
297 if ((strcmp(constraint->name(), name) == 0) &&
298 (constraint->type() <= _validating_type)) {
299 found = constraint;
300 break;
301 }
302 }
303 return found;
304 }
305
306 // Check constraints for specific constraint type.
307 bool CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::ConstraintType type) {
308 // Skip if we already checked.
309 if (type < _validating_type) {
310 return true;
311 }
312 _validating_type = type;
313
314 bool status = true;
315 for (int i=0; i<length(); i++) {
316 CommandLineFlagConstraint* constraint = at(i);
317 if (type != constraint->type()) continue;
318 const char* name = constraint->name();
319 Flag* flag = Flag::find_flag(name, strlen(name), true, true);
320 // We must check for NULL here as lp64_product flags on 32 bit architecture
321 // can generate constraint check (despite that they are declared as constants),
322 // but they will not be returned by Flag::find_flag()
323 if (flag != NULL) {
324 if (flag->is_bool()) {
325 bool value = flag->get_bool();
326 if (constraint->apply_bool(value, true) != Flag::SUCCESS) status = false;
327 } else if (flag->is_int()) {
328 int value = flag->get_int();
329 if (constraint->apply_int(value, true) != Flag::SUCCESS) status = false;
330 } else if (flag->is_uint()) {
331 uint value = flag->get_uint();
|