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