annotate src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp @ 50590:4fa726f796f5

8202781: Fix typo in DiscoveredListIterator::complete_enqeue Reviewed-by: kbarrett
author tschatzl
date Tue, 08 May 2018 16:49:20 +0200
parents 3661f31c6df4
children 0195ee80e530
rev   line source
gziemski@50371 1 /*
gziemski@50371 2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
gziemski@50371 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
gziemski@50371 4 *
gziemski@50371 5 * This code is free software; you can redistribute it and/or modify it
gziemski@50371 6 * under the terms of the GNU General Public License version 2 only, as
gziemski@50371 7 * published by the Free Software Foundation.
gziemski@50371 8 *
gziemski@50371 9 * This code is distributed in the hope that it will be useful, but WITHOUT
gziemski@50371 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
gziemski@50371 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
gziemski@50371 12 * version 2 for more details (a copy is included in the LICENSE file that
gziemski@50371 13 * accompanied this code).
gziemski@50371 14 *
gziemski@50371 15 * You should have received a copy of the GNU General Public License version
gziemski@50371 16 * 2 along with this work; if not, write to the Free Software Foundation,
gziemski@50371 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
gziemski@50371 18 *
gziemski@50371 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
gziemski@50371 20 * or visit www.oracle.com if you need additional information or have any
gziemski@50371 21 * questions.
gziemski@50371 22 *
gziemski@50371 23 */
gziemski@50371 24
gziemski@50371 25 #include "precompiled.hpp"
gziemski@50371 26 #include "gc/shared/collectedHeap.hpp"
gziemski@50371 27 #include "gc/shared/collectorPolicy.hpp"
stefank@50518 28 #include "gc/shared/gcConfig.hpp"
gziemski@50413 29 #include "gc/shared/jvmFlagConstraintsGC.hpp"
gziemski@50371 30 #include "gc/shared/plab.hpp"
gziemski@50371 31 #include "gc/shared/threadLocalAllocBuffer.hpp"
gziemski@50371 32 #include "runtime/arguments.hpp"
gziemski@50413 33 #include "runtime/flags/jvmFlagRangeList.hpp"
gziemski@50371 34 #include "runtime/globals.hpp"
gziemski@50371 35 #include "runtime/globals_extension.hpp"
gziemski@50371 36 #include "runtime/thread.inline.hpp"
gziemski@50371 37 #include "utilities/align.hpp"
gziemski@50371 38 #include "utilities/defaultStream.hpp"
gziemski@50371 39 #include "utilities/macros.hpp"
stefank@50518 40 #if INCLUDE_CMSGC
gziemski@50413 41 #include "gc/cms/jvmFlagConstraintsCMS.hpp"
stefank@50518 42 #endif
stefank@50518 43 #if INCLUDE_G1GC
gziemski@50413 44 #include "gc/g1/jvmFlagConstraintsG1.hpp"
stefank@50518 45 #endif
stefank@50518 46 #if INCLUDE_PARALLELGC
gziemski@50413 47 #include "gc/parallel/jvmFlagConstraintsParallel.hpp"
gziemski@50371 48 #endif
gziemski@50371 49 #ifdef COMPILER1
gziemski@50371 50 #include "c1/c1_globals.hpp"
gziemski@50371 51 #endif // COMPILER1
gziemski@50371 52 #ifdef COMPILER2
gziemski@50371 53 #include "opto/c2_globals.hpp"
gziemski@50371 54 #endif // COMPILER2
gziemski@50371 55
gziemski@50371 56 // Some flags that have default values that indicate that the
gziemski@50371 57 // JVM should automatically determine an appropriate value
gziemski@50371 58 // for that flag. In those cases it is only appropriate for the
gziemski@50371 59 // constraint checking to be done if the user has specified the
gziemski@50371 60 // value(s) of the flag(s) on the command line. In the constraint
gziemski@50371 61 // checking functions, FLAG_IS_CMDLINE() is used to check if
gziemski@50371 62 // the flag has been set by the user and so should be checked.
gziemski@50371 63
gziemski@50371 64 // As ParallelGCThreads differs among GC modes, we need constraint function.
gziemski@50413 65 JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) {
gziemski@50413 66 JVMFlag::Error status = JVMFlag::SUCCESS;
gziemski@50371 67
stefank@50518 68 #if INCLUDE_PARALLELGC
gziemski@50371 69 status = ParallelGCThreadsConstraintFuncParallel(value, verbose);
gziemski@50413 70 if (status != JVMFlag::SUCCESS) {
gziemski@50371 71 return status;
gziemski@50371 72 }
stefank@50518 73 #endif
gziemski@50371 74
stefank@50518 75 #if INCLUDE_CMSGC
gziemski@50371 76 status = ParallelGCThreadsConstraintFuncCMS(value, verbose);
gziemski@50413 77 if (status != JVMFlag::SUCCESS) {
gziemski@50371 78 return status;
gziemski@50371 79 }
gziemski@50371 80 #endif
gziemski@50371 81
gziemski@50371 82 return status;
gziemski@50371 83 }
gziemski@50371 84
gziemski@50371 85 // As ConcGCThreads should be smaller than ParallelGCThreads,
gziemski@50371 86 // we need constraint function.
gziemski@50413 87 JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) {
gziemski@50371 88 // CMS and G1 GCs use ConcGCThreads.
stefank@50518 89 if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
stefank@50518 90 GCConfig::is_gc_selected(CollectedHeap::G1)) && (value > ParallelGCThreads)) {
gziemski@50371 91 CommandLineError::print(verbose,
gziemski@50371 92 "ConcGCThreads (" UINT32_FORMAT ") must be "
gziemski@50371 93 "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n",
gziemski@50371 94 value, ParallelGCThreads);
gziemski@50413 95 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 96 }
stefank@50518 97
gziemski@50413 98 return JVMFlag::SUCCESS;
gziemski@50371 99 }
gziemski@50371 100
gziemski@50413 101 static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) {
stefank@50518 102 if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
stefank@50518 103 GCConfig::is_gc_selected(CollectedHeap::G1) ||
stefank@50518 104 GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value < PLAB::min_size())) {
gziemski@50371 105 CommandLineError::print(verbose,
gziemski@50371 106 "%s (" SIZE_FORMAT ") must be "
gziemski@50371 107 "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n",
gziemski@50371 108 name, value, PLAB::min_size());
gziemski@50413 109 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 110 }
stefank@50518 111
gziemski@50413 112 return JVMFlag::SUCCESS;
gziemski@50371 113 }
gziemski@50371 114
gziemski@50413 115 JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
stefank@50518 116 if ((GCConfig::is_gc_selected(CollectedHeap::CMS) ||
stefank@50518 117 GCConfig::is_gc_selected(CollectedHeap::G1) ||
stefank@50518 118 GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value > PLAB::max_size())) {
gziemski@50371 119 CommandLineError::print(verbose,
gziemski@50371 120 "%s (" SIZE_FORMAT ") must be "
gziemski@50371 121 "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n",
gziemski@50371 122 name, value, PLAB::max_size());
gziemski@50413 123 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 124 }
stefank@50518 125
gziemski@50413 126 return JVMFlag::SUCCESS;
gziemski@50371 127 }
gziemski@50371 128
gziemski@50413 129 static JVMFlag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) {
gziemski@50413 130 JVMFlag::Error status = MinPLABSizeBounds(name, value, verbose);
gziemski@50371 131
gziemski@50413 132 if (status == JVMFlag::SUCCESS) {
gziemski@50371 133 return MaxPLABSizeBounds(name, value, verbose);
gziemski@50371 134 }
gziemski@50371 135 return status;
gziemski@50371 136 }
gziemski@50371 137
gziemski@50413 138 JVMFlag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50371 139 return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose);
gziemski@50371 140 }
gziemski@50371 141
gziemski@50413 142 JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50413 143 JVMFlag::Error status = JVMFlag::SUCCESS;
gziemski@50371 144
stefank@50518 145 #if INCLUDE_CMSGC
gziemski@50371 146 if (UseConcMarkSweepGC) {
gziemski@50371 147 return OldPLABSizeConstraintFuncCMS(value, verbose);
stefank@50518 148 } else
stefank@50518 149 #endif
stefank@50518 150 {
gziemski@50371 151 status = MinMaxPLABSizeBounds("OldPLABSize", value, verbose);
gziemski@50371 152 }
stefank@50518 153
gziemski@50371 154 return status;
gziemski@50371 155 }
gziemski@50371 156
gziemski@50413 157 JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
gziemski@50371 158 if (value > MaxHeapFreeRatio) {
gziemski@50371 159 CommandLineError::print(verbose,
gziemski@50371 160 "MinHeapFreeRatio (" UINTX_FORMAT ") must be "
gziemski@50371 161 "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
gziemski@50371 162 value, MaxHeapFreeRatio);
gziemski@50413 163 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 164 } else {
gziemski@50413 165 return JVMFlag::SUCCESS;
gziemski@50371 166 }
gziemski@50371 167 }
gziemski@50371 168
gziemski@50413 169 JVMFlag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) {
gziemski@50371 170 if (value < MinHeapFreeRatio) {
gziemski@50371 171 CommandLineError::print(verbose,
gziemski@50371 172 "MaxHeapFreeRatio (" UINTX_FORMAT ") must be "
gziemski@50371 173 "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n",
gziemski@50371 174 value, MinHeapFreeRatio);
gziemski@50413 175 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 176 } else {
gziemski@50413 177 return JVMFlag::SUCCESS;
gziemski@50371 178 }
gziemski@50371 179 }
gziemski@50371 180
gziemski@50413 181 static JVMFlag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, intx softRef, bool verbose) {
gziemski@50371 182 if ((softRef > 0) && ((maxHeap / M) > (max_uintx / softRef))) {
gziemski@50371 183 CommandLineError::print(verbose,
gziemski@50371 184 "Desired lifetime of SoftReferences cannot be expressed correctly. "
gziemski@50371 185 "MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB "
gziemski@50371 186 "(" INTX_FORMAT ") is too large\n",
gziemski@50371 187 maxHeap, softRef);
gziemski@50413 188 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 189 } else {
gziemski@50413 190 return JVMFlag::SUCCESS;
gziemski@50371 191 }
gziemski@50371 192 }
gziemski@50371 193
gziemski@50413 194 JVMFlag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) {
gziemski@50371 195 return CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(MaxHeapSize, value, verbose);
gziemski@50371 196 }
gziemski@50371 197
gziemski@50413 198 JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50371 199 if (value > MarkStackSizeMax) {
gziemski@50371 200 CommandLineError::print(verbose,
gziemski@50371 201 "MarkStackSize (" SIZE_FORMAT ") must be "
gziemski@50371 202 "less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n",
gziemski@50371 203 value, MarkStackSizeMax);
gziemski@50413 204 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 205 } else {
gziemski@50413 206 return JVMFlag::SUCCESS;
gziemski@50371 207 }
gziemski@50371 208 }
gziemski@50371 209
gziemski@50413 210 JVMFlag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
gziemski@50371 211 if (value > MaxMetaspaceFreeRatio) {
gziemski@50371 212 CommandLineError::print(verbose,
gziemski@50371 213 "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
gziemski@50371 214 "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
gziemski@50371 215 value, MaxMetaspaceFreeRatio);
gziemski@50413 216 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 217 } else {
gziemski@50413 218 return JVMFlag::SUCCESS;
gziemski@50371 219 }
gziemski@50371 220 }
gziemski@50371 221
gziemski@50413 222 JVMFlag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) {
gziemski@50371 223 if (value < MinMetaspaceFreeRatio) {
gziemski@50371 224 CommandLineError::print(verbose,
gziemski@50371 225 "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be "
gziemski@50371 226 "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n",
gziemski@50371 227 value, MinMetaspaceFreeRatio);
gziemski@50413 228 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 229 } else {
gziemski@50413 230 return JVMFlag::SUCCESS;
gziemski@50371 231 }
gziemski@50371 232 }
gziemski@50371 233
gziemski@50413 234 JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) {
stefank@50518 235 #if INCLUDE_PARALLELGC
gziemski@50413 236 JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose);
gziemski@50413 237 if (status != JVMFlag::SUCCESS) {
gziemski@50371 238 return status;
gziemski@50371 239 }
gziemski@50371 240 #endif
gziemski@50371 241
gziemski@50413 242 return JVMFlag::SUCCESS;
gziemski@50371 243 }
gziemski@50371 244
gziemski@50413 245 JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) {
stefank@50518 246 #if INCLUDE_PARALLELGC
gziemski@50413 247 JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose);
gziemski@50413 248 if (status != JVMFlag::SUCCESS) {
gziemski@50371 249 return status;
gziemski@50371 250 }
gziemski@50371 251 #endif
gziemski@50371 252
gziemski@50371 253 // MaxTenuringThreshold=0 means NeverTenure=false && AlwaysTenure=true
gziemski@50371 254 if ((value == 0) && (NeverTenure || !AlwaysTenure)) {
gziemski@50371 255 CommandLineError::print(verbose,
gziemski@50371 256 "MaxTenuringThreshold (0) should match to NeverTenure=false "
gziemski@50371 257 "&& AlwaysTenure=true. But we have NeverTenure=%s "
gziemski@50371 258 "AlwaysTenure=%s\n",
gziemski@50371 259 NeverTenure ? "true" : "false",
gziemski@50371 260 AlwaysTenure ? "true" : "false");
gziemski@50413 261 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 262 }
gziemski@50413 263 return JVMFlag::SUCCESS;
gziemski@50371 264 }
gziemski@50371 265
gziemski@50413 266 JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) {
stefank@50518 267 #if INCLUDE_G1GC
gziemski@50413 268 JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose);
gziemski@50413 269 if (status != JVMFlag::SUCCESS) {
gziemski@50371 270 return status;
gziemski@50371 271 }
gziemski@50371 272 #endif
gziemski@50371 273
gziemski@50413 274 return JVMFlag::SUCCESS;
gziemski@50371 275 }
gziemski@50371 276
gziemski@50413 277 JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) {
stefank@50518 278 #if INCLUDE_G1GC
gziemski@50413 279 JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose);
gziemski@50413 280 if (status != JVMFlag::SUCCESS) {
gziemski@50371 281 return status;
gziemski@50371 282 }
gziemski@50371 283 #endif
gziemski@50371 284
gziemski@50413 285 return JVMFlag::SUCCESS;
gziemski@50371 286 }
gziemski@50371 287
gziemski@50413 288 JVMFlag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50371 289 size_t aligned_max = align_down(max_uintx/2, Metaspace::reserve_alignment_words());
gziemski@50371 290 if (value > aligned_max) {
gziemski@50371 291 CommandLineError::print(verbose,
gziemski@50371 292 "InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be "
gziemski@50371 293 "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
gziemski@50371 294 value, aligned_max);
gziemski@50413 295 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 296 }
gziemski@50413 297 return JVMFlag::SUCCESS;
gziemski@50371 298 }
gziemski@50371 299
gziemski@50371 300 // To avoid an overflow by 'align_up(value, alignment)'.
gziemski@50413 301 static JVMFlag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) {
gziemski@50371 302 size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
gziemski@50371 303 if (value > aligned_max) {
gziemski@50371 304 CommandLineError::print(verbose,
gziemski@50371 305 "%s (" SIZE_FORMAT ") must be "
gziemski@50371 306 "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n",
gziemski@50371 307 name, value, aligned_max);
gziemski@50413 308 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 309 }
gziemski@50413 310 return JVMFlag::SUCCESS;
gziemski@50371 311 }
gziemski@50371 312
gziemski@50413 313 static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bool verbose) {
gziemski@50371 314 size_t heap_alignment;
gziemski@50371 315
stefank@50518 316 #if INCLUDE_G1GC
gziemski@50371 317 if (UseG1GC) {
gziemski@50371 318 // For G1 GC, we don't know until G1CollectorPolicy is created.
gziemski@50371 319 heap_alignment = MaxSizeForHeapAlignmentG1();
gziemski@50371 320 } else
gziemski@50371 321 #endif
gziemski@50371 322 {
gziemski@50371 323 heap_alignment = CollectorPolicy::compute_heap_alignment();
gziemski@50371 324 }
gziemski@50371 325
gziemski@50371 326 return MaxSizeForAlignment(name, value, heap_alignment, verbose);
gziemski@50371 327 }
gziemski@50371 328
gziemski@50413 329 JVMFlag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50371 330 return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose);
gziemski@50371 331 }
gziemski@50371 332
gziemski@50413 333 JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50413 334 JVMFlag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose);
gziemski@50371 335
gziemski@50413 336 if (status == JVMFlag::SUCCESS) {
gziemski@50371 337 status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose);
gziemski@50371 338 }
gziemski@50371 339 return status;
gziemski@50371 340 }
gziemski@50371 341
gziemski@50413 342 JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) {
gziemski@50371 343 // If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value.
gziemski@50371 344 // Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx.
gziemski@50371 345 if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) {
gziemski@50371 346 CommandLineError::print(verbose,
gziemski@50371 347 "HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. "
gziemski@50371 348 "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n",
gziemski@50371 349 value, MaxHeapSize, max_uintx);
gziemski@50413 350 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 351 }
gziemski@50371 352
gziemski@50371 353 return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose);
gziemski@50371 354 }
gziemski@50371 355
gziemski@50413 356 JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) {
stefank@50518 357 #if INCLUDE_G1GC
gziemski@50413 358 JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose);
gziemski@50413 359 if (status != JVMFlag::SUCCESS) {
gziemski@50371 360 return status;
gziemski@50371 361 }
gziemski@50371 362 #endif
gziemski@50371 363
gziemski@50413 364 return JVMFlag::SUCCESS;
gziemski@50371 365 }
gziemski@50371 366
gziemski@50413 367 JVMFlag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50371 368 // At least, alignment reserve area is needed.
gziemski@50371 369 if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) {
gziemski@50371 370 CommandLineError::print(verbose,
gziemski@50371 371 "MinTLABSize (" SIZE_FORMAT ") must be "
gziemski@50371 372 "greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n",
gziemski@50371 373 value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes());
gziemski@50413 374 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 375 }
gziemski@50371 376 if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
gziemski@50371 377 CommandLineError::print(verbose,
gziemski@50371 378 "MinTLABSize (" SIZE_FORMAT ") must be "
gziemski@50371 379 "less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n",
gziemski@50371 380 value, ThreadLocalAllocBuffer::max_size() * HeapWordSize);
gziemski@50413 381 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 382 }
gziemski@50413 383 return JVMFlag::SUCCESS;
gziemski@50371 384 }
gziemski@50371 385
gziemski@50413 386 JVMFlag::Error TLABSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50371 387 // Skip for default value of zero which means set ergonomically.
gziemski@50371 388 if (FLAG_IS_CMDLINE(TLABSize)) {
gziemski@50371 389 if (value < MinTLABSize) {
gziemski@50371 390 CommandLineError::print(verbose,
gziemski@50371 391 "TLABSize (" SIZE_FORMAT ") must be "
gziemski@50371 392 "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n",
gziemski@50371 393 value, MinTLABSize);
gziemski@50413 394 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 395 }
gziemski@50371 396 if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) {
gziemski@50371 397 CommandLineError::print(verbose,
gziemski@50371 398 "TLABSize (" SIZE_FORMAT ") must be "
gziemski@50371 399 "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n",
gziemski@50371 400 value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize));
gziemski@50413 401 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 402 }
gziemski@50371 403 }
gziemski@50413 404 return JVMFlag::SUCCESS;
gziemski@50371 405 }
gziemski@50371 406
gziemski@50371 407 // We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(),
gziemski@50371 408 // so AfterMemoryInit type is enough to check.
gziemski@50413 409 JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) {
gziemski@50371 410 if (UseTLAB) {
gziemski@50371 411 size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit();
gziemski@50371 412
gziemski@50371 413 // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'.
gziemski@50371 414 if (refill_waste_limit > (max_uintx - value)) {
gziemski@50371 415 CommandLineError::print(verbose,
gziemski@50371 416 "TLABWasteIncrement (" UINTX_FORMAT ") must be "
gziemski@50371 417 "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n",
gziemski@50371 418 value, (max_uintx - refill_waste_limit));
gziemski@50413 419 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 420 }
gziemski@50371 421 }
gziemski@50413 422 return JVMFlag::SUCCESS;
gziemski@50371 423 }
gziemski@50371 424
gziemski@50413 425 JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) {
gziemski@50371 426 if (FLAG_IS_CMDLINE(SurvivorRatio) &&
gziemski@50371 427 (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) {
gziemski@50371 428 CommandLineError::print(verbose,
gziemski@50371 429 "SurvivorRatio (" UINTX_FORMAT ") must be "
gziemski@50371 430 "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n",
gziemski@50371 431 value,
gziemski@50371 432 (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()));
gziemski@50413 433 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 434 } else {
gziemski@50413 435 return JVMFlag::SUCCESS;
gziemski@50371 436 }
gziemski@50371 437 }
gziemski@50371 438
gziemski@50413 439 JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50371 440 if (value > MaxMetaspaceSize) {
gziemski@50371 441 CommandLineError::print(verbose,
gziemski@50371 442 "MetaspaceSize (" SIZE_FORMAT ") must be "
gziemski@50371 443 "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n",
gziemski@50371 444 value, MaxMetaspaceSize);
gziemski@50413 445 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 446 } else {
gziemski@50413 447 return JVMFlag::SUCCESS;
gziemski@50371 448 }
gziemski@50371 449 }
gziemski@50371 450
gziemski@50413 451 JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
gziemski@50371 452 if (value < MetaspaceSize) {
gziemski@50371 453 CommandLineError::print(verbose,
gziemski@50371 454 "MaxMetaspaceSize (" SIZE_FORMAT ") must be "
gziemski@50371 455 "greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n",
gziemski@50371 456 value, MaxMetaspaceSize);
gziemski@50413 457 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 458 } else {
gziemski@50413 459 return JVMFlag::SUCCESS;
gziemski@50371 460 }
gziemski@50371 461 }
gziemski@50371 462
gziemski@50413 463 JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
gziemski@50371 464 if (value != 0) {
gziemski@50371 465 if (!is_power_of_2(value)) {
gziemski@50371 466 CommandLineError::print(verbose,
gziemski@50371 467 "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
gziemski@50371 468 "power of 2\n",
gziemski@50371 469 value);
gziemski@50413 470 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 471 }
gziemski@50371 472 if (value < ObjectAlignmentInBytes) {
gziemski@50371 473 CommandLineError::print(verbose,
gziemski@50371 474 "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
gziemski@50371 475 "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
gziemski@50371 476 value, ObjectAlignmentInBytes);
gziemski@50413 477 return JVMFlag::VIOLATES_CONSTRAINT;
gziemski@50371 478 }
gziemski@50371 479 }
gziemski@50413 480 return JVMFlag::SUCCESS;
gziemski@50371 481 }