Mercurial > hg > truffle
annotate src/share/vm/runtime/globals.cpp @ 3917:eca1193ca245
4965777: GC changes to support use of discovered field for pending references
Summary: If and when the reference handler thread is able to use the discovered field to link reference objects in its pending list, so will GC. In that case, GC will scan through this field once a reference object has been placed on the pending list, but not scan that field before that stage, as the field is used by the concurrent GC thread to link discovered objects. When ReferenceHandleR thread does not use the discovered field for the purpose of linking the elements in the pending list, as would be the case in older JDKs, the JVM will fall back to the old behaviour of using the next field for that purpose.
Reviewed-by: jcoomes, mchung, stefank
author | ysr |
---|---|
date | Wed, 07 Sep 2011 13:55:42 -0700 |
parents | ed69575596ac |
children | 763f01599ff4 |
rev | line source |
---|---|
0 | 1 /* |
1692 | 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1150
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1150
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1150
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "memory/allocation.inline.hpp" | |
27 #include "oops/oop.inline.hpp" | |
28 #include "runtime/arguments.hpp" | |
29 #include "runtime/globals.hpp" | |
30 #include "runtime/globals_extension.hpp" | |
31 #include "utilities/ostream.hpp" | |
32 #include "utilities/top.hpp" | |
33 #ifndef SERIALGC | |
34 #include "gc_implementation/g1/g1_globals.hpp" | |
35 #endif | |
36 #ifdef COMPILER1 | |
37 #include "c1/c1_globals.hpp" | |
38 #endif | |
39 #ifdef COMPILER2 | |
40 #include "opto/c2_globals.hpp" | |
41 #endif | |
42 #ifdef SHARK | |
43 #include "shark/shark_globals.hpp" | |
44 #endif | |
0 | 45 |
46 | |
47 RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \ | |
48 MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \ | |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
49 MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \ |
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
50 MATERIALIZE_NOTPRODUCT_FLAG, \ |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
51 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
|
52 MATERIALIZE_LP64_PRODUCT_FLAG) |
0 | 53 |
54 RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \ | |
55 MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \ | |
56 MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG) | |
57 | |
58 bool Flag::is_unlocker() const { | |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
59 return strcmp(name, "UnlockDiagnosticVMOptions") == 0 || |
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
60 strcmp(name, "UnlockExperimentalVMOptions") == 0; |
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
61 |
0 | 62 } |
63 | |
64 bool Flag::is_unlocked() const { | |
65 if (strcmp(kind, "{diagnostic}") == 0) { | |
2460 | 66 if (strcmp(name, "EnableInvokeDynamic") == 0 && UnlockExperimentalVMOptions && !UnlockDiagnosticVMOptions) { |
67 // transitional logic to allow tests to run until they are changed | |
68 static int warned; | |
69 if (++warned == 1) warning("Use -XX:+UnlockDiagnosticVMOptions before EnableInvokeDynamic flag"); | |
70 return true; | |
71 } | |
0 | 72 return UnlockDiagnosticVMOptions; |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
1067
diff
changeset
|
73 } else if (strcmp(kind, "{experimental}") == 0 || |
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
1067
diff
changeset
|
74 strcmp(kind, "{C2 experimental}") == 0) { |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
75 return UnlockExperimentalVMOptions; |
0 | 76 } else { |
77 return true; | |
78 } | |
79 } | |
80 | |
81 bool Flag::is_writeable() const { | |
82 return (strcmp(kind, "{manageable}") == 0 || strcmp(kind, "{product rw}") == 0); | |
83 } | |
84 | |
85 // All flags except "manageable" are assumed internal flags. | |
86 // Long term, we need to define a mechanism to specify which flags | |
87 // are external/stable and change this function accordingly. | |
88 bool Flag::is_external() const { | |
89 return (strcmp(kind, "{manageable}") == 0); | |
90 } | |
91 | |
92 // Length of format string (e.g. "%.1234s") for printing ccstr below | |
93 #define FORMAT_BUFFER_LEN 16 | |
94 | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
95 void Flag::print_on(outputStream* st, bool withComments) { |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
96 st->print("%9s %-40s %c= ", type, name, (origin != DEFAULT ? ':' : ' ')); |
1067
ba7ea42fc66e
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
1064
diff
changeset
|
97 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
|
98 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
|
99 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
|
100 if (is_uint64_t()) st->print("%-16lu", get_uint64_t()); |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
101 if (is_double()) st->print("%-16f", get_double()); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
102 |
0 | 103 if (is_ccstr()) { |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
104 const char* cp = get_ccstr(); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
105 if (cp != NULL) { |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
106 const char* eol; |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
107 while ((eol = strchr(cp, '\n')) != NULL) { |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
108 char format_buffer[FORMAT_BUFFER_LEN]; |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
109 size_t llen = pointer_delta(eol, cp, sizeof(char)); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
110 jio_snprintf(format_buffer, FORMAT_BUFFER_LEN, |
103 | 111 "%%." SIZE_FORMAT "s", llen); |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
112 st->print(format_buffer, cp); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
113 st->cr(); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
114 cp = eol+1; |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
115 st->print("%5s %-35s += ", "", name); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
116 } |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
117 st->print("%-16s", cp); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
118 } |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
119 else st->print("%-16s", ""); |
0 | 120 } |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
121 st->print("%-20s", kind); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
122 if (withComments) { |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
123 #ifndef PRODUCT |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
124 st->print("%s", doc ); |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
125 #endif |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
126 } |
0 | 127 st->cr(); |
128 } | |
129 | |
130 void Flag::print_as_flag(outputStream* st) { | |
131 if (is_bool()) { | |
132 st->print("-XX:%s%s", get_bool() ? "+" : "-", name); | |
133 } else if (is_intx()) { | |
134 st->print("-XX:%s=" INTX_FORMAT, name, get_intx()); | |
135 } else if (is_uintx()) { | |
136 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
|
137 } else if (is_uint64_t()) { |
ba7ea42fc66e
6898160: Need serviceability support for new vm argument type 'uint64_t'
phh
parents:
1064
diff
changeset
|
138 st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t()); |
0 | 139 } else if (is_ccstr()) { |
140 st->print("-XX:%s=", name); | |
103 | 141 const char* cp = get_ccstr(); |
142 if (cp != NULL) { | |
143 // Need to turn embedded '\n's back into separate arguments | |
144 // Not so efficient to print one character at a time, | |
145 // but the choice is to do the transformation to a buffer | |
146 // and print that. And this need not be efficient. | |
147 for (; *cp != '\0'; cp += 1) { | |
148 switch (*cp) { | |
149 default: | |
150 st->print("%c", *cp); | |
151 break; | |
152 case '\n': | |
153 st->print(" -XX:%s=", name); | |
154 break; | |
155 } | |
0 | 156 } |
157 } | |
158 } else { | |
159 ShouldNotReachHere(); | |
160 } | |
161 } | |
162 | |
163 // 4991491 do not "optimize out" the was_set false values: omitting them | |
164 // tickles a Microsoft compiler bug causing flagTable to be malformed | |
165 | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
166 #define RUNTIME_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{product}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
167 #define RUNTIME_PD_PRODUCT_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{pd product}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
168 #define RUNTIME_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{diagnostic}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
169 #define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{experimental}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
170 #define RUNTIME_MANAGEABLE_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{manageable}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
171 #define RUNTIME_PRODUCT_RW_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{product rw}", DEFAULT }, |
0 | 172 |
173 #ifdef PRODUCT | |
174 #define RUNTIME_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ | |
175 #define RUNTIME_PD_DEVELOP_FLAG_STRUCT(type, name, doc) /* flag is constant */ | |
176 #define RUNTIME_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) | |
177 #else | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
178 #define RUNTIME_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
179 #define RUNTIME_PD_DEVELOP_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, doc, "{pd}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
180 #define RUNTIME_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{notproduct}", DEFAULT }, |
0 | 181 #endif |
182 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
183 #ifdef _LP64 |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
184 #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{lp64_product}", DEFAULT }, |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
185 #else |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
186 #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
|
187 #endif // _LP64 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
103
diff
changeset
|
188 |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
189 #define C1_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C1 product}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
190 #define C1_PD_PRODUCT_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C1 pd product}", DEFAULT }, |
0 | 191 #ifdef PRODUCT |
192 #define C1_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ | |
193 #define C1_PD_DEVELOP_FLAG_STRUCT(type, name, doc) /* flag is constant */ | |
194 #define C1_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) | |
195 #else | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
196 #define C1_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{C1}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
197 #define C1_PD_DEVELOP_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, doc, "{C1 pd}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
198 #define C1_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{C1 notproduct}", DEFAULT }, |
0 | 199 #endif |
200 | |
201 | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
202 #define C2_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C2 product}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
203 #define C2_PD_PRODUCT_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C2 pd product}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
204 #define C2_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C2 diagnostic}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
205 #define C2_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{C2 experimental}", DEFAULT }, |
0 | 206 #ifdef PRODUCT |
207 #define C2_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ | |
208 #define C2_PD_DEVELOP_FLAG_STRUCT(type, name, doc) /* flag is constant */ | |
209 #define C2_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) | |
210 #else | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
211 #define C2_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{C2}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
212 #define C2_PD_DEVELOP_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, doc, "{C2 pd}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
213 #define C2_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{C2 notproduct}", DEFAULT }, |
0 | 214 #endif |
215 | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
216 #define SHARK_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{Shark product}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
217 #define SHARK_PD_PRODUCT_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{Shark pd product}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
218 #define SHARK_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) "{Shark diagnostic}", DEFAULT }, |
1692 | 219 #ifdef PRODUCT |
220 #define SHARK_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */ | |
221 #define SHARK_PD_DEVELOP_FLAG_STRUCT(type, name, doc) /* flag is constant */ | |
222 #define SHARK_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) | |
223 #else | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
224 #define SHARK_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{Shark}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
225 #define SHARK_PD_DEVELOP_FLAG_STRUCT(type, name, doc) { #type, XSTR(name), &name, doc, "{Shark pd}", DEFAULT }, |
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
226 #define SHARK_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, doc, "{Shark notproduct}", DEFAULT }, |
1692 | 227 #endif |
0 | 228 |
229 static Flag flagTable[] = { | |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
230 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 | 231 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
|
232 #ifndef SERIALGC |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
233 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
|
234 #endif // SERIALGC |
0 | 235 #ifdef COMPILER1 |
236 C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, C1_PD_DEVELOP_FLAG_STRUCT, C1_PRODUCT_FLAG_STRUCT, C1_PD_PRODUCT_FLAG_STRUCT, C1_NOTPRODUCT_FLAG_STRUCT) | |
237 #endif | |
238 #ifdef COMPILER2 | |
1080
7c57aead6d3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
1067
diff
changeset
|
239 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 | 240 #endif |
1692 | 241 #ifdef SHARK |
242 SHARK_FLAGS(SHARK_DEVELOP_FLAG_STRUCT, SHARK_PD_DEVELOP_FLAG_STRUCT, SHARK_PRODUCT_FLAG_STRUCT, SHARK_PD_PRODUCT_FLAG_STRUCT, SHARK_DIAGNOSTIC_FLAG_STRUCT, SHARK_NOTPRODUCT_FLAG_STRUCT) | |
243 #endif | |
0 | 244 {0, NULL, NULL} |
245 }; | |
246 | |
247 Flag* Flag::flags = flagTable; | |
248 size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag)); | |
249 | |
250 inline bool str_equal(const char* s, char* q, size_t len) { | |
251 // s is null terminated, q is not! | |
252 if (strlen(s) != (unsigned int) len) return false; | |
253 return strncmp(s, q, len) == 0; | |
254 } | |
255 | |
256 Flag* Flag::find_flag(char* name, size_t length) { | |
257 for (Flag* current = &flagTable[0]; current->name; current++) { | |
258 if (str_equal(current->name, name, length)) { | |
259 if (!(current->is_unlocked() || current->is_unlocker())) { | |
350
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
260 // disable use of diagnostic or experimental flags until they |
d28aa69f0959
6618726: Introduce -XX:+UnlockExperimentalVMOptions flag
ysr
parents:
342
diff
changeset
|
261 // are explicitly unlocked |
0 | 262 return NULL; |
263 } | |
264 return current; | |
265 } | |
266 } | |
267 return NULL; | |
268 } | |
269 | |
270 // Returns the address of the index'th element | |
271 static Flag* address_of_flag(CommandLineFlagWithType flag) { | |
272 assert((size_t)flag < Flag::numFlags, "bad command line flag index"); | |
273 return &Flag::flags[flag]; | |
274 } | |
275 | |
276 bool CommandLineFlagsEx::is_default(CommandLineFlag flag) { | |
277 assert((size_t)flag < Flag::numFlags, "bad command line flag index"); | |
278 Flag* f = &Flag::flags[flag]; | |
279 return (f->origin == DEFAULT); | |
280 } | |
281 | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
282 bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) { |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
283 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
|
284 Flag* f = &Flag::flags[flag]; |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
285 return (f->origin == ERGONOMIC); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
286 } |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
287 |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
288 bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) { |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
289 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
|
290 Flag* f = &Flag::flags[flag]; |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
291 return (f->origin == COMMAND_LINE); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
292 } |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
0
diff
changeset
|
293 |
0 | 294 bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) { |
295 Flag* result = Flag::find_flag((char*)name, strlen(name)); | |
296 if (result == NULL) return false; | |
297 *value = (result->origin == COMMAND_LINE); | |
298 return true; | |
299 } | |
300 | |
301 bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) { | |
302 Flag* result = Flag::find_flag(name, len); | |
303 if (result == NULL) return false; | |
304 if (!result->is_bool()) return false; | |
305 *value = result->get_bool(); | |
306 return true; | |
307 } | |
308 | |
309 bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, FlagValueOrigin origin) { | |
310 Flag* result = Flag::find_flag(name, len); | |
311 if (result == NULL) return false; | |
312 if (!result->is_bool()) return false; | |
313 bool old_value = result->get_bool(); | |
314 result->set_bool(*value); | |
315 *value = old_value; | |
316 result->origin = origin; | |
317 return true; | |
318 } | |
319 | |
320 void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, FlagValueOrigin origin) { | |
321 Flag* faddr = address_of_flag(flag); | |
322 guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type"); | |
323 faddr->set_bool(value); | |
324 faddr->origin = origin; | |
325 } | |
326 | |
327 bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) { | |
328 Flag* result = Flag::find_flag(name, len); | |
329 if (result == NULL) return false; | |
330 if (!result->is_intx()) return false; | |
331 *value = result->get_intx(); | |
332 return true; | |
333 } | |
334 | |
335 bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, FlagValueOrigin origin) { | |
336 Flag* result = Flag::find_flag(name, len); | |
337 if (result == NULL) return false; | |
338 if (!result->is_intx()) return false; | |
339 intx old_value = result->get_intx(); | |
340 result->set_intx(*value); | |
341 *value = old_value; | |
342 result->origin = origin; | |
343 return true; | |
344 } | |
345 | |
346 void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, FlagValueOrigin origin) { | |
347 Flag* faddr = address_of_flag(flag); | |
348 guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type"); | |
349 faddr->set_intx(value); | |
350 faddr->origin = origin; | |
351 } | |
352 | |
353 bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) { | |
354 Flag* result = Flag::find_flag(name, len); | |
355 if (result == NULL) return false; | |
356 if (!result->is_uintx()) return false; | |
357 *value = result->get_uintx(); | |
358 return true; | |
359 } | |
360 | |
361 bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, FlagValueOrigin origin) { | |
362 Flag* result = Flag::find_flag(name, len); | |
363 if (result == NULL) return false; | |
364 if (!result->is_uintx()) return false; | |
365 uintx old_value = result->get_uintx(); | |
366 result->set_uintx(*value); | |
367 *value = old_value; | |
368 result->origin = origin; | |
369 return true; | |
370 } | |
371 | |
372 void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, FlagValueOrigin origin) { | |
373 Flag* faddr = address_of_flag(flag); | |
374 guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type"); | |
375 faddr->set_uintx(value); | |
376 faddr->origin = origin; | |
377 } | |
378 | |
1064 | 379 bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) { |
380 Flag* result = Flag::find_flag(name, len); | |
381 if (result == NULL) return false; | |
382 if (!result->is_uint64_t()) return false; | |
383 *value = result->get_uint64_t(); | |
384 return true; | |
385 } | |
386 | |
387 bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, FlagValueOrigin origin) { | |
388 Flag* result = Flag::find_flag(name, len); | |
389 if (result == NULL) return false; | |
390 if (!result->is_uint64_t()) return false; | |
391 uint64_t old_value = result->get_uint64_t(); | |
392 result->set_uint64_t(*value); | |
393 *value = old_value; | |
394 result->origin = origin; | |
395 return true; | |
396 } | |
397 | |
398 void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, FlagValueOrigin origin) { | |
399 Flag* faddr = address_of_flag(flag); | |
400 guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type"); | |
401 faddr->set_uint64_t(value); | |
402 faddr->origin = origin; | |
403 } | |
404 | |
0 | 405 bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) { |
406 Flag* result = Flag::find_flag(name, len); | |
407 if (result == NULL) return false; | |
408 if (!result->is_double()) return false; | |
409 *value = result->get_double(); | |
410 return true; | |
411 } | |
412 | |
413 bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, FlagValueOrigin origin) { | |
414 Flag* result = Flag::find_flag(name, len); | |
415 if (result == NULL) return false; | |
416 if (!result->is_double()) return false; | |
417 double old_value = result->get_double(); | |
418 result->set_double(*value); | |
419 *value = old_value; | |
420 result->origin = origin; | |
421 return true; | |
422 } | |
423 | |
424 void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, FlagValueOrigin origin) { | |
425 Flag* faddr = address_of_flag(flag); | |
426 guarantee(faddr != NULL && faddr->is_double(), "wrong flag type"); | |
427 faddr->set_double(value); | |
428 faddr->origin = origin; | |
429 } | |
430 | |
431 bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) { | |
432 Flag* result = Flag::find_flag(name, len); | |
433 if (result == NULL) return false; | |
434 if (!result->is_ccstr()) return false; | |
435 *value = result->get_ccstr(); | |
436 return true; | |
437 } | |
438 | |
439 // Contract: Flag will make private copy of the incoming value. | |
440 // Outgoing value is always malloc-ed, and caller MUST call free. | |
441 bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, FlagValueOrigin origin) { | |
442 Flag* result = Flag::find_flag(name, len); | |
443 if (result == NULL) return false; | |
444 if (!result->is_ccstr()) return false; | |
445 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
|
446 char* new_value = NULL; |
885fe0f95828
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
196
diff
changeset
|
447 if (*value != NULL) { |
885fe0f95828
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
196
diff
changeset
|
448 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
|
449 strcpy(new_value, *value); |
885fe0f95828
6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents:
196
diff
changeset
|
450 } |
0 | 451 result->set_ccstr(new_value); |
452 if (result->origin == DEFAULT && old_value != NULL) { | |
453 // Prior value is NOT heap allocated, but was a literal constant. | |
454 char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1); | |
455 strcpy(old_value_to_free, old_value); | |
456 old_value = old_value_to_free; | |
457 } | |
458 *value = old_value; | |
459 result->origin = origin; | |
460 return true; | |
461 } | |
462 | |
463 // Contract: Flag will make private copy of the incoming value. | |
464 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin) { | |
465 Flag* faddr = address_of_flag(flag); | |
466 guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); | |
467 ccstr old_value = faddr->get_ccstr(); | |
468 char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1); | |
469 strcpy(new_value, value); | |
470 faddr->set_ccstr(new_value); | |
471 if (faddr->origin != DEFAULT && old_value != NULL) { | |
472 // Prior value is heap allocated so free it. | |
473 FREE_C_HEAP_ARRAY(char, old_value); | |
474 } | |
475 faddr->origin = origin; | |
476 } | |
477 | |
478 extern "C" { | |
479 static int compare_flags(const void* void_a, const void* void_b) { | |
480 return strcmp((*((Flag**) void_a))->name, (*((Flag**) void_b))->name); | |
481 } | |
482 } | |
483 | |
484 void CommandLineFlags::printSetFlags() { | |
485 // Print which flags were set on the command line | |
486 // note: this method is called before the thread structure is in place | |
487 // which means resource allocation cannot be used. | |
488 | |
489 // Compute size | |
490 int length= 0; | |
491 while (flagTable[length].name != NULL) length++; | |
492 | |
493 // Sort | |
494 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length); | |
495 for (int index = 0; index < length; index++) { | |
496 array[index] = &flagTable[index]; | |
497 } | |
498 qsort(array, length, sizeof(Flag*), compare_flags); | |
499 | |
500 // Print | |
501 for (int i = 0; i < length; i++) { | |
502 if (array[i]->origin /* naked field! */) { | |
503 array[i]->print_as_flag(tty); | |
504 tty->print(" "); | |
505 } | |
506 } | |
507 tty->cr(); | |
508 FREE_C_HEAP_ARRAY(Flag*, array); | |
509 } | |
510 | |
511 #ifndef PRODUCT | |
512 | |
513 | |
514 void CommandLineFlags::verify() { | |
515 assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict"); | |
516 } | |
517 | |
1150 | 518 #endif // PRODUCT |
519 | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
520 void CommandLineFlags::printFlags(bool withComments) { |
0 | 521 // Print the flags sorted by name |
522 // note: this method is called before the thread structure is in place | |
523 // which means resource allocation cannot be used. | |
524 | |
525 // Compute size | |
526 int length= 0; | |
527 while (flagTable[length].name != NULL) length++; | |
528 | |
529 // Sort | |
530 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length); | |
531 for (int index = 0; index < length; index++) { | |
532 array[index] = &flagTable[index]; | |
533 } | |
534 qsort(array, length, sizeof(Flag*), compare_flags); | |
535 | |
536 // Print | |
537 tty->print_cr("[Global flags]"); | |
538 for (int i = 0; i < length; i++) { | |
539 if (array[i]->is_unlocked()) { | |
1768
6ee479178066
6979444: add command line option to print command line flags descriptions
ikrylov
parents:
1692
diff
changeset
|
540 array[i]->print_on(tty, withComments); |
0 | 541 } |
542 } | |
543 FREE_C_HEAP_ARRAY(Flag*, array); | |
544 } |