1135 } 1136 #endif 1137 1138 void Arguments::set_tiered_flags() { 1139 // With tiered, set default policy to AdvancedThresholdPolicy, which is 3. 1140 if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) { 1141 FLAG_SET_DEFAULT(CompilationPolicyChoice, 3); 1142 } 1143 if (CompilationPolicyChoice < 2) { 1144 vm_exit_during_initialization( 1145 "Incompatible compilation policy selected", NULL); 1146 } 1147 // Increase the code cache size - tiered compiles a lot more. 1148 if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) { 1149 FLAG_SET_ERGO(uintx, ReservedCodeCacheSize, ReservedCodeCacheSize * 5); 1150 } 1151 // Enable SegmentedCodeCache if TieredCompilation is enabled and ReservedCodeCacheSize >= 240M 1152 if (FLAG_IS_DEFAULT(SegmentedCodeCache) && ReservedCodeCacheSize >= 240*M) { 1153 FLAG_SET_ERGO(bool, SegmentedCodeCache, true); 1154 1155 // Multiply sizes by 5 but fix NonMethodCodeHeapSize (distribute among non-profiled and profiled code heap) 1156 if (FLAG_IS_DEFAULT(ProfiledCodeHeapSize)) { 1157 FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, ProfiledCodeHeapSize * 5 + NonMethodCodeHeapSize * 2); 1158 } 1159 if (FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) { 1160 FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, NonProfiledCodeHeapSize * 5 + NonMethodCodeHeapSize * 2); 1161 } 1162 // Check consistency of code heap sizes 1163 if ((NonMethodCodeHeapSize + NonProfiledCodeHeapSize + ProfiledCodeHeapSize) != ReservedCodeCacheSize) { 1164 jio_fprintf(defaultStream::error_stream(), 1165 "Invalid code heap sizes: NonMethodCodeHeapSize(%dK) + ProfiledCodeHeapSize(%dK) + NonProfiledCodeHeapSize(%dK) = %dK. Must be equal to ReservedCodeCacheSize = %uK.\n", 1166 NonMethodCodeHeapSize/K, ProfiledCodeHeapSize/K, NonProfiledCodeHeapSize/K, 1167 (NonMethodCodeHeapSize + ProfiledCodeHeapSize + NonProfiledCodeHeapSize)/K, ReservedCodeCacheSize/K); 1168 vm_exit(1); 1169 } 1170 } 1171 if (!UseInterpreter) { // -Xcomp 1172 Tier3InvokeNotifyFreqLog = 0; 1173 Tier4InvocationThreshold = 0; 1174 } 1175 } 1176 1177 /** 1178 * Returns the minimum number of compiler threads needed to run the JVM. The following 1179 * configurations are possible. 1180 * 1181 * 1) The JVM is build using an interpreter only. As a result, the minimum number of 1182 * compiler threads is 0. 1183 * 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As 1184 * a result, either C1 or C2 is used, so the minimum number of compiler threads is 1. 1185 * 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However, 1186 * the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only 1187 * C1 can be used, so the minimum number of compiler threads is 1. 2485 jio_fprintf(defaultStream::error_stream(), 2486 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K, 2487 os::vm_page_size()/K); 2488 status = false; 2489 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) { 2490 jio_fprintf(defaultStream::error_stream(), 2491 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n", 2492 ReservedCodeCacheSize/K, InitialCodeCacheSize/K); 2493 status = false; 2494 } else if (ReservedCodeCacheSize < min_code_cache_size) { 2495 jio_fprintf(defaultStream::error_stream(), 2496 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K, 2497 min_code_cache_size/K); 2498 status = false; 2499 } else if (ReservedCodeCacheSize > 2*G) { 2500 // Code cache size larger than MAXINT is not supported. 2501 jio_fprintf(defaultStream::error_stream(), 2502 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M, 2503 (2*G)/M); 2504 status = false; 2505 } else if (NonMethodCodeHeapSize < min_code_cache_size){ 2506 jio_fprintf(defaultStream::error_stream(), 2507 "Invalid NonMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonMethodCodeHeapSize/K, 2508 min_code_cache_size/K); 2509 status = false; 2510 } else if ((!FLAG_IS_DEFAULT(NonMethodCodeHeapSize) || !FLAG_IS_DEFAULT(ProfiledCodeHeapSize) || !FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) 2511 && (NonMethodCodeHeapSize + NonProfiledCodeHeapSize + ProfiledCodeHeapSize) != ReservedCodeCacheSize) { 2512 jio_fprintf(defaultStream::error_stream(), 2513 "Invalid code heap sizes: NonMethodCodeHeapSize(%dK) + ProfiledCodeHeapSize(%dK) + NonProfiledCodeHeapSize(%dK) = %dK. Must be equal to ReservedCodeCacheSize = %uK.\n", 2514 NonMethodCodeHeapSize/K, ProfiledCodeHeapSize/K, NonProfiledCodeHeapSize/K, 2515 (NonMethodCodeHeapSize + ProfiledCodeHeapSize + NonProfiledCodeHeapSize)/K, ReservedCodeCacheSize/K); 2516 status = false; 2517 } 2518 2519 status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction"); 2520 status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity"); 2521 status &= verify_interval(CodeCacheMinBlockLength, 1, 100, "CodeCacheMinBlockLength"); 2522 status &= verify_interval(CodeCacheSegmentSize, 1, 1024, "CodeCacheSegmentSize"); 2523 2524 int min_number_of_compiler_threads = get_min_number_of_compiler_threads(); 2525 // The default CICompilerCount's value is CI_COMPILER_COUNT. 2526 assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number"); 2527 // Check the minimum number of compiler threads 2528 status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount"); 2529 2530 if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) { 2531 warning("The VM option CICompilerCountPerCPU overrides CICompilerCount."); 2532 } 2533 2534 return status; 2535 } 2921 julong long_CodeCacheExpansionSize = 0; 2922 ArgsRange errcode = parse_memory_size(tail, &long_CodeCacheExpansionSize, os::vm_page_size()); 2923 if (errcode != arg_in_range) { 2924 jio_fprintf(defaultStream::error_stream(), 2925 "Invalid argument: %s. Must be at least %luK.\n", option->optionString, 2926 os::vm_page_size()/K); 2927 return JNI_EINVAL; 2928 } 2929 FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize); 2930 } else if (match_option(option, "-Xmaxjitcodesize", &tail) || 2931 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { 2932 julong long_ReservedCodeCacheSize = 0; 2933 2934 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1); 2935 if (errcode != arg_in_range) { 2936 jio_fprintf(defaultStream::error_stream(), 2937 "Invalid maximum code cache size: %s.\n", option->optionString); 2938 return JNI_EINVAL; 2939 } 2940 FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize); 2941 // -XX:NonMethodCodeHeapSize= 2942 } else if (match_option(option, "-XX:NonMethodCodeHeapSize=", &tail)) { 2943 julong long_NonMethodCodeHeapSize = 0; 2944 2945 ArgsRange errcode = parse_memory_size(tail, &long_NonMethodCodeHeapSize, 1); 2946 if (errcode != arg_in_range) { 2947 jio_fprintf(defaultStream::error_stream(), 2948 "Invalid maximum non-method code heap size: %s.\n", option->optionString); 2949 return JNI_EINVAL; 2950 } 2951 FLAG_SET_CMDLINE(uintx, NonMethodCodeHeapSize, (uintx)long_NonMethodCodeHeapSize); 2952 // -XX:ProfiledCodeHeapSize= 2953 } else if (match_option(option, "-XX:ProfiledCodeHeapSize=", &tail)) { 2954 julong long_ProfiledCodeHeapSize = 0; 2955 2956 ArgsRange errcode = parse_memory_size(tail, &long_ProfiledCodeHeapSize, 1); 2957 if (errcode != arg_in_range) { 2958 jio_fprintf(defaultStream::error_stream(), 2959 "Invalid maximum profiled code heap size: %s.\n", option->optionString); 2960 return JNI_EINVAL; 2961 } 2962 FLAG_SET_CMDLINE(uintx, ProfiledCodeHeapSize, (uintx)long_ProfiledCodeHeapSize); 2963 // -XX:NonProfiledCodeHeapSizee= 2964 } else if (match_option(option, "-XX:NonProfiledCodeHeapSize=", &tail)) { 2965 julong long_NonProfiledCodeHeapSize = 0; 2966 2967 ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1); 2968 if (errcode != arg_in_range) { 2969 jio_fprintf(defaultStream::error_stream(), 2970 "Invalid maximum non-profiled code heap size: %s.\n", option->optionString); 2971 return JNI_EINVAL; | 1135 } 1136 #endif 1137 1138 void Arguments::set_tiered_flags() { 1139 // With tiered, set default policy to AdvancedThresholdPolicy, which is 3. 1140 if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) { 1141 FLAG_SET_DEFAULT(CompilationPolicyChoice, 3); 1142 } 1143 if (CompilationPolicyChoice < 2) { 1144 vm_exit_during_initialization( 1145 "Incompatible compilation policy selected", NULL); 1146 } 1147 // Increase the code cache size - tiered compiles a lot more. 1148 if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) { 1149 FLAG_SET_ERGO(uintx, ReservedCodeCacheSize, ReservedCodeCacheSize * 5); 1150 } 1151 // Enable SegmentedCodeCache if TieredCompilation is enabled and ReservedCodeCacheSize >= 240M 1152 if (FLAG_IS_DEFAULT(SegmentedCodeCache) && ReservedCodeCacheSize >= 240*M) { 1153 FLAG_SET_ERGO(bool, SegmentedCodeCache, true); 1154 1155 // Multiply sizes by 5 but fix NonNMethodCodeHeapSize (distribute among non-profiled and profiled code heap) 1156 if (FLAG_IS_DEFAULT(ProfiledCodeHeapSize)) { 1157 FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, ProfiledCodeHeapSize * 5 + NonNMethodCodeHeapSize * 2); 1158 } 1159 if (FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) { 1160 FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, NonProfiledCodeHeapSize * 5 + NonNMethodCodeHeapSize * 2); 1161 } 1162 // Check consistency of code heap sizes 1163 if ((NonNMethodCodeHeapSize + NonProfiledCodeHeapSize + ProfiledCodeHeapSize) != ReservedCodeCacheSize) { 1164 jio_fprintf(defaultStream::error_stream(), 1165 "Invalid code heap sizes: NonNMethodCodeHeapSize(%dK) + ProfiledCodeHeapSize(%dK) + NonProfiledCodeHeapSize(%dK) = %dK. Must be equal to ReservedCodeCacheSize = %uK.\n", 1166 NonNMethodCodeHeapSize/K, ProfiledCodeHeapSize/K, NonProfiledCodeHeapSize/K, 1167 (NonNMethodCodeHeapSize + ProfiledCodeHeapSize + NonProfiledCodeHeapSize)/K, ReservedCodeCacheSize/K); 1168 vm_exit(1); 1169 } 1170 } 1171 if (!UseInterpreter) { // -Xcomp 1172 Tier3InvokeNotifyFreqLog = 0; 1173 Tier4InvocationThreshold = 0; 1174 } 1175 } 1176 1177 /** 1178 * Returns the minimum number of compiler threads needed to run the JVM. The following 1179 * configurations are possible. 1180 * 1181 * 1) The JVM is build using an interpreter only. As a result, the minimum number of 1182 * compiler threads is 0. 1183 * 2) The JVM is build using the compiler(s) and tiered compilation is disabled. As 1184 * a result, either C1 or C2 is used, so the minimum number of compiler threads is 1. 1185 * 3) The JVM is build using the compiler(s) and tiered compilation is enabled. However, 1186 * the option "TieredStopAtLevel < CompLevel_full_optimization". As a result, only 1187 * C1 can be used, so the minimum number of compiler threads is 1. 2485 jio_fprintf(defaultStream::error_stream(), 2486 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K, 2487 os::vm_page_size()/K); 2488 status = false; 2489 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) { 2490 jio_fprintf(defaultStream::error_stream(), 2491 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n", 2492 ReservedCodeCacheSize/K, InitialCodeCacheSize/K); 2493 status = false; 2494 } else if (ReservedCodeCacheSize < min_code_cache_size) { 2495 jio_fprintf(defaultStream::error_stream(), 2496 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K, 2497 min_code_cache_size/K); 2498 status = false; 2499 } else if (ReservedCodeCacheSize > 2*G) { 2500 // Code cache size larger than MAXINT is not supported. 2501 jio_fprintf(defaultStream::error_stream(), 2502 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M, 2503 (2*G)/M); 2504 status = false; 2505 } else if (NonNMethodCodeHeapSize < min_code_cache_size){ 2506 jio_fprintf(defaultStream::error_stream(), 2507 "Invalid NonNMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonNMethodCodeHeapSize/K, 2508 min_code_cache_size/K); 2509 status = false; 2510 } else if ((!FLAG_IS_DEFAULT(NonNMethodCodeHeapSize) || !FLAG_IS_DEFAULT(ProfiledCodeHeapSize) || !FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) 2511 && (NonNMethodCodeHeapSize + NonProfiledCodeHeapSize + ProfiledCodeHeapSize) != ReservedCodeCacheSize) { 2512 jio_fprintf(defaultStream::error_stream(), 2513 "Invalid code heap sizes: NonNMethodCodeHeapSize(%dK) + ProfiledCodeHeapSize(%dK) + NonProfiledCodeHeapSize(%dK) = %dK. Must be equal to ReservedCodeCacheSize = %uK.\n", 2514 NonNMethodCodeHeapSize/K, ProfiledCodeHeapSize/K, NonProfiledCodeHeapSize/K, 2515 (NonNMethodCodeHeapSize + ProfiledCodeHeapSize + NonProfiledCodeHeapSize)/K, ReservedCodeCacheSize/K); 2516 status = false; 2517 } 2518 2519 status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction"); 2520 status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity"); 2521 status &= verify_interval(CodeCacheMinBlockLength, 1, 100, "CodeCacheMinBlockLength"); 2522 status &= verify_interval(CodeCacheSegmentSize, 1, 1024, "CodeCacheSegmentSize"); 2523 2524 int min_number_of_compiler_threads = get_min_number_of_compiler_threads(); 2525 // The default CICompilerCount's value is CI_COMPILER_COUNT. 2526 assert(min_number_of_compiler_threads <= CI_COMPILER_COUNT, "minimum should be less or equal default number"); 2527 // Check the minimum number of compiler threads 2528 status &=verify_min_value(CICompilerCount, min_number_of_compiler_threads, "CICompilerCount"); 2529 2530 if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) { 2531 warning("The VM option CICompilerCountPerCPU overrides CICompilerCount."); 2532 } 2533 2534 return status; 2535 } 2921 julong long_CodeCacheExpansionSize = 0; 2922 ArgsRange errcode = parse_memory_size(tail, &long_CodeCacheExpansionSize, os::vm_page_size()); 2923 if (errcode != arg_in_range) { 2924 jio_fprintf(defaultStream::error_stream(), 2925 "Invalid argument: %s. Must be at least %luK.\n", option->optionString, 2926 os::vm_page_size()/K); 2927 return JNI_EINVAL; 2928 } 2929 FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize); 2930 } else if (match_option(option, "-Xmaxjitcodesize", &tail) || 2931 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { 2932 julong long_ReservedCodeCacheSize = 0; 2933 2934 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1); 2935 if (errcode != arg_in_range) { 2936 jio_fprintf(defaultStream::error_stream(), 2937 "Invalid maximum code cache size: %s.\n", option->optionString); 2938 return JNI_EINVAL; 2939 } 2940 FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize); 2941 // -XX:NonNMethodCodeHeapSize= 2942 } else if (match_option(option, "-XX:NonNMethodCodeHeapSize=", &tail)) { 2943 julong long_NonNMethodCodeHeapSize = 0; 2944 2945 ArgsRange errcode = parse_memory_size(tail, &long_NonNMethodCodeHeapSize, 1); 2946 if (errcode != arg_in_range) { 2947 jio_fprintf(defaultStream::error_stream(), 2948 "Invalid maximum non-nmethod code heap size: %s.\n", option->optionString); 2949 return JNI_EINVAL; 2950 } 2951 FLAG_SET_CMDLINE(uintx, NonNMethodCodeHeapSize, (uintx)long_NonNMethodCodeHeapSize); 2952 // -XX:ProfiledCodeHeapSize= 2953 } else if (match_option(option, "-XX:ProfiledCodeHeapSize=", &tail)) { 2954 julong long_ProfiledCodeHeapSize = 0; 2955 2956 ArgsRange errcode = parse_memory_size(tail, &long_ProfiledCodeHeapSize, 1); 2957 if (errcode != arg_in_range) { 2958 jio_fprintf(defaultStream::error_stream(), 2959 "Invalid maximum profiled code heap size: %s.\n", option->optionString); 2960 return JNI_EINVAL; 2961 } 2962 FLAG_SET_CMDLINE(uintx, ProfiledCodeHeapSize, (uintx)long_ProfiledCodeHeapSize); 2963 // -XX:NonProfiledCodeHeapSizee= 2964 } else if (match_option(option, "-XX:NonProfiledCodeHeapSize=", &tail)) { 2965 julong long_NonProfiledCodeHeapSize = 0; 2966 2967 ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1); 2968 if (errcode != arg_in_range) { 2969 jio_fprintf(defaultStream::error_stream(), 2970 "Invalid maximum non-profiled code heap size: %s.\n", option->optionString); 2971 return JNI_EINVAL; |