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 "runtime/arguments.hpp" 27 #include "runtime/commandLineFlagConstraintsCompiler.hpp" 28 #include "runtime/commandLineFlagRangeList.hpp" 29 #include "runtime/globals.hpp" 30 #include "utilities/defaultStream.hpp" 31 32 Flag::Error AliasLevelConstraintFunc(intx value, bool verbose) { 33 if ((value <= 1) && (Arguments::mode() == Arguments::_comp)) { 34 CommandLineError::print(verbose, 35 "AliasLevel (" INTX_FORMAT ") is not " 36 "compatible with -Xcomp \n", 37 value); 38 return Flag::VIOLATES_CONSTRAINT; 39 } else { 40 return Flag::SUCCESS; 41 } 42 } 43 44 /** 45 * Validate the minimum number of compiler threads needed to run the 67 min_number_of_compiler_threads = 2; // case 4 (tiered) 68 } 69 #endif 70 71 // The default CICompilerCount's value is CI_COMPILER_COUNT. 72 // With a client VM, -XX:+TieredCompilation causes TieredCompilation 73 // to be true here (the option is validated later) and 74 // min_number_of_compiler_threads to exceed CI_COMPILER_COUNT. 75 min_number_of_compiler_threads = MIN2(min_number_of_compiler_threads, CI_COMPILER_COUNT); 76 77 if (value < (intx)min_number_of_compiler_threads) { 78 CommandLineError::print(verbose, 79 "CICompilerCount (" INTX_FORMAT ") must be " 80 "at least %d \n", 81 value, min_number_of_compiler_threads); 82 return Flag::VIOLATES_CONSTRAINT; 83 } else { 84 return Flag::SUCCESS; 85 } 86 } | 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 "oops/metadata.hpp" 27 #include "runtime/os.hpp" 28 #include "code/relocInfo.hpp" 29 #include "interpreter/invocationCounter.hpp" 30 #include "runtime/arguments.hpp" 31 #include "runtime/commandLineFlagConstraintsCompiler.hpp" 32 #include "runtime/commandLineFlagRangeList.hpp" 33 #include "runtime/globals.hpp" 34 #include "utilities/defaultStream.hpp" 35 36 Flag::Error AliasLevelConstraintFunc(intx value, bool verbose) { 37 if ((value <= 1) && (Arguments::mode() == Arguments::_comp)) { 38 CommandLineError::print(verbose, 39 "AliasLevel (" INTX_FORMAT ") is not " 40 "compatible with -Xcomp \n", 41 value); 42 return Flag::VIOLATES_CONSTRAINT; 43 } else { 44 return Flag::SUCCESS; 45 } 46 } 47 48 /** 49 * Validate the minimum number of compiler threads needed to run the 71 min_number_of_compiler_threads = 2; // case 4 (tiered) 72 } 73 #endif 74 75 // The default CICompilerCount's value is CI_COMPILER_COUNT. 76 // With a client VM, -XX:+TieredCompilation causes TieredCompilation 77 // to be true here (the option is validated later) and 78 // min_number_of_compiler_threads to exceed CI_COMPILER_COUNT. 79 min_number_of_compiler_threads = MIN2(min_number_of_compiler_threads, CI_COMPILER_COUNT); 80 81 if (value < (intx)min_number_of_compiler_threads) { 82 CommandLineError::print(verbose, 83 "CICompilerCount (" INTX_FORMAT ") must be " 84 "at least %d \n", 85 value, min_number_of_compiler_threads); 86 return Flag::VIOLATES_CONSTRAINT; 87 } else { 88 return Flag::SUCCESS; 89 } 90 } 91 92 Flag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) { 93 if (value < 0) { 94 CommandLineError::print(verbose, 95 "Unable to determine system-specific value for AllocatePrefetchDistance. " 96 "Please provide appropriate value, if unsure, use 0 to disable prefetching\n"); 97 return Flag::VIOLATES_CONSTRAINT; 98 } 99 100 return Flag::SUCCESS; 101 } 102 103 Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { 104 intx max_value = max_intx; 105 #if defined(SPARC) 106 max_value = 1; 107 #elif defined(X86) 108 max_value = 3; 109 #endif 110 if (value < 0 || value > max_value) { 111 CommandLineError::print(verbose, 112 "AllocatePrefetchInstr (" INTX_FORMAT ") must be " 113 "between 0 and " INTX_FORMAT "\n", value, max_value); 114 return Flag::VIOLATES_CONSTRAINT; 115 } 116 117 return Flag::SUCCESS; 118 } 119 120 Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { 121 if (value < 0 || value > max_jint) { 122 CommandLineError::print(verbose, 123 "AllocatePrefetchStepSize (" INTX_FORMAT ") " 124 "must be between 0 and %d\n", 125 AllocatePrefetchStepSize, 126 max_jint); 127 return Flag::VIOLATES_CONSTRAINT; 128 } 129 130 if (AllocatePrefetchDistance % AllocatePrefetchStepSize != 0) { 131 CommandLineError::print(verbose, 132 "AllocatePrefetchDistance (" INTX_FORMAT ") " 133 "%% AllocatePrefetchStepSize (" INTX_FORMAT ") " 134 "= " INTX_FORMAT " " 135 "must be 0\n", 136 AllocatePrefetchDistance, AllocatePrefetchStepSize, 137 AllocatePrefetchDistance % AllocatePrefetchStepSize); 138 return Flag::VIOLATES_CONSTRAINT; 139 } 140 141 return Flag::SUCCESS; 142 } 143 144 Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { 145 if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) { 146 CommandLineError::print(verbose, 147 "CompileThreshold (" INTX_FORMAT ") " 148 "must be between 0 and %d\n", 149 value, 150 INT_MAX >> InvocationCounter::count_shift); 151 return Flag::VIOLATES_CONSTRAINT; 152 } 153 154 return Flag::SUCCESS; 155 } 156 157 Flag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) { 158 int backward_branch_limit; 159 if (ProfileInterpreter) { 160 if (OnStackReplacePercentage < InterpreterProfilePercentage) { 161 CommandLineError::print(verbose, 162 "OnStackReplacePercentage (" INTX_FORMAT ") must be " 163 "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", 164 OnStackReplacePercentage, InterpreterProfilePercentage); 165 return Flag::VIOLATES_CONSTRAINT; 166 } 167 168 backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100) 169 << InvocationCounter::count_shift; 170 171 if (backward_branch_limit < 0) { 172 CommandLineError::print(verbose, 173 "CompileThreshold * (InterpreterProfilePercentage - OnStackReplacePercentage) / 100 = " 174 INTX_FORMAT " " 175 "must be between 0 and " INTX_FORMAT ", try changing " 176 "CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n", 177 (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100, 178 INT_MAX >> InvocationCounter::count_shift); 179 return Flag::VIOLATES_CONSTRAINT; 180 } 181 } else { 182 if (OnStackReplacePercentage < 0 ) { 183 CommandLineError::print(verbose, 184 "OnStackReplacePercentage (" INTX_FORMAT ") must be " 185 "non-negative\n", OnStackReplacePercentage); 186 return Flag::VIOLATES_CONSTRAINT; 187 } 188 189 backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100) 190 << InvocationCounter::count_shift; 191 192 if (backward_branch_limit < 0) { 193 CommandLineError::print(verbose, 194 "CompileThreshold * OnStackReplacePercentage / 100 = " INTX_FORMAT " " 195 "must be between 0 and " INTX_FORMAT ", try changing " 196 "CompileThreshold and/or OnStackReplacePercentage\n", 197 (CompileThreshold * OnStackReplacePercentage) / 100, 198 INT_MAX >> InvocationCounter::count_shift); 199 return Flag::VIOLATES_CONSTRAINT; 200 } 201 } 202 return Flag::SUCCESS; 203 } 204 205 Flag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) { 206 if (CodeCacheSegmentSize < (uintx)CodeEntryAlignment) { 207 CommandLineError::print(verbose, 208 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 209 "larger than or equal to CodeEntryAlignment (" INTX_FORMAT ")" 210 "to align entry points\n", 211 CodeCacheSegmentSize, CodeEntryAlignment); 212 return Flag::VIOLATES_CONSTRAINT; 213 } 214 215 if (CodeCacheSegmentSize < sizeof(jdouble)) { 216 CommandLineError::print(verbose, 217 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 218 "at least " SIZE_FORMAT " to align constants\n", 219 CodeCacheSegmentSize, sizeof(jdouble)); 220 return Flag::VIOLATES_CONSTRAINT; 221 } 222 223 #ifdef COMPILER2 224 if (CodeCacheSegmentSize < (uintx)OptoLoopAlignment) { 225 CommandLineError::print(verbose, 226 "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " 227 "larger than or equal to OptoLoopAlignment (" INTX_FORMAT ")" 228 "to align inner loops\n", 229 CodeCacheSegmentSize, OptoLoopAlignment); 230 return Flag::VIOLATES_CONSTRAINT; 231 } 232 #endif 233 234 return Flag::SUCCESS; 235 } 236 237 Flag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) { 238 if (value < min_jint || value > max_jint) { 239 CommandLineError::print(verbose, 240 "CompileThreadPriority (" INTX_FORMAT ") " 241 "must be between %d and %d. " 242 "Please also make sure to specify values that are " 243 "meaningful to your operating system\n", 244 value, min_jint, max_jint); 245 return Flag::VIOLATES_CONSTRAINT; 246 } 247 248 return Flag::SUCCESS; 249 } 250 251 Flag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) { 252 #ifdef SPARC 253 if (CodeEntryAlignment % relocInfo::addr_unit() != 0) { 254 CommandLineError::print(verbose, 255 "CodeEntryAlignment (" INTX_FORMAT ") must be " 256 "multiple of NOP size\n", CodeEntryAlignment); 257 return Flag::VIOLATES_CONSTRAINT; 258 } 259 #endif 260 261 if (!is_power_of_2(value)) { 262 CommandLineError::print(verbose, 263 "CodeEntryAlignment (" INTX_FORMAT ") must be " 264 "a power of two\n", CodeEntryAlignment); 265 return Flag::VIOLATES_CONSTRAINT; 266 } 267 268 if (CodeEntryAlignment < 16) { 269 CommandLineError::print(verbose, 270 "CodeEntryAlignment (" INTX_FORMAT ") must be " 271 "greater than or equal to %d\n", 272 CodeEntryAlignment, 16); 273 return Flag::VIOLATES_CONSTRAINT; 274 } 275 276 return Flag::SUCCESS; 277 } 278 279 Flag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) { 280 if (value < 0 || value > 16) { 281 CommandLineError::print(verbose, 282 "OptoLoopAlignment (" INTX_FORMAT ") " 283 "must be between 0 and 16\n", 284 value); 285 return Flag::VIOLATES_CONSTRAINT; 286 } 287 288 if (!is_power_of_2(value)) { 289 CommandLineError::print(verbose, 290 "OptoLoopAlignment (" INTX_FORMAT ") " 291 "must be a power of two\n", 292 value); 293 return Flag::VIOLATES_CONSTRAINT; 294 } 295 296 #ifdef SPARC 297 if (OptoLoopAlignment % relocInfo::addr_unit() != 0) { 298 CommandLineError::print(verbose, 299 "OptoLoopAlignment (" INTX_FORMAT ") must be " 300 "multiple of NOP size\n"); 301 return Flag::VIOLATES_CONSTRAINT; 302 } 303 #endif 304 305 return Flag::SUCCESS; 306 } 307 308 Flag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose) { 309 if (value != 0) { 310 CommandLineError::print(verbose, 311 "ArraycopyDstPrefetchDistance (" INTX_FORMAT ") must be 0\n"); 312 return Flag::VIOLATES_CONSTRAINT; 313 } 314 315 return Flag::SUCCESS; 316 } 317 318 Flag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) { 319 if (value != 0) { 320 CommandLineError::print(verbose, 321 "ArraycopySrcPrefetchDistance (" INTX_FORMAT ") must be 0\n"); 322 return Flag::VIOLATES_CONSTRAINT; 323 } 324 325 return Flag::SUCCESS; 326 } 327 328 Flag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) { 329 for (int i = 0; i < 3; i++) { 330 if (value % 10 > 2) { 331 CommandLineError::print(verbose, 332 "Invalid value (" UINTX_FORMAT ") " 333 "in TypeProfileLevel at position %d\n", value, i); 334 return Flag::VIOLATES_CONSTRAINT; 335 } 336 value = value / 10; 337 } 338 339 return Flag::SUCCESS; 340 } 341 342 #ifdef COMPILER2 343 Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { 344 if (InteriorEntryAlignment > CodeEntryAlignment) { 345 CommandLineError::print(verbose, 346 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 347 "less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n", 348 InteriorEntryAlignment, CodeEntryAlignment); 349 return Flag::VIOLATES_CONSTRAINT; 350 } 351 352 #ifdef SPARC 353 if (InteriorEntryAlignment % relocInfo::addr_unit() != 0) { 354 CommandLineError::print(verbose, 355 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 356 "multiple of NOP size\n"); 357 return Flag::VIOLATES_CONSTRAINT; 358 } 359 #endif 360 361 if (!is_power_of_2(value)) { 362 CommandLineError::print(verbose, 363 "InteriorEntryAlignment (" INTX_FORMAT ") must be " 364 "a power of two\n", InteriorEntryAlignment); 365 return Flag::VIOLATES_CONSTRAINT; 366 } 367 368 int minimum_alignment = 16; 369 #if defined(SPARC) || (defined(X86) && !defined(AMD64)) 370 minimum_alignment = 4; 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 Flag::VIOLATES_CONSTRAINT; 379 } 380 381 return Flag::SUCCESS; 382 } 383 384 Flag::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 Flag::VIOLATES_CONSTRAINT; 391 } 392 393 return Flag::SUCCESS; 394 } 395 #endif // COMPILER2 |