author | kvn |
Thu, 07 Jan 2010 16:24:17 -0800 | |
changeset 4579 | 62478db2dc78 |
parent 4450 | 6d700b859b3e |
child 5547 | f4b087cbb361 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
670 | 2 |
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
1 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
# include "incls/_precompiled.incl" |
|
26 |
# include "incls/_globals.cpp.incl" |
|
27 |
||
28 |
||
29 |
RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \ |
|
30 |
MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \ |
|
1382
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
31 |
MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \ |
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
32 |
MATERIALIZE_NOTPRODUCT_FLAG, \ |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
350
diff
changeset
|
33 |
MATERIALIZE_MANAGEABLE_FLAG, MATERIALIZE_PRODUCT_RW_FLAG, \ |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
350
diff
changeset
|
34 |
MATERIALIZE_LP64_PRODUCT_FLAG) |
1 | 35 |
|
36 |
RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \ |
|
37 |
MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \ |
|
38 |
MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG) |
|
39 |
||
40 |
bool Flag::is_unlocker() const { |
|
1382
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
41 |
return strcmp(name, "UnlockDiagnosticVMOptions") == 0 || |
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
42 |
strcmp(name, "UnlockExperimentalVMOptions") == 0; |
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
43 |
|
1 | 44 |
} |
45 |
||
46 |
bool Flag::is_unlocked() const { |
|
47 |
if (strcmp(kind, "{diagnostic}") == 0) { |
|
48 |
return UnlockDiagnosticVMOptions; |
|
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4437
diff
changeset
|
49 |
} else if (strcmp(kind, "{experimental}") == 0 || |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4437
diff
changeset
|
50 |
strcmp(kind, "{C2 experimental}") == 0) { |
1382
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
51 |
return UnlockExperimentalVMOptions; |
1 | 52 |
} else { |
53 |
return true; |
|
54 |
} |
|
55 |
} |
|
56 |
||
57 |
bool Flag::is_writeable() const { |
|
58 |
return (strcmp(kind, "{manageable}") == 0 || strcmp(kind, "{product rw}") == 0); |
|
59 |
} |
|
60 |
||
61 |
// All flags except "manageable" are assumed internal flags. |
|
62 |
// Long term, we need to define a mechanism to specify which flags |
|
63 |
// are external/stable and change this function accordingly. |
|
64 |
bool Flag::is_external() const { |
|
65 |
return (strcmp(kind, "{manageable}") == 0); |
|
66 |
} |
|
67 |
||
68 |
// Length of format string (e.g. "%.1234s") for printing ccstr below |
|
69 |
#define FORMAT_BUFFER_LEN 16 |
|
70 |
||
71 |
void Flag::print_on(outputStream* st) { |
|
72 |
st->print("%5s %-35s %c= ", type, name, (origin != DEFAULT ? ':' : ' ')); |
|
4437
d1abc17afffb
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
4434
diff
changeset
|
73 |
if (is_bool()) st->print("%-16s", get_bool() ? "true" : "false"); |
d1abc17afffb
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
4434
diff
changeset
|
74 |
if (is_intx()) st->print("%-16ld", get_intx()); |
d1abc17afffb
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
4434
diff
changeset
|
75 |
if (is_uintx()) st->print("%-16lu", get_uintx()); |
d1abc17afffb
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
4434
diff
changeset
|
76 |
if (is_uint64_t()) st->print("%-16lu", get_uint64_t()); |
1 | 77 |
if (is_ccstr()) { |
78 |
const char* cp = get_ccstr(); |
|
350 | 79 |
if (cp != NULL) { |
80 |
const char* eol; |
|
81 |
while ((eol = strchr(cp, '\n')) != NULL) { |
|
82 |
char format_buffer[FORMAT_BUFFER_LEN]; |
|
83 |
size_t llen = pointer_delta(eol, cp, sizeof(char)); |
|
84 |
jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, |
|
85 |
"%%." SIZE_FORMAT "s", llen); |
|
86 |
st->print(format_buffer, cp); |
|
87 |
st->cr(); |
|
88 |
cp = eol+1; |
|
89 |
st->print("%5s %-35s += ", "", name); |
|
90 |
} |
|
91 |
st->print("%-16s", cp); |
|
1 | 92 |
} |
93 |
} |
|
94 |
st->print(" %s", kind); |
|
95 |
st->cr(); |
|
96 |
} |
|
97 |
||
98 |
void Flag::print_as_flag(outputStream* st) { |
|
99 |
if (is_bool()) { |
|
100 |
st->print("-XX:%s%s", get_bool() ? "+" : "-", name); |
|
101 |
} else if (is_intx()) { |
|
102 |
st->print("-XX:%s=" INTX_FORMAT, name, get_intx()); |
|
103 |
} else if (is_uintx()) { |
|
104 |
st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx()); |
|
4437
d1abc17afffb
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
4434
diff
changeset
|
105 |
} else if (is_uint64_t()) { |
d1abc17afffb
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
4434
diff
changeset
|
106 |
st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t()); |
1 | 107 |
} else if (is_ccstr()) { |
108 |
st->print("-XX:%s=", name); |
|
350 | 109 |
const char* cp = get_ccstr(); |
110 |
if (cp != NULL) { |
|
111 |
// Need to turn embedded '\n's back into separate arguments |
|
112 |
// Not so efficient to print one character at a time, |
|
113 |
// but the choice is to do the transformation to a buffer |
|
114 |
// and print that. And this need not be efficient. |
|
115 |
for (; *cp != '\0'; cp += 1) { |
|
116 |
switch (*cp) { |
|
117 |
default: |
|
118 |
st->print("%c", *cp); |
|
119 |
break; |
|
120 |
case '\n': |
|
121 |
st->print(" -XX:%s=", name); |
|
122 |
break; |
|
123 |
} |
|
1 | 124 |
} |
125 |
} |
|
126 |
} else { |
|
127 |
ShouldNotReachHere(); |
|
128 |
} |
|
129 |
} |
|
130 |
||
131 |
// 4991491 do not "optimize out" the was_set false values: omitting them |
|
132 |
// tickles a Microsoft compiler bug causing flagTable to be malformed |
|
133 |
||
134 |
#define RUNTIME_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{product}", DEFAULT }, |
|
135 |
#define RUNTIME_PD_PRODUCT_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, "{pd product}", DEFAULT }, |
|
136 |
#define RUNTIME_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{diagnostic}", DEFAULT }, |
|
1382
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
137 |
#define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{experimental}", DEFAULT }, |
1 | 138 |
#define RUNTIME_MANAGEABLE_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{manageable}", DEFAULT }, |
139 |
#define RUNTIME_PRODUCT_RW_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{product rw}", DEFAULT }, |
|
140 |
||
141 |
#ifdef PRODUCT |
|
142 |
#define RUNTIME_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ |
|
143 |
#define RUNTIME_PD_DEVELOP_FLAG_STRUCT(type, name, doc) /* flag is constant */ |
|
144 |
#define RUNTIME_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) |
|
145 |
#else |
|
146 |
#define RUNTIME_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "", DEFAULT }, |
|
147 |
#define RUNTIME_PD_DEVELOP_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, "{pd}", DEFAULT }, |
|
148 |
#define RUNTIME_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{notproduct}", DEFAULT }, |
|
149 |
#endif |
|
150 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
350
diff
changeset
|
151 |
#ifdef _LP64 |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
350
diff
changeset
|
152 |
#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{lp64_product}", DEFAULT }, |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
350
diff
changeset
|
153 |
#else |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
350
diff
changeset
|
154 |
#define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
350
diff
changeset
|
155 |
#endif // _LP64 |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
350
diff
changeset
|
156 |
|
1 | 157 |
#define C1_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C1 product}", DEFAULT }, |
158 |
#define C1_PD_PRODUCT_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, "{C1 pd product}", DEFAULT }, |
|
159 |
#ifdef PRODUCT |
|
160 |
#define C1_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ |
|
161 |
#define C1_PD_DEVELOP_FLAG_STRUCT(type, name, doc) /* flag is constant */ |
|
162 |
#define C1_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) |
|
163 |
#else |
|
164 |
#define C1_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C1}", DEFAULT }, |
|
165 |
#define C1_PD_DEVELOP_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, "{C1 pd}", DEFAULT }, |
|
166 |
#define C1_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C1 notproduct}", DEFAULT }, |
|
167 |
#endif |
|
168 |
||
169 |
||
170 |
#define C2_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 product}", DEFAULT }, |
|
171 |
#define C2_PD_PRODUCT_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, "{C2 pd product}", DEFAULT }, |
|
172 |
#define C2_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 diagnostic}", DEFAULT }, |
|
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4437
diff
changeset
|
173 |
#define C2_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 experimental}", DEFAULT }, |
1 | 174 |
#ifdef PRODUCT |
175 |
#define C2_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ |
|
176 |
#define C2_PD_DEVELOP_FLAG_STRUCT(type, name, doc) /* flag is constant */ |
|
177 |
#define C2_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) |
|
178 |
#else |
|
179 |
#define C2_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2}", DEFAULT }, |
|
180 |
#define C2_PD_DEVELOP_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, "{C2 pd}", DEFAULT }, |
|
181 |
#define C2_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 notproduct}", DEFAULT }, |
|
182 |
#endif |
|
183 |
||
184 |
||
185 |
static Flag flagTable[] = { |
|
1382
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
186 |
RUNTIME_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_EXPERIMENTAL_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT, RUNTIME_MANAGEABLE_FLAG_STRUCT, RUNTIME_PRODUCT_RW_FLAG_STRUCT, RUNTIME_LP64_PRODUCT_FLAG_STRUCT) |
1 | 187 |
RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT) |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
188 |
#ifndef SERIALGC |
1382
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
189 |
G1_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_EXPERIMENTAL_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT, RUNTIME_MANAGEABLE_FLAG_STRUCT, RUNTIME_PRODUCT_RW_FLAG_STRUCT) |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
190 |
#endif // SERIALGC |
1 | 191 |
#ifdef COMPILER1 |
192 |
C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, C1_PD_DEVELOP_FLAG_STRUCT, C1_PRODUCT_FLAG_STRUCT, C1_PD_PRODUCT_FLAG_STRUCT, C1_NOTPRODUCT_FLAG_STRUCT) |
|
193 |
#endif |
|
194 |
#ifdef COMPILER2 |
|
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4437
diff
changeset
|
195 |
C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, C2_PD_DEVELOP_FLAG_STRUCT, C2_PRODUCT_FLAG_STRUCT, C2_PD_PRODUCT_FLAG_STRUCT, C2_DIAGNOSTIC_FLAG_STRUCT, C2_EXPERIMENTAL_FLAG_STRUCT, C2_NOTPRODUCT_FLAG_STRUCT) |
1 | 196 |
#endif |
197 |
{0, NULL, NULL} |
|
198 |
}; |
|
199 |
||
200 |
Flag* Flag::flags = flagTable; |
|
201 |
size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag)); |
|
202 |
||
203 |
inline bool str_equal(const char* s, char* q, size_t len) { |
|
204 |
// s is null terminated, q is not! |
|
205 |
if (strlen(s) != (unsigned int) len) return false; |
|
206 |
return strncmp(s, q, len) == 0; |
|
207 |
} |
|
208 |
||
209 |
Flag* Flag::find_flag(char* name, size_t length) { |
|
210 |
for (Flag* current = &flagTable[0]; current->name; current++) { |
|
211 |
if (str_equal(current->name, name, length)) { |
|
212 |
if (!(current->is_unlocked() || current->is_unlocker())) { |
|
1382
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
213 |
// disable use of diagnostic or experimental flags until they |
fa3de4068282
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
1374
diff
changeset
|
214 |
// are explicitly unlocked |
1 | 215 |
return NULL; |
216 |
} |
|
217 |
return current; |
|
218 |
} |
|
219 |
} |
|
220 |
return NULL; |
|
221 |
} |
|
222 |
||
223 |
// Returns the address of the index'th element |
|
224 |
static Flag* address_of_flag(CommandLineFlagWithType flag) { |
|
225 |
assert((size_t)flag < Flag::numFlags, "bad command line flag index"); |
|
226 |
return &Flag::flags[flag]; |
|
227 |
} |
|
228 |
||
229 |
bool CommandLineFlagsEx::is_default(CommandLineFlag flag) { |
|
230 |
assert((size_t)flag < Flag::numFlags, "bad command line flag index"); |
|
231 |
Flag* f = &Flag::flags[flag]; |
|
232 |
return (f->origin == DEFAULT); |
|
233 |
} |
|
234 |
||
186
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
235 |
bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) { |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
236 |
assert((size_t)flag < Flag::numFlags, "bad command line flag index"); |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
237 |
Flag* f = &Flag::flags[flag]; |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
238 |
return (f->origin == ERGONOMIC); |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
239 |
} |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
240 |
|
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
241 |
bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) { |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
242 |
assert((size_t)flag < Flag::numFlags, "bad command line flag index"); |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
243 |
Flag* f = &Flag::flags[flag]; |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
244 |
return (f->origin == COMMAND_LINE); |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
245 |
} |
32e6c95f8d9b
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
1
diff
changeset
|
246 |
|
1 | 247 |
bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) { |
248 |
Flag* result = Flag::find_flag((char*)name, strlen(name)); |
|
249 |
if (result == NULL) return false; |
|
250 |
*value = (result->origin == COMMAND_LINE); |
|
251 |
return true; |
|
252 |
} |
|
253 |
||
254 |
bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) { |
|
255 |
Flag* result = Flag::find_flag(name, len); |
|
256 |
if (result == NULL) return false; |
|
257 |
if (!result->is_bool()) return false; |
|
258 |
*value = result->get_bool(); |
|
259 |
return true; |
|
260 |
} |
|
261 |
||
262 |
bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, FlagValueOrigin origin) { |
|
263 |
Flag* result = Flag::find_flag(name, len); |
|
264 |
if (result == NULL) return false; |
|
265 |
if (!result->is_bool()) return false; |
|
266 |
bool old_value = result->get_bool(); |
|
267 |
result->set_bool(*value); |
|
268 |
*value = old_value; |
|
269 |
result->origin = origin; |
|
270 |
return true; |
|
271 |
} |
|
272 |
||
273 |
void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, FlagValueOrigin origin) { |
|
274 |
Flag* faddr = address_of_flag(flag); |
|
275 |
guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type"); |
|
276 |
faddr->set_bool(value); |
|
277 |
faddr->origin = origin; |
|
278 |
} |
|
279 |
||
280 |
bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) { |
|
281 |
Flag* result = Flag::find_flag(name, len); |
|
282 |
if (result == NULL) return false; |
|
283 |
if (!result->is_intx()) return false; |
|
284 |
*value = result->get_intx(); |
|
285 |
return true; |
|
286 |
} |
|
287 |
||
288 |
bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, FlagValueOrigin origin) { |
|
289 |
Flag* result = Flag::find_flag(name, len); |
|
290 |
if (result == NULL) return false; |
|
291 |
if (!result->is_intx()) return false; |
|
292 |
intx old_value = result->get_intx(); |
|
293 |
result->set_intx(*value); |
|
294 |
*value = old_value; |
|
295 |
result->origin = origin; |
|
296 |
return true; |
|
297 |
} |
|
298 |
||
299 |
void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, FlagValueOrigin origin) { |
|
300 |
Flag* faddr = address_of_flag(flag); |
|
301 |
guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type"); |
|
302 |
faddr->set_intx(value); |
|
303 |
faddr->origin = origin; |
|
304 |
} |
|
305 |
||
306 |
bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) { |
|
307 |
Flag* result = Flag::find_flag(name, len); |
|
308 |
if (result == NULL) return false; |
|
309 |
if (!result->is_uintx()) return false; |
|
310 |
*value = result->get_uintx(); |
|
311 |
return true; |
|
312 |
} |
|
313 |
||
314 |
bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, FlagValueOrigin origin) { |
|
315 |
Flag* result = Flag::find_flag(name, len); |
|
316 |
if (result == NULL) return false; |
|
317 |
if (!result->is_uintx()) return false; |
|
318 |
uintx old_value = result->get_uintx(); |
|
319 |
result->set_uintx(*value); |
|
320 |
*value = old_value; |
|
321 |
result->origin = origin; |
|
322 |
return true; |
|
323 |
} |
|
324 |
||
325 |
void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, FlagValueOrigin origin) { |
|
326 |
Flag* faddr = address_of_flag(flag); |
|
327 |
guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type"); |
|
328 |
faddr->set_uintx(value); |
|
329 |
faddr->origin = origin; |
|
330 |
} |
|
331 |
||
4434 | 332 |
bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) { |
333 |
Flag* result = Flag::find_flag(name, len); |
|
334 |
if (result == NULL) return false; |
|
335 |
if (!result->is_uint64_t()) return false; |
|
336 |
*value = result->get_uint64_t(); |
|
337 |
return true; |
|
338 |
} |
|
339 |
||
340 |
bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, FlagValueOrigin origin) { |
|
341 |
Flag* result = Flag::find_flag(name, len); |
|
342 |
if (result == NULL) return false; |
|
343 |
if (!result->is_uint64_t()) return false; |
|
344 |
uint64_t old_value = result->get_uint64_t(); |
|
345 |
result->set_uint64_t(*value); |
|
346 |
*value = old_value; |
|
347 |
result->origin = origin; |
|
348 |
return true; |
|
349 |
} |
|
350 |
||
351 |
void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, FlagValueOrigin origin) { |
|
352 |
Flag* faddr = address_of_flag(flag); |
|
353 |
guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type"); |
|
354 |
faddr->set_uint64_t(value); |
|
355 |
faddr->origin = origin; |
|
356 |
} |
|
357 |
||
1 | 358 |
bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) { |
359 |
Flag* result = Flag::find_flag(name, len); |
|
360 |
if (result == NULL) return false; |
|
361 |
if (!result->is_double()) return false; |
|
362 |
*value = result->get_double(); |
|
363 |
return true; |
|
364 |
} |
|
365 |
||
366 |
bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, FlagValueOrigin origin) { |
|
367 |
Flag* result = Flag::find_flag(name, len); |
|
368 |
if (result == NULL) return false; |
|
369 |
if (!result->is_double()) return false; |
|
370 |
double old_value = result->get_double(); |
|
371 |
result->set_double(*value); |
|
372 |
*value = old_value; |
|
373 |
result->origin = origin; |
|
374 |
return true; |
|
375 |
} |
|
376 |
||
377 |
void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, FlagValueOrigin origin) { |
|
378 |
Flag* faddr = address_of_flag(flag); |
|
379 |
guarantee(faddr != NULL && faddr->is_double(), "wrong flag type"); |
|
380 |
faddr->set_double(value); |
|
381 |
faddr->origin = origin; |
|
382 |
} |
|
383 |
||
384 |
bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) { |
|
385 |
Flag* result = Flag::find_flag(name, len); |
|
386 |
if (result == NULL) return false; |
|
387 |
if (!result->is_ccstr()) return false; |
|
388 |
*value = result->get_ccstr(); |
|
389 |
return true; |
|
390 |
} |
|
391 |
||
392 |
// Contract: Flag will make private copy of the incoming value. |
|
393 |
// Outgoing value is always malloc-ed, and caller MUST call free. |
|
394 |
bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, FlagValueOrigin origin) { |
|
395 |
Flag* result = Flag::find_flag(name, len); |
|
396 |
if (result == NULL) return false; |
|
397 |
if (!result->is_ccstr()) return false; |
|
398 |
ccstr old_value = result->get_ccstr(); |
|
1402
ccb40ce62b79
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
670
diff
changeset
|
399 |
char* new_value = NULL; |
ccb40ce62b79
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
670
diff
changeset
|
400 |
if (*value != NULL) { |
ccb40ce62b79
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
670
diff
changeset
|
401 |
new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1); |
ccb40ce62b79
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
670
diff
changeset
|
402 |
strcpy(new_value, *value); |
ccb40ce62b79
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
670
diff
changeset
|
403 |
} |
1 | 404 |
result->set_ccstr(new_value); |
405 |
if (result->origin == DEFAULT && old_value != NULL) { |
|
406 |
// Prior value is NOT heap allocated, but was a literal constant. |
|
407 |
char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1); |
|
408 |
strcpy(old_value_to_free, old_value); |
|
409 |
old_value = old_value_to_free; |
|
410 |
} |
|
411 |
*value = old_value; |
|
412 |
result->origin = origin; |
|
413 |
return true; |
|
414 |
} |
|
415 |
||
416 |
// Contract: Flag will make private copy of the incoming value. |
|
417 |
void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin) { |
|
418 |
Flag* faddr = address_of_flag(flag); |
|
419 |
guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); |
|
420 |
ccstr old_value = faddr->get_ccstr(); |
|
421 |
char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1); |
|
422 |
strcpy(new_value, value); |
|
423 |
faddr->set_ccstr(new_value); |
|
424 |
if (faddr->origin != DEFAULT && old_value != NULL) { |
|
425 |
// Prior value is heap allocated so free it. |
|
426 |
FREE_C_HEAP_ARRAY(char, old_value); |
|
427 |
} |
|
428 |
faddr->origin = origin; |
|
429 |
} |
|
430 |
||
431 |
extern "C" { |
|
432 |
static int compare_flags(const void* void_a, const void* void_b) { |
|
433 |
return strcmp((*((Flag**) void_a))->name, (*((Flag**) void_b))->name); |
|
434 |
} |
|
435 |
} |
|
436 |
||
437 |
void CommandLineFlags::printSetFlags() { |
|
438 |
// Print which flags were set on the command line |
|
439 |
// note: this method is called before the thread structure is in place |
|
440 |
// which means resource allocation cannot be used. |
|
441 |
||
442 |
// Compute size |
|
443 |
int length= 0; |
|
444 |
while (flagTable[length].name != NULL) length++; |
|
445 |
||
446 |
// Sort |
|
447 |
Flag** array = NEW_C_HEAP_ARRAY(Flag*, length); |
|
448 |
for (int index = 0; index < length; index++) { |
|
449 |
array[index] = &flagTable[index]; |
|
450 |
} |
|
451 |
qsort(array, length, sizeof(Flag*), compare_flags); |
|
452 |
||
453 |
||
454 |
for (int i = 0; i < length; i++) { |
|
455 |
if (array[i]->origin /* naked field! */) { |
|
456 |
array[i]->print_as_flag(tty); |
|
457 |
tty->print(" "); |
|
458 |
} |
|
459 |
} |
|
460 |
tty->cr(); |
|
461 |
FREE_C_HEAP_ARRAY(Flag*, array); |
|
462 |
} |
|
463 |
||
464 |
#ifndef PRODUCT |
|
465 |
||
466 |
||
467 |
void CommandLineFlags::verify() { |
|
468 |
assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict"); |
|
469 |
} |
|
470 |
||
4579 | 471 |
#endif // PRODUCT |
472 |
||
1 | 473 |
void CommandLineFlags::printFlags() { |
474 |
// Print the flags sorted by name |
|
475 |
// note: this method is called before the thread structure is in place |
|
476 |
// which means resource allocation cannot be used. |
|
477 |
||
478 |
// Compute size |
|
479 |
int length= 0; |
|
480 |
while (flagTable[length].name != NULL) length++; |
|
481 |
||
482 |
// Sort |
|
483 |
Flag** array = NEW_C_HEAP_ARRAY(Flag*, length); |
|
484 |
for (int index = 0; index < length; index++) { |
|
485 |
array[index] = &flagTable[index]; |
|
486 |
} |
|
487 |
qsort(array, length, sizeof(Flag*), compare_flags); |
|
488 |
||
489 |
||
490 |
tty->print_cr("[Global flags]"); |
|
491 |
for (int i = 0; i < length; i++) { |
|
492 |
if (array[i]->is_unlocked()) { |
|
493 |
array[i]->print_on(tty); |
|
494 |
} |
|
495 |
} |
|
496 |
FREE_C_HEAP_ARRAY(Flag*, array); |
|
497 |
} |