112 PathString *Arguments::_system_boot_class_path = NULL; |
112 PathString *Arguments::_system_boot_class_path = NULL; |
113 bool Arguments::_has_jimage = false; |
113 bool Arguments::_has_jimage = false; |
114 |
114 |
115 char* Arguments::_ext_dirs = NULL; |
115 char* Arguments::_ext_dirs = NULL; |
116 |
116 |
|
117 bool PathString::set_value(const char *value) { |
|
118 if (_value != NULL) { |
|
119 FreeHeap(_value); |
|
120 } |
|
121 _value = AllocateHeap(strlen(value)+1, mtArguments); |
|
122 assert(_value != NULL, "Unable to allocate space for new path value"); |
|
123 if (_value != NULL) { |
|
124 strcpy(_value, value); |
|
125 } else { |
|
126 // not able to allocate |
|
127 return false; |
|
128 } |
|
129 return true; |
|
130 } |
|
131 |
|
132 void PathString::append_value(const char *value) { |
|
133 char *sp; |
|
134 size_t len = 0; |
|
135 if (value != NULL) { |
|
136 len = strlen(value); |
|
137 if (_value != NULL) { |
|
138 len += strlen(_value); |
|
139 } |
|
140 sp = AllocateHeap(len+2, mtArguments); |
|
141 assert(sp != NULL, "Unable to allocate space for new append path value"); |
|
142 if (sp != NULL) { |
|
143 if (_value != NULL) { |
|
144 strcpy(sp, _value); |
|
145 strcat(sp, os::path_separator()); |
|
146 strcat(sp, value); |
|
147 FreeHeap(_value); |
|
148 } else { |
|
149 strcpy(sp, value); |
|
150 } |
|
151 _value = sp; |
|
152 } |
|
153 } |
|
154 } |
|
155 |
|
156 PathString::PathString(const char* value) { |
|
157 if (value == NULL) { |
|
158 _value = NULL; |
|
159 } else { |
|
160 _value = AllocateHeap(strlen(value)+1, mtArguments); |
|
161 strcpy(_value, value); |
|
162 } |
|
163 } |
|
164 |
|
165 PathString::~PathString() { |
|
166 if (_value != NULL) { |
|
167 FreeHeap(_value); |
|
168 _value = NULL; |
|
169 } |
|
170 } |
|
171 |
|
172 ModulePatchPath::ModulePatchPath(const char* module_name, const char* path) { |
|
173 assert(module_name != NULL && path != NULL, "Invalid module name or path value"); |
|
174 size_t len = strlen(module_name) + 1; |
|
175 _module_name = AllocateHeap(len, mtInternal); |
|
176 strncpy(_module_name, module_name, len); // copy the trailing null |
|
177 _path = new PathString(path); |
|
178 } |
|
179 |
|
180 ModulePatchPath::~ModulePatchPath() { |
|
181 if (_module_name != NULL) { |
|
182 FreeHeap(_module_name); |
|
183 _module_name = NULL; |
|
184 } |
|
185 if (_path != NULL) { |
|
186 delete _path; |
|
187 _path = NULL; |
|
188 } |
|
189 } |
|
190 |
|
191 SystemProperty::SystemProperty(const char* key, const char* value, bool writeable, bool internal) : PathString(value) { |
|
192 if (key == NULL) { |
|
193 _key = NULL; |
|
194 } else { |
|
195 _key = AllocateHeap(strlen(key)+1, mtArguments); |
|
196 strcpy(_key, key); |
|
197 } |
|
198 _next = NULL; |
|
199 _internal = internal; |
|
200 _writeable = writeable; |
|
201 } |
|
202 |
|
203 AgentLibrary::AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) { |
|
204 _name = AllocateHeap(strlen(name)+1, mtArguments); |
|
205 strcpy(_name, name); |
|
206 if (options == NULL) { |
|
207 _options = NULL; |
|
208 } else { |
|
209 _options = AllocateHeap(strlen(options)+1, mtArguments); |
|
210 strcpy(_options, options); |
|
211 } |
|
212 _is_absolute_path = is_absolute_path; |
|
213 _os_lib = os_lib; |
|
214 _next = NULL; |
|
215 _state = agent_invalid; |
|
216 _is_static_lib = false; |
|
217 } |
|
218 |
117 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining |
219 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining |
118 // part of the option string. |
220 // part of the option string. |
119 static bool match_option(const JavaVMOption *option, const char* name, |
221 static bool match_option(const JavaVMOption *option, const char* name, |
120 const char** tail) { |
222 const char** tail) { |
121 size_t len = strlen(name); |
223 size_t len = strlen(name); |
177 #define LIMITMODS_LEN 9 |
279 #define LIMITMODS_LEN 9 |
178 #define PATH "path" |
280 #define PATH "path" |
179 #define PATH_LEN 4 |
281 #define PATH_LEN 4 |
180 #define UPGRADE_PATH "upgrade.path" |
282 #define UPGRADE_PATH "upgrade.path" |
181 #define UPGRADE_PATH_LEN 12 |
283 #define UPGRADE_PATH_LEN 12 |
|
284 |
|
285 void Arguments::add_init_library(const char* name, char* options) { |
|
286 _libraryList.add(new AgentLibrary(name, options, false, NULL)); |
|
287 } |
|
288 |
|
289 void Arguments::add_init_agent(const char* name, char* options, bool absolute_path) { |
|
290 _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); |
|
291 } |
|
292 |
|
293 // Late-binding agents not started via arguments |
|
294 void Arguments::add_loaded_agent(AgentLibrary *agentLib) { |
|
295 _agentList.add(agentLib); |
|
296 } |
|
297 |
|
298 void Arguments::add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib) { |
|
299 _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); |
|
300 } |
182 |
301 |
183 // Return TRUE if option matches 'property', or 'property=', or 'property.'. |
302 // Return TRUE if option matches 'property', or 'property=', or 'property.'. |
184 static bool matches_property_suffix(const char* option, const char* property, size_t len) { |
303 static bool matches_property_suffix(const char* option, const char* property, size_t len) { |
185 return ((strncmp(option, property, len) == 0) && |
304 return ((strncmp(option, property, len) == 0) && |
186 (option[len] == '=' || option[len] == '.' || option[len] == '\0')); |
305 (option[len] == '=' || option[len] == '.' || option[len] == '\0')); |
2151 #endif |
2270 #endif |
2152 |
2271 |
2153 // Check lower bounds of the code cache |
2272 // Check lower bounds of the code cache |
2154 // Template Interpreter code is approximately 3X larger in debug builds. |
2273 // Template Interpreter code is approximately 3X larger in debug builds. |
2155 uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); |
2274 uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); |
2156 if (InitialCodeCacheSize < (uintx)os::vm_page_size()) { |
2275 if (ReservedCodeCacheSize < InitialCodeCacheSize) { |
2157 jio_fprintf(defaultStream::error_stream(), |
|
2158 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K, |
|
2159 os::vm_page_size()/K); |
|
2160 status = false; |
|
2161 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) { |
|
2162 jio_fprintf(defaultStream::error_stream(), |
2276 jio_fprintf(defaultStream::error_stream(), |
2163 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n", |
2277 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n", |
2164 ReservedCodeCacheSize/K, InitialCodeCacheSize/K); |
2278 ReservedCodeCacheSize/K, InitialCodeCacheSize/K); |
2165 status = false; |
2279 status = false; |
2166 } else if (ReservedCodeCacheSize < min_code_cache_size) { |
2280 } else if (ReservedCodeCacheSize < min_code_cache_size) { |
2211 if (!FLAG_IS_DEFAULT(PostLoopMultiversioning)) { |
2325 if (!FLAG_IS_DEFAULT(PostLoopMultiversioning)) { |
2212 warning("PostLoopMultiversioning disabled because RangeCheckElimination is disabled."); |
2326 warning("PostLoopMultiversioning disabled because RangeCheckElimination is disabled."); |
2213 } |
2327 } |
2214 FLAG_SET_CMDLINE(bool, PostLoopMultiversioning, false); |
2328 FLAG_SET_CMDLINE(bool, PostLoopMultiversioning, false); |
2215 } |
2329 } |
|
2330 if (UseCountedLoopSafepoints && LoopStripMiningIter == 0) { |
|
2331 if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) { |
|
2332 warning("When counted loop safepoints are enabled, LoopStripMiningIter must be at least 1 (a safepoint every 1 iteration): setting it to 1"); |
|
2333 } |
|
2334 LoopStripMiningIter = 1; |
|
2335 } else if (!UseCountedLoopSafepoints && LoopStripMiningIter > 0) { |
|
2336 if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) { |
|
2337 warning("Disabling counted safepoints implies no loop strip mining: setting LoopStripMiningIter to 0"); |
|
2338 } |
|
2339 LoopStripMiningIter = 0; |
|
2340 } |
|
2341 if (FLAG_IS_DEFAULT(LoopStripMiningIterShortLoop)) { |
|
2342 // blind guess |
|
2343 LoopStripMiningIterShortLoop = LoopStripMiningIter / 10; |
|
2344 } |
2216 #endif |
2345 #endif |
|
2346 if (!FLAG_IS_DEFAULT(AllocateHeapAt)) { |
|
2347 if ((UseNUMAInterleaving && !FLAG_IS_DEFAULT(UseNUMAInterleaving)) || (UseNUMA && !FLAG_IS_DEFAULT(UseNUMA))) { |
|
2348 log_warning(arguments) ("NUMA support for Heap depends on the file system when AllocateHeapAt option is used.\n"); |
|
2349 } |
|
2350 } |
2217 return status; |
2351 return status; |
2218 } |
2352 } |
2219 |
2353 |
2220 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore, |
2354 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore, |
2221 const char* option_type) { |
2355 const char* option_type) { |
2769 return err; |
2903 return err; |
2770 } |
2904 } |
2771 if (FLAG_SET_CMDLINE(intx, ThreadStackSize, value) != Flag::SUCCESS) { |
2905 if (FLAG_SET_CMDLINE(intx, ThreadStackSize, value) != Flag::SUCCESS) { |
2772 return JNI_EINVAL; |
2906 return JNI_EINVAL; |
2773 } |
2907 } |
2774 } else if (match_option(option, "-XX:CodeCacheExpansionSize=", &tail)) { |
|
2775 julong long_CodeCacheExpansionSize = 0; |
|
2776 ArgsRange errcode = parse_memory_size(tail, &long_CodeCacheExpansionSize, os::vm_page_size()); |
|
2777 if (errcode != arg_in_range) { |
|
2778 jio_fprintf(defaultStream::error_stream(), |
|
2779 "Invalid argument: %s. Must be at least %luK.\n", option->optionString, |
|
2780 os::vm_page_size()/K); |
|
2781 return JNI_EINVAL; |
|
2782 } |
|
2783 if (FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize) != Flag::SUCCESS) { |
|
2784 return JNI_EINVAL; |
|
2785 } |
|
2786 } else if (match_option(option, "-Xmaxjitcodesize", &tail) || |
2908 } else if (match_option(option, "-Xmaxjitcodesize", &tail) || |
2787 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { |
2909 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) { |
2788 julong long_ReservedCodeCacheSize = 0; |
2910 julong long_ReservedCodeCacheSize = 0; |
2789 |
2911 |
2790 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1); |
2912 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1); |
2792 jio_fprintf(defaultStream::error_stream(), |
2914 jio_fprintf(defaultStream::error_stream(), |
2793 "Invalid maximum code cache size: %s.\n", option->optionString); |
2915 "Invalid maximum code cache size: %s.\n", option->optionString); |
2794 return JNI_EINVAL; |
2916 return JNI_EINVAL; |
2795 } |
2917 } |
2796 if (FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize) != Flag::SUCCESS) { |
2918 if (FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize) != Flag::SUCCESS) { |
2797 return JNI_EINVAL; |
|
2798 } |
|
2799 // -XX:NonNMethodCodeHeapSize= |
|
2800 } else if (match_option(option, "-XX:NonNMethodCodeHeapSize=", &tail)) { |
|
2801 julong long_NonNMethodCodeHeapSize = 0; |
|
2802 |
|
2803 ArgsRange errcode = parse_memory_size(tail, &long_NonNMethodCodeHeapSize, 1); |
|
2804 if (errcode != arg_in_range) { |
|
2805 jio_fprintf(defaultStream::error_stream(), |
|
2806 "Invalid maximum non-nmethod code heap size: %s.\n", option->optionString); |
|
2807 return JNI_EINVAL; |
|
2808 } |
|
2809 if (FLAG_SET_CMDLINE(uintx, NonNMethodCodeHeapSize, (uintx)long_NonNMethodCodeHeapSize) != Flag::SUCCESS) { |
|
2810 return JNI_EINVAL; |
|
2811 } |
|
2812 // -XX:ProfiledCodeHeapSize= |
|
2813 } else if (match_option(option, "-XX:ProfiledCodeHeapSize=", &tail)) { |
|
2814 julong long_ProfiledCodeHeapSize = 0; |
|
2815 |
|
2816 ArgsRange errcode = parse_memory_size(tail, &long_ProfiledCodeHeapSize, 1); |
|
2817 if (errcode != arg_in_range) { |
|
2818 jio_fprintf(defaultStream::error_stream(), |
|
2819 "Invalid maximum profiled code heap size: %s.\n", option->optionString); |
|
2820 return JNI_EINVAL; |
|
2821 } |
|
2822 if (FLAG_SET_CMDLINE(uintx, ProfiledCodeHeapSize, (uintx)long_ProfiledCodeHeapSize) != Flag::SUCCESS) { |
|
2823 return JNI_EINVAL; |
|
2824 } |
|
2825 // -XX:NonProfiledCodeHeapSizee= |
|
2826 } else if (match_option(option, "-XX:NonProfiledCodeHeapSize=", &tail)) { |
|
2827 julong long_NonProfiledCodeHeapSize = 0; |
|
2828 |
|
2829 ArgsRange errcode = parse_memory_size(tail, &long_NonProfiledCodeHeapSize, 1); |
|
2830 if (errcode != arg_in_range) { |
|
2831 jio_fprintf(defaultStream::error_stream(), |
|
2832 "Invalid maximum non-profiled code heap size: %s.\n", option->optionString); |
|
2833 return JNI_EINVAL; |
|
2834 } |
|
2835 if (FLAG_SET_CMDLINE(uintx, NonProfiledCodeHeapSize, (uintx)long_NonProfiledCodeHeapSize) != Flag::SUCCESS) { |
|
2836 return JNI_EINVAL; |
2919 return JNI_EINVAL; |
2837 } |
2920 } |
2838 // -green |
2921 // -green |
2839 } else if (match_option(option, "-green")) { |
2922 } else if (match_option(option, "-green")) { |
2840 jio_fprintf(defaultStream::error_stream(), |
2923 jio_fprintf(defaultStream::error_stream(), |
4305 if (!UseBiasedLocking || EmitSync != 0) { |
4396 if (!UseBiasedLocking || EmitSync != 0) { |
4306 UseOptoBiasInlining = false; |
4397 UseOptoBiasInlining = false; |
4307 } |
4398 } |
4308 #endif |
4399 #endif |
4309 |
4400 |
4310 bool aot_enabled = UseAOT && AOTLibrary != NULL; |
|
4311 bool jvmci_enabled = NOT_JVMCI(false) JVMCI_ONLY(EnableJVMCI || UseJVMCICompiler); |
|
4312 bool handshakes_supported = SafepointMechanism::supports_thread_local_poll() && !aot_enabled && !jvmci_enabled && ThreadLocalHandshakes; |
|
4313 // ThreadLocalHandshakesConstraintFunc handles the constraints. |
4401 // ThreadLocalHandshakesConstraintFunc handles the constraints. |
4314 // Here we try to figure out if a mutual exclusive option have been set that conflict with a default. |
|
4315 if (handshakes_supported) { |
|
4316 FLAG_SET_DEFAULT(UseAOT, false); // Clear the AOT flag to make sure it doesn't try to initialize. |
|
4317 } else { |
|
4318 if (FLAG_IS_DEFAULT(ThreadLocalHandshakes) && ThreadLocalHandshakes) { |
|
4319 if (aot_enabled) { |
|
4320 // If user enabled AOT but ThreadLocalHandshakes is at default set it to false. |
|
4321 log_debug(ergo)("Disabling ThreadLocalHandshakes for UseAOT."); |
|
4322 FLAG_SET_DEFAULT(ThreadLocalHandshakes, false); |
|
4323 } else if (jvmci_enabled){ |
|
4324 // If user enabled JVMCI but ThreadLocalHandshakes is at default set it to false. |
|
4325 log_debug(ergo)("Disabling ThreadLocalHandshakes for EnableJVMCI/UseJVMCICompiler."); |
|
4326 FLAG_SET_DEFAULT(ThreadLocalHandshakes, false); |
|
4327 } |
|
4328 } |
|
4329 } |
|
4330 if (FLAG_IS_DEFAULT(ThreadLocalHandshakes) || !SafepointMechanism::supports_thread_local_poll()) { |
4402 if (FLAG_IS_DEFAULT(ThreadLocalHandshakes) || !SafepointMechanism::supports_thread_local_poll()) { |
4331 log_debug(ergo)("ThreadLocalHandshakes %s", ThreadLocalHandshakes ? "enabled." : "disabled."); |
4403 log_debug(ergo)("ThreadLocalHandshakes %s", ThreadLocalHandshakes ? "enabled." : "disabled."); |
4332 } else { |
4404 } else { |
4333 log_info(ergo)("ThreadLocalHandshakes %s", ThreadLocalHandshakes ? "enabled." : "disabled."); |
4405 log_info(ergo)("ThreadLocalHandshakes %s", ThreadLocalHandshakes ? "enabled." : "disabled."); |
4334 } |
4406 } |
4336 return JNI_OK; |
4408 return JNI_OK; |
4337 } |
4409 } |
4338 |
4410 |
4339 jint Arguments::adjust_after_os() { |
4411 jint Arguments::adjust_after_os() { |
4340 if (UseNUMA) { |
4412 if (UseNUMA) { |
4341 if (UseParallelGC || UseParallelOldGC) { |
4413 if (!FLAG_IS_DEFAULT(AllocateHeapAt)) { |
|
4414 FLAG_SET_ERGO(bool, UseNUMA, false); |
|
4415 } else if (UseParallelGC || UseParallelOldGC) { |
4342 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) { |
4416 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) { |
4343 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M); |
4417 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M); |
4344 } |
4418 } |
4345 } |
4419 } |
4346 // UseNUMAInterleaving is set to ON for all collectors and |
4420 // UseNUMAInterleaving is set to ON for all collectors and |