Mercurial > hg > truffle
annotate src/share/vm/runtime/globals.cpp @ 1299:9eba43136cb5
6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob
Summary: Passing a null pointer to an InvokeDynamic function call should lead to a NullPointerException.
Reviewed-by: kvn, never
author | twisti |
---|---|
date | Tue, 16 Mar 2010 11:52:17 +0100 |
parents | f62a22282a47 |
children | c18cbe5936b8 |
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; | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
1067
diff
changeset
|
49 } else if (strcmp(kind, "{experimental}") == 0 || |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
1067
diff
changeset
|
50 strcmp(kind, "{C2 experimental}") == 0) { |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
51 return UnlockExperimentalVMOptions; |
0 | 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 ? ':' : ' ')); | |
1067
ba7ea42fc66e
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
1064
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 if (is_uint64_t()) st->print("%-16lu", get_uint64_t()); |
0 | 77 if (is_ccstr()) { |
78 const char* cp = get_ccstr(); | |
103 | 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); | |
0 | 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()); | |
1067
ba7ea42fc66e
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
1064
diff
changeset
|
105 } else if (is_uint64_t()) { |
ba7ea42fc66e
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
1064
diff
changeset
|
106 st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t()); |
0 | 107 } else if (is_ccstr()) { |
108 st->print("-XX:%s=", name); | |
103 | 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 } | |
0 | 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 }, | |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
137 #define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{experimental}", DEFAULT }, |
0 | 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 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
151 #ifdef _LP64 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
152 #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
|
153 #else |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
154 #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
|
155 #endif // _LP64 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
156 |
0 | 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 }, | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
1067
diff
changeset
|
173 #define C2_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 experimental}", DEFAULT }, |
0 | 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[] = { | |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
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) |
0 | 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) |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
188 #ifndef SERIALGC |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
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) |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
190 #endif // SERIALGC |
0 | 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 | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
1067
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) |
0 | 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())) { | |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
213 // disable use of diagnostic or experimental flags until they |
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
214 // are explicitly unlocked |
0 | 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 | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
235 bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) { |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
236 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
|
237 Flag* f = &Flag::flags[flag]; |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
238 return (f->origin == ERGONOMIC); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
239 } |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
240 |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
241 bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) { |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
242 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
|
243 Flag* f = &Flag::flags[flag]; |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
244 return (f->origin == COMMAND_LINE); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
245 } |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
246 |
0 | 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 | |
1064 | 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 | |
0 | 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(); | |
370
885fe0f95828
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
196
diff
changeset
|
399 char* new_value = NULL; |
885fe0f95828
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
196
diff
changeset
|
400 if (*value != NULL) { |
885fe0f95828
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
196
diff
changeset
|
401 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
|
402 strcpy(new_value, *value); |
885fe0f95828
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
196
diff
changeset
|
403 } |
0 | 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 // Print | |
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 | |
1150 | 471 #endif // PRODUCT |
472 | |
0 | 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 // Print | |
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 } |