13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "runtime/arguments.hpp"
27 #include "runtime/commandLineFlagConstraintsGC.hpp"
28 #include "runtime/globals.hpp"
29 #include "utilities/defaultStream.hpp"
30
31 #if INCLUDE_ALL_GCS
32 #include "gc/g1/g1_globals.hpp"
33 #endif // INCLUDE_ALL_GCS
34 #ifdef COMPILER1
35 #include "c1/c1_globals.hpp"
36 #endif // COMPILER1
37 #ifdef COMPILER2
38 #include "opto/c2_globals.hpp"
39 #endif // COMPILER2
40
41 Flag::Error MinHeapFreeRatioConstraintFunc(bool verbose, uintx* value) {
42 if ((CommandLineFlags::finishedInitializing()) && (*value > MaxHeapFreeRatio)) {
43 if (verbose == true) {
44 jio_fprintf(defaultStream::error_stream(),
45 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
46 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
47 *value, MaxHeapFreeRatio);
48 }
49 return Flag::VIOLATES_CONSTRAINT;
50 } else {
51 return Flag::SUCCESS;
52 }
53 }
54
55 Flag::Error MaxHeapFreeRatioConstraintFunc(bool verbose, uintx* value) {
56 if ((CommandLineFlags::finishedInitializing()) && (*value < MinHeapFreeRatio)) {
57 if (verbose == true) {
58 jio_fprintf(defaultStream::error_stream(),
59 "MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
60 "equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
61 *value, MinHeapFreeRatio);
62 }
63 return Flag::VIOLATES_CONSTRAINT;
64 } else {
65 return Flag::SUCCESS;
66 }
67 }
68
69 Flag::Error MinMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value) {
70 if ((CommandLineFlags::finishedInitializing()) && (*value > MaxMetaspaceFreeRatio)) {
71 if (verbose == true) {
72 jio_fprintf(defaultStream::error_stream(),
73 "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be less than or "
74 "equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
75 *value, MaxMetaspaceFreeRatio);
76 }
77 return Flag::VIOLATES_CONSTRAINT;
78 } else {
79 return Flag::SUCCESS;
80 }
81 }
82
83 Flag::Error MaxMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value) {
84 if ((CommandLineFlags::finishedInitializing()) && (*value < MinMetaspaceFreeRatio)) {
85 if (verbose == true) {
86 jio_fprintf(defaultStream::error_stream(),
87 "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be greater than or "
88 "equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
89 *value, MinMetaspaceFreeRatio);
90 }
91 return Flag::VIOLATES_CONSTRAINT;
92 } else {
93 return Flag::SUCCESS;
94 }
95 }
96
97 // GC workaround for "-XX:+UseConcMarkSweepGC"
98 // which sets InitialTenuringThreshold to 7 but leaves MaxTenuringThreshold remaining at 6
99 // and therefore would invalidate the constraint
100 #define UseConcMarkSweepGCWorkaroundIfNeeded(initial, max) { \
101 if ((initial == 7) && (max == 6)) { \
102 return Flag::SUCCESS; \
103 } \
104 }
105
106 Flag::Error InitialTenuringThresholdConstraintFunc(bool verbose, uintx* value) {
107 UseConcMarkSweepGCWorkaroundIfNeeded(*value, MaxTenuringThreshold);
108
109 if ((CommandLineFlags::finishedInitializing()) && (*value > MaxTenuringThreshold)) {
110 if (verbose == true) {
111 jio_fprintf(defaultStream::error_stream(),
112 "InitialTenuringThreshold (" UINTX_FORMAT ") must be less than or "
113 "equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n",
114 *value, MaxTenuringThreshold);
115 }
116 return Flag::VIOLATES_CONSTRAINT;
117 } else {
118 return Flag::SUCCESS;
119 }
120 }
121
122 Flag::Error MaxTenuringThresholdConstraintFunc(bool verbose, uintx* value) {
123 UseConcMarkSweepGCWorkaroundIfNeeded(InitialTenuringThreshold, *value);
124
125 if ((CommandLineFlags::finishedInitializing()) && (*value < InitialTenuringThreshold)) {
126 if (verbose == true) {
127 jio_fprintf(defaultStream::error_stream(),
128 "MaxTenuringThreshold (" UINTX_FORMAT ") must be greater than or "
129 "equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n",
130 *value, InitialTenuringThreshold);
131 }
132 return Flag::VIOLATES_CONSTRAINT;
133 } else {
134 return Flag::SUCCESS;
135 }
136 }
137
138 #if INCLUDE_ALL_GCS
139
140 Flag::Error G1NewSizePercentConstraintFunc(bool verbose, uintx* value) {
141 if ((CommandLineFlags::finishedInitializing()) && (*value > G1MaxNewSizePercent)) {
142 if (verbose == true) {
143 jio_fprintf(defaultStream::error_stream(),
144 "G1NewSizePercent (" UINTX_FORMAT ") must be less than or "
145 "equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n",
146 *value, G1MaxNewSizePercent);
147 }
148 return Flag::VIOLATES_CONSTRAINT;
149 } else {
150 return Flag::SUCCESS;
151 }
152 }
153
154 Flag::Error G1MaxNewSizePercentConstraintFunc(bool verbose, uintx* value) {
155 if ((CommandLineFlags::finishedInitializing()) && (*value < G1NewSizePercent)) {
156 if (verbose == true) {
157 jio_fprintf(defaultStream::error_stream(),
158 "G1MaxNewSizePercent (" UINTX_FORMAT ") must be greater than or "
159 "equal to G1NewSizePercent (" UINTX_FORMAT ")\n",
160 *value, G1NewSizePercent);
161 }
162 return Flag::VIOLATES_CONSTRAINT;
163 } else {
164 return Flag::SUCCESS;
165 }
166 }
167
168 #endif // INCLUDE_ALL_GCS
169
170 Flag::Error CMSOldPLABMinConstraintFunc(bool verbose, size_t* value) {
171 if ((CommandLineFlags::finishedInitializing()) && (*value > CMSOldPLABMax)) {
172 if (verbose == true) {
173 jio_fprintf(defaultStream::error_stream(),
174 "CMSOldPLABMin (" SIZE_FORMAT ") must be less than or "
175 "equal to CMSOldPLABMax (" SIZE_FORMAT ")\n",
176 *value, CMSOldPLABMax);
177 }
178 return Flag::VIOLATES_CONSTRAINT;
179 } else {
180 return Flag::SUCCESS;
181 }
182 }
183
184 Flag::Error CMSPrecleanDenominatorConstraintFunc(bool verbose, uintx* value) {
185 if ((CommandLineFlags::finishedInitializing()) && (*value <= CMSPrecleanNumerator)) {
186 if (verbose == true) {
187 jio_fprintf(defaultStream::error_stream(),
188 "CMSPrecleanDenominator (" UINTX_FORMAT ") must be strickly greater than "
189 "CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
190 *value, CMSPrecleanNumerator);
191 }
192 return Flag::VIOLATES_CONSTRAINT;
193 } else {
194 return Flag::SUCCESS;
195 }
196 }
197
198 Flag::Error CMSPrecleanNumeratorConstraintFunc(bool verbose, uintx* value) {
199 if ((CommandLineFlags::finishedInitializing()) && (*value > (CMSPrecleanDenominator - 1))) {
200 if (verbose == true) {
201 jio_fprintf(defaultStream::error_stream(),
202 "CMSPrecleanNumerator (" UINTX_FORMAT ") must be less than or "
203 "equal to CMSPrecleanDenominator - 1 (" UINTX_FORMAT ")\n", *value,
204 CMSPrecleanDenominator - 1);
205 }
206 return Flag::VIOLATES_CONSTRAINT;
207 } else {
208 return Flag::SUCCESS;
209 }
210 }
211
212 Flag::Error SurvivorAlignmentInBytesConstraintFunc(bool verbose, intx* value) {
213 if (CommandLineFlags::finishedInitializing()) {
214 if (*value != 0) {
215 if (!is_power_of_2(*value)) {
216 if (verbose == true) {
217 jio_fprintf(defaultStream::error_stream(),
218 "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be power of 2\n",
219 *value);
220 }
221 return Flag::VIOLATES_CONSTRAINT;
222 }
223 if (*value < ObjectAlignmentInBytes) {
224 if (verbose == true) {
225 jio_fprintf(defaultStream::error_stream(),
226 "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be greater than or "
227 "equal to ObjectAlignmentInBytes (" INTX_FORMAT ") \n",
228 *value, ObjectAlignmentInBytes);
229 }
230 return Flag::VIOLATES_CONSTRAINT;
231 }
232 }
233 }
234 return Flag::SUCCESS;
235 }
|
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "runtime/arguments.hpp"
27 #include "runtime/commandLineFlagConstraintsGC.hpp"
28 #include "runtime/globals.hpp"
29 #include "utilities/defaultStream.hpp"
30
31 #if INCLUDE_ALL_GCS
32 #include "gc/g1/g1_globals.hpp"
33 #include "gc/g1/heapRegionBounds.inline.hpp"
34 #include "gc/parallel/parallelScavengeHeap.hpp"
35 #include "gc/shared/plab.hpp"
36 #endif // INCLUDE_ALL_GCS
37 #ifdef COMPILER1
38 #include "c1/c1_globals.hpp"
39 #endif // COMPILER1
40 #ifdef COMPILER2
41 #include "opto/c2_globals.hpp"
42 #endif // COMPILER2
43
44 static Flag::Error MinPLABSizeBounds(const char* name, bool verbose, size_t* value) {
45 #if INCLUDE_ALL_GCS
46 if ((UseConcMarkSweepGC || UseG1GC) && (*value < PLAB::min_size())) {
47 if (verbose == true) {
48 jio_fprintf(defaultStream::error_stream(),
49 "%s (" SIZE_FORMAT ") must be greater than "
50 "ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
51 name, *value, PLAB::min_size());
52 }
53 return Flag::VIOLATES_CONSTRAINT;
54 }
55 #endif // INCLUDE_ALL_GCS
56 return Flag::SUCCESS;
57 }
58
59 static Flag::Error MaxPLABSizeBounds(const char* name, bool verbose, size_t* value) {
60 #if INCLUDE_ALL_GCS
61 if ((UseConcMarkSweepGC || UseG1GC) && (*value > PLAB::max_size())) {
62 if (verbose == true) {
63 jio_fprintf(defaultStream::error_stream(),
64 "%s (" SIZE_FORMAT ") must be less than "
65 "ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
66 name, *value, PLAB::max_size());
67 }
68 return Flag::VIOLATES_CONSTRAINT;
69 }
70 #endif // INCLUDE_ALL_GCS
71 return Flag::SUCCESS;
72 }
73
74 static Flag::Error MinMaxPLABSizeBounds(const char* name, bool verbose, size_t* value) {
75 if (MinPLABSizeBounds(name, verbose, value) == Flag::SUCCESS) {
76 return MaxPLABSizeBounds(name, verbose, value);
77 }
78 return Flag::VIOLATES_CONSTRAINT;
79 }
80
81 Flag::Error YoungPLABSizeConstraintFunc(bool verbose, size_t* value) {
82 return MinMaxPLABSizeBounds("YoungPLABSize", verbose, value);
83 }
84
85 Flag::Error MinHeapFreeRatioConstraintFunc(bool verbose, uintx* value) {
86 if (*value > MaxHeapFreeRatio) {
87 if (verbose == true) {
88 jio_fprintf(defaultStream::error_stream(),
89 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
90 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
91 *value, MaxHeapFreeRatio);
92 }
93 return Flag::VIOLATES_CONSTRAINT;
94 } else {
95 return Flag::SUCCESS;
96 }
97 }
98
99 Flag::Error MaxHeapFreeRatioConstraintFunc(bool verbose, uintx* value) {
100 if (*value < MinHeapFreeRatio) {
101 if (verbose == true) {
102 jio_fprintf(defaultStream::error_stream(),
103 "MaxHeapFreeRatio (" UINTX_FORMAT ") must be greater than or "
104 "equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
105 *value, MinHeapFreeRatio);
106 }
107 return Flag::VIOLATES_CONSTRAINT;
108 } else {
109 return Flag::SUCCESS;
110 }
111 }
112
113 Flag::Error MinMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value) {
114 if (*value > MaxMetaspaceFreeRatio) {
115 if (verbose == true) {
116 jio_fprintf(defaultStream::error_stream(),
117 "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be less than or "
118 "equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
119 *value, MaxMetaspaceFreeRatio);
120 }
121 return Flag::VIOLATES_CONSTRAINT;
122 } else {
123 return Flag::SUCCESS;
124 }
125 }
126
127 Flag::Error MaxMetaspaceFreeRatioConstraintFunc(bool verbose, uintx* value) {
128 if (*value < MinMetaspaceFreeRatio) {
129 if (verbose == true) {
130 jio_fprintf(defaultStream::error_stream(),
131 "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be greater than or "
132 "equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
133 *value, MinMetaspaceFreeRatio);
134 }
135 return Flag::VIOLATES_CONSTRAINT;
136 } else {
137 return Flag::SUCCESS;
138 }
139 }
140
141 // GC workaround for "-XX:+UseConcMarkSweepGC"
142 // which sets InitialTenuringThreshold to 7 but leaves MaxTenuringThreshold remaining at 6
143 // and therefore would invalidate the constraint
144 #define UseConcMarkSweepGCWorkaroundIfNeeded(initial, max) { \
145 if ((initial == 7) && (max == 6)) { \
146 return Flag::SUCCESS; \
147 } \
148 }
149
150 Flag::Error InitialTenuringThresholdConstraintFunc(bool verbose, uintx* value) {
151 UseConcMarkSweepGCWorkaroundIfNeeded(*value, MaxTenuringThreshold);
152
153 if (*value > MaxTenuringThreshold) {
154 if (verbose == true) {
155 jio_fprintf(defaultStream::error_stream(),
156 "InitialTenuringThreshold (" UINTX_FORMAT ") must be less than or "
157 "equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n",
158 *value, MaxTenuringThreshold);
159 }
160 return Flag::VIOLATES_CONSTRAINT;
161 } else {
162 return Flag::SUCCESS;
163 }
164 }
165
166 Flag::Error MaxTenuringThresholdConstraintFunc(bool verbose, uintx* value) {
167 UseConcMarkSweepGCWorkaroundIfNeeded(InitialTenuringThreshold, *value);
168
169 if (*value < InitialTenuringThreshold) {
170 if (verbose == true) {
171 jio_fprintf(defaultStream::error_stream(),
172 "MaxTenuringThreshold (" UINTX_FORMAT ") must be greater than or "
173 "equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n",
174 *value, InitialTenuringThreshold);
175 }
176 return Flag::VIOLATES_CONSTRAINT;
177 } else {
178 return Flag::SUCCESS;
179 }
180 }
181
182 #if INCLUDE_ALL_GCS
183 Flag::Error G1NewSizePercentConstraintFunc(bool verbose, uintx* value) {
184 if (*value > G1MaxNewSizePercent) {
185 if (verbose == true) {
186 jio_fprintf(defaultStream::error_stream(),
187 "G1NewSizePercent (" UINTX_FORMAT ") must be less than or "
188 "equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n",
189 *value, G1MaxNewSizePercent);
190 }
191 return Flag::VIOLATES_CONSTRAINT;
192 } else {
193 return Flag::SUCCESS;
194 }
195 }
196
197 Flag::Error G1MaxNewSizePercentConstraintFunc(bool verbose, uintx* value) {
198 if (*value < G1NewSizePercent) {
199 if (verbose == true) {
200 jio_fprintf(defaultStream::error_stream(),
201 "G1MaxNewSizePercent (" UINTX_FORMAT ") must be greater than or "
202 "equal to G1NewSizePercent (" UINTX_FORMAT ")\n",
203 *value, G1NewSizePercent);
204 }
205 return Flag::VIOLATES_CONSTRAINT;
206 } else {
207 return Flag::SUCCESS;
208 }
209 }
210
211 #endif // INCLUDE_ALL_GCS
212
213 Flag::Error CMSOldPLABMinConstraintFunc(bool verbose, size_t* value) {
214 if (*value > CMSOldPLABMax) {
215 if (verbose == true) {
216 jio_fprintf(defaultStream::error_stream(),
217 "CMSOldPLABMin (" SIZE_FORMAT ") must be less than or "
218 "equal to CMSOldPLABMax (" SIZE_FORMAT ")\n",
219 *value, CMSOldPLABMax);
220 }
221 return Flag::VIOLATES_CONSTRAINT;
222 } else {
223 return Flag::SUCCESS;
224 }
225 }
226
227 Flag::Error CMSPrecleanDenominatorConstraintFunc(bool verbose, uintx* value) {
228 if (*value <= CMSPrecleanNumerator) {
229 if (verbose == true) {
230 jio_fprintf(defaultStream::error_stream(),
231 "CMSPrecleanDenominator (" UINTX_FORMAT ") must be strickly greater than "
232 "CMSPrecleanNumerator (" UINTX_FORMAT ")\n",
233 *value, CMSPrecleanNumerator);
234 }
235 return Flag::VIOLATES_CONSTRAINT;
236 } else {
237 return Flag::SUCCESS;
238 }
239 }
240
241 Flag::Error CMSPrecleanNumeratorConstraintFunc(bool verbose, uintx* value) {
242 if (*value > (CMSPrecleanDenominator - 1)) {
243 if (verbose == true) {
244 jio_fprintf(defaultStream::error_stream(),
245 "CMSPrecleanNumerator (" UINTX_FORMAT ") must be less than or "
246 "equal to CMSPrecleanDenominator - 1 (" UINTX_FORMAT ")\n", *value,
247 CMSPrecleanDenominator - 1);
248 }
249 return Flag::VIOLATES_CONSTRAINT;
250 } else {
251 return Flag::SUCCESS;
252 }
253 }
254
255 Flag::Error SurvivorAlignmentInBytesConstraintFunc(bool verbose, intx* value) {
256 if (*value != 0) {
257 if (!is_power_of_2(*value)) {
258 if (verbose == true) {
259 jio_fprintf(defaultStream::error_stream(),
260 "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be power of 2\n",
261 *value);
262 }
263 return Flag::VIOLATES_CONSTRAINT;
264 }
265 if (*value < ObjectAlignmentInBytes) {
266 if (verbose == true) {
267 jio_fprintf(defaultStream::error_stream(),
268 "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be greater than or "
269 "equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
270 *value, ObjectAlignmentInBytes);
271 }
272 return Flag::VIOLATES_CONSTRAINT;
273 }
274 }
275 return Flag::SUCCESS;
276 }
|