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 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 } | 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 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/commandLineFlagRangeList.hpp" 29 #include "runtime/globals.hpp" 30 #include "utilities/defaultStream.hpp" 31 32 #if INCLUDE_ALL_GCS 33 #include "gc/g1/g1_globals.hpp" 34 #include "gc/g1/heapRegionBounds.inline.hpp" 35 #include "gc/parallel/parallelScavengeHeap.hpp" 36 #include "gc/shared/plab.hpp" 37 #endif // INCLUDE_ALL_GCS 38 #ifdef COMPILER1 39 #include "c1/c1_globals.hpp" 40 #endif // COMPILER1 41 #ifdef COMPILER2 42 #include "opto/c2_globals.hpp" 43 #endif // COMPILER2 44 45 static Flag::Error MinPLABSizeBounds(const char* name, size_t value, bool verbose) { 46 #if INCLUDE_ALL_GCS 47 if ((UseConcMarkSweepGC || UseG1GC) && (value < PLAB::min_size())) { 48 CommandLineError::print(verbose, 49 "%s (" SIZE_FORMAT ") must be " 50 "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n", 51 name, value, PLAB::min_size()); 52 return Flag::VIOLATES_CONSTRAINT; 53 } 54 #endif // INCLUDE_ALL_GCS 55 return Flag::SUCCESS; 56 } 57 58 static Flag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) { 59 #if INCLUDE_ALL_GCS 60 if ((UseConcMarkSweepGC || UseG1GC) && (value > PLAB::max_size())) { 61 CommandLineError::print(verbose, 62 "%s (" SIZE_FORMAT ") must be " 63 "less than ergonomic PLAB maximum size (" SIZE_FORMAT ")\n", 64 name, value, PLAB::min_size()); 65 return Flag::VIOLATES_CONSTRAINT; 66 } 67 #endif // INCLUDE_ALL_GCS 68 return Flag::SUCCESS; 69 } 70 71 static Flag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool verbose) { 72 if (MinPLABSizeBounds(name, value, verbose) == Flag::SUCCESS) { 73 return MaxPLABSizeBounds(name, value, verbose); 74 } 75 return Flag::VIOLATES_CONSTRAINT; 76 } 77 78 Flag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) { 79 return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose); 80 } 81 82 Flag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) { 83 if (value > MaxHeapFreeRatio) { 84 CommandLineError::print(verbose, 85 "MinHeapFreeRatio (" UINTX_FORMAT ") must be " 86 "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n", 87 value, MaxHeapFreeRatio); 88 return Flag::VIOLATES_CONSTRAINT; 89 } else { 90 return Flag::SUCCESS; 91 } 92 } 93 94 Flag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) { 95 if (value < MinHeapFreeRatio) { 96 CommandLineError::print(verbose, 97 "MaxHeapFreeRatio (" UINTX_FORMAT ") must be " 98 "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n", 99 value, MinHeapFreeRatio); 100 return Flag::VIOLATES_CONSTRAINT; 101 } else { 102 return Flag::SUCCESS; 103 } 104 } 105 106 Flag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { 107 if (value > MaxMetaspaceFreeRatio) { 108 CommandLineError::print(verbose, 109 "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be " 110 "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n", 111 value, MaxMetaspaceFreeRatio); 112 return Flag::VIOLATES_CONSTRAINT; 113 } else { 114 return Flag::SUCCESS; 115 } 116 } 117 118 Flag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { 119 if (value < MinMetaspaceFreeRatio) { 120 CommandLineError::print(verbose, 121 "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be " 122 "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n", 123 value, MinMetaspaceFreeRatio); 124 return Flag::VIOLATES_CONSTRAINT; 125 } else { 126 return Flag::SUCCESS; 127 } 128 } 129 130 // GC workaround for "-XX:+UseConcMarkSweepGC" 131 // which sets InitialTenuringThreshold to 7 but leaves MaxTenuringThreshold remaining at 6 132 // and therefore would invalidate the constraint 133 #define UseConcMarkSweepGCWorkaroundIfNeeded(initial, max) { \ 134 if ((initial == 7) && (max == 6)) { \ 135 return Flag::SUCCESS; \ 136 } \ 137 } 138 139 Flag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) { 140 UseConcMarkSweepGCWorkaroundIfNeeded(value, MaxTenuringThreshold); 141 142 if (value > MaxTenuringThreshold) { 143 CommandLineError::print(verbose, 144 "InitialTenuringThreshold (" UINTX_FORMAT ") must be " 145 "less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n", 146 value, MaxTenuringThreshold); 147 return Flag::VIOLATES_CONSTRAINT; 148 } else { 149 return Flag::SUCCESS; 150 } 151 } 152 153 Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) { 154 UseConcMarkSweepGCWorkaroundIfNeeded(InitialTenuringThreshold, value); 155 156 if (value < InitialTenuringThreshold) { 157 CommandLineError::print(verbose, 158 "MaxTenuringThreshold (" UINTX_FORMAT ") must be " 159 "greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n", 160 value, InitialTenuringThreshold); 161 return Flag::VIOLATES_CONSTRAINT; 162 } else { 163 return Flag::SUCCESS; 164 } 165 } 166 167 #if INCLUDE_ALL_GCS 168 Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) { 169 if (value > G1MaxNewSizePercent) { 170 CommandLineError::print(verbose, 171 "G1NewSizePercent (" UINTX_FORMAT ") must be " 172 "less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n", 173 value, G1MaxNewSizePercent); 174 return Flag::VIOLATES_CONSTRAINT; 175 } else { 176 return Flag::SUCCESS; 177 } 178 } 179 180 Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) { 181 if (value < G1NewSizePercent) { 182 CommandLineError::print(verbose, 183 "G1MaxNewSizePercent (" UINTX_FORMAT ") must be " 184 "greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n", 185 value, G1NewSizePercent); 186 return Flag::VIOLATES_CONSTRAINT; 187 } else { 188 return Flag::SUCCESS; 189 } 190 } 191 192 #endif // INCLUDE_ALL_GCS 193 194 Flag::Error CMSOldPLABMinConstraintFunc(size_t value, bool verbose) { 195 if (value > CMSOldPLABMax) { 196 CommandLineError::print(verbose, 197 "CMSOldPLABMin (" SIZE_FORMAT ") must be " 198 "less than or equal to CMSOldPLABMax (" SIZE_FORMAT ")\n", 199 value, CMSOldPLABMax); 200 return Flag::VIOLATES_CONSTRAINT; 201 } else { 202 return Flag::SUCCESS; 203 } 204 } 205 206 Flag::Error CMSPrecleanDenominatorConstraintFunc(uintx value, bool verbose) { 207 if (value <= CMSPrecleanNumerator) { 208 CommandLineError::print(verbose, 209 "CMSPrecleanDenominator (" UINTX_FORMAT ") must be " 210 "strickly greater than CMSPrecleanNumerator (" UINTX_FORMAT ")\n", 211 value, CMSPrecleanNumerator); 212 return Flag::VIOLATES_CONSTRAINT; 213 } else { 214 return Flag::SUCCESS; 215 } 216 } 217 218 Flag::Error CMSPrecleanNumeratorConstraintFunc(uintx value, bool verbose) { 219 if (value > (CMSPrecleanDenominator - 1)) { 220 CommandLineError::print(verbose, 221 "CMSPrecleanNumerator (" UINTX_FORMAT ") must be " 222 "less than or equal to CMSPrecleanDenominator - 1 (" UINTX_FORMAT ")\n", 223 value, CMSPrecleanDenominator - 1); 224 return Flag::VIOLATES_CONSTRAINT; 225 } else { 226 return Flag::SUCCESS; 227 } 228 } 229 230 Flag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) { 231 if (value != 0) { 232 if (!is_power_of_2(value)) { 233 CommandLineError::print(verbose, 234 "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " 235 "power of 2\n", 236 value); 237 return Flag::VIOLATES_CONSTRAINT; 238 } 239 if (value < ObjectAlignmentInBytes) { 240 CommandLineError::print(verbose, 241 "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " 242 "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n", 243 value, ObjectAlignmentInBytes); 244 return Flag::VIOLATES_CONSTRAINT; 245 } 246 } 247 return Flag::SUCCESS; 248 } |