comparison src/share/vm/runtime/globals.hpp @ 12322:72b7e96c1922

8024545: make develop and notproduct flag values available in product builds Reviewed-by: dholmes, kvn
author twisti
date Thu, 26 Sep 2013 12:07:53 -0700
parents da051ce490eb
children 510fbd28919c a07c25e4f67e
comparison
equal deleted inserted replaced
12295:1b64d46620a3 12322:72b7e96c1922
192 192
193 // string type aliases used only in this file 193 // string type aliases used only in this file
194 typedef const char* ccstr; 194 typedef const char* ccstr;
195 typedef const char* ccstrlist; // represents string arguments which accumulate 195 typedef const char* ccstrlist; // represents string arguments which accumulate
196 196
197 enum FlagValueOrigin {
198 DEFAULT = 0,
199 COMMAND_LINE = 1,
200 ENVIRON_VAR = 2,
201 CONFIG_FILE = 3,
202 MANAGEMENT = 4,
203 ERGONOMIC = 5,
204 ATTACH_ON_DEMAND = 6,
205 INTERNAL = 99
206 };
207
208 struct Flag { 197 struct Flag {
209 const char *type; 198 enum Flags {
210 const char *name; 199 // value origin
211 void* addr; 200 DEFAULT = 0,
212 201 COMMAND_LINE = 1,
213 NOT_PRODUCT(const char *doc;) 202 ENVIRON_VAR = 2,
214 203 CONFIG_FILE = 3,
215 const char *kind; 204 MANAGEMENT = 4,
216 FlagValueOrigin origin; 205 ERGONOMIC = 5,
206 ATTACH_ON_DEMAND = 6,
207 INTERNAL = 7,
208
209 LAST_VALUE_ORIGIN = INTERNAL,
210 VALUE_ORIGIN_BITS = 4,
211 VALUE_ORIGIN_MASK = right_n_bits(VALUE_ORIGIN_BITS),
212
213 // flag kind
214 KIND_PRODUCT = 1 << 4,
215 KIND_MANAGEABLE = 1 << 5,
216 KIND_DIAGNOSTIC = 1 << 6,
217 KIND_EXPERIMENTAL = 1 << 7,
218 KIND_NOT_PRODUCT = 1 << 8,
219 KIND_DEVELOP = 1 << 9,
220 KIND_PLATFORM_DEPENDENT = 1 << 10,
221 KIND_READ_WRITE = 1 << 11,
222 KIND_C1 = 1 << 12,
223 KIND_C2 = 1 << 13,
224 KIND_ARCH = 1 << 14,
225 KIND_SHARK = 1 << 15,
226 KIND_LP64_PRODUCT = 1 << 16,
227 KIND_COMMERCIAL = 1 << 17,
228
229 KIND_MASK = ~VALUE_ORIGIN_MASK
230 };
231
232 const char* _type;
233 const char* _name;
234 void* _addr;
235 NOT_PRODUCT(const char* _doc;)
236 Flags _flags;
217 237
218 // points to all Flags static array 238 // points to all Flags static array
219 static Flag *flags; 239 static Flag* flags;
220 240
221 // number of flags 241 // number of flags
222 static size_t numFlags; 242 static size_t numFlags;
223 243
224 static Flag* find_flag(const char* name, size_t length, bool allow_locked = false); 244 static Flag* find_flag(const char* name, size_t length, bool allow_locked = false);
225 static Flag* fuzzy_match(const char* name, size_t length, bool allow_locked = false); 245 static Flag* fuzzy_match(const char* name, size_t length, bool allow_locked = false);
226 246
227 bool is_bool() const { return strcmp(type, "bool") == 0; } 247 void check_writable();
228 bool get_bool() const { return *((bool*) addr); } 248
229 void set_bool(bool value) { *((bool*) addr) = value; } 249 bool is_bool() const;
230 250 bool get_bool() const;
231 bool is_intx() const { return strcmp(type, "intx") == 0; } 251 void set_bool(bool value);
232 intx get_intx() const { return *((intx*) addr); } 252
233 void set_intx(intx value) { *((intx*) addr) = value; } 253 bool is_intx() const;
234 254 intx get_intx() const;
235 bool is_uintx() const { return strcmp(type, "uintx") == 0; } 255 void set_intx(intx value);
236 uintx get_uintx() const { return *((uintx*) addr); } 256
237 void set_uintx(uintx value) { *((uintx*) addr) = value; } 257 bool is_uintx() const;
238 258 uintx get_uintx() const;
239 bool is_uint64_t() const { return strcmp(type, "uint64_t") == 0; } 259 void set_uintx(uintx value);
240 uint64_t get_uint64_t() const { return *((uint64_t*) addr); } 260
241 void set_uint64_t(uint64_t value) { *((uint64_t*) addr) = value; } 261 bool is_uint64_t() const;
242 262 uint64_t get_uint64_t() const;
243 bool is_double() const { return strcmp(type, "double") == 0; } 263 void set_uint64_t(uint64_t value);
244 double get_double() const { return *((double*) addr); } 264
245 void set_double(double value) { *((double*) addr) = value; } 265 bool is_double() const;
246 266 double get_double() const;
247 bool is_ccstr() const { return strcmp(type, "ccstr") == 0 || strcmp(type, "ccstrlist") == 0; } 267 void set_double(double value);
248 bool ccstr_accumulates() const { return strcmp(type, "ccstrlist") == 0; } 268
249 ccstr get_ccstr() const { return *((ccstr*) addr); } 269 bool is_ccstr() const;
250 void set_ccstr(ccstr value) { *((ccstr*) addr) = value; } 270 bool ccstr_accumulates() const;
271 ccstr get_ccstr() const;
272 void set_ccstr(ccstr value);
273
274 Flags get_origin();
275 void set_origin(Flags origin);
276
277 bool is_default();
278 bool is_ergonomic();
279 bool is_command_line();
280
281 bool is_product() const;
282 bool is_manageable() const;
283 bool is_diagnostic() const;
284 bool is_experimental() const;
285 bool is_notproduct() const;
286 bool is_develop() const;
287 bool is_read_write() const;
288 bool is_commercial() const;
289
290 bool is_constant_in_binary() const;
251 291
252 bool is_unlocker() const; 292 bool is_unlocker() const;
253 bool is_unlocked() const; 293 bool is_unlocked() const;
254 bool is_writeable() const; 294 bool is_writeable() const;
255 bool is_external() const; 295 bool is_external() const;
261 301
262 void get_locked_message(char*, int) const; 302 void get_locked_message(char*, int) const;
263 void get_locked_message_ext(char*, int) const; 303 void get_locked_message_ext(char*, int) const;
264 304
265 void print_on(outputStream* st, bool withComments = false ); 305 void print_on(outputStream* st, bool withComments = false );
306 void print_kind(outputStream* st);
266 void print_as_flag(outputStream* st); 307 void print_as_flag(outputStream* st);
267 }; 308 };
268 309
269 // debug flags control various aspects of the VM and are global accessible 310 // debug flags control various aspects of the VM and are global accessible
270 311
308 349
309 class CommandLineFlags { 350 class CommandLineFlags {
310 public: 351 public:
311 static bool boolAt(char* name, size_t len, bool* value); 352 static bool boolAt(char* name, size_t len, bool* value);
312 static bool boolAt(char* name, bool* value) { return boolAt(name, strlen(name), value); } 353 static bool boolAt(char* name, bool* value) { return boolAt(name, strlen(name), value); }
313 static bool boolAtPut(char* name, size_t len, bool* value, FlagValueOrigin origin); 354 static bool boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin);
314 static bool boolAtPut(char* name, bool* value, FlagValueOrigin origin) { return boolAtPut(name, strlen(name), value, origin); } 355 static bool boolAtPut(char* name, bool* value, Flag::Flags origin) { return boolAtPut(name, strlen(name), value, origin); }
315 356
316 static bool intxAt(char* name, size_t len, intx* value); 357 static bool intxAt(char* name, size_t len, intx* value);
317 static bool intxAt(char* name, intx* value) { return intxAt(name, strlen(name), value); } 358 static bool intxAt(char* name, intx* value) { return intxAt(name, strlen(name), value); }
318 static bool intxAtPut(char* name, size_t len, intx* value, FlagValueOrigin origin); 359 static bool intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin);
319 static bool intxAtPut(char* name, intx* value, FlagValueOrigin origin) { return intxAtPut(name, strlen(name), value, origin); } 360 static bool intxAtPut(char* name, intx* value, Flag::Flags origin) { return intxAtPut(name, strlen(name), value, origin); }
320 361
321 static bool uintxAt(char* name, size_t len, uintx* value); 362 static bool uintxAt(char* name, size_t len, uintx* value);
322 static bool uintxAt(char* name, uintx* value) { return uintxAt(name, strlen(name), value); } 363 static bool uintxAt(char* name, uintx* value) { return uintxAt(name, strlen(name), value); }
323 static bool uintxAtPut(char* name, size_t len, uintx* value, FlagValueOrigin origin); 364 static bool uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin);
324 static bool uintxAtPut(char* name, uintx* value, FlagValueOrigin origin) { return uintxAtPut(name, strlen(name), value, origin); } 365 static bool uintxAtPut(char* name, uintx* value, Flag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); }
325 366
326 static bool uint64_tAt(char* name, size_t len, uint64_t* value); 367 static bool uint64_tAt(char* name, size_t len, uint64_t* value);
327 static bool uint64_tAt(char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); } 368 static bool uint64_tAt(char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); }
328 static bool uint64_tAtPut(char* name, size_t len, uint64_t* value, FlagValueOrigin origin); 369 static bool uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin);
329 static bool uint64_tAtPut(char* name, uint64_t* value, FlagValueOrigin origin) { return uint64_tAtPut(name, strlen(name), value, origin); } 370 static bool uint64_tAtPut(char* name, uint64_t* value, Flag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
330 371
331 static bool doubleAt(char* name, size_t len, double* value); 372 static bool doubleAt(char* name, size_t len, double* value);
332 static bool doubleAt(char* name, double* value) { return doubleAt(name, strlen(name), value); } 373 static bool doubleAt(char* name, double* value) { return doubleAt(name, strlen(name), value); }
333 static bool doubleAtPut(char* name, size_t len, double* value, FlagValueOrigin origin); 374 static bool doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin);
334 static bool doubleAtPut(char* name, double* value, FlagValueOrigin origin) { return doubleAtPut(name, strlen(name), value, origin); } 375 static bool doubleAtPut(char* name, double* value, Flag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); }
335 376
336 static bool ccstrAt(char* name, size_t len, ccstr* value); 377 static bool ccstrAt(char* name, size_t len, ccstr* value);
337 static bool ccstrAt(char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); } 378 static bool ccstrAt(char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); }
338 static bool ccstrAtPut(char* name, size_t len, ccstr* value, FlagValueOrigin origin); 379 static bool ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin);
339 static bool ccstrAtPut(char* name, ccstr* value, FlagValueOrigin origin) { return ccstrAtPut(name, strlen(name), value, origin); } 380 static bool ccstrAtPut(char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); }
340 381
341 // Returns false if name is not a command line flag. 382 // Returns false if name is not a command line flag.
342 static bool wasSetOnCmdline(const char* name, bool* value); 383 static bool wasSetOnCmdline(const char* name, bool* value);
343 static void printSetFlags(outputStream* out); 384 static void printSetFlags(outputStream* out);
344 385
3725 /* 3766 /*
3726 * Macros for factoring of globals 3767 * Macros for factoring of globals
3727 */ 3768 */
3728 3769
3729 // Interface macros 3770 // Interface macros
3730 #define DECLARE_PRODUCT_FLAG(type, name, value, doc) extern "C" type name; 3771 #define DECLARE_PRODUCT_FLAG(type, name, value, doc) extern "C" type name;
3731 #define DECLARE_PD_PRODUCT_FLAG(type, name, doc) extern "C" type name; 3772 #define DECLARE_PD_PRODUCT_FLAG(type, name, doc) extern "C" type name;
3732 #define DECLARE_DIAGNOSTIC_FLAG(type, name, value, doc) extern "C" type name; 3773 #define DECLARE_DIAGNOSTIC_FLAG(type, name, value, doc) extern "C" type name;
3733 #define DECLARE_EXPERIMENTAL_FLAG(type, name, value, doc) extern "C" type name; 3774 #define DECLARE_EXPERIMENTAL_FLAG(type, name, value, doc) extern "C" type name;
3734 #define DECLARE_MANAGEABLE_FLAG(type, name, value, doc) extern "C" type name; 3775 #define DECLARE_MANAGEABLE_FLAG(type, name, value, doc) extern "C" type name;
3735 #define DECLARE_PRODUCT_RW_FLAG(type, name, value, doc) extern "C" type name; 3776 #define DECLARE_PRODUCT_RW_FLAG(type, name, value, doc) extern "C" type name;
3736 #ifdef PRODUCT 3777 #ifdef PRODUCT
3737 #define DECLARE_DEVELOPER_FLAG(type, name, value, doc) const type name = value; 3778 #define DECLARE_DEVELOPER_FLAG(type, name, value, doc) extern "C" type CONST_##name; const type name = value;
3738 #define DECLARE_PD_DEVELOPER_FLAG(type, name, doc) const type name = pd_##name; 3779 #define DECLARE_PD_DEVELOPER_FLAG(type, name, doc) extern "C" type CONST_##name; const type name = pd_##name;
3739 #define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc) 3780 #define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc) extern "C" type CONST_##name;
3740 #else 3781 #else
3741 #define DECLARE_DEVELOPER_FLAG(type, name, value, doc) extern "C" type name; 3782 #define DECLARE_DEVELOPER_FLAG(type, name, value, doc) extern "C" type name;
3742 #define DECLARE_PD_DEVELOPER_FLAG(type, name, doc) extern "C" type name; 3783 #define DECLARE_PD_DEVELOPER_FLAG(type, name, doc) extern "C" type name;
3743 #define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc) extern "C" type name; 3784 #define DECLARE_NOTPRODUCT_FLAG(type, name, value, doc) extern "C" type name;
3744 #endif 3785 #endif
3745 // Special LP64 flags, product only needed for now. 3786 // Special LP64 flags, product only needed for now.
3746 #ifdef _LP64 3787 #ifdef _LP64
3747 #define DECLARE_LP64_PRODUCT_FLAG(type, name, value, doc) extern "C" type name; 3788 #define DECLARE_LP64_PRODUCT_FLAG(type, name, value, doc) extern "C" type name;
3748 #else 3789 #else
3749 #define DECLARE_LP64_PRODUCT_FLAG(type, name, value, doc) const type name = value; 3790 #define DECLARE_LP64_PRODUCT_FLAG(type, name, value, doc) const type name = value;
3750 #endif // _LP64 3791 #endif // _LP64
3751 3792
3752 // Implementation macros 3793 // Implementation macros
3753 #define MATERIALIZE_PRODUCT_FLAG(type, name, value, doc) type name = value; 3794 #define MATERIALIZE_PRODUCT_FLAG(type, name, value, doc) type name = value;
3754 #define MATERIALIZE_PD_PRODUCT_FLAG(type, name, doc) type name = pd_##name; 3795 #define MATERIALIZE_PD_PRODUCT_FLAG(type, name, doc) type name = pd_##name;
3755 #define MATERIALIZE_DIAGNOSTIC_FLAG(type, name, value, doc) type name = value; 3796 #define MATERIALIZE_DIAGNOSTIC_FLAG(type, name, value, doc) type name = value;
3756 #define MATERIALIZE_EXPERIMENTAL_FLAG(type, name, value, doc) type name = value; 3797 #define MATERIALIZE_EXPERIMENTAL_FLAG(type, name, value, doc) type name = value;
3757 #define MATERIALIZE_MANAGEABLE_FLAG(type, name, value, doc) type name = value; 3798 #define MATERIALIZE_MANAGEABLE_FLAG(type, name, value, doc) type name = value;
3758 #define MATERIALIZE_PRODUCT_RW_FLAG(type, name, value, doc) type name = value; 3799 #define MATERIALIZE_PRODUCT_RW_FLAG(type, name, value, doc) type name = value;
3759 #ifdef PRODUCT 3800 #ifdef PRODUCT
3760 #define MATERIALIZE_DEVELOPER_FLAG(type, name, value, doc) /* flag name is constant */ 3801 #define MATERIALIZE_DEVELOPER_FLAG(type, name, value, doc) type CONST_##name = value;
3761 #define MATERIALIZE_PD_DEVELOPER_FLAG(type, name, doc) /* flag name is constant */ 3802 #define MATERIALIZE_PD_DEVELOPER_FLAG(type, name, doc) type CONST_##name = pd_##name;
3762 #define MATERIALIZE_NOTPRODUCT_FLAG(type, name, value, doc) 3803 #define MATERIALIZE_NOTPRODUCT_FLAG(type, name, value, doc) type CONST_##name = value;
3763 #else 3804 #else
3764 #define MATERIALIZE_DEVELOPER_FLAG(type, name, value, doc) type name = value; 3805 #define MATERIALIZE_DEVELOPER_FLAG(type, name, value, doc) type name = value;
3765 #define MATERIALIZE_PD_DEVELOPER_FLAG(type, name, doc) type name = pd_##name; 3806 #define MATERIALIZE_PD_DEVELOPER_FLAG(type, name, doc) type name = pd_##name;
3766 #define MATERIALIZE_NOTPRODUCT_FLAG(type, name, value, doc) type name = value; 3807 #define MATERIALIZE_NOTPRODUCT_FLAG(type, name, value, doc) type name = value;
3767 #endif 3808 #endif
3768 #ifdef _LP64 3809 #ifdef _LP64
3769 #define MATERIALIZE_LP64_PRODUCT_FLAG(type, name, value, doc) type name = value; 3810 #define MATERIALIZE_LP64_PRODUCT_FLAG(type, name, value, doc) type name = value;
3770 #else 3811 #else
3771 #define MATERIALIZE_LP64_PRODUCT_FLAG(type, name, value, doc) /* flag is constant */ 3812 #define MATERIALIZE_LP64_PRODUCT_FLAG(type, name, value, doc) /* flag is constant */
3772 #endif // _LP64 3813 #endif // _LP64
3773 3814
3774 RUNTIME_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_EXPERIMENTAL_FLAG, DECLARE_NOTPRODUCT_FLAG, DECLARE_MANAGEABLE_FLAG, DECLARE_PRODUCT_RW_FLAG, DECLARE_LP64_PRODUCT_FLAG) 3815 RUNTIME_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_EXPERIMENTAL_FLAG, DECLARE_NOTPRODUCT_FLAG, DECLARE_MANAGEABLE_FLAG, DECLARE_PRODUCT_RW_FLAG, DECLARE_LP64_PRODUCT_FLAG)