1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
247 const char* _name;
248 void* _addr;
249 NOT_PRODUCT(const char* _doc;)
250 Flags _flags;
251
252 // points to all Flags static array
253 static Flag* flags;
254
255 // number of flags
256 static size_t numFlags;
257
258 static Flag* find_flag(const char* name, size_t length, bool allow_locked = false, bool return_flag = false);
259 static Flag* fuzzy_match(const char* name, size_t length, bool allow_locked = false);
260
261 void check_writable();
262
263 bool is_bool() const;
264 bool get_bool() const;
265 void set_bool(bool value);
266
267 bool is_intx() const;
268 intx get_intx() const;
269 void set_intx(intx value);
270
271 bool is_uintx() const;
272 uintx get_uintx() const;
273 void set_uintx(uintx value);
274
275 bool is_uint64_t() const;
276 uint64_t get_uint64_t() const;
277 void set_uint64_t(uint64_t value);
278
279 bool is_double() const;
280 double get_double() const;
281 void set_double(double value);
282
283 bool is_ccstr() const;
284 bool ccstr_accumulates() const;
285 ccstr get_ccstr() const;
286 void set_ccstr(ccstr value);
287
288 Flags get_origin();
289 void set_origin(Flags origin);
290
291 bool is_default();
292 bool is_ergonomic();
293 bool is_command_line();
294
295 bool is_product() const;
296 bool is_manageable() const;
297 bool is_diagnostic() const;
298 bool is_experimental() const;
358 double val;
359 double* flag;
360 public:
361 DoubleFlagSetting(double& fl, double newValue) { flag = &fl; val = fl; fl = newValue; }
362 ~DoubleFlagSetting() { *flag = val; }
363 };
364
365
366 class CommandLineFlags {
367 public:
368 static bool boolAt(const char* name, size_t len, bool* value);
369 static bool boolAt(const char* name, bool* value) { return boolAt(name, strlen(name), value); }
370 static bool boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin);
371 static bool boolAtPut(const char* name, bool* value, Flag::Flags origin) { return boolAtPut(name, strlen(name), value, origin); }
372
373 static bool intxAt(const char* name, size_t len, intx* value);
374 static bool intxAt(const char* name, intx* value) { return intxAt(name, strlen(name), value); }
375 static bool intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin);
376 static bool intxAtPut(const char* name, intx* value, Flag::Flags origin) { return intxAtPut(name, strlen(name), value, origin); }
377
378 static bool uintxAt(const char* name, size_t len, uintx* value);
379 static bool uintxAt(const char* name, uintx* value) { return uintxAt(name, strlen(name), value); }
380 static bool uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin);
381 static bool uintxAtPut(const char* name, uintx* value, Flag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); }
382
383 static bool uint64_tAt(const char* name, size_t len, uint64_t* value);
384 static bool uint64_tAt(const char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); }
385 static bool uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin);
386 static bool uint64_tAtPut(const char* name, uint64_t* value, Flag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
387
388 static bool doubleAt(const char* name, size_t len, double* value);
389 static bool doubleAt(const char* name, double* value) { return doubleAt(name, strlen(name), value); }
390 static bool doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin);
391 static bool doubleAtPut(const char* name, double* value, Flag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); }
392
393 static bool ccstrAt(const char* name, size_t len, ccstr* value);
394 static bool ccstrAt(const char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); }
395 // Contract: Flag will make private copy of the incoming value.
396 // Outgoing value is always malloc-ed, and caller MUST call free.
397 static bool ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin);
398 static bool ccstrAtPut(const char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); }
399
400 // Returns false if name is not a command line flag.
401 static bool wasSetOnCmdline(const char* name, bool* value);
402 static void printSetFlags(outputStream* out);
403
404 static void printFlags(outputStream* out, bool withComments);
405
406 static void verify() PRODUCT_RETURN;
407 };
408
409 // use this for flags that are true by default in the debug version but
410 // false in the optimized version, and vice versa
411 #ifdef ASSERT
412 #define trueInDebug true
413 #define falseInDebug false
414 #else
415 #define trueInDebug false
416 #define falseInDebug true
417 #endif
418
419 // use this for flags that are true per default in the product build
420 // but false in development builds, and vice versa
421 #ifdef PRODUCT
422 #define trueInProduct true
423 #define falseInProduct false
424 #else
425 #define trueInProduct false
426 #define falseInProduct true
427 #endif
428
3973 \
3974 diagnostic(ccstr, SharedArchiveFile, NULL, \
3975 "Override the default location of the CDS archive file") \
3976 \
3977 product(ccstr, ExtraSharedClassListFile, NULL, \
3978 "Extra classlist for building the CDS archive file") \
3979 \
3980 experimental(uintx, ArrayAllocatorMallocLimit, \
3981 SOLARIS_ONLY(64*K) NOT_SOLARIS(max_uintx), \
3982 "Allocation less than this value will be allocated " \
3983 "using malloc. Larger allocations will use mmap.") \
3984 \
3985 product(bool, EnableTracing, false, \
3986 "Enable event-based tracing") \
3987 \
3988 product(bool, UseLockedTracing, false, \
3989 "Use locked-tracing when doing event-based tracing") \
3990 \
3991 product_pd(bool, PreserveFramePointer, \
3992 "Use the FP register for holding the frame pointer " \
3993 "and not as a general purpose register.")
3994
3995 /*
3996 * Macros for factoring of globals
3997 */
3998
3999 // Interface macros
4000 #define DECLARE_PRODUCT_FLAG(type, name, value, doc) extern "C" type name;
4001 #define DECLARE_PD_PRODUCT_FLAG(type, name, doc) extern "C" type name;
4002 #define DECLARE_DIAGNOSTIC_FLAG(type, name, value, doc) extern "C" type name;
4003 #define DECLARE_EXPERIMENTAL_FLAG(type, name, value, doc) extern "C" type name;
4004 #define DECLARE_MANAGEABLE_FLAG(type, name, value, doc) extern "C" type name;
4005 #define DECLARE_PRODUCT_RW_FLAG(type, name, value, doc) extern "C" type name;
4006 #ifdef PRODUCT
4007 #define DECLARE_DEVELOPER_FLAG(type, name, value, doc) extern "C" type CONST_##name; const type name = value;
4008 #define DECLARE_PD_DEVELOPER_FLAG(type, name, doc) extern "C" type CONST_##name; const type name = pd_##name;
4009 #define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc) extern "C" type CONST_##name;
4010 #else
4011 #define DECLARE_DEVELOPER_FLAG(type, name, value, doc) extern "C" type name;
4012 #define DECLARE_PD_DEVELOPER_FLAG(type, name, doc) extern "C" type name;
4013 #define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc) extern "C" type name;
|
1 /*
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
247 const char* _name;
248 void* _addr;
249 NOT_PRODUCT(const char* _doc;)
250 Flags _flags;
251
252 // points to all Flags static array
253 static Flag* flags;
254
255 // number of flags
256 static size_t numFlags;
257
258 static Flag* find_flag(const char* name, size_t length, bool allow_locked = false, bool return_flag = false);
259 static Flag* fuzzy_match(const char* name, size_t length, bool allow_locked = false);
260
261 void check_writable();
262
263 bool is_bool() const;
264 bool get_bool() const;
265 void set_bool(bool value);
266
267 bool is_int() const;
268 int get_int() const;
269 void set_int(int value);
270
271 bool is_uint() const;
272 uint get_uint() const;
273 void set_uint(uint value);
274
275 bool is_intx() const;
276 intx get_intx() const;
277 void set_intx(intx value);
278
279 bool is_uintx() const;
280 uintx get_uintx() const;
281 void set_uintx(uintx value);
282
283 bool is_uint64_t() const;
284 uint64_t get_uint64_t() const;
285 void set_uint64_t(uint64_t value);
286
287 bool is_size_t() const;
288 size_t get_size_t() const;
289 void set_size_t(size_t value);
290
291 bool is_double() const;
292 double get_double() const;
293 void set_double(double value);
294
295 bool is_ccstr() const;
296 bool ccstr_accumulates() const;
297 ccstr get_ccstr() const;
298 void set_ccstr(ccstr value);
299
300 Flags get_origin();
301 void set_origin(Flags origin);
302
303 bool is_default();
304 bool is_ergonomic();
305 bool is_command_line();
306
307 bool is_product() const;
308 bool is_manageable() const;
309 bool is_diagnostic() const;
310 bool is_experimental() const;
370 double val;
371 double* flag;
372 public:
373 DoubleFlagSetting(double& fl, double newValue) { flag = &fl; val = fl; fl = newValue; }
374 ~DoubleFlagSetting() { *flag = val; }
375 };
376
377
378 class CommandLineFlags {
379 public:
380 static bool boolAt(const char* name, size_t len, bool* value);
381 static bool boolAt(const char* name, bool* value) { return boolAt(name, strlen(name), value); }
382 static bool boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin);
383 static bool boolAtPut(const char* name, bool* value, Flag::Flags origin) { return boolAtPut(name, strlen(name), value, origin); }
384
385 static bool intxAt(const char* name, size_t len, intx* value);
386 static bool intxAt(const char* name, intx* value) { return intxAt(name, strlen(name), value); }
387 static bool intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin);
388 static bool intxAtPut(const char* name, intx* value, Flag::Flags origin) { return intxAtPut(name, strlen(name), value, origin); }
389
390 static bool uintxAt(const char* name, size_t len, uintx* value, bool allow_locked = false, bool return_flag = false);
391 static bool uintxAt(const char* name, uintx* value, bool allow_locked = false, bool return_flag = false) { return uintxAt(name, strlen(name), value, allow_locked, return_flag); }
392 static bool uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin);
393 static bool uintxAtPut(const char* name, uintx* value, Flag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); }
394
395 static bool uint64_tAt(const char* name, size_t len, uint64_t* value);
396 static bool uint64_tAt(const char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); }
397 static bool uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin);
398 static bool uint64_tAtPut(const char* name, uint64_t* value, Flag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
399
400 static bool doubleAt(const char* name, size_t len, double* value);
401 static bool doubleAt(const char* name, double* value) { return doubleAt(name, strlen(name), value); }
402 static bool doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin);
403 static bool doubleAtPut(const char* name, double* value, Flag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); }
404
405 static bool ccstrAt(const char* name, size_t len, ccstr* value);
406 static bool ccstrAt(const char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); }
407 // Contract: Flag will make private copy of the incoming value.
408 // Outgoing value is always malloc-ed, and caller MUST call free.
409 static bool ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin);
410 static bool ccstrAtPut(const char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); }
411
412 // Returns false if name is not a command line flag.
413 static bool wasSetOnCmdline(const char* name, bool* value);
414 static void printSetFlags(outputStream* out);
415
416 static void printFlags(outputStream* out, bool withComments);
417
418 static void verify() PRODUCT_RETURN;
419 };
420
421 #if INCLUDE_TRACE
422 #define TRACE_ONLY(code) code
423 #else
424 #define TRACE_ONLY(code)
425 #endif
426
427 // use this for flags that are true by default in the debug version but
428 // false in the optimized version, and vice versa
429 #ifdef ASSERT
430 #define trueInDebug true
431 #define falseInDebug false
432 #else
433 #define trueInDebug false
434 #define falseInDebug true
435 #endif
436
437 // use this for flags that are true per default in the product build
438 // but false in development builds, and vice versa
439 #ifdef PRODUCT
440 #define trueInProduct true
441 #define falseInProduct false
442 #else
443 #define trueInProduct false
444 #define falseInProduct true
445 #endif
446
3991 \
3992 diagnostic(ccstr, SharedArchiveFile, NULL, \
3993 "Override the default location of the CDS archive file") \
3994 \
3995 product(ccstr, ExtraSharedClassListFile, NULL, \
3996 "Extra classlist for building the CDS archive file") \
3997 \
3998 experimental(uintx, ArrayAllocatorMallocLimit, \
3999 SOLARIS_ONLY(64*K) NOT_SOLARIS(max_uintx), \
4000 "Allocation less than this value will be allocated " \
4001 "using malloc. Larger allocations will use mmap.") \
4002 \
4003 product(bool, EnableTracing, false, \
4004 "Enable event-based tracing") \
4005 \
4006 product(bool, UseLockedTracing, false, \
4007 "Use locked-tracing when doing event-based tracing") \
4008 \
4009 product_pd(bool, PreserveFramePointer, \
4010 "Use the FP register for holding the frame pointer " \
4011 "and not as a general purpose register.") \
4012 \
4013 TRACE_ONLY(product(bool, FlightRecorder, false, \
4014 "Enable Flight Recorder")) \
4015 \
4016 TRACE_ONLY(product(ccstr, FlightRecorderOptions, NULL, \
4017 "Flight Recorder options")) \
4018 \
4019 TRACE_ONLY(product(ccstr, StartFlightRecording, NULL, \
4020 "Start flight recording with options")) \
4021 \
4022 experimental(bool, UseFastUnorderedTimeStamps, false, \
4023 "Use platform unstable time where supported for timestamps only") \
4024 \
4025 product(bool, PrintJFRLog, false, \
4026 "Print JFR log ") \
4027 \
4028 product(bool, EnableJFR, false, "Enable JFR feature") \
4029
4030 /*
4031 * Macros for factoring of globals
4032 */
4033
4034 // Interface macros
4035 #define DECLARE_PRODUCT_FLAG(type, name, value, doc) extern "C" type name;
4036 #define DECLARE_PD_PRODUCT_FLAG(type, name, doc) extern "C" type name;
4037 #define DECLARE_DIAGNOSTIC_FLAG(type, name, value, doc) extern "C" type name;
4038 #define DECLARE_EXPERIMENTAL_FLAG(type, name, value, doc) extern "C" type name;
4039 #define DECLARE_MANAGEABLE_FLAG(type, name, value, doc) extern "C" type name;
4040 #define DECLARE_PRODUCT_RW_FLAG(type, name, value, doc) extern "C" type name;
4041 #ifdef PRODUCT
4042 #define DECLARE_DEVELOPER_FLAG(type, name, value, doc) extern "C" type CONST_##name; const type name = value;
4043 #define DECLARE_PD_DEVELOPER_FLAG(type, name, doc) extern "C" type CONST_##name; const type name = pd_##name;
4044 #define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc) extern "C" type CONST_##name;
4045 #else
4046 #define DECLARE_DEVELOPER_FLAG(type, name, value, doc) extern "C" type name;
4047 #define DECLARE_PD_DEVELOPER_FLAG(type, name, doc) extern "C" type name;
4048 #define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc) extern "C" type name;
|