1/*
2 * Copyright (c) 2003, 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 *
23 */
24
25#ifndef SHARE_RUNTIME_GLOBALS_EXTENSION_HPP
26#define SHARE_RUNTIME_GLOBALS_EXTENSION_HPP
27
28#include "runtime/globals.hpp"
29#include "utilities/macros.hpp"
30
31// Construct enum of Flag_<cmdline-arg> constants.
32
33#define FLAG_MEMBER_ENUM(name) Flag_##name##_enum
34#define FLAG_MEMBER_ENUM_(name) FLAG_MEMBER_ENUM(name),
35
36#define FLAG_MEMBER_ENUM_PRODUCT(type, name, value, doc) FLAG_MEMBER_ENUM_(name)
37#define FLAG_MEMBER_ENUM_PD_PRODUCT(type, name, doc) FLAG_MEMBER_ENUM_(name)
38#define FLAG_MEMBER_ENUM_DIAGNOSTIC(type, name, value, doc) FLAG_MEMBER_ENUM_(name)
39#define FLAG_MEMBER_ENUM_PD_DIAGNOSTIC(type, name, doc) FLAG_MEMBER_ENUM_(name)
40#define FLAG_MEMBER_ENUM_EXPERIMENTAL(type, name, value, doc) FLAG_MEMBER_ENUM_(name)
41#define FLAG_MEMBER_ENUM_MANAGEABLE(type, name, value, doc) FLAG_MEMBER_ENUM_(name)
42#define FLAG_MEMBER_ENUM_PRODUCT_RW(type, name, value, doc) FLAG_MEMBER_ENUM_(name)
43#define FLAG_MEMBER_ENUM_DEVELOP(type, name, value, doc) FLAG_MEMBER_ENUM_(name)
44#define FLAG_MEMBER_ENUM_PD_DEVELOP(type, name, doc) FLAG_MEMBER_ENUM_(name)
45#define FLAG_MEMBER_ENUM_NOTPRODUCT(type, name, value, doc) FLAG_MEMBER_ENUM_(name)
46#ifdef _LP64
47#define FLAG_MEMBER_ENUM_LP64_PRODUCT(type, name, value, doc) FLAG_MEMBER_ENUM_(name)
48#else
49#define FLAG_MEMBER_ENUM_LP64_PRODUCT(type, name, value, doc) /* flag is constant */
50#endif // _LP64
51
52typedef enum {
53 ALL_FLAGS(FLAG_MEMBER_ENUM_DEVELOP,
54 FLAG_MEMBER_ENUM_PD_DEVELOP,
55 FLAG_MEMBER_ENUM_PRODUCT,
56 FLAG_MEMBER_ENUM_PD_PRODUCT,
57 FLAG_MEMBER_ENUM_DIAGNOSTIC,
58 FLAG_MEMBER_ENUM_PD_DIAGNOSTIC,
59 FLAG_MEMBER_ENUM_EXPERIMENTAL,
60 FLAG_MEMBER_ENUM_NOTPRODUCT,
61 FLAG_MEMBER_ENUM_MANAGEABLE,
62 FLAG_MEMBER_ENUM_PRODUCT_RW,
63 FLAG_MEMBER_ENUM_LP64_PRODUCT,
64 IGNORE_RANGE,
65 IGNORE_CONSTRAINT,
66 IGNORE_WRITEABLE)
67 JVMFLAGSENUM_EXT
68 NUM_JVMFlagsEnum
69} JVMFlagsEnum;
70
71// Can't put the following in JVMFlags because
72// of a circular dependency on the enum definition.
73class JVMFlagEx : JVMFlag {
74 public:
75 static JVMFlag::Error boolAtPut(JVMFlagsEnum flag, bool value, JVMFlag::Flags origin);
76 static JVMFlag::Error intAtPut(JVMFlagsEnum flag, int value, JVMFlag::Flags origin);
77 static JVMFlag::Error uintAtPut(JVMFlagsEnum flag, uint value, JVMFlag::Flags origin);
78 static JVMFlag::Error intxAtPut(JVMFlagsEnum flag, intx value, JVMFlag::Flags origin);
79 static JVMFlag::Error uintxAtPut(JVMFlagsEnum flag, uintx value, JVMFlag::Flags origin);
80 static JVMFlag::Error uint64_tAtPut(JVMFlagsEnum flag, uint64_t value, JVMFlag::Flags origin);
81 static JVMFlag::Error size_tAtPut(JVMFlagsEnum flag, size_t value, JVMFlag::Flags origin);
82 static JVMFlag::Error doubleAtPut(JVMFlagsEnum flag, double value, JVMFlag::Flags origin);
83 // Contract: Flag will make private copy of the incoming value
84 static JVMFlag::Error ccstrAtPut(JVMFlagsEnum flag, ccstr value, JVMFlag::Flags origin);
85 static JVMFlag::Error ccstrlistAtPut(JVMFlagsEnum flag, ccstr value, JVMFlag::Flags origin) {
86 return ccstrAtPut(flag, value, origin);
87 }
88
89 static bool is_default(JVMFlagsEnum flag);
90 static bool is_ergo(JVMFlagsEnum flag);
91 static bool is_cmdline(JVMFlagsEnum flag);
92
93 static void setOnCmdLine(JVMFlagsEnum flag);
94};
95
96// Construct set functions for all flags
97
98#define FLAG_MEMBER_SET(name) Flag_##name##_set
99#define FLAG_MEMBER_SET_(type, name) inline JVMFlag::Error FLAG_MEMBER_SET(name)(type value, JVMFlag::Flags origin) { return JVMFlagEx::type##AtPut(FLAG_MEMBER_ENUM(name), value, origin); }
100
101#define FLAG_MEMBER_SET_PRODUCT(type, name, value, doc) FLAG_MEMBER_SET_(type, name)
102#define FLAG_MEMBER_SET_PD_PRODUCT(type, name, doc) FLAG_MEMBER_SET_(type, name)
103#define FLAG_MEMBER_SET_DIAGNOSTIC(type, name, value, doc) FLAG_MEMBER_SET_(type, name)
104#define FLAG_MEMBER_SET_PD_DIAGNOSTIC(type, name, doc) FLAG_MEMBER_SET_(type, name)
105#define FLAG_MEMBER_SET_EXPERIMENTAL(type, name, value, doc) FLAG_MEMBER_SET_(type, name)
106#define FLAG_MEMBER_SET_MANAGEABLE(type, name, value, doc) FLAG_MEMBER_SET_(type, name)
107#define FLAG_MEMBER_SET_PRODUCT_RW(type, name, value, doc) FLAG_MEMBER_SET_(type, name)
108#define FLAG_MEMBER_SET_DEVELOP(type, name, value, doc) FLAG_MEMBER_SET_(type, name)
109#define FLAG_MEMBER_SET_PD_DEVELOP(type, name, doc) FLAG_MEMBER_SET_(type, name)
110#define FLAG_MEMBER_SET_NOTPRODUCT(type, name, value, doc) FLAG_MEMBER_SET_(type, name)
111#ifdef _LP64
112#define FLAG_MEMBER_SET_LP64_PRODUCT(type, name, value, doc) FLAG_MEMBER_SET_(type, name)
113#else
114#define FLAG_MEMBER_SET_LP64_PRODUCT(type, name, value, doc) /* flag is constant */
115#endif // _LP64
116
117ALL_FLAGS(FLAG_MEMBER_SET_DEVELOP,
118 FLAG_MEMBER_SET_PD_DEVELOP,
119 FLAG_MEMBER_SET_PRODUCT,
120 FLAG_MEMBER_SET_PD_PRODUCT,
121 FLAG_MEMBER_SET_DIAGNOSTIC,
122 FLAG_MEMBER_SET_PD_DIAGNOSTIC,
123 FLAG_MEMBER_SET_EXPERIMENTAL,
124 FLAG_MEMBER_SET_NOTPRODUCT,
125 FLAG_MEMBER_SET_MANAGEABLE,
126 FLAG_MEMBER_SET_PRODUCT_RW,
127 FLAG_MEMBER_SET_LP64_PRODUCT,
128 IGNORE_RANGE,
129 IGNORE_CONSTRAINT,
130 IGNORE_WRITEABLE)
131
132#define FLAG_IS_DEFAULT(name) (JVMFlagEx::is_default(FLAG_MEMBER_ENUM(name)))
133#define FLAG_IS_ERGO(name) (JVMFlagEx::is_ergo(FLAG_MEMBER_ENUM(name)))
134#define FLAG_IS_CMDLINE(name) (JVMFlagEx::is_cmdline(FLAG_MEMBER_ENUM(name)))
135
136#define FLAG_SET_DEFAULT(name, value) ((name) = (value))
137
138#define FLAG_SET_CMDLINE(name, value) (JVMFlagEx::setOnCmdLine(FLAG_MEMBER_ENUM(name)), \
139 FLAG_MEMBER_SET(name)((value), JVMFlag::COMMAND_LINE))
140#define FLAG_SET_ERGO(name, value) (FLAG_MEMBER_SET(name)((value), JVMFlag::ERGONOMIC))
141#define FLAG_SET_MGMT(name, value) (FLAG_MEMBER_SET(name)((value), JVMFlag::MANAGEMENT))
142
143#define FLAG_SET_ERGO_IF_DEFAULT(name, value) \
144 do { \
145 if (FLAG_IS_DEFAULT(name)) { \
146 FLAG_SET_ERGO(name, value); \
147 } \
148 } while (0)
149
150#endif // SHARE_RUNTIME_GLOBALS_EXTENSION_HPP
151