1 /* 2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact 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 "code/relocInfo.hpp" 27 #include "compiler/compilerDefinitions.hpp" 28 #include "oops/metadata.hpp" 29 #include "runtime/os.hpp" 30 #include "interpreter/invocationCounter.hpp" 31 #include "runtime/arguments.hpp" 32 #include "runtime/commandLineFlagConstraintsCompiler.hpp" 33 #include "runtime/commandLineFlagRangeList.hpp" 34 #include "runtime/globals.hpp" 35 #include "runtime/globals_extension.hpp" 36 #include "utilities/defaultStream.hpp" 37 38 Flag::Error AliasLevelConstraintFunc(intx value, bool verbose) { 39 if ((value <= 1) && (Arguments::mode() == Arguments::_comp || Arguments::mode() == Arguments::_mixed)) { 40 CommandLineError::print(verbose, 41 "AliasLevel (" INTX_FORMAT ") is not " 42 "compatible with -Xcomp or -Xmixed\n", 43 value); 44 return Flag::VIOLATES_CONSTRAINT; 45 } else { 46 return Flag::SUCCESS; 47 } 48 } 49 50 /** 51 * Validate the minimum number of compiler threads needed to run the 52 * JVM. The following configurations are possible. 53 * 54 * 1) The JVM is build using an interpreter only. As a result, the minimum number of 55 * compiler threads is 0. 56 * 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As 57 * a result, either C1 or C2 is used, so the minimum number of compiler threads is 1. 58 * 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However, 59 * the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only 60 * C1 can be used, so the minimum number of compiler threads is 1. 61 * 4) The JVM is build using the compilers and tiered compilation is enabled. The option 62 * 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result, 63 * the minimum number of compiler threads is 2. 64 */ 65 Flag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { 66 int min_number_of_compiler_threads = 0; 67 #if !defined(COMPILER1) && !defined(COMPILER2) && !INCLUDE_JVMCI 68 // case 1 69 #else 70 if (!TieredCompilation || (TieredStopAtLevel < CompLevel_full_optimization)) { 71 min_number_of_compiler_threads = 1; // case 2 or case 3 72 } else { 73 min_number_of_compiler_threads = 2; // case 4 (tiered) 74 } 75 #endif 76 77 // The default CICompilerCount's value is CI_COMPILER_COUNT. 78 // With a client VM, -XX:+TieredCompilation causes TieredCompilation 79 // to be true here (the option is validated later) and 80 // min_number_of_compiler_threads to exceed CI_COMPILER_COUNT. 81 min_number_of_compiler_threads = MIN2(min_number_of_compiler_threads, CI_COMPILER_COUNT); 82 83 if (value < (intx)min_number_of_compiler_threads) { 84 CommandLineError::print(verbose, 85 "CICompilerCount (" INTX_FORMAT ") must be " 86 "at least %d \n", 87 value, min_number_of_compiler_threads); 88 return Flag::VIOLATES_CONSTRAINT; 89 } else { 90 return Flag::SUCCESS; 91 } 92 } 93 94 Flag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) { 95 if (value < 0 || value > 512) { 96 CommandLineError::print(verbose, 97 "AllocatePrefetchDistance (" INTX_FORMAT ") must be " 98 "between 0 and " INTX_FORMAT "\n", 99 AllocatePrefetchDistance, 512); 100 return Flag::VIOLATES_CONSTRAINT; 101 } 102 103 return Flag::SUCCESS; 104 } 105 106 Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { 107 if (AllocatePrefetchStyle == 3) { 108 if (value % wordSize != 0) { 109 CommandLineError::print(verbose, 110 "AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n", 111 value, wordSize); 112 return Flag::VIOLATES_CONSTRAINT; 113 } 114 } 115 return Flag::SUCCESS; 116 } 117 118 Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { 119 intx max_value = max_intx; 120 #if defined(SPARC) 121 max_value = 1; 122 #elif defined(X86) 123 max_value = 3; 124 #endif 125 if (value < 0 || value > max_value) { 126 CommandLineError::print(verbose, 127 "AllocatePrefetchInstr (" INTX_FORMAT ") must be " 128 "between 0 and " INTX_FORMAT "\n", value, max_value); 129 return Flag::VIOLATES_CONSTRAINT; 130 } 131 132 return Flag::SUCCESS; 133 } 134 135 Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { 136 if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) { 137 CommandLineError::print(verbose, 138 "CompileThreshold (" INTX_FORMAT ") " 139 "must be between 0 and %d\n", 140 value, 141 INT_MAX >> InvocationCounter::count_shift); 142 return Flag::VIOLATES_CONSTRAINT; 143 } 144 145 return Flag::SUCCESS; 146 } 147 148 Flag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) { 149 int backward_branch_limit; 150 if (ProfileInterpreter) { 151 if (OnStackReplacePercentage < InterpreterProfilePercentage) { 152 CommandLineError::print(verbose, 153 "OnStackReplacePercentage (" INTX_FORMAT ") must be " 154 "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", 155 OnStackReplacePercentage, InterpreterProfilePercentage); 156 return Flag::VIOLATES_CONSTRAINT; 157 } 158 159 backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100) 160 << InvocationCounter::count_shift; 161 162 if (backward_branch_limit < 0) { 163 CommandLineError::print(verbose, 164 "CompileThreshold * (InterpreterProfilePercentage - OnStackReplacePercentage) / 100 = " 165 INTX_FORMAT " " 166 "must be between 0 and " INTX_FORMAT ", try changing " 167 "CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n", 168 (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100, 169 INT_MAX >> InvocationCounter::count_shift); 170 return Flag::VIOLATES_CONSTRAINT; 171 } 172 } else { 173 if (OnStackReplacePercentage < 0 ) { 174 CommandLineError::print(verbose, 175 "OnStackReplacePercentage (" INTX_FORMAT ") must be " 176 "non-negative\n", OnStackReplacePercentage); 177 return Flag::VIOLATES_CONSTRAINT; 178 } 179 180 backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100) 181 << InvocationCounter::count_shift; 182 183 if (backward_branch_limit < 0) { 184 CommandLineError::print(verbose, 185 "CompileThreshold * OnStackReplacePercentage / 100 = " INTX_FORMAT " " 186 "must be between 0 and " INTX_FORMAT ", try changing " 187 "CompileThreshold and/or OnStackReplacePercentage\n", 188 (CompileThreshold * OnStackReplacePercentage) / 100, 189 INT_MAX >> InvocationCounter::count_shift); 190 return Flag::VIOLATES_CONSTRAINT; 191 } 192 } 193 return Flag::SUCCESS; 194 } 195 196 Flag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) { 197 if (CodeCacheSegmentSize < (uintx)CodeEntryAlignment) { 198 CommandLineError::print(verbose, 199 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 200 "larger than or equal to CodeEntryAlignment (" INTX_FORMAT ") " 201 "to align entry points\n", 202 CodeCacheSegmentSize, CodeEntryAlignment); 203 return Flag::VIOLATES_CONSTRAINT; 204 } 205 206 if (CodeCacheSegmentSize < sizeof(jdouble)) { 207 CommandLineError::print(verbose, 208 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 209 "at least " SIZE_FORMAT " to align constants\n", 210 CodeCacheSegmentSize, sizeof(jdouble)); 211 return Flag::VIOLATES_CONSTRAINT; 212 } 213 214 #ifdef COMPILER2 215 if (CodeCacheSegmentSize < (uintx)OptoLoopAlignment) { 216 CommandLineError::print(verbose, 217 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 218 "larger than or equal to OptoLoopAlignment (" INTX_FORMAT ") " 219 "to align inner loops\n", 220 CodeCacheSegmentSize, OptoLoopAlignment); 221 return Flag::VIOLATES_CONSTRAINT; 222 } 223 #endif 224 225 return Flag::SUCCESS; 226 } 227 228 Flag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) { 229 #ifdef SOLARIS 230 if ((value < MinimumPriority || value > MaximumPriority) && 231 (value != -1) && (value != -FXCriticalPriority)) { 232 CommandLineError::print(verbose, 233 "CompileThreadPriority (" INTX_FORMAT ") must be " 234 "between %d and %d inclusively or -1 (means no change) " 235 "or %d (special value for critical thread class/priority)\n", 236 value, MinimumPriority, MaximumPriority, -FXCriticalPriority); 237 return Flag::VIOLATES_CONSTRAINT; 238 } 239 #endif 240 241 return Flag::SUCCESS; 242 } 243 244 Flag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) { 245 #ifdef SPARC 246 if (CodeEntryAlignment % relocInfo::addr_unit() != 0) { 247 CommandLineError::print(verbose, 248 "CodeEntryAlignment (" INTX_FORMAT ") must be " 249 "multiple of NOP size\n", CodeEntryAlignment); 250 return Flag::VIOLATES_CONSTRAINT; 251 } 252 #endif 253 254 if (!is_power_of_2(value)) { 255 CommandLineError::print(verbose, 256 "CodeEntryAlignment (" INTX_FORMAT ") must be " 257 "a power of two\n", CodeEntryAlignment); 258 return Flag::VIOLATES_CONSTRAINT; 259 } 260 261 if (CodeEntryAlignment < 16) { 262 CommandLineError::print(verbose, 263 "CodeEntryAlignment (" INTX_FORMAT ") must be " 264 "greater than or equal to %d\n", 265 CodeEntryAlignment, 16); 266 return Flag::VIOLATES_CONSTRAINT; 267 } 268 269 return Flag::SUCCESS; 270 } 271 272 Flag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) { 273 if (!is_power_of_2(value)) { 274 CommandLineError::print(verbose, 275 "OptoLoopAlignment (" INTX_FORMAT ") " 276 "must be a power of two\n", 277 value); 278 return Flag::VIOLATES_CONSTRAINT; 279 } 280 281 // Relevant on ppc, s390, sparc. Will be optimized where 282 // addr_unit() == 1. 283 if (OptoLoopAlignment % relocInfo::addr_unit() != 0) { 284 CommandLineError::print(verbose, 285 "OptoLoopAlignment (" INTX_FORMAT ") must be " 286 "multiple of NOP size (%d)\n", 287 value, relocInfo::addr_unit()); 288 return Flag::VIOLATES_CONSTRAINT; 289 } 290 291 return Flag::SUCCESS; 292 } 293 294 Flag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose) { 295 if (value >= 4032) { 296 CommandLineError::print(verbose, 297 "ArraycopyDstPrefetchDistance (" UINTX_FORMAT ") must be" 298 "between 0 and 4031\n", value); 299 return Flag::VIOLATES_CONSTRAINT; 300 } 301 302 return Flag::SUCCESS; 303 } 304 305 Flag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) { 306 if (value >= 4032) { 307 CommandLineError::print(verbose, 308 "ArraycopySrcPrefetchDistance (" UINTX_FORMAT ") must be" 309 "between 0 and 4031\n", value); 310 return Flag::VIOLATES_CONSTRAINT; 311 } 312 313 return Flag::SUCCESS; 314 } 315 316 Flag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) { 317 for (int i = 0; i < 3; i++) { 318 if (value % 10 > 2) { 319 CommandLineError::print(verbose, 320 "Invalid value (" UINTX_FORMAT ") " 321 "in TypeProfileLevel at position %d\n", value, i); 322 return Flag::VIOLATES_CONSTRAINT; 323 } 324 value = value / 10; 325 } 326 327 return Flag::SUCCESS; 328 } 329 330 Flag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) { 331 if (value % BytesPerLong != 0) { 332 return Flag::VIOLATES_CONSTRAINT; 333 } else { 334 return Flag::SUCCESS; 335 } 336 } 337 338 #ifdef COMPILER2 339 Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { 340 if (InteriorEntryAlignment > CodeEntryAlignment) { 341 CommandLineError::print(verbose, 342 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 343 "less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n", 344 InteriorEntryAlignment, CodeEntryAlignment); 345 return Flag::VIOLATES_CONSTRAINT; 346 } 347 348 #ifdef SPARC 349 if (InteriorEntryAlignment % relocInfo::addr_unit() != 0) { 350 CommandLineError::print(verbose, 351 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 352 "multiple of NOP size\n"); 353 return Flag::VIOLATES_CONSTRAINT; 354 } 355 #endif 356 357 if (!is_power_of_2(value)) { 358 CommandLineError::print(verbose, 359 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 360 "a power of two\n", InteriorEntryAlignment); 361 return Flag::VIOLATES_CONSTRAINT; 362 } 363 364 int minimum_alignment = 16; 365 #if defined(SPARC) || (defined(X86) && !defined(AMD64)) 366 minimum_alignment = 4; 367 #elif defined(S390) 368 minimum_alignment = 2; 369 #endif 370 371 if (InteriorEntryAlignment < minimum_alignment) { 372 CommandLineError::print(verbose, 373 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 374 "greater than or equal to %d\n", 375 InteriorEntryAlignment, minimum_alignment); 376 return Flag::VIOLATES_CONSTRAINT; 377 } 378 379 return Flag::SUCCESS; 380 } 381 382 Flag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose) { 383 if (value < MaxNodeLimit * 2 / 100 || value > MaxNodeLimit * 40 / 100) { 384 CommandLineError::print(verbose, 385 "NodeLimitFudgeFactor must be between 2%% and 40%% " 386 "of MaxNodeLimit (" INTX_FORMAT ")\n", 387 MaxNodeLimit); 388 return Flag::VIOLATES_CONSTRAINT; 389 } 390 391 return Flag::SUCCESS; 392 } 393 #endif // COMPILER2 394 395 Flag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) { 396 #if INCLUDE_RTM_OPT 397 if (UseRTMLocking && !is_power_of_2(RTMTotalCountIncrRate)) { 398 CommandLineError::print(verbose, 399 "RTMTotalCountIncrRate (" INTX_FORMAT 400 ") must be a power of 2, resetting it to 64\n", 401 RTMTotalCountIncrRate); 402 FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64); 403 } 404 #endif 405 406 return Flag::SUCCESS; 407 } | 1 /* 2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact 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 "code/relocInfo.hpp" 27 #include "compiler/compilerDefinitions.hpp" 28 #include "oops/metadata.hpp" 29 #include "runtime/globals_extension.hpp" 30 #include "runtime/os.hpp" 31 #include "interpreter/invocationCounter.hpp" 32 #include "runtime/arguments.hpp" 33 #include "runtime/jvmFlagConstraintsCompiler.hpp" 34 #include "runtime/jvmFlagRangeList.hpp" 35 #include "utilities/defaultStream.hpp" 36 #ifdef COMPILER2 37 #include "opto/c2_globals.hpp" 38 #endif 39 40 JVMFlag::Error AliasLevelConstraintFunc(intx value, bool verbose) { 41 if ((value <= 1) && (Arguments::mode() == Arguments::_comp || Arguments::mode() == Arguments::_mixed)) { 42 CommandLineError::print(verbose, 43 "AliasLevel (" INTX_FORMAT ") is not " 44 "compatible with -Xcomp or -Xmixed\n", 45 value); 46 return JVMFlag::VIOLATES_CONSTRAINT; 47 } else { 48 return JVMFlag::SUCCESS; 49 } 50 } 51 52 /** 53 * Validate the minimum number of compiler threads needed to run the 54 * JVM. The following configurations are possible. 55 * 56 * 1) The JVM is build using an interpreter only. As a result, the minimum number of 57 * compiler threads is 0. 58 * 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As 59 * a result, either C1 or C2 is used, so the minimum number of compiler threads is 1. 60 * 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However, 61 * the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only 62 * C1 can be used, so the minimum number of compiler threads is 1. 63 * 4) The JVM is build using the compilers and tiered compilation is enabled. The option 64 * 'TieredStopAtLevel = CompLevel_full_optimization' (the default value). As a result, 65 * the minimum number of compiler threads is 2. 66 */ 67 JVMFlag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { 68 int min_number_of_compiler_threads = 0; 69 #if !defined(COMPILER1) && !defined(COMPILER2) && !INCLUDE_JVMCI 70 // case 1 71 #else 72 if (!TieredCompilation || (TieredStopAtLevel < CompLevel_full_optimization)) { 73 min_number_of_compiler_threads = 1; // case 2 or case 3 74 } else { 75 min_number_of_compiler_threads = 2; // case 4 (tiered) 76 } 77 #endif 78 79 // The default CICompilerCount's value is CI_COMPILER_COUNT. 80 // With a client VM, -XX:+TieredCompilation causes TieredCompilation 81 // to be true here (the option is validated later) and 82 // min_number_of_compiler_threads to exceed CI_COMPILER_COUNT. 83 min_number_of_compiler_threads = MIN2(min_number_of_compiler_threads, CI_COMPILER_COUNT); 84 85 if (value < (intx)min_number_of_compiler_threads) { 86 CommandLineError::print(verbose, 87 "CICompilerCount (" INTX_FORMAT ") must be " 88 "at least %d \n", 89 value, min_number_of_compiler_threads); 90 return JVMFlag::VIOLATES_CONSTRAINT; 91 } else { 92 return JVMFlag::SUCCESS; 93 } 94 } 95 96 JVMFlag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) { 97 if (value < 0 || value > 512) { 98 CommandLineError::print(verbose, 99 "AllocatePrefetchDistance (" INTX_FORMAT ") must be " 100 "between 0 and " INTX_FORMAT "\n", 101 AllocatePrefetchDistance, 512); 102 return JVMFlag::VIOLATES_CONSTRAINT; 103 } 104 105 return JVMFlag::SUCCESS; 106 } 107 108 JVMFlag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { 109 if (AllocatePrefetchStyle == 3) { 110 if (value % wordSize != 0) { 111 CommandLineError::print(verbose, 112 "AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n", 113 value, wordSize); 114 return JVMFlag::VIOLATES_CONSTRAINT; 115 } 116 } 117 return JVMFlag::SUCCESS; 118 } 119 120 JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { 121 intx max_value = max_intx; 122 #if defined(SPARC) 123 max_value = 1; 124 #elif defined(X86) 125 max_value = 3; 126 #endif 127 if (value < 0 || value > max_value) { 128 CommandLineError::print(verbose, 129 "AllocatePrefetchInstr (" INTX_FORMAT ") must be " 130 "between 0 and " INTX_FORMAT "\n", value, max_value); 131 return JVMFlag::VIOLATES_CONSTRAINT; 132 } 133 134 return JVMFlag::SUCCESS; 135 } 136 137 JVMFlag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { 138 if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) { 139 CommandLineError::print(verbose, 140 "CompileThreshold (" INTX_FORMAT ") " 141 "must be between 0 and %d\n", 142 value, 143 INT_MAX >> InvocationCounter::count_shift); 144 return JVMFlag::VIOLATES_CONSTRAINT; 145 } 146 147 return JVMFlag::SUCCESS; 148 } 149 150 JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) { 151 int backward_branch_limit; 152 if (ProfileInterpreter) { 153 if (OnStackReplacePercentage < InterpreterProfilePercentage) { 154 CommandLineError::print(verbose, 155 "OnStackReplacePercentage (" INTX_FORMAT ") must be " 156 "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", 157 OnStackReplacePercentage, InterpreterProfilePercentage); 158 return JVMFlag::VIOLATES_CONSTRAINT; 159 } 160 161 backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100) 162 << InvocationCounter::count_shift; 163 164 if (backward_branch_limit < 0) { 165 CommandLineError::print(verbose, 166 "CompileThreshold * (InterpreterProfilePercentage - OnStackReplacePercentage) / 100 = " 167 INTX_FORMAT " " 168 "must be between 0 and " INTX_FORMAT ", try changing " 169 "CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n", 170 (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100, 171 INT_MAX >> InvocationCounter::count_shift); 172 return JVMFlag::VIOLATES_CONSTRAINT; 173 } 174 } else { 175 if (OnStackReplacePercentage < 0 ) { 176 CommandLineError::print(verbose, 177 "OnStackReplacePercentage (" INTX_FORMAT ") must be " 178 "non-negative\n", OnStackReplacePercentage); 179 return JVMFlag::VIOLATES_CONSTRAINT; 180 } 181 182 backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100) 183 << InvocationCounter::count_shift; 184 185 if (backward_branch_limit < 0) { 186 CommandLineError::print(verbose, 187 "CompileThreshold * OnStackReplacePercentage / 100 = " INTX_FORMAT " " 188 "must be between 0 and " INTX_FORMAT ", try changing " 189 "CompileThreshold and/or OnStackReplacePercentage\n", 190 (CompileThreshold * OnStackReplacePercentage) / 100, 191 INT_MAX >> InvocationCounter::count_shift); 192 return JVMFlag::VIOLATES_CONSTRAINT; 193 } 194 } 195 return JVMFlag::SUCCESS; 196 } 197 198 JVMFlag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) { 199 if (CodeCacheSegmentSize < (uintx)CodeEntryAlignment) { 200 CommandLineError::print(verbose, 201 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 202 "larger than or equal to CodeEntryAlignment (" INTX_FORMAT ") " 203 "to align entry points\n", 204 CodeCacheSegmentSize, CodeEntryAlignment); 205 return JVMFlag::VIOLATES_CONSTRAINT; 206 } 207 208 if (CodeCacheSegmentSize < sizeof(jdouble)) { 209 CommandLineError::print(verbose, 210 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 211 "at least " SIZE_FORMAT " to align constants\n", 212 CodeCacheSegmentSize, sizeof(jdouble)); 213 return JVMFlag::VIOLATES_CONSTRAINT; 214 } 215 216 #ifdef COMPILER2 217 if (CodeCacheSegmentSize < (uintx)OptoLoopAlignment) { 218 CommandLineError::print(verbose, 219 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 220 "larger than or equal to OptoLoopAlignment (" INTX_FORMAT ") " 221 "to align inner loops\n", 222 CodeCacheSegmentSize, OptoLoopAlignment); 223 return JVMFlag::VIOLATES_CONSTRAINT; 224 } 225 #endif 226 227 return JVMFlag::SUCCESS; 228 } 229 230 JVMFlag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) { 231 #ifdef SOLARIS 232 if ((value < MinimumPriority || value > MaximumPriority) && 233 (value != -1) && (value != -FXCriticalPriority)) { 234 CommandLineError::print(verbose, 235 "CompileThreadPriority (" INTX_FORMAT ") must be " 236 "between %d and %d inclusively or -1 (means no change) " 237 "or %d (special value for critical thread class/priority)\n", 238 value, MinimumPriority, MaximumPriority, -FXCriticalPriority); 239 return JVMFlag::VIOLATES_CONSTRAINT; 240 } 241 #endif 242 243 return JVMFlag::SUCCESS; 244 } 245 246 JVMFlag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) { 247 #ifdef SPARC 248 if (CodeEntryAlignment % relocInfo::addr_unit() != 0) { 249 CommandLineError::print(verbose, 250 "CodeEntryAlignment (" INTX_FORMAT ") must be " 251 "multiple of NOP size\n", CodeEntryAlignment); 252 return JVMFlag::VIOLATES_CONSTRAINT; 253 } 254 #endif 255 256 if (!is_power_of_2(value)) { 257 CommandLineError::print(verbose, 258 "CodeEntryAlignment (" INTX_FORMAT ") must be " 259 "a power of two\n", CodeEntryAlignment); 260 return JVMFlag::VIOLATES_CONSTRAINT; 261 } 262 263 if (CodeEntryAlignment < 16) { 264 CommandLineError::print(verbose, 265 "CodeEntryAlignment (" INTX_FORMAT ") must be " 266 "greater than or equal to %d\n", 267 CodeEntryAlignment, 16); 268 return JVMFlag::VIOLATES_CONSTRAINT; 269 } 270 271 return JVMFlag::SUCCESS; 272 } 273 274 JVMFlag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) { 275 if (!is_power_of_2(value)) { 276 CommandLineError::print(verbose, 277 "OptoLoopAlignment (" INTX_FORMAT ") " 278 "must be a power of two\n", 279 value); 280 return JVMFlag::VIOLATES_CONSTRAINT; 281 } 282 283 // Relevant on ppc, s390, sparc. Will be optimized where 284 // addr_unit() == 1. 285 if (OptoLoopAlignment % relocInfo::addr_unit() != 0) { 286 CommandLineError::print(verbose, 287 "OptoLoopAlignment (" INTX_FORMAT ") must be " 288 "multiple of NOP size (%d)\n", 289 value, relocInfo::addr_unit()); 290 return JVMFlag::VIOLATES_CONSTRAINT; 291 } 292 293 return JVMFlag::SUCCESS; 294 } 295 296 JVMFlag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose) { 297 if (value >= 4032) { 298 CommandLineError::print(verbose, 299 "ArraycopyDstPrefetchDistance (" UINTX_FORMAT ") must be" 300 "between 0 and 4031\n", value); 301 return JVMFlag::VIOLATES_CONSTRAINT; 302 } 303 304 return JVMFlag::SUCCESS; 305 } 306 307 JVMFlag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) { 308 if (value >= 4032) { 309 CommandLineError::print(verbose, 310 "ArraycopySrcPrefetchDistance (" UINTX_FORMAT ") must be" 311 "between 0 and 4031\n", value); 312 return JVMFlag::VIOLATES_CONSTRAINT; 313 } 314 315 return JVMFlag::SUCCESS; 316 } 317 318 JVMFlag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) { 319 for (int i = 0; i < 3; i++) { 320 if (value % 10 > 2) { 321 CommandLineError::print(verbose, 322 "Invalid value (" UINTX_FORMAT ") " 323 "in TypeProfileLevel at position %d\n", value, i); 324 return JVMFlag::VIOLATES_CONSTRAINT; 325 } 326 value = value / 10; 327 } 328 329 return JVMFlag::SUCCESS; 330 } 331 332 JVMFlag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) { 333 if (value % BytesPerLong != 0) { 334 return JVMFlag::VIOLATES_CONSTRAINT; 335 } else { 336 return JVMFlag::SUCCESS; 337 } 338 } 339 340 #ifdef COMPILER2 341 JVMFlag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { 342 if (InteriorEntryAlignment > CodeEntryAlignment) { 343 CommandLineError::print(verbose, 344 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 345 "less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n", 346 InteriorEntryAlignment, CodeEntryAlignment); 347 return JVMFlag::VIOLATES_CONSTRAINT; 348 } 349 350 #ifdef SPARC 351 if (InteriorEntryAlignment % relocInfo::addr_unit() != 0) { 352 CommandLineError::print(verbose, 353 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 354 "multiple of NOP size\n"); 355 return JVMFlag::VIOLATES_CONSTRAINT; 356 } 357 #endif 358 359 if (!is_power_of_2(value)) { 360 CommandLineError::print(verbose, 361 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 362 "a power of two\n", InteriorEntryAlignment); 363 return JVMFlag::VIOLATES_CONSTRAINT; 364 } 365 366 int minimum_alignment = 16; 367 #if defined(SPARC) || (defined(X86) && !defined(AMD64)) 368 minimum_alignment = 4; 369 #elif defined(S390) 370 minimum_alignment = 2; 371 #endif 372 373 if (InteriorEntryAlignment < minimum_alignment) { 374 CommandLineError::print(verbose, 375 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 376 "greater than or equal to %d\n", 377 InteriorEntryAlignment, minimum_alignment); 378 return JVMFlag::VIOLATES_CONSTRAINT; 379 } 380 381 return JVMFlag::SUCCESS; 382 } 383 384 JVMFlag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose) { 385 if (value < MaxNodeLimit * 2 / 100 || value > MaxNodeLimit * 40 / 100) { 386 CommandLineError::print(verbose, 387 "NodeLimitFudgeFactor must be between 2%% and 40%% " 388 "of MaxNodeLimit (" INTX_FORMAT ")\n", 389 MaxNodeLimit); 390 return JVMFlag::VIOLATES_CONSTRAINT; 391 } 392 393 return JVMFlag::SUCCESS; 394 } 395 #endif // COMPILER2 396 397 JVMFlag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) { 398 #if INCLUDE_RTM_OPT 399 if (UseRTMLocking && !is_power_of_2(RTMTotalCountIncrRate)) { 400 CommandLineError::print(verbose, 401 "RTMTotalCountIncrRate (" INTX_FORMAT 402 ") must be a power of 2, resetting it to 64\n", 403 RTMTotalCountIncrRate); 404 FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64); 405 } 406 #endif 407 408 return JVMFlag::SUCCESS; 409 } |