Mercurial > hg > truffle
annotate src/share/vm/runtime/arguments.cpp @ 483:0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
Reviewed-by: jmasa
author | jcoomes |
---|---|
date | Thu, 11 Dec 2008 12:05:21 -0800 |
parents | 171e581e8161 |
children | 2494ab195856 |
rev | line source |
---|---|
0 | 1 /* |
196 | 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_arguments.cpp.incl" | |
27 | |
28 #define DEFAULT_VENDOR_URL_BUG "http://java.sun.com/webapps/bugreport/crash.jsp" | |
29 #define DEFAULT_JAVA_LAUNCHER "generic" | |
30 | |
31 char** Arguments::_jvm_flags_array = NULL; | |
32 int Arguments::_num_jvm_flags = 0; | |
33 char** Arguments::_jvm_args_array = NULL; | |
34 int Arguments::_num_jvm_args = 0; | |
35 char* Arguments::_java_command = NULL; | |
36 SystemProperty* Arguments::_system_properties = NULL; | |
37 const char* Arguments::_gc_log_filename = NULL; | |
38 bool Arguments::_has_profile = false; | |
39 bool Arguments::_has_alloc_profile = false; | |
40 uintx Arguments::_initial_heap_size = 0; | |
41 uintx Arguments::_min_heap_size = 0; | |
42 Arguments::Mode Arguments::_mode = _mixed; | |
43 bool Arguments::_java_compiler = false; | |
44 bool Arguments::_xdebug_mode = false; | |
45 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; | |
46 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER; | |
47 int Arguments::_sun_java_launcher_pid = -1; | |
48 | |
49 // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*) | |
50 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; | |
51 bool Arguments::_UseOnStackReplacement = UseOnStackReplacement; | |
52 bool Arguments::_BackgroundCompilation = BackgroundCompilation; | |
53 bool Arguments::_ClipInlining = ClipInlining; | |
54 intx Arguments::_Tier2CompileThreshold = Tier2CompileThreshold; | |
55 | |
56 char* Arguments::SharedArchivePath = NULL; | |
57 | |
58 AgentLibraryList Arguments::_libraryList; | |
59 AgentLibraryList Arguments::_agentList; | |
60 | |
61 abort_hook_t Arguments::_abort_hook = NULL; | |
62 exit_hook_t Arguments::_exit_hook = NULL; | |
63 vfprintf_hook_t Arguments::_vfprintf_hook = NULL; | |
64 | |
65 | |
66 SystemProperty *Arguments::_java_ext_dirs = NULL; | |
67 SystemProperty *Arguments::_java_endorsed_dirs = NULL; | |
68 SystemProperty *Arguments::_sun_boot_library_path = NULL; | |
69 SystemProperty *Arguments::_java_library_path = NULL; | |
70 SystemProperty *Arguments::_java_home = NULL; | |
71 SystemProperty *Arguments::_java_class_path = NULL; | |
72 SystemProperty *Arguments::_sun_boot_class_path = NULL; | |
73 | |
74 char* Arguments::_meta_index_path = NULL; | |
75 char* Arguments::_meta_index_dir = NULL; | |
76 | |
77 static bool force_client_mode = false; | |
78 | |
79 // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string | |
80 | |
81 static bool match_option(const JavaVMOption *option, const char* name, | |
82 const char** tail) { | |
83 int len = (int)strlen(name); | |
84 if (strncmp(option->optionString, name, len) == 0) { | |
85 *tail = option->optionString + len; | |
86 return true; | |
87 } else { | |
88 return false; | |
89 } | |
90 } | |
91 | |
92 static void logOption(const char* opt) { | |
93 if (PrintVMOptions) { | |
94 jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt); | |
95 } | |
96 } | |
97 | |
98 // Process java launcher properties. | |
99 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) { | |
100 // See if sun.java.launcher or sun.java.launcher.pid is defined. | |
101 // Must do this before setting up other system properties, | |
102 // as some of them may depend on launcher type. | |
103 for (int index = 0; index < args->nOptions; index++) { | |
104 const JavaVMOption* option = args->options + index; | |
105 const char* tail; | |
106 | |
107 if (match_option(option, "-Dsun.java.launcher=", &tail)) { | |
108 process_java_launcher_argument(tail, option->extraInfo); | |
109 continue; | |
110 } | |
111 if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) { | |
112 _sun_java_launcher_pid = atoi(tail); | |
113 continue; | |
114 } | |
115 } | |
116 } | |
117 | |
118 // Initialize system properties key and value. | |
119 void Arguments::init_system_properties() { | |
120 | |
121 PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.version", "1.0", false)); | |
122 PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.name", | |
123 "Java Virtual Machine Specification", false)); | |
124 PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.vendor", | |
125 "Sun Microsystems Inc.", false)); | |
126 PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(), false)); | |
127 PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(), false)); | |
128 PropertyList_add(&_system_properties, new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false)); | |
129 PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true)); | |
130 | |
131 // following are JVMTI agent writeable properties. | |
132 // Properties values are set to NULL and they are | |
133 // os specific they are initialized in os::init_system_properties_values(). | |
134 _java_ext_dirs = new SystemProperty("java.ext.dirs", NULL, true); | |
135 _java_endorsed_dirs = new SystemProperty("java.endorsed.dirs", NULL, true); | |
136 _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true); | |
137 _java_library_path = new SystemProperty("java.library.path", NULL, true); | |
138 _java_home = new SystemProperty("java.home", NULL, true); | |
139 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true); | |
140 | |
141 _java_class_path = new SystemProperty("java.class.path", "", true); | |
142 | |
143 // Add to System Property list. | |
144 PropertyList_add(&_system_properties, _java_ext_dirs); | |
145 PropertyList_add(&_system_properties, _java_endorsed_dirs); | |
146 PropertyList_add(&_system_properties, _sun_boot_library_path); | |
147 PropertyList_add(&_system_properties, _java_library_path); | |
148 PropertyList_add(&_system_properties, _java_home); | |
149 PropertyList_add(&_system_properties, _java_class_path); | |
150 PropertyList_add(&_system_properties, _sun_boot_class_path); | |
151 | |
152 // Set OS specific system properties values | |
153 os::init_system_properties_values(); | |
154 } | |
155 | |
242 | 156 /** |
157 * Provide a slightly more user-friendly way of eliminating -XX flags. | |
158 * When a flag is eliminated, it can be added to this list in order to | |
159 * continue accepting this flag on the command-line, while issuing a warning | |
160 * and ignoring the value. Once the JDK version reaches the 'accept_until' | |
161 * limit, we flatly refuse to admit the existence of the flag. This allows | |
162 * a flag to die correctly over JDK releases using HSX. | |
163 */ | |
164 typedef struct { | |
165 const char* name; | |
166 JDK_Version obsoleted_in; // when the flag went away | |
167 JDK_Version accept_until; // which version to start denying the existence | |
168 } ObsoleteFlag; | |
0 | 169 |
242 | 170 static ObsoleteFlag obsolete_jvm_flags[] = { |
171 { "UseTrainGC", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
172 { "UseSpecialLargeObjectHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
173 { "UseOversizedCarHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
174 { "TraceCarAllocation", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
175 { "PrintTrainGCProcessingStats", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
176 { "LogOfCarSpaceSize", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
177 { "OversizedCarThreshold", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
178 { "MinTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
179 { "DefaultTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
180 { "MaxTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
181 { "DelayTickAdjustment", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
182 { "ProcessingToTenuringRatio", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
183 { "MinTrainLength", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | |
184 { "AppendRatio", JDK_Version::jdk_update(6,10), JDK_Version::jdk(7) }, | |
185 { NULL, JDK_Version(0), JDK_Version(0) } | |
186 }; | |
187 | |
188 // Returns true if the flag is obsolete and fits into the range specified | |
189 // for being ignored. In the case that the flag is ignored, the 'version' | |
190 // value is filled in with the version number when the flag became | |
191 // obsolete so that that value can be displayed to the user. | |
192 bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) { | |
0 | 193 int i = 0; |
242 | 194 assert(version != NULL, "Must provide a version buffer"); |
195 while (obsolete_jvm_flags[i].name != NULL) { | |
196 const ObsoleteFlag& flag_status = obsolete_jvm_flags[i]; | |
0 | 197 // <flag>=xxx form |
198 // [-|+]<flag> form | |
242 | 199 if ((strncmp(flag_status.name, s, strlen(flag_status.name)) == 0) || |
0 | 200 ((s[0] == '+' || s[0] == '-') && |
242 | 201 (strncmp(flag_status.name, &s[1], strlen(flag_status.name)) == 0))) { |
202 if (JDK_Version::current().compare(flag_status.accept_until) == -1) { | |
203 *version = flag_status.obsoleted_in; | |
204 return true; | |
205 } | |
0 | 206 } |
207 i++; | |
208 } | |
209 return false; | |
210 } | |
211 | |
212 // Constructs the system class path (aka boot class path) from the following | |
213 // components, in order: | |
214 // | |
215 // prefix // from -Xbootclasspath/p:... | |
216 // endorsed // the expansion of -Djava.endorsed.dirs=... | |
217 // base // from os::get_system_properties() or -Xbootclasspath= | |
218 // suffix // from -Xbootclasspath/a:... | |
219 // | |
220 // java.endorsed.dirs is a list of directories; any jar or zip files in the | |
221 // directories are added to the sysclasspath just before the base. | |
222 // | |
223 // This could be AllStatic, but it isn't needed after argument processing is | |
224 // complete. | |
225 class SysClassPath: public StackObj { | |
226 public: | |
227 SysClassPath(const char* base); | |
228 ~SysClassPath(); | |
229 | |
230 inline void set_base(const char* base); | |
231 inline void add_prefix(const char* prefix); | |
232 inline void add_suffix(const char* suffix); | |
233 inline void reset_path(const char* base); | |
234 | |
235 // Expand the jar/zip files in each directory listed by the java.endorsed.dirs | |
236 // property. Must be called after all command-line arguments have been | |
237 // processed (in particular, -Djava.endorsed.dirs=...) and before calling | |
238 // combined_path(). | |
239 void expand_endorsed(); | |
240 | |
241 inline const char* get_base() const { return _items[_scp_base]; } | |
242 inline const char* get_prefix() const { return _items[_scp_prefix]; } | |
243 inline const char* get_suffix() const { return _items[_scp_suffix]; } | |
244 inline const char* get_endorsed() const { return _items[_scp_endorsed]; } | |
245 | |
246 // Combine all the components into a single c-heap-allocated string; caller | |
247 // must free the string if/when no longer needed. | |
248 char* combined_path(); | |
249 | |
250 private: | |
251 // Utility routines. | |
252 static char* add_to_path(const char* path, const char* str, bool prepend); | |
253 static char* add_jars_to_path(char* path, const char* directory); | |
254 | |
255 inline void reset_item_at(int index); | |
256 | |
257 // Array indices for the items that make up the sysclasspath. All except the | |
258 // base are allocated in the C heap and freed by this class. | |
259 enum { | |
260 _scp_prefix, // from -Xbootclasspath/p:... | |
261 _scp_endorsed, // the expansion of -Djava.endorsed.dirs=... | |
262 _scp_base, // the default sysclasspath | |
263 _scp_suffix, // from -Xbootclasspath/a:... | |
264 _scp_nitems // the number of items, must be last. | |
265 }; | |
266 | |
267 const char* _items[_scp_nitems]; | |
268 DEBUG_ONLY(bool _expansion_done;) | |
269 }; | |
270 | |
271 SysClassPath::SysClassPath(const char* base) { | |
272 memset(_items, 0, sizeof(_items)); | |
273 _items[_scp_base] = base; | |
274 DEBUG_ONLY(_expansion_done = false;) | |
275 } | |
276 | |
277 SysClassPath::~SysClassPath() { | |
278 // Free everything except the base. | |
279 for (int i = 0; i < _scp_nitems; ++i) { | |
280 if (i != _scp_base) reset_item_at(i); | |
281 } | |
282 DEBUG_ONLY(_expansion_done = false;) | |
283 } | |
284 | |
285 inline void SysClassPath::set_base(const char* base) { | |
286 _items[_scp_base] = base; | |
287 } | |
288 | |
289 inline void SysClassPath::add_prefix(const char* prefix) { | |
290 _items[_scp_prefix] = add_to_path(_items[_scp_prefix], prefix, true); | |
291 } | |
292 | |
293 inline void SysClassPath::add_suffix(const char* suffix) { | |
294 _items[_scp_suffix] = add_to_path(_items[_scp_suffix], suffix, false); | |
295 } | |
296 | |
297 inline void SysClassPath::reset_item_at(int index) { | |
298 assert(index < _scp_nitems && index != _scp_base, "just checking"); | |
299 if (_items[index] != NULL) { | |
300 FREE_C_HEAP_ARRAY(char, _items[index]); | |
301 _items[index] = NULL; | |
302 } | |
303 } | |
304 | |
305 inline void SysClassPath::reset_path(const char* base) { | |
306 // Clear the prefix and suffix. | |
307 reset_item_at(_scp_prefix); | |
308 reset_item_at(_scp_suffix); | |
309 set_base(base); | |
310 } | |
311 | |
312 //------------------------------------------------------------------------------ | |
313 | |
314 void SysClassPath::expand_endorsed() { | |
315 assert(_items[_scp_endorsed] == NULL, "can only be called once."); | |
316 | |
317 const char* path = Arguments::get_property("java.endorsed.dirs"); | |
318 if (path == NULL) { | |
319 path = Arguments::get_endorsed_dir(); | |
320 assert(path != NULL, "no default for java.endorsed.dirs"); | |
321 } | |
322 | |
323 char* expanded_path = NULL; | |
324 const char separator = *os::path_separator(); | |
325 const char* const end = path + strlen(path); | |
326 while (path < end) { | |
327 const char* tmp_end = strchr(path, separator); | |
328 if (tmp_end == NULL) { | |
329 expanded_path = add_jars_to_path(expanded_path, path); | |
330 path = end; | |
331 } else { | |
332 char* dirpath = NEW_C_HEAP_ARRAY(char, tmp_end - path + 1); | |
333 memcpy(dirpath, path, tmp_end - path); | |
334 dirpath[tmp_end - path] = '\0'; | |
335 expanded_path = add_jars_to_path(expanded_path, dirpath); | |
336 FREE_C_HEAP_ARRAY(char, dirpath); | |
337 path = tmp_end + 1; | |
338 } | |
339 } | |
340 _items[_scp_endorsed] = expanded_path; | |
341 DEBUG_ONLY(_expansion_done = true;) | |
342 } | |
343 | |
344 // Combine the bootclasspath elements, some of which may be null, into a single | |
345 // c-heap-allocated string. | |
346 char* SysClassPath::combined_path() { | |
347 assert(_items[_scp_base] != NULL, "empty default sysclasspath"); | |
348 assert(_expansion_done, "must call expand_endorsed() first."); | |
349 | |
350 size_t lengths[_scp_nitems]; | |
351 size_t total_len = 0; | |
352 | |
353 const char separator = *os::path_separator(); | |
354 | |
355 // Get the lengths. | |
356 int i; | |
357 for (i = 0; i < _scp_nitems; ++i) { | |
358 if (_items[i] != NULL) { | |
359 lengths[i] = strlen(_items[i]); | |
360 // Include space for the separator char (or a NULL for the last item). | |
361 total_len += lengths[i] + 1; | |
362 } | |
363 } | |
364 assert(total_len > 0, "empty sysclasspath not allowed"); | |
365 | |
366 // Copy the _items to a single string. | |
367 char* cp = NEW_C_HEAP_ARRAY(char, total_len); | |
368 char* cp_tmp = cp; | |
369 for (i = 0; i < _scp_nitems; ++i) { | |
370 if (_items[i] != NULL) { | |
371 memcpy(cp_tmp, _items[i], lengths[i]); | |
372 cp_tmp += lengths[i]; | |
373 *cp_tmp++ = separator; | |
374 } | |
375 } | |
376 *--cp_tmp = '\0'; // Replace the extra separator. | |
377 return cp; | |
378 } | |
379 | |
380 // Note: path must be c-heap-allocated (or NULL); it is freed if non-null. | |
381 char* | |
382 SysClassPath::add_to_path(const char* path, const char* str, bool prepend) { | |
383 char *cp; | |
384 | |
385 assert(str != NULL, "just checking"); | |
386 if (path == NULL) { | |
387 size_t len = strlen(str) + 1; | |
388 cp = NEW_C_HEAP_ARRAY(char, len); | |
389 memcpy(cp, str, len); // copy the trailing null | |
390 } else { | |
391 const char separator = *os::path_separator(); | |
392 size_t old_len = strlen(path); | |
393 size_t str_len = strlen(str); | |
394 size_t len = old_len + str_len + 2; | |
395 | |
396 if (prepend) { | |
397 cp = NEW_C_HEAP_ARRAY(char, len); | |
398 char* cp_tmp = cp; | |
399 memcpy(cp_tmp, str, str_len); | |
400 cp_tmp += str_len; | |
401 *cp_tmp = separator; | |
402 memcpy(++cp_tmp, path, old_len + 1); // copy the trailing null | |
403 FREE_C_HEAP_ARRAY(char, path); | |
404 } else { | |
405 cp = REALLOC_C_HEAP_ARRAY(char, path, len); | |
406 char* cp_tmp = cp + old_len; | |
407 *cp_tmp = separator; | |
408 memcpy(++cp_tmp, str, str_len + 1); // copy the trailing null | |
409 } | |
410 } | |
411 return cp; | |
412 } | |
413 | |
414 // Scan the directory and append any jar or zip files found to path. | |
415 // Note: path must be c-heap-allocated (or NULL); it is freed if non-null. | |
416 char* SysClassPath::add_jars_to_path(char* path, const char* directory) { | |
417 DIR* dir = os::opendir(directory); | |
418 if (dir == NULL) return path; | |
419 | |
420 char dir_sep[2] = { '\0', '\0' }; | |
421 size_t directory_len = strlen(directory); | |
422 const char fileSep = *os::file_separator(); | |
423 if (directory[directory_len - 1] != fileSep) dir_sep[0] = fileSep; | |
424 | |
425 /* Scan the directory for jars/zips, appending them to path. */ | |
426 struct dirent *entry; | |
427 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory)); | |
428 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { | |
429 const char* name = entry->d_name; | |
430 const char* ext = name + strlen(name) - 4; | |
431 bool isJarOrZip = ext > name && | |
432 (os::file_name_strcmp(ext, ".jar") == 0 || | |
433 os::file_name_strcmp(ext, ".zip") == 0); | |
434 if (isJarOrZip) { | |
435 char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name)); | |
436 sprintf(jarpath, "%s%s%s", directory, dir_sep, name); | |
437 path = add_to_path(path, jarpath, false); | |
438 FREE_C_HEAP_ARRAY(char, jarpath); | |
439 } | |
440 } | |
441 FREE_C_HEAP_ARRAY(char, dbuf); | |
442 os::closedir(dir); | |
443 return path; | |
444 } | |
445 | |
446 // Parses a memory size specification string. | |
447 static bool atomll(const char *s, jlong* result) { | |
448 jlong n = 0; | |
449 int args_read = sscanf(s, os::jlong_format_specifier(), &n); | |
450 if (args_read != 1) { | |
451 return false; | |
452 } | |
453 while (*s != '\0' && isdigit(*s)) { | |
454 s++; | |
455 } | |
456 // 4705540: illegal if more characters are found after the first non-digit | |
457 if (strlen(s) > 1) { | |
458 return false; | |
459 } | |
460 switch (*s) { | |
461 case 'T': case 't': | |
462 *result = n * G * K; | |
463 return true; | |
464 case 'G': case 'g': | |
465 *result = n * G; | |
466 return true; | |
467 case 'M': case 'm': | |
468 *result = n * M; | |
469 return true; | |
470 case 'K': case 'k': | |
471 *result = n * K; | |
472 return true; | |
473 case '\0': | |
474 *result = n; | |
475 return true; | |
476 default: | |
477 return false; | |
478 } | |
479 } | |
480 | |
481 Arguments::ArgsRange Arguments::check_memory_size(jlong size, jlong min_size) { | |
482 if (size < min_size) return arg_too_small; | |
483 // Check that size will fit in a size_t (only relevant on 32-bit) | |
484 if ((julong) size > max_uintx) return arg_too_big; | |
485 return arg_in_range; | |
486 } | |
487 | |
488 // Describe an argument out of range error | |
489 void Arguments::describe_range_error(ArgsRange errcode) { | |
490 switch(errcode) { | |
491 case arg_too_big: | |
492 jio_fprintf(defaultStream::error_stream(), | |
493 "The specified size exceeds the maximum " | |
494 "representable size.\n"); | |
495 break; | |
496 case arg_too_small: | |
497 case arg_unreadable: | |
498 case arg_in_range: | |
499 // do nothing for now | |
500 break; | |
501 default: | |
502 ShouldNotReachHere(); | |
503 } | |
504 } | |
505 | |
506 static bool set_bool_flag(char* name, bool value, FlagValueOrigin origin) { | |
507 return CommandLineFlags::boolAtPut(name, &value, origin); | |
508 } | |
509 | |
510 | |
511 static bool set_fp_numeric_flag(char* name, char* value, FlagValueOrigin origin) { | |
512 double v; | |
513 if (sscanf(value, "%lf", &v) != 1) { | |
514 return false; | |
515 } | |
516 | |
517 if (CommandLineFlags::doubleAtPut(name, &v, origin)) { | |
518 return true; | |
519 } | |
520 return false; | |
521 } | |
522 | |
523 | |
524 static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) { | |
525 jlong v; | |
526 intx intx_v; | |
527 bool is_neg = false; | |
528 // Check the sign first since atomll() parses only unsigned values. | |
529 if (*value == '-') { | |
530 if (!CommandLineFlags::intxAt(name, &intx_v)) { | |
531 return false; | |
532 } | |
533 value++; | |
534 is_neg = true; | |
535 } | |
536 if (!atomll(value, &v)) { | |
537 return false; | |
538 } | |
539 intx_v = (intx) v; | |
540 if (is_neg) { | |
541 intx_v = -intx_v; | |
542 } | |
543 if (CommandLineFlags::intxAtPut(name, &intx_v, origin)) { | |
544 return true; | |
545 } | |
546 uintx uintx_v = (uintx) v; | |
547 if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) { | |
548 return true; | |
549 } | |
550 return false; | |
551 } | |
552 | |
553 | |
554 static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) { | |
555 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; | |
556 // Contract: CommandLineFlags always returns a pointer that needs freeing. | |
557 FREE_C_HEAP_ARRAY(char, value); | |
558 return true; | |
559 } | |
560 | |
561 static bool append_to_string_flag(char* name, const char* new_value, FlagValueOrigin origin) { | |
562 const char* old_value = ""; | |
563 if (!CommandLineFlags::ccstrAt(name, &old_value)) return false; | |
564 size_t old_len = old_value != NULL ? strlen(old_value) : 0; | |
565 size_t new_len = strlen(new_value); | |
566 const char* value; | |
567 char* free_this_too = NULL; | |
568 if (old_len == 0) { | |
569 value = new_value; | |
570 } else if (new_len == 0) { | |
571 value = old_value; | |
572 } else { | |
573 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1); | |
574 // each new setting adds another LINE to the switch: | |
575 sprintf(buf, "%s\n%s", old_value, new_value); | |
576 value = buf; | |
577 free_this_too = buf; | |
578 } | |
579 (void) CommandLineFlags::ccstrAtPut(name, &value, origin); | |
580 // CommandLineFlags always returns a pointer that needs freeing. | |
581 FREE_C_HEAP_ARRAY(char, value); | |
582 if (free_this_too != NULL) { | |
583 // CommandLineFlags made its own copy, so I must delete my own temp. buffer. | |
584 FREE_C_HEAP_ARRAY(char, free_this_too); | |
585 } | |
586 return true; | |
587 } | |
588 | |
589 | |
590 bool Arguments::parse_argument(const char* arg, FlagValueOrigin origin) { | |
591 | |
592 // range of acceptable characters spelled out for portability reasons | |
593 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]" | |
594 #define BUFLEN 255 | |
595 char name[BUFLEN+1]; | |
596 char dummy; | |
597 | |
598 if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) { | |
599 return set_bool_flag(name, false, origin); | |
600 } | |
601 if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) { | |
602 return set_bool_flag(name, true, origin); | |
603 } | |
604 | |
605 char punct; | |
606 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') { | |
607 const char* value = strchr(arg, '=') + 1; | |
608 Flag* flag = Flag::find_flag(name, strlen(name)); | |
609 if (flag != NULL && flag->is_ccstr()) { | |
610 if (flag->ccstr_accumulates()) { | |
611 return append_to_string_flag(name, value, origin); | |
612 } else { | |
613 if (value[0] == '\0') { | |
614 value = NULL; | |
615 } | |
616 return set_string_flag(name, value, origin); | |
617 } | |
618 } | |
619 } | |
620 | |
621 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE ":%c", name, &punct) == 2 && punct == '=') { | |
622 const char* value = strchr(arg, '=') + 1; | |
623 // -XX:Foo:=xxx will reset the string flag to the given value. | |
624 if (value[0] == '\0') { | |
625 value = NULL; | |
626 } | |
627 return set_string_flag(name, value, origin); | |
628 } | |
629 | |
630 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]" | |
631 #define SIGNED_NUMBER_RANGE "[-0123456789]" | |
632 #define NUMBER_RANGE "[0123456789]" | |
633 char value[BUFLEN + 1]; | |
634 char value2[BUFLEN + 1]; | |
635 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) { | |
636 // Looks like a floating-point number -- try again with more lenient format string | |
637 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) { | |
638 return set_fp_numeric_flag(name, value, origin); | |
639 } | |
640 } | |
641 | |
642 #define VALUE_RANGE "[-kmgtKMGT0123456789]" | |
643 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) { | |
644 return set_numeric_flag(name, value, origin); | |
645 } | |
646 | |
647 return false; | |
648 } | |
649 | |
650 | |
651 void Arguments::add_string(char*** bldarray, int* count, const char* arg) { | |
652 assert(bldarray != NULL, "illegal argument"); | |
653 | |
654 if (arg == NULL) { | |
655 return; | |
656 } | |
657 | |
658 int index = *count; | |
659 | |
660 // expand the array and add arg to the last element | |
661 (*count)++; | |
662 if (*bldarray == NULL) { | |
663 *bldarray = NEW_C_HEAP_ARRAY(char*, *count); | |
664 } else { | |
665 *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, *count); | |
666 } | |
667 (*bldarray)[index] = strdup(arg); | |
668 } | |
669 | |
670 void Arguments::build_jvm_args(const char* arg) { | |
671 add_string(&_jvm_args_array, &_num_jvm_args, arg); | |
672 } | |
673 | |
674 void Arguments::build_jvm_flags(const char* arg) { | |
675 add_string(&_jvm_flags_array, &_num_jvm_flags, arg); | |
676 } | |
677 | |
678 // utility function to return a string that concatenates all | |
679 // strings in a given char** array | |
680 const char* Arguments::build_resource_string(char** args, int count) { | |
681 if (args == NULL || count == 0) { | |
682 return NULL; | |
683 } | |
684 size_t length = strlen(args[0]) + 1; // add 1 for the null terminator | |
685 for (int i = 1; i < count; i++) { | |
686 length += strlen(args[i]) + 1; // add 1 for a space | |
687 } | |
688 char* s = NEW_RESOURCE_ARRAY(char, length); | |
689 strcpy(s, args[0]); | |
690 for (int j = 1; j < count; j++) { | |
691 strcat(s, " "); | |
692 strcat(s, args[j]); | |
693 } | |
694 return (const char*) s; | |
695 } | |
696 | |
697 void Arguments::print_on(outputStream* st) { | |
698 st->print_cr("VM Arguments:"); | |
699 if (num_jvm_flags() > 0) { | |
700 st->print("jvm_flags: "); print_jvm_flags_on(st); | |
701 } | |
702 if (num_jvm_args() > 0) { | |
703 st->print("jvm_args: "); print_jvm_args_on(st); | |
704 } | |
705 st->print_cr("java_command: %s", java_command() ? java_command() : "<unknown>"); | |
706 st->print_cr("Launcher Type: %s", _sun_java_launcher); | |
707 } | |
708 | |
709 void Arguments::print_jvm_flags_on(outputStream* st) { | |
710 if (_num_jvm_flags > 0) { | |
711 for (int i=0; i < _num_jvm_flags; i++) { | |
712 st->print("%s ", _jvm_flags_array[i]); | |
713 } | |
714 st->print_cr(""); | |
715 } | |
716 } | |
717 | |
718 void Arguments::print_jvm_args_on(outputStream* st) { | |
719 if (_num_jvm_args > 0) { | |
720 for (int i=0; i < _num_jvm_args; i++) { | |
721 st->print("%s ", _jvm_args_array[i]); | |
722 } | |
723 st->print_cr(""); | |
724 } | |
725 } | |
726 | |
242 | 727 bool Arguments::process_argument(const char* arg, |
728 jboolean ignore_unrecognized, FlagValueOrigin origin) { | |
729 | |
730 JDK_Version since = JDK_Version(); | |
0 | 731 |
732 if (parse_argument(arg, origin)) { | |
733 // do nothing | |
242 | 734 } else if (is_newly_obsolete(arg, &since)) { |
735 enum { bufsize = 256 }; | |
736 char buffer[bufsize]; | |
737 since.to_string(buffer, bufsize); | |
0 | 738 jio_fprintf(defaultStream::error_stream(), |
242 | 739 "Warning: The flag %s has been EOL'd as of %s and will" |
740 " be ignored\n", arg, buffer); | |
0 | 741 } else { |
742 if (!ignore_unrecognized) { | |
743 jio_fprintf(defaultStream::error_stream(), | |
744 "Unrecognized VM option '%s'\n", arg); | |
745 // allow for commandline "commenting out" options like -XX:#+Verbose | |
746 if (strlen(arg) == 0 || arg[0] != '#') { | |
747 return false; | |
748 } | |
749 } | |
750 } | |
751 return true; | |
752 } | |
753 | |
754 | |
755 bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) { | |
756 FILE* stream = fopen(file_name, "rb"); | |
757 if (stream == NULL) { | |
758 if (should_exist) { | |
759 jio_fprintf(defaultStream::error_stream(), | |
760 "Could not open settings file %s\n", file_name); | |
761 return false; | |
762 } else { | |
763 return true; | |
764 } | |
765 } | |
766 | |
767 char token[1024]; | |
768 int pos = 0; | |
769 | |
770 bool in_white_space = true; | |
771 bool in_comment = false; | |
772 bool in_quote = false; | |
773 char quote_c = 0; | |
774 bool result = true; | |
775 | |
776 int c = getc(stream); | |
777 while(c != EOF) { | |
778 if (in_white_space) { | |
779 if (in_comment) { | |
780 if (c == '\n') in_comment = false; | |
781 } else { | |
782 if (c == '#') in_comment = true; | |
783 else if (!isspace(c)) { | |
784 in_white_space = false; | |
785 token[pos++] = c; | |
786 } | |
787 } | |
788 } else { | |
789 if (c == '\n' || (!in_quote && isspace(c))) { | |
790 // token ends at newline, or at unquoted whitespace | |
791 // this allows a way to include spaces in string-valued options | |
792 token[pos] = '\0'; | |
793 logOption(token); | |
794 result &= process_argument(token, ignore_unrecognized, CONFIG_FILE); | |
795 build_jvm_flags(token); | |
796 pos = 0; | |
797 in_white_space = true; | |
798 in_quote = false; | |
799 } else if (!in_quote && (c == '\'' || c == '"')) { | |
800 in_quote = true; | |
801 quote_c = c; | |
802 } else if (in_quote && (c == quote_c)) { | |
803 in_quote = false; | |
804 } else { | |
805 token[pos++] = c; | |
806 } | |
807 } | |
808 c = getc(stream); | |
809 } | |
810 if (pos > 0) { | |
811 token[pos] = '\0'; | |
812 result &= process_argument(token, ignore_unrecognized, CONFIG_FILE); | |
813 build_jvm_flags(token); | |
814 } | |
815 fclose(stream); | |
816 return result; | |
817 } | |
818 | |
819 //============================================================================================================= | |
820 // Parsing of properties (-D) | |
821 | |
822 const char* Arguments::get_property(const char* key) { | |
823 return PropertyList_get_value(system_properties(), key); | |
824 } | |
825 | |
826 bool Arguments::add_property(const char* prop) { | |
827 const char* eq = strchr(prop, '='); | |
828 char* key; | |
829 // ns must be static--its address may be stored in a SystemProperty object. | |
830 const static char ns[1] = {0}; | |
831 char* value = (char *)ns; | |
832 | |
833 size_t key_len = (eq == NULL) ? strlen(prop) : (eq - prop); | |
834 key = AllocateHeap(key_len + 1, "add_property"); | |
835 strncpy(key, prop, key_len); | |
836 key[key_len] = '\0'; | |
837 | |
838 if (eq != NULL) { | |
839 size_t value_len = strlen(prop) - key_len - 1; | |
840 value = AllocateHeap(value_len + 1, "add_property"); | |
841 strncpy(value, &prop[key_len + 1], value_len + 1); | |
842 } | |
843 | |
844 if (strcmp(key, "java.compiler") == 0) { | |
845 process_java_compiler_argument(value); | |
846 FreeHeap(key); | |
847 if (eq != NULL) { | |
848 FreeHeap(value); | |
849 } | |
850 return true; | |
851 } | |
852 else if (strcmp(key, "sun.java.command") == 0) { | |
853 | |
854 _java_command = value; | |
855 | |
856 // don't add this property to the properties exposed to the java application | |
857 FreeHeap(key); | |
858 return true; | |
859 } | |
860 else if (strcmp(key, "sun.java.launcher.pid") == 0) { | |
861 // launcher.pid property is private and is processed | |
862 // in process_sun_java_launcher_properties(); | |
863 // the sun.java.launcher property is passed on to the java application | |
864 FreeHeap(key); | |
865 if (eq != NULL) { | |
866 FreeHeap(value); | |
867 } | |
868 return true; | |
869 } | |
870 else if (strcmp(key, "java.vendor.url.bug") == 0) { | |
871 // save it in _java_vendor_url_bug, so JVM fatal error handler can access | |
872 // its value without going through the property list or making a Java call. | |
873 _java_vendor_url_bug = value; | |
874 } | |
875 | |
876 // Create new property and add at the end of the list | |
877 PropertyList_unique_add(&_system_properties, key, value); | |
878 return true; | |
879 } | |
880 | |
881 //=========================================================================================================== | |
882 // Setting int/mixed/comp mode flags | |
883 | |
884 void Arguments::set_mode_flags(Mode mode) { | |
885 // Set up default values for all flags. | |
886 // If you add a flag to any of the branches below, | |
887 // add a default value for it here. | |
888 set_java_compiler(false); | |
889 _mode = mode; | |
890 | |
891 // Ensure Agent_OnLoad has the correct initial values. | |
892 // This may not be the final mode; mode may change later in onload phase. | |
893 PropertyList_unique_add(&_system_properties, "java.vm.info", | |
894 (char*)Abstract_VM_Version::vm_info_string()); | |
895 | |
896 UseInterpreter = true; | |
897 UseCompiler = true; | |
898 UseLoopCounter = true; | |
899 | |
900 // Default values may be platform/compiler dependent - | |
901 // use the saved values | |
902 ClipInlining = Arguments::_ClipInlining; | |
903 AlwaysCompileLoopMethods = Arguments::_AlwaysCompileLoopMethods; | |
904 UseOnStackReplacement = Arguments::_UseOnStackReplacement; | |
905 BackgroundCompilation = Arguments::_BackgroundCompilation; | |
906 Tier2CompileThreshold = Arguments::_Tier2CompileThreshold; | |
907 | |
908 // Change from defaults based on mode | |
909 switch (mode) { | |
910 default: | |
911 ShouldNotReachHere(); | |
912 break; | |
913 case _int: | |
914 UseCompiler = false; | |
915 UseLoopCounter = false; | |
916 AlwaysCompileLoopMethods = false; | |
917 UseOnStackReplacement = false; | |
918 break; | |
919 case _mixed: | |
920 // same as default | |
921 break; | |
922 case _comp: | |
923 UseInterpreter = false; | |
924 BackgroundCompilation = false; | |
925 ClipInlining = false; | |
926 break; | |
927 } | |
928 } | |
929 | |
930 | |
931 // Conflict: required to use shared spaces (-Xshare:on), but | |
932 // incompatible command line options were chosen. | |
933 | |
934 static void no_shared_spaces() { | |
935 if (RequireSharedSpaces) { | |
936 jio_fprintf(defaultStream::error_stream(), | |
937 "Class data sharing is inconsistent with other specified options.\n"); | |
938 vm_exit_during_initialization("Unable to use shared archive.", NULL); | |
939 } else { | |
940 FLAG_SET_DEFAULT(UseSharedSpaces, false); | |
941 } | |
942 } | |
943 | |
944 | |
945 // If the user has chosen ParallelGCThreads > 0, we set UseParNewGC | |
946 // if it's not explictly set or unset. If the user has chosen | |
947 // UseParNewGC and not explicitly set ParallelGCThreads we | |
948 // set it, unless this is a single cpu machine. | |
949 void Arguments::set_parnew_gc_flags() { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
950 assert(!UseSerialGC && !UseParallelGC && !UseG1GC, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
951 "control point invariant"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
952 assert(UseParNewGC, "Error"); |
0 | 953 |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
954 // Turn off AdaptiveSizePolicy by default for parnew until it is |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
955 // complete. |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
956 if (FLAG_IS_DEFAULT(UseAdaptiveSizePolicy)) { |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
957 FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
958 } |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
959 |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
960 if (ParallelGCThreads == 0) { |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
961 FLAG_SET_DEFAULT(ParallelGCThreads, |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
962 Abstract_VM_Version::parallel_worker_threads()); |
0 | 963 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { |
964 FLAG_SET_DEFAULT(UseParNewGC, false); | |
965 } | |
966 } | |
967 if (!UseParNewGC) { | |
968 FLAG_SET_DEFAULT(ParallelGCThreads, 0); | |
969 } else { | |
970 no_shared_spaces(); | |
971 | |
972 // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 correspondinly, | |
973 // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration | |
974 // we set them to 1024 and 1024. | |
975 // See CR 6362902. | |
976 if (FLAG_IS_DEFAULT(YoungPLABSize)) { | |
977 FLAG_SET_DEFAULT(YoungPLABSize, (intx)1024); | |
978 } | |
979 if (FLAG_IS_DEFAULT(OldPLABSize)) { | |
980 FLAG_SET_DEFAULT(OldPLABSize, (intx)1024); | |
981 } | |
982 | |
983 // AlwaysTenure flag should make ParNew to promote all at first collection. | |
984 // See CR 6362902. | |
985 if (AlwaysTenure) { | |
986 FLAG_SET_CMDLINE(intx, MaxTenuringThreshold, 0); | |
987 } | |
988 } | |
989 } | |
990 | |
991 // Adjust some sizes to suit CMS and/or ParNew needs; these work well on | |
992 // sparc/solaris for certain applications, but would gain from | |
993 // further optimization and tuning efforts, and would almost | |
994 // certainly gain from analysis of platform and environment. | |
995 void Arguments::set_cms_and_parnew_gc_flags() { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
996 assert(!UseSerialGC && !UseParallelGC, "Error"); |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
997 assert(UseConcMarkSweepGC, "CMS is expected to be on here"); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
998 |
0 | 999 // If we are using CMS, we prefer to UseParNewGC, |
1000 // unless explicitly forbidden. | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1001 if (FLAG_IS_DEFAULT(UseParNewGC)) { |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1002 FLAG_SET_ERGO(bool, UseParNewGC, true); |
0 | 1003 } |
1004 | |
1005 // Turn off AdaptiveSizePolicy by default for cms until it is | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1006 // complete. |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1007 if (FLAG_IS_DEFAULT(UseAdaptiveSizePolicy)) { |
0 | 1008 FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false); |
1009 } | |
1010 | |
1011 // In either case, adjust ParallelGCThreads and/or UseParNewGC | |
1012 // as needed. | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1013 if (UseParNewGC) { |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1014 set_parnew_gc_flags(); |
0 | 1015 } |
1016 | |
1017 // Now make adjustments for CMS | |
1018 size_t young_gen_per_worker; | |
1019 intx new_ratio; | |
1020 size_t min_new_default; | |
1021 intx tenuring_default; | |
1022 if (CMSUseOldDefaults) { // old defaults: "old" as of 6.0 | |
1023 if FLAG_IS_DEFAULT(CMSYoungGenPerWorker) { | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1024 FLAG_SET_ERGO(intx, CMSYoungGenPerWorker, 4*M); |
0 | 1025 } |
1026 young_gen_per_worker = 4*M; | |
1027 new_ratio = (intx)15; | |
1028 min_new_default = 4*M; | |
1029 tenuring_default = (intx)0; | |
1030 } else { // new defaults: "new" as of 6.0 | |
1031 young_gen_per_worker = CMSYoungGenPerWorker; | |
1032 new_ratio = (intx)7; | |
1033 min_new_default = 16*M; | |
1034 tenuring_default = (intx)4; | |
1035 } | |
1036 | |
1037 // Preferred young gen size for "short" pauses | |
1038 const uintx parallel_gc_threads = | |
1039 (ParallelGCThreads == 0 ? 1 : ParallelGCThreads); | |
1040 const size_t preferred_max_new_size_unaligned = | |
1041 ScaleForWordSize(young_gen_per_worker * parallel_gc_threads); | |
1042 const size_t preferred_max_new_size = | |
1043 align_size_up(preferred_max_new_size_unaligned, os::vm_page_size()); | |
1044 | |
1045 // Unless explicitly requested otherwise, size young gen | |
1046 // for "short" pauses ~ 4M*ParallelGCThreads | |
1047 if (FLAG_IS_DEFAULT(MaxNewSize)) { // MaxNewSize not set at command-line | |
1048 if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1049 FLAG_SET_ERGO(uintx, MaxNewSize, MAX2(NewSize, preferred_max_new_size)); |
0 | 1050 } else { |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1051 FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size); |
0 | 1052 } |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1053 if(PrintGCDetails && Verbose) { |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1054 // Too early to use gclog_or_tty |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1055 tty->print_cr("Ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1056 } |
0 | 1057 } |
1058 // Unless explicitly requested otherwise, prefer a large | |
1059 // Old to Young gen size so as to shift the collection load | |
1060 // to the old generation concurrent collector | |
1061 if (FLAG_IS_DEFAULT(NewRatio)) { | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1062 FLAG_SET_ERGO(intx, NewRatio, MAX2(NewRatio, new_ratio)); |
0 | 1063 |
1064 size_t min_new = align_size_up(ScaleForWordSize(min_new_default), os::vm_page_size()); | |
1065 size_t prev_initial_size = initial_heap_size(); | |
1066 if (prev_initial_size != 0 && prev_initial_size < min_new+OldSize) { | |
1067 set_initial_heap_size(min_new+OldSize); | |
1068 // Currently minimum size and the initial heap sizes are the same. | |
1069 set_min_heap_size(initial_heap_size()); | |
1070 if (PrintGCDetails && Verbose) { | |
1071 warning("Initial heap size increased to " SIZE_FORMAT " M from " | |
1072 SIZE_FORMAT " M; use -XX:NewSize=... for finer control.", | |
1073 initial_heap_size()/M, prev_initial_size/M); | |
1074 } | |
1075 } | |
1076 // MaxHeapSize is aligned down in collectorPolicy | |
1077 size_t max_heap = align_size_down(MaxHeapSize, | |
1078 CardTableRS::ct_max_alignment_constraint()); | |
1079 | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1080 if(PrintGCDetails && Verbose) { |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1081 // Too early to use gclog_or_tty |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1082 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1083 " initial_heap_size: " SIZE_FORMAT |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1084 " max_heap: " SIZE_FORMAT, |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1085 min_heap_size(), initial_heap_size(), max_heap); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1086 } |
0 | 1087 if (max_heap > min_new) { |
1088 // Unless explicitly requested otherwise, make young gen | |
1089 // at least min_new, and at most preferred_max_new_size. | |
1090 if (FLAG_IS_DEFAULT(NewSize)) { | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1091 FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new)); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1092 FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize)); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1093 if(PrintGCDetails && Verbose) { |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1094 // Too early to use gclog_or_tty |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1095 tty->print_cr("Ergo set NewSize: " SIZE_FORMAT, NewSize); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1096 } |
0 | 1097 } |
1098 // Unless explicitly requested otherwise, size old gen | |
1099 // so that it's at least 3X of NewSize to begin with; | |
1100 // later NewRatio will decide how it grows; see above. | |
1101 if (FLAG_IS_DEFAULT(OldSize)) { | |
1102 if (max_heap > NewSize) { | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1103 FLAG_SET_ERGO(uintx, OldSize, MIN2(3*NewSize, max_heap - NewSize)); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1104 if(PrintGCDetails && Verbose) { |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1105 // Too early to use gclog_or_tty |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1106 tty->print_cr("Ergo set OldSize: " SIZE_FORMAT, OldSize); |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1107 } |
0 | 1108 } |
1109 } | |
1110 } | |
1111 } | |
1112 // Unless explicitly requested otherwise, definitely | |
1113 // promote all objects surviving "tenuring_default" scavenges. | |
1114 if (FLAG_IS_DEFAULT(MaxTenuringThreshold) && | |
1115 FLAG_IS_DEFAULT(SurvivorRatio)) { | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1116 FLAG_SET_ERGO(intx, MaxTenuringThreshold, tenuring_default); |
0 | 1117 } |
1118 // If we decided above (or user explicitly requested) | |
1119 // `promote all' (via MaxTenuringThreshold := 0), | |
1120 // prefer minuscule survivor spaces so as not to waste | |
1121 // space for (non-existent) survivors | |
1122 if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) { | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1123 FLAG_SET_ERGO(intx, SurvivorRatio, MAX2((intx)1024, SurvivorRatio)); |
0 | 1124 } |
1125 // If OldPLABSize is set and CMSParPromoteBlocksToClaim is not, | |
1126 // set CMSParPromoteBlocksToClaim equal to OldPLABSize. | |
1127 // This is done in order to make ParNew+CMS configuration to work | |
1128 // with YoungPLABSize and OldPLABSize options. | |
1129 // See CR 6362902. | |
1130 if (!FLAG_IS_DEFAULT(OldPLABSize)) { | |
1131 if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) { | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1132 // OldPLABSize is not the default value but CMSParPromoteBlocksToClaim |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1133 // is. In this situtation let CMSParPromoteBlocksToClaim follow |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1134 // the value (either from the command line or ergonomics) of |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1135 // OldPLABSize. Following OldPLABSize is an ergonomics decision. |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1136 FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, OldPLABSize); |
0 | 1137 } |
1138 else { | |
1139 // OldPLABSize and CMSParPromoteBlocksToClaim are both set. | |
1140 // CMSParPromoteBlocksToClaim is a collector-specific flag, so | |
1141 // we'll let it to take precedence. | |
1142 jio_fprintf(defaultStream::error_stream(), | |
1143 "Both OldPLABSize and CMSParPromoteBlocksToClaim options are specified " | |
1144 "for the CMS collector. CMSParPromoteBlocksToClaim will take precedence.\n"); | |
1145 } | |
1146 } | |
1147 } | |
1148 | |
135
b7268662a986
6689523: max heap calculation for compressed oops is off by MaxPermSize
coleenp
parents:
113
diff
changeset
|
1149 inline uintx max_heap_for_compressed_oops() { |
b7268662a986
6689523: max heap calculation for compressed oops is off by MaxPermSize
coleenp
parents:
113
diff
changeset
|
1150 LP64_ONLY(return oopDesc::OopEncodingHeapMax - MaxPermSize - os::vm_page_size()); |
b7268662a986
6689523: max heap calculation for compressed oops is off by MaxPermSize
coleenp
parents:
113
diff
changeset
|
1151 NOT_LP64(return DefaultMaxRAM); |
b7268662a986
6689523: max heap calculation for compressed oops is off by MaxPermSize
coleenp
parents:
113
diff
changeset
|
1152 } |
b7268662a986
6689523: max heap calculation for compressed oops is off by MaxPermSize
coleenp
parents:
113
diff
changeset
|
1153 |
0 | 1154 bool Arguments::should_auto_select_low_pause_collector() { |
1155 if (UseAutoGCSelectPolicy && | |
1156 !FLAG_IS_DEFAULT(MaxGCPauseMillis) && | |
1157 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) { | |
1158 if (PrintGCDetails) { | |
1159 // Cannot use gclog_or_tty yet. | |
1160 tty->print_cr("Automatic selection of the low pause collector" | |
1161 " based on pause goal of %d (ms)", MaxGCPauseMillis); | |
1162 } | |
1163 return true; | |
1164 } | |
1165 return false; | |
1166 } | |
1167 | |
1168 void Arguments::set_ergonomics_flags() { | |
1169 // Parallel GC is not compatible with sharing. If one specifies | |
1170 // that they want sharing explicitly, do not set ergonmics flags. | |
1171 if (DumpSharedSpaces || ForceSharedSpaces) { | |
1172 return; | |
1173 } | |
1174 | |
1175 if (os::is_server_class_machine() && !force_client_mode ) { | |
1176 // If no other collector is requested explicitly, | |
1177 // let the VM select the collector based on | |
1178 // machine class and automatic selection policy. | |
1179 if (!UseSerialGC && | |
1180 !UseConcMarkSweepGC && | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1181 !UseG1GC && |
0 | 1182 !UseParNewGC && |
1183 !DumpSharedSpaces && | |
1184 FLAG_IS_DEFAULT(UseParallelGC)) { | |
1185 if (should_auto_select_low_pause_collector()) { | |
1186 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true); | |
1187 } else { | |
1188 FLAG_SET_ERGO(bool, UseParallelGC, true); | |
1189 } | |
1190 no_shared_spaces(); | |
1191 } | |
1192 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1193 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1194 #ifdef _LP64 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1195 // Compressed Headers do not work with CMS, which uses a bit in the klass |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1196 // field offset to determine free list chunk markers. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1197 // Check that UseCompressedOops can be set with the max heap size allocated |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1198 // by ergonomics. |
187 | 1199 if (MaxHeapSize <= max_heap_for_compressed_oops()) { |
344 | 1200 if (FLAG_IS_DEFAULT(UseCompressedOops) && !UseG1GC) { |
239 | 1201 // Turn off until bug is fixed. |
185 | 1202 // the following line to return it to default status. |
239 | 1203 // FLAG_SET_ERGO(bool, UseCompressedOops, true); |
344 | 1204 } else if (UseCompressedOops && UseG1GC) { |
1205 warning(" UseCompressedOops does not currently work with UseG1GC; switching off UseCompressedOops. "); | |
1206 FLAG_SET_DEFAULT(UseCompressedOops, false); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1207 } |
325
93befa083681
6741004: UseLargePages + UseCompressedOops breaks implicit null checking guard page
coleenp
parents:
276
diff
changeset
|
1208 #ifdef _WIN64 |
93befa083681
6741004: UseLargePages + UseCompressedOops breaks implicit null checking guard page
coleenp
parents:
276
diff
changeset
|
1209 if (UseLargePages && UseCompressedOops) { |
93befa083681
6741004: UseLargePages + UseCompressedOops breaks implicit null checking guard page
coleenp
parents:
276
diff
changeset
|
1210 // Cannot allocate guard pages for implicit checks in indexed addressing |
93befa083681
6741004: UseLargePages + UseCompressedOops breaks implicit null checking guard page
coleenp
parents:
276
diff
changeset
|
1211 // mode, when large pages are specified on windows. |
93befa083681
6741004: UseLargePages + UseCompressedOops breaks implicit null checking guard page
coleenp
parents:
276
diff
changeset
|
1212 FLAG_SET_DEFAULT(UseImplicitNullCheckForNarrowOop, false); |
93befa083681
6741004: UseLargePages + UseCompressedOops breaks implicit null checking guard page
coleenp
parents:
276
diff
changeset
|
1213 } |
93befa083681
6741004: UseLargePages + UseCompressedOops breaks implicit null checking guard page
coleenp
parents:
276
diff
changeset
|
1214 #endif // _WIN64 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1215 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1216 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) { |
344 | 1217 warning("Max heap size too large for Compressed Oops"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1218 FLAG_SET_DEFAULT(UseCompressedOops, false); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1219 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1220 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1221 // Also checks that certain machines are slower with compressed oops |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1222 // in vm_version initialization code. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
76
diff
changeset
|
1223 #endif // _LP64 |
0 | 1224 } |
1225 | |
1226 void Arguments::set_parallel_gc_flags() { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1227 assert(UseParallelGC || UseParallelOldGC, "Error"); |
0 | 1228 // If parallel old was requested, automatically enable parallel scavenge. |
1229 if (UseParallelOldGC && !UseParallelGC && FLAG_IS_DEFAULT(UseParallelGC)) { | |
1230 FLAG_SET_DEFAULT(UseParallelGC, true); | |
1231 } | |
1232 | |
1233 // If no heap maximum was requested explicitly, use some reasonable fraction | |
1234 // of the physical memory, up to a maximum of 1GB. | |
1235 if (UseParallelGC) { | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1236 FLAG_SET_ERGO(uintx, ParallelGCThreads, |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1237 Abstract_VM_Version::parallel_worker_threads()); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1238 |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1239 // PS is a server collector, setup the heap sizes accordingly. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1240 set_server_heap_size(); |
0 | 1241 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the |
1242 // SurvivorRatio has been set, reset their default values to SurvivorRatio + | |
1243 // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger. | |
1244 // See CR 6362902 for details. | |
1245 if (!FLAG_IS_DEFAULT(SurvivorRatio)) { | |
1246 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) { | |
1247 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2); | |
1248 } | |
1249 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) { | |
1250 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2); | |
1251 } | |
1252 } | |
1253 | |
1254 if (UseParallelOldGC) { | |
1255 // Par compact uses lower default values since they are treated as | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1256 // minimums. These are different defaults because of the different |
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1257 // interpretation and are not ergonomically set. |
0 | 1258 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) { |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1259 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1); |
0 | 1260 } |
1261 if (FLAG_IS_DEFAULT(PermMarkSweepDeadRatio)) { | |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
1262 FLAG_SET_DEFAULT(PermMarkSweepDeadRatio, 5); |
0 | 1263 } |
1264 } | |
1265 } | |
1266 } | |
1267 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1268 void Arguments::set_g1_gc_flags() { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1269 assert(UseG1GC, "Error"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1270 // G1 is a server collector, setup the heap sizes accordingly. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1271 set_server_heap_size(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1272 #ifdef COMPILER1 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1273 FastTLABRefill = false; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1274 #endif |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1275 FLAG_SET_DEFAULT(ParallelGCThreads, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1276 Abstract_VM_Version::parallel_worker_threads()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1277 if (ParallelGCThreads == 0) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1278 FLAG_SET_DEFAULT(ParallelGCThreads, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1279 Abstract_VM_Version::parallel_worker_threads |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1280 ()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1281 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1282 no_shared_spaces(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1283 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1284 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1285 void Arguments::set_server_heap_size() { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1286 if (FLAG_IS_DEFAULT(MaxHeapSize)) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1287 const uint64_t reasonable_fraction = |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1288 os::physical_memory() / DefaultMaxRAMFraction; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1289 const uint64_t maximum_size = (uint64_t) |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1290 (FLAG_IS_DEFAULT(DefaultMaxRAM) && UseCompressedOops ? |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1291 MIN2(max_heap_for_compressed_oops(), DefaultMaxRAM) : |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1292 DefaultMaxRAM); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1293 size_t reasonable_max = |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1294 (size_t) os::allocatable_physical_memory(reasonable_fraction); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1295 if (reasonable_max > maximum_size) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1296 reasonable_max = maximum_size; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1297 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1298 if (PrintGCDetails && Verbose) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1299 // Cannot use gclog_or_tty yet. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1300 tty->print_cr(" Max heap size for server class platform " |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1301 SIZE_FORMAT, reasonable_max); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1302 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1303 // If the initial_heap_size has not been set with -Xms, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1304 // then set it as fraction of size of physical memory |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1305 // respecting the maximum and minimum sizes of the heap. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1306 if (initial_heap_size() == 0) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1307 const uint64_t reasonable_initial_fraction = |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1308 os::physical_memory() / DefaultInitialRAMFraction; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1309 const size_t reasonable_initial = |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1310 (size_t) os::allocatable_physical_memory(reasonable_initial_fraction); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1311 const size_t minimum_size = NewSize + OldSize; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1312 set_initial_heap_size(MAX2(MIN2(reasonable_initial, reasonable_max), |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1313 minimum_size)); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1314 // Currently the minimum size and the initial heap sizes are the same. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1315 set_min_heap_size(initial_heap_size()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1316 if (PrintGCDetails && Verbose) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1317 // Cannot use gclog_or_tty yet. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1318 tty->print_cr(" Initial heap size for server class platform " |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1319 SIZE_FORMAT, initial_heap_size()); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1320 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1321 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1322 // A minimum size was specified on the command line. Be sure |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1323 // that the maximum size is consistent. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1324 if (initial_heap_size() > reasonable_max) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1325 reasonable_max = initial_heap_size(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1326 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1327 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1328 FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx) reasonable_max); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1329 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1330 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1331 |
0 | 1332 // This must be called after ergonomics because we want bytecode rewriting |
1333 // if the server compiler is used, or if UseSharedSpaces is disabled. | |
1334 void Arguments::set_bytecode_flags() { | |
1335 // Better not attempt to store into a read-only space. | |
1336 if (UseSharedSpaces) { | |
1337 FLAG_SET_DEFAULT(RewriteBytecodes, false); | |
1338 FLAG_SET_DEFAULT(RewriteFrequentPairs, false); | |
1339 } | |
1340 | |
1341 if (!RewriteBytecodes) { | |
1342 FLAG_SET_DEFAULT(RewriteFrequentPairs, false); | |
1343 } | |
1344 } | |
1345 | |
1346 // Aggressive optimization flags -XX:+AggressiveOpts | |
1347 void Arguments::set_aggressive_opts_flags() { | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1348 #ifdef COMPILER2 |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1349 if (AggressiveOpts || !FLAG_IS_DEFAULT(AutoBoxCacheMax)) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1350 if (FLAG_IS_DEFAULT(EliminateAutoBox)) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1351 FLAG_SET_DEFAULT(EliminateAutoBox, true); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1352 } |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1353 if (FLAG_IS_DEFAULT(AutoBoxCacheMax)) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1354 FLAG_SET_DEFAULT(AutoBoxCacheMax, 20000); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1355 } |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1356 |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1357 // Feed the cache size setting into the JDK |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1358 char buffer[1024]; |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1359 sprintf(buffer, "java.lang.Integer.IntegerCache.high=%d", AutoBoxCacheMax); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1360 add_property(buffer); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1361 } |
65 | 1362 if (AggressiveOpts && FLAG_IS_DEFAULT(DoEscapeAnalysis)) { |
1363 FLAG_SET_DEFAULT(DoEscapeAnalysis, true); | |
1364 } | |
169
9148c65abefc
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
135
diff
changeset
|
1365 if (AggressiveOpts && FLAG_IS_DEFAULT(SpecialArraysEquals)) { |
9148c65abefc
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
135
diff
changeset
|
1366 FLAG_SET_DEFAULT(SpecialArraysEquals, true); |
9148c65abefc
6695049: (coll) Create an x86 intrinsic for Arrays.equals
rasbold
parents:
135
diff
changeset
|
1367 } |
416
b6cfd754403d
6649622: HotSpot Biased locking needs tuning on latest CPUs
never
parents:
363
diff
changeset
|
1368 if (AggressiveOpts && FLAG_IS_DEFAULT(BiasedLockingStartupDelay)) { |
b6cfd754403d
6649622: HotSpot Biased locking needs tuning on latest CPUs
never
parents:
363
diff
changeset
|
1369 FLAG_SET_DEFAULT(BiasedLockingStartupDelay, 500); |
b6cfd754403d
6649622: HotSpot Biased locking needs tuning on latest CPUs
never
parents:
363
diff
changeset
|
1370 } |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1371 #endif |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1372 |
0 | 1373 if (AggressiveOpts) { |
61 | 1374 // Sample flag setting code |
1375 // if (FLAG_IS_DEFAULT(EliminateZeroing)) { | |
1376 // FLAG_SET_DEFAULT(EliminateZeroing, true); | |
1377 // } | |
0 | 1378 } |
1379 } | |
1380 | |
1381 //=========================================================================================================== | |
1382 // Parsing of java.compiler property | |
1383 | |
1384 void Arguments::process_java_compiler_argument(char* arg) { | |
1385 // For backwards compatibility, Djava.compiler=NONE or "" | |
1386 // causes us to switch to -Xint mode UNLESS -Xdebug | |
1387 // is also specified. | |
1388 if (strlen(arg) == 0 || strcasecmp(arg, "NONE") == 0) { | |
1389 set_java_compiler(true); // "-Djava.compiler[=...]" most recently seen. | |
1390 } | |
1391 } | |
1392 | |
1393 void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) { | |
1394 _sun_java_launcher = strdup(launcher); | |
1395 } | |
1396 | |
1397 bool Arguments::created_by_java_launcher() { | |
1398 assert(_sun_java_launcher != NULL, "property must have value"); | |
1399 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0; | |
1400 } | |
1401 | |
1402 //=========================================================================================================== | |
1403 // Parsing of main arguments | |
1404 | |
1405 bool Arguments::verify_percentage(uintx value, const char* name) { | |
1406 if (value <= 100) { | |
1407 return true; | |
1408 } | |
1409 jio_fprintf(defaultStream::error_stream(), | |
1410 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", | |
1411 name, value); | |
1412 return false; | |
1413 } | |
1414 | |
1415 static void set_serial_gc_flags() { | |
1416 FLAG_SET_DEFAULT(UseSerialGC, true); | |
1417 FLAG_SET_DEFAULT(UseParNewGC, false); | |
1418 FLAG_SET_DEFAULT(UseConcMarkSweepGC, false); | |
1419 FLAG_SET_DEFAULT(UseParallelGC, false); | |
1420 FLAG_SET_DEFAULT(UseParallelOldGC, false); | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1421 FLAG_SET_DEFAULT(UseG1GC, false); |
0 | 1422 } |
1423 | |
1424 static bool verify_serial_gc_flags() { | |
1425 return (UseSerialGC && | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1426 !(UseParNewGC || UseConcMarkSweepGC || UseG1GC || |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1427 UseParallelGC || UseParallelOldGC)); |
0 | 1428 } |
1429 | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1430 // Check consistency of GC selection |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1431 bool Arguments::check_gc_consistency() { |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1432 bool status = true; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1433 // Ensure that the user has not selected conflicting sets |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1434 // of collectors. [Note: this check is merely a user convenience; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1435 // collectors over-ride each other so that only a non-conflicting |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1436 // set is selected; however what the user gets is not what they |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1437 // may have expected from the combination they asked for. It's |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1438 // better to reduce user confusion by not allowing them to |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1439 // select conflicting combinations. |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1440 uint i = 0; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1441 if (UseSerialGC) i++; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1442 if (UseConcMarkSweepGC || UseParNewGC) i++; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1443 if (UseParallelGC || UseParallelOldGC) i++; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1444 if (i > 1) { |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1445 jio_fprintf(defaultStream::error_stream(), |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1446 "Conflicting collector combinations in option list; " |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1447 "please refer to the release notes for the combinations " |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1448 "allowed\n"); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1449 status = false; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1450 } |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1451 |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1452 return status; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1453 } |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1454 |
0 | 1455 // Check the consistency of vm_init_args |
1456 bool Arguments::check_vm_args_consistency() { | |
1457 // Method for adding checks for flag consistency. | |
1458 // The intent is to warn the user of all possible conflicts, | |
1459 // before returning an error. | |
1460 // Note: Needs platform-dependent factoring. | |
1461 bool status = true; | |
1462 | |
1463 #if ( (defined(COMPILER2) && defined(SPARC))) | |
1464 // NOTE: The call to VM_Version_init depends on the fact that VM_Version_init | |
1465 // on sparc doesn't require generation of a stub as is the case on, e.g., | |
1466 // x86. Normally, VM_Version_init must be called from init_globals in | |
1467 // init.cpp, which is called by the initial java thread *after* arguments | |
1468 // have been parsed. VM_Version_init gets called twice on sparc. | |
1469 extern void VM_Version_init(); | |
1470 VM_Version_init(); | |
1471 if (!VM_Version::has_v9()) { | |
1472 jio_fprintf(defaultStream::error_stream(), | |
1473 "V8 Machine detected, Server requires V9\n"); | |
1474 status = false; | |
1475 } | |
1476 #endif /* COMPILER2 && SPARC */ | |
1477 | |
1478 // Allow both -XX:-UseStackBanging and -XX:-UseBoundThreads in non-product | |
1479 // builds so the cost of stack banging can be measured. | |
1480 #if (defined(PRODUCT) && defined(SOLARIS)) | |
1481 if (!UseBoundThreads && !UseStackBanging) { | |
1482 jio_fprintf(defaultStream::error_stream(), | |
1483 "-UseStackBanging conflicts with -UseBoundThreads\n"); | |
1484 | |
1485 status = false; | |
1486 } | |
1487 #endif | |
1488 | |
1489 if (TLABRefillWasteFraction == 0) { | |
1490 jio_fprintf(defaultStream::error_stream(), | |
1491 "TLABRefillWasteFraction should be a denominator, " | |
1492 "not " SIZE_FORMAT "\n", | |
1493 TLABRefillWasteFraction); | |
1494 status = false; | |
1495 } | |
1496 | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1497 status = status && verify_percentage(MaxLiveObjectEvacuationRatio, |
0 | 1498 "MaxLiveObjectEvacuationRatio"); |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1499 status = status && verify_percentage(AdaptiveSizePolicyWeight, |
0 | 1500 "AdaptiveSizePolicyWeight"); |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1501 status = status && verify_percentage(AdaptivePermSizeWeight, "AdaptivePermSizeWeight"); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1502 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance"); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1503 status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio"); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1504 status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio"); |
0 | 1505 |
1506 if (MinHeapFreeRatio > MaxHeapFreeRatio) { | |
1507 jio_fprintf(defaultStream::error_stream(), | |
1508 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or " | |
1509 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n", | |
1510 MinHeapFreeRatio, MaxHeapFreeRatio); | |
1511 status = false; | |
1512 } | |
1513 // Keeping the heap 100% free is hard ;-) so limit it to 99%. | |
1514 MinHeapFreeRatio = MIN2(MinHeapFreeRatio, (uintx) 99); | |
1515 | |
1516 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) { | |
1517 MarkSweepAlwaysCompactCount = 1; // Move objects every gc. | |
1518 } | |
1519 | |
483
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1520 if (UseParallelOldGC && ParallelOldGCSplitALot) { |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1521 // Settings to encourage splitting. |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1522 if (!FLAG_IS_CMDLINE(NewRatio)) { |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1523 FLAG_SET_CMDLINE(intx, NewRatio, 2); |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1524 } |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1525 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) { |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1526 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1527 } |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1528 } |
0f773163217d
6765954: par compact - stress mode for splitting young gen spaces
jcoomes
parents:
449
diff
changeset
|
1529 |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1530 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1531 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit"); |
0 | 1532 if (GCTimeLimit == 100) { |
1533 // Turn off gc-overhead-limit-exceeded checks | |
1534 FLAG_SET_DEFAULT(UseGCOverheadLimit, false); | |
1535 } | |
1536 | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1537 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); |
0 | 1538 |
1539 // Check user specified sharing option conflict with Parallel GC | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1540 bool cannot_share = (UseConcMarkSweepGC || UseG1GC || UseParNewGC || |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
1541 UseParallelGC || UseParallelOldGC || |
0 | 1542 SOLARIS_ONLY(UseISM) NOT_SOLARIS(UseLargePages)); |
1543 | |
1544 if (cannot_share) { | |
1545 // Either force sharing on by forcing the other options off, or | |
1546 // force sharing off. | |
1547 if (DumpSharedSpaces || ForceSharedSpaces) { | |
1548 set_serial_gc_flags(); | |
1549 FLAG_SET_DEFAULT(SOLARIS_ONLY(UseISM) NOT_SOLARIS(UseLargePages), false); | |
1550 } else { | |
1551 no_shared_spaces(); | |
1552 } | |
1553 } | |
1554 | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1555 status = status && check_gc_consistency(); |
0 | 1556 |
1557 if (_has_alloc_profile) { | |
1558 if (UseParallelGC || UseParallelOldGC) { | |
1559 jio_fprintf(defaultStream::error_stream(), | |
1560 "error: invalid argument combination.\n" | |
1561 "Allocation profiling (-Xaprof) cannot be used together with " | |
1562 "Parallel GC (-XX:+UseParallelGC or -XX:+UseParallelOldGC).\n"); | |
1563 status = false; | |
1564 } | |
1565 if (UseConcMarkSweepGC) { | |
1566 jio_fprintf(defaultStream::error_stream(), | |
1567 "error: invalid argument combination.\n" | |
1568 "Allocation profiling (-Xaprof) cannot be used together with " | |
1569 "the CMS collector (-XX:+UseConcMarkSweepGC).\n"); | |
1570 status = false; | |
1571 } | |
1572 } | |
1573 | |
1574 if (CMSIncrementalMode) { | |
1575 if (!UseConcMarkSweepGC) { | |
1576 jio_fprintf(defaultStream::error_stream(), | |
1577 "error: invalid argument combination.\n" | |
1578 "The CMS collector (-XX:+UseConcMarkSweepGC) must be " | |
1579 "selected in order\nto use CMSIncrementalMode.\n"); | |
1580 status = false; | |
1581 } else { | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1582 status = status && verify_percentage(CMSIncrementalDutyCycle, |
0 | 1583 "CMSIncrementalDutyCycle"); |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1584 status = status && verify_percentage(CMSIncrementalDutyCycleMin, |
0 | 1585 "CMSIncrementalDutyCycleMin"); |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1586 status = status && verify_percentage(CMSIncrementalSafetyFactor, |
0 | 1587 "CMSIncrementalSafetyFactor"); |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1588 status = status && verify_percentage(CMSIncrementalOffset, |
0 | 1589 "CMSIncrementalOffset"); |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
1590 status = status && verify_percentage(CMSExpAvgFactor, |
0 | 1591 "CMSExpAvgFactor"); |
1592 // If it was not set on the command line, set | |
1593 // CMSInitiatingOccupancyFraction to 1 so icms can initiate cycles early. | |
1594 if (CMSInitiatingOccupancyFraction < 0) { | |
1595 FLAG_SET_DEFAULT(CMSInitiatingOccupancyFraction, 1); | |
1596 } | |
1597 } | |
1598 } | |
1599 | |
1600 // CMS space iteration, which FLSVerifyAllHeapreferences entails, | |
1601 // insists that we hold the requisite locks so that the iteration is | |
1602 // MT-safe. For the verification at start-up and shut-down, we don't | |
1603 // yet have a good way of acquiring and releasing these locks, | |
1604 // which are not visible at the CollectedHeap level. We want to | |
1605 // be able to acquire these locks and then do the iteration rather | |
1606 // than just disable the lock verification. This will be fixed under | |
1607 // bug 4788986. | |
1608 if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) { | |
1609 if (VerifyGCStartAt == 0) { | |
1610 warning("Heap verification at start-up disabled " | |
1611 "(due to current incompatibility with FLSVerifyAllHeapReferences)"); | |
1612 VerifyGCStartAt = 1; // Disable verification at start-up | |
1613 } | |
1614 if (VerifyBeforeExit) { | |
1615 warning("Heap verification at shutdown disabled " | |
1616 "(due to current incompatibility with FLSVerifyAllHeapReferences)"); | |
1617 VerifyBeforeExit = false; // Disable verification at shutdown | |
1618 } | |
1619 } | |
1620 | |
1621 // Note: only executed in non-PRODUCT mode | |
1622 if (!UseAsyncConcMarkSweepGC && | |
1623 (ExplicitGCInvokesConcurrent || | |
1624 ExplicitGCInvokesConcurrentAndUnloadsClasses)) { | |
1625 jio_fprintf(defaultStream::error_stream(), | |
1626 "error: +ExplictGCInvokesConcurrent[AndUnloadsClasses] conflicts" | |
1627 " with -UseAsyncConcMarkSweepGC"); | |
1628 status = false; | |
1629 } | |
1630 | |
1631 return status; | |
1632 } | |
1633 | |
1634 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore, | |
1635 const char* option_type) { | |
1636 if (ignore) return false; | |
1637 | |
1638 const char* spacer = " "; | |
1639 if (option_type == NULL) { | |
1640 option_type = ++spacer; // Set both to the empty string. | |
1641 } | |
1642 | |
1643 if (os::obsolete_option(option)) { | |
1644 jio_fprintf(defaultStream::error_stream(), | |
1645 "Obsolete %s%soption: %s\n", option_type, spacer, | |
1646 option->optionString); | |
1647 return false; | |
1648 } else { | |
1649 jio_fprintf(defaultStream::error_stream(), | |
1650 "Unrecognized %s%soption: %s\n", option_type, spacer, | |
1651 option->optionString); | |
1652 return true; | |
1653 } | |
1654 } | |
1655 | |
1656 static const char* user_assertion_options[] = { | |
1657 "-da", "-ea", "-disableassertions", "-enableassertions", 0 | |
1658 }; | |
1659 | |
1660 static const char* system_assertion_options[] = { | |
1661 "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0 | |
1662 }; | |
1663 | |
1664 // Return true if any of the strings in null-terminated array 'names' matches. | |
1665 // If tail_allowed is true, then the tail must begin with a colon; otherwise, | |
1666 // the option must match exactly. | |
1667 static bool match_option(const JavaVMOption* option, const char** names, const char** tail, | |
1668 bool tail_allowed) { | |
1669 for (/* empty */; *names != NULL; ++names) { | |
1670 if (match_option(option, *names, tail)) { | |
1671 if (**tail == '\0' || tail_allowed && **tail == ':') { | |
1672 return true; | |
1673 } | |
1674 } | |
1675 } | |
1676 return false; | |
1677 } | |
1678 | |
1679 Arguments::ArgsRange Arguments::parse_memory_size(const char* s, | |
1680 jlong* long_arg, | |
1681 jlong min_size) { | |
1682 if (!atomll(s, long_arg)) return arg_unreadable; | |
1683 return check_memory_size(*long_arg, min_size); | |
1684 } | |
1685 | |
1686 // Parse JavaVMInitArgs structure | |
1687 | |
1688 jint Arguments::parse_vm_init_args(const JavaVMInitArgs* args) { | |
1689 // For components of the system classpath. | |
1690 SysClassPath scp(Arguments::get_sysclasspath()); | |
1691 bool scp_assembly_required = false; | |
1692 | |
1693 // Save default settings for some mode flags | |
1694 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; | |
1695 Arguments::_UseOnStackReplacement = UseOnStackReplacement; | |
1696 Arguments::_ClipInlining = ClipInlining; | |
1697 Arguments::_BackgroundCompilation = BackgroundCompilation; | |
1698 Arguments::_Tier2CompileThreshold = Tier2CompileThreshold; | |
1699 | |
1700 // Parse JAVA_TOOL_OPTIONS environment variable (if present) | |
1701 jint result = parse_java_tool_options_environment_variable(&scp, &scp_assembly_required); | |
1702 if (result != JNI_OK) { | |
1703 return result; | |
1704 } | |
1705 | |
1706 // Parse JavaVMInitArgs structure passed in | |
1707 result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, COMMAND_LINE); | |
1708 if (result != JNI_OK) { | |
1709 return result; | |
1710 } | |
1711 | |
1712 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM) | |
1713 result = parse_java_options_environment_variable(&scp, &scp_assembly_required); | |
1714 if (result != JNI_OK) { | |
1715 return result; | |
1716 } | |
1717 | |
1718 // Do final processing now that all arguments have been parsed | |
1719 result = finalize_vm_init_args(&scp, scp_assembly_required); | |
1720 if (result != JNI_OK) { | |
1721 return result; | |
1722 } | |
1723 | |
1724 return JNI_OK; | |
1725 } | |
1726 | |
1727 | |
1728 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, | |
1729 SysClassPath* scp_p, | |
1730 bool* scp_assembly_required_p, | |
1731 FlagValueOrigin origin) { | |
1732 // Remaining part of option string | |
1733 const char* tail; | |
1734 | |
1735 // iterate over arguments | |
1736 for (int index = 0; index < args->nOptions; index++) { | |
1737 bool is_absolute_path = false; // for -agentpath vs -agentlib | |
1738 | |
1739 const JavaVMOption* option = args->options + index; | |
1740 | |
1741 if (!match_option(option, "-Djava.class.path", &tail) && | |
1742 !match_option(option, "-Dsun.java.command", &tail) && | |
1743 !match_option(option, "-Dsun.java.launcher", &tail)) { | |
1744 | |
1745 // add all jvm options to the jvm_args string. This string | |
1746 // is used later to set the java.vm.args PerfData string constant. | |
1747 // the -Djava.class.path and the -Dsun.java.command options are | |
1748 // omitted from jvm_args string as each have their own PerfData | |
1749 // string constant object. | |
1750 build_jvm_args(option->optionString); | |
1751 } | |
1752 | |
1753 // -verbose:[class/gc/jni] | |
1754 if (match_option(option, "-verbose", &tail)) { | |
1755 if (!strcmp(tail, ":class") || !strcmp(tail, "")) { | |
1756 FLAG_SET_CMDLINE(bool, TraceClassLoading, true); | |
1757 FLAG_SET_CMDLINE(bool, TraceClassUnloading, true); | |
1758 } else if (!strcmp(tail, ":gc")) { | |
1759 FLAG_SET_CMDLINE(bool, PrintGC, true); | |
1760 FLAG_SET_CMDLINE(bool, TraceClassUnloading, true); | |
1761 } else if (!strcmp(tail, ":jni")) { | |
1762 FLAG_SET_CMDLINE(bool, PrintJNIResolving, true); | |
1763 } | |
1764 // -da / -ea / -disableassertions / -enableassertions | |
1765 // These accept an optional class/package name separated by a colon, e.g., | |
1766 // -da:java.lang.Thread. | |
1767 } else if (match_option(option, user_assertion_options, &tail, true)) { | |
1768 bool enable = option->optionString[1] == 'e'; // char after '-' is 'e' | |
1769 if (*tail == '\0') { | |
1770 JavaAssertions::setUserClassDefault(enable); | |
1771 } else { | |
1772 assert(*tail == ':', "bogus match by match_option()"); | |
1773 JavaAssertions::addOption(tail + 1, enable); | |
1774 } | |
1775 // -dsa / -esa / -disablesystemassertions / -enablesystemassertions | |
1776 } else if (match_option(option, system_assertion_options, &tail, false)) { | |
1777 bool enable = option->optionString[1] == 'e'; // char after '-' is 'e' | |
1778 JavaAssertions::setSystemClassDefault(enable); | |
1779 // -bootclasspath: | |
1780 } else if (match_option(option, "-Xbootclasspath:", &tail)) { | |
1781 scp_p->reset_path(tail); | |
1782 *scp_assembly_required_p = true; | |
1783 // -bootclasspath/a: | |
1784 } else if (match_option(option, "-Xbootclasspath/a:", &tail)) { | |
1785 scp_p->add_suffix(tail); | |
1786 *scp_assembly_required_p = true; | |
1787 // -bootclasspath/p: | |
1788 } else if (match_option(option, "-Xbootclasspath/p:", &tail)) { | |
1789 scp_p->add_prefix(tail); | |
1790 *scp_assembly_required_p = true; | |
1791 // -Xrun | |
1792 } else if (match_option(option, "-Xrun", &tail)) { | |
1793 if(tail != NULL) { | |
1794 const char* pos = strchr(tail, ':'); | |
1795 size_t len = (pos == NULL) ? strlen(tail) : pos - tail; | |
1796 char* name = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len + 1), tail, len); | |
1797 name[len] = '\0'; | |
1798 | |
1799 char *options = NULL; | |
1800 if(pos != NULL) { | |
1801 size_t len2 = strlen(pos+1) + 1; // options start after ':'. Final zero must be copied. | |
1802 options = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len2), pos+1, len2); | |
1803 } | |
1804 #ifdef JVMTI_KERNEL | |
1805 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { | |
1806 warning("profiling and debugging agents are not supported with Kernel VM"); | |
1807 } else | |
1808 #endif // JVMTI_KERNEL | |
1809 add_init_library(name, options); | |
1810 } | |
1811 // -agentlib and -agentpath | |
1812 } else if (match_option(option, "-agentlib:", &tail) || | |
1813 (is_absolute_path = match_option(option, "-agentpath:", &tail))) { | |
1814 if(tail != NULL) { | |
1815 const char* pos = strchr(tail, '='); | |
1816 size_t len = (pos == NULL) ? strlen(tail) : pos - tail; | |
1817 char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1), tail, len); | |
1818 name[len] = '\0'; | |
1819 | |
1820 char *options = NULL; | |
1821 if(pos != NULL) { | |
1822 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1), pos + 1); | |
1823 } | |
1824 #ifdef JVMTI_KERNEL | |
1825 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { | |
1826 warning("profiling and debugging agents are not supported with Kernel VM"); | |
1827 } else | |
1828 #endif // JVMTI_KERNEL | |
1829 add_init_agent(name, options, is_absolute_path); | |
1830 | |
1831 } | |
1832 // -javaagent | |
1833 } else if (match_option(option, "-javaagent:", &tail)) { | |
1834 if(tail != NULL) { | |
1835 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1), tail); | |
1836 add_init_agent("instrument", options, false); | |
1837 } | |
1838 // -Xnoclassgc | |
1839 } else if (match_option(option, "-Xnoclassgc", &tail)) { | |
1840 FLAG_SET_CMDLINE(bool, ClassUnloading, false); | |
1841 // -Xincgc: i-CMS | |
1842 } else if (match_option(option, "-Xincgc", &tail)) { | |
1843 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true); | |
1844 FLAG_SET_CMDLINE(bool, CMSIncrementalMode, true); | |
1845 // -Xnoincgc: no i-CMS | |
1846 } else if (match_option(option, "-Xnoincgc", &tail)) { | |
1847 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false); | |
1848 FLAG_SET_CMDLINE(bool, CMSIncrementalMode, false); | |
1849 // -Xconcgc | |
1850 } else if (match_option(option, "-Xconcgc", &tail)) { | |
1851 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true); | |
1852 // -Xnoconcgc | |
1853 } else if (match_option(option, "-Xnoconcgc", &tail)) { | |
1854 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false); | |
1855 // -Xbatch | |
1856 } else if (match_option(option, "-Xbatch", &tail)) { | |
1857 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false); | |
1858 // -Xmn for compatibility with other JVM vendors | |
1859 } else if (match_option(option, "-Xmn", &tail)) { | |
1860 jlong long_initial_eden_size = 0; | |
1861 ArgsRange errcode = parse_memory_size(tail, &long_initial_eden_size, 1); | |
1862 if (errcode != arg_in_range) { | |
1863 jio_fprintf(defaultStream::error_stream(), | |
1864 "Invalid initial eden size: %s\n", option->optionString); | |
1865 describe_range_error(errcode); | |
1866 return JNI_EINVAL; | |
1867 } | |
1868 FLAG_SET_CMDLINE(uintx, MaxNewSize, (size_t) long_initial_eden_size); | |
1869 FLAG_SET_CMDLINE(uintx, NewSize, (size_t) long_initial_eden_size); | |
1870 // -Xms | |
1871 } else if (match_option(option, "-Xms", &tail)) { | |
1872 jlong long_initial_heap_size = 0; | |
1873 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 1); | |
1874 if (errcode != arg_in_range) { | |
1875 jio_fprintf(defaultStream::error_stream(), | |
1876 "Invalid initial heap size: %s\n", option->optionString); | |
1877 describe_range_error(errcode); | |
1878 return JNI_EINVAL; | |
1879 } | |
1880 set_initial_heap_size((size_t) long_initial_heap_size); | |
1881 // Currently the minimum size and the initial heap sizes are the same. | |
1882 set_min_heap_size(initial_heap_size()); | |
1883 // -Xmx | |
1884 } else if (match_option(option, "-Xmx", &tail)) { | |
1885 jlong long_max_heap_size = 0; | |
1886 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); | |
1887 if (errcode != arg_in_range) { | |
1888 jio_fprintf(defaultStream::error_stream(), | |
1889 "Invalid maximum heap size: %s\n", option->optionString); | |
1890 describe_range_error(errcode); | |
1891 return JNI_EINVAL; | |
1892 } | |
1893 FLAG_SET_CMDLINE(uintx, MaxHeapSize, (size_t) long_max_heap_size); | |
1894 // Xmaxf | |
1895 } else if (match_option(option, "-Xmaxf", &tail)) { | |
1896 int maxf = (int)(atof(tail) * 100); | |
1897 if (maxf < 0 || maxf > 100) { | |
1898 jio_fprintf(defaultStream::error_stream(), | |
1899 "Bad max heap free percentage size: %s\n", | |
1900 option->optionString); | |
1901 return JNI_EINVAL; | |
1902 } else { | |
1903 FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf); | |
1904 } | |
1905 // Xminf | |
1906 } else if (match_option(option, "-Xminf", &tail)) { | |
1907 int minf = (int)(atof(tail) * 100); | |
1908 if (minf < 0 || minf > 100) { | |
1909 jio_fprintf(defaultStream::error_stream(), | |
1910 "Bad min heap free percentage size: %s\n", | |
1911 option->optionString); | |
1912 return JNI_EINVAL; | |
1913 } else { | |
1914 FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf); | |
1915 } | |
1916 // -Xss | |
1917 } else if (match_option(option, "-Xss", &tail)) { | |
1918 jlong long_ThreadStackSize = 0; | |
1919 ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000); | |
1920 if (errcode != arg_in_range) { | |
1921 jio_fprintf(defaultStream::error_stream(), | |
1922 "Invalid thread stack size: %s\n", option->optionString); | |
1923 describe_range_error(errcode); | |
1924 return JNI_EINVAL; | |
1925 } | |
1926 // Internally track ThreadStackSize in units of 1024 bytes. | |
1927 FLAG_SET_CMDLINE(intx, ThreadStackSize, | |
1928 round_to((int)long_ThreadStackSize, K) / K); | |
1929 // -Xoss | |
1930 } else if (match_option(option, "-Xoss", &tail)) { | |
1931 // HotSpot does not have separate native and Java stacks, ignore silently for compatibility | |
1932 // -Xmaxjitcodesize | |
1933 } else if (match_option(option, "-Xmaxjitcodesize", &tail)) { | |
1934 jlong long_ReservedCodeCacheSize = 0; | |
1935 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, | |
1936 InitialCodeCacheSize); | |
1937 if (errcode != arg_in_range) { | |
1938 jio_fprintf(defaultStream::error_stream(), | |
1939 "Invalid maximum code cache size: %s\n", | |
1940 option->optionString); | |
1941 describe_range_error(errcode); | |
1942 return JNI_EINVAL; | |
1943 } | |
1944 FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize); | |
1945 // -green | |
1946 } else if (match_option(option, "-green", &tail)) { | |
1947 jio_fprintf(defaultStream::error_stream(), | |
1948 "Green threads support not available\n"); | |
1949 return JNI_EINVAL; | |
1950 // -native | |
1951 } else if (match_option(option, "-native", &tail)) { | |
1952 // HotSpot always uses native threads, ignore silently for compatibility | |
1953 // -Xsqnopause | |
1954 } else if (match_option(option, "-Xsqnopause", &tail)) { | |
1955 // EVM option, ignore silently for compatibility | |
1956 // -Xrs | |
1957 } else if (match_option(option, "-Xrs", &tail)) { | |
1958 // Classic/EVM option, new functionality | |
1959 FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true); | |
1960 } else if (match_option(option, "-Xusealtsigs", &tail)) { | |
1961 // change default internal VM signals used - lower case for back compat | |
1962 FLAG_SET_CMDLINE(bool, UseAltSigs, true); | |
1963 // -Xoptimize | |
1964 } else if (match_option(option, "-Xoptimize", &tail)) { | |
1965 // EVM option, ignore silently for compatibility | |
1966 // -Xprof | |
1967 } else if (match_option(option, "-Xprof", &tail)) { | |
1968 #ifndef FPROF_KERNEL | |
1969 _has_profile = true; | |
1970 #else // FPROF_KERNEL | |
1971 // do we have to exit? | |
1972 warning("Kernel VM does not support flat profiling."); | |
1973 #endif // FPROF_KERNEL | |
1974 // -Xaprof | |
1975 } else if (match_option(option, "-Xaprof", &tail)) { | |
1976 _has_alloc_profile = true; | |
1977 // -Xconcurrentio | |
1978 } else if (match_option(option, "-Xconcurrentio", &tail)) { | |
1979 FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true); | |
1980 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false); | |
1981 FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1); | |
1982 FLAG_SET_CMDLINE(bool, UseTLAB, false); | |
1983 FLAG_SET_CMDLINE(uintx, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation | |
1984 | |
1985 // -Xinternalversion | |
1986 } else if (match_option(option, "-Xinternalversion", &tail)) { | |
1987 jio_fprintf(defaultStream::output_stream(), "%s\n", | |
1988 VM_Version::internal_vm_info_string()); | |
1989 vm_exit(0); | |
1990 #ifndef PRODUCT | |
1991 // -Xprintflags | |
1992 } else if (match_option(option, "-Xprintflags", &tail)) { | |
1993 CommandLineFlags::printFlags(); | |
1994 vm_exit(0); | |
1995 #endif | |
1996 // -D | |
1997 } else if (match_option(option, "-D", &tail)) { | |
1998 if (!add_property(tail)) { | |
1999 return JNI_ENOMEM; | |
2000 } | |
2001 // Out of the box management support | |
2002 if (match_option(option, "-Dcom.sun.management", &tail)) { | |
2003 FLAG_SET_CMDLINE(bool, ManagementServer, true); | |
2004 } | |
2005 // -Xint | |
2006 } else if (match_option(option, "-Xint", &tail)) { | |
2007 set_mode_flags(_int); | |
2008 // -Xmixed | |
2009 } else if (match_option(option, "-Xmixed", &tail)) { | |
2010 set_mode_flags(_mixed); | |
2011 // -Xcomp | |
2012 } else if (match_option(option, "-Xcomp", &tail)) { | |
2013 // for testing the compiler; turn off all flags that inhibit compilation | |
2014 set_mode_flags(_comp); | |
2015 | |
2016 // -Xshare:dump | |
2017 } else if (match_option(option, "-Xshare:dump", &tail)) { | |
2018 #ifdef TIERED | |
2019 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true); | |
2020 set_mode_flags(_int); // Prevent compilation, which creates objects | |
2021 #elif defined(COMPILER2) | |
2022 vm_exit_during_initialization( | |
2023 "Dumping a shared archive is not supported on the Server JVM.", NULL); | |
2024 #elif defined(KERNEL) | |
2025 vm_exit_during_initialization( | |
2026 "Dumping a shared archive is not supported on the Kernel JVM.", NULL); | |
2027 #else | |
2028 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true); | |
2029 set_mode_flags(_int); // Prevent compilation, which creates objects | |
2030 #endif | |
2031 // -Xshare:on | |
2032 } else if (match_option(option, "-Xshare:on", &tail)) { | |
2033 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); | |
2034 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); | |
2035 #ifdef TIERED | |
2036 FLAG_SET_CMDLINE(bool, ForceSharedSpaces, true); | |
2037 #endif // TIERED | |
2038 // -Xshare:auto | |
2039 } else if (match_option(option, "-Xshare:auto", &tail)) { | |
2040 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); | |
2041 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false); | |
2042 // -Xshare:off | |
2043 } else if (match_option(option, "-Xshare:off", &tail)) { | |
2044 FLAG_SET_CMDLINE(bool, UseSharedSpaces, false); | |
2045 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false); | |
2046 | |
2047 // -Xverify | |
2048 } else if (match_option(option, "-Xverify", &tail)) { | |
2049 if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) { | |
2050 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true); | |
2051 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true); | |
2052 } else if (strcmp(tail, ":remote") == 0) { | |
2053 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false); | |
2054 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true); | |
2055 } else if (strcmp(tail, ":none") == 0) { | |
2056 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false); | |
2057 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false); | |
2058 } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) { | |
2059 return JNI_EINVAL; | |
2060 } | |
2061 // -Xdebug | |
2062 } else if (match_option(option, "-Xdebug", &tail)) { | |
2063 // note this flag has been used, then ignore | |
2064 set_xdebug_mode(true); | |
2065 // -Xnoagent | |
2066 } else if (match_option(option, "-Xnoagent", &tail)) { | |
2067 // For compatibility with classic. HotSpot refuses to load the old style agent.dll. | |
2068 } else if (match_option(option, "-Xboundthreads", &tail)) { | |
2069 // Bind user level threads to kernel threads (Solaris only) | |
2070 FLAG_SET_CMDLINE(bool, UseBoundThreads, true); | |
2071 } else if (match_option(option, "-Xloggc:", &tail)) { | |
2072 // Redirect GC output to the file. -Xloggc:<filename> | |
2073 // ostream_init_log(), when called will use this filename | |
2074 // to initialize a fileStream. | |
2075 _gc_log_filename = strdup(tail); | |
2076 FLAG_SET_CMDLINE(bool, PrintGC, true); | |
2077 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true); | |
2078 FLAG_SET_CMDLINE(bool, TraceClassUnloading, true); | |
2079 | |
2080 // JNI hooks | |
2081 } else if (match_option(option, "-Xcheck", &tail)) { | |
2082 if (!strcmp(tail, ":jni")) { | |
2083 CheckJNICalls = true; | |
2084 } else if (is_bad_option(option, args->ignoreUnrecognized, | |
2085 "check")) { | |
2086 return JNI_EINVAL; | |
2087 } | |
2088 } else if (match_option(option, "vfprintf", &tail)) { | |
2089 _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo); | |
2090 } else if (match_option(option, "exit", &tail)) { | |
2091 _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo); | |
2092 } else if (match_option(option, "abort", &tail)) { | |
2093 _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo); | |
2094 // -XX:+AggressiveHeap | |
2095 } else if (match_option(option, "-XX:+AggressiveHeap", &tail)) { | |
2096 | |
2097 // This option inspects the machine and attempts to set various | |
2098 // parameters to be optimal for long-running, memory allocation | |
2099 // intensive jobs. It is intended for machines with large | |
2100 // amounts of cpu and memory. | |
2101 | |
2102 // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit | |
2103 // VM, but we may not be able to represent the total physical memory | |
2104 // available (like having 8gb of memory on a box but using a 32bit VM). | |
2105 // Thus, we need to make sure we're using a julong for intermediate | |
2106 // calculations. | |
2107 julong initHeapSize; | |
2108 julong total_memory = os::physical_memory(); | |
2109 | |
2110 if (total_memory < (julong)256*M) { | |
2111 jio_fprintf(defaultStream::error_stream(), | |
2112 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n"); | |
2113 vm_exit(1); | |
2114 } | |
2115 | |
2116 // The heap size is half of available memory, or (at most) | |
2117 // all of possible memory less 160mb (leaving room for the OS | |
2118 // when using ISM). This is the maximum; because adaptive sizing | |
2119 // is turned on below, the actual space used may be smaller. | |
2120 | |
2121 initHeapSize = MIN2(total_memory / (julong)2, | |
2122 total_memory - (julong)160*M); | |
2123 | |
2124 // Make sure that if we have a lot of memory we cap the 32 bit | |
2125 // process space. The 64bit VM version of this function is a nop. | |
2126 initHeapSize = os::allocatable_physical_memory(initHeapSize); | |
2127 | |
2128 // The perm gen is separate but contiguous with the | |
2129 // object heap (and is reserved with it) so subtract it | |
2130 // from the heap size. | |
2131 if (initHeapSize > MaxPermSize) { | |
2132 initHeapSize = initHeapSize - MaxPermSize; | |
2133 } else { | |
2134 warning("AggressiveHeap and MaxPermSize values may conflict"); | |
2135 } | |
2136 | |
2137 if (FLAG_IS_DEFAULT(MaxHeapSize)) { | |
2138 FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize); | |
2139 set_initial_heap_size(MaxHeapSize); | |
2140 // Currently the minimum size and the initial heap sizes are the same. | |
2141 set_min_heap_size(initial_heap_size()); | |
2142 } | |
2143 if (FLAG_IS_DEFAULT(NewSize)) { | |
2144 // Make the young generation 3/8ths of the total heap. | |
2145 FLAG_SET_CMDLINE(uintx, NewSize, | |
2146 ((julong)MaxHeapSize / (julong)8) * (julong)3); | |
2147 FLAG_SET_CMDLINE(uintx, MaxNewSize, NewSize); | |
2148 } | |
2149 | |
2150 FLAG_SET_DEFAULT(UseLargePages, true); | |
2151 | |
2152 // Increase some data structure sizes for efficiency | |
2153 FLAG_SET_CMDLINE(uintx, BaseFootPrintEstimate, MaxHeapSize); | |
2154 FLAG_SET_CMDLINE(bool, ResizeTLAB, false); | |
2155 FLAG_SET_CMDLINE(uintx, TLABSize, 256*K); | |
2156 | |
2157 // See the OldPLABSize comment below, but replace 'after promotion' | |
2158 // with 'after copying'. YoungPLABSize is the size of the survivor | |
2159 // space per-gc-thread buffers. The default is 4kw. | |
2160 FLAG_SET_CMDLINE(uintx, YoungPLABSize, 256*K); // Note: this is in words | |
2161 | |
2162 // OldPLABSize is the size of the buffers in the old gen that | |
2163 // UseParallelGC uses to promote live data that doesn't fit in the | |
2164 // survivor spaces. At any given time, there's one for each gc thread. | |
2165 // The default size is 1kw. These buffers are rarely used, since the | |
2166 // survivor spaces are usually big enough. For specjbb, however, there | |
2167 // are occasions when there's lots of live data in the young gen | |
2168 // and we end up promoting some of it. We don't have a definite | |
2169 // explanation for why bumping OldPLABSize helps, but the theory | |
2170 // is that a bigger PLAB results in retaining something like the | |
2171 // original allocation order after promotion, which improves mutator | |
2172 // locality. A minor effect may be that larger PLABs reduce the | |
2173 // number of PLAB allocation events during gc. The value of 8kw | |
2174 // was arrived at by experimenting with specjbb. | |
2175 FLAG_SET_CMDLINE(uintx, OldPLABSize, 8*K); // Note: this is in words | |
2176 | |
2177 // CompilationPolicyChoice=0 causes the server compiler to adopt | |
2178 // a more conservative which-method-do-I-compile policy when one | |
2179 // of the counters maintained by the interpreter trips. The | |
2180 // result is reduced startup time and improved specjbb and | |
2181 // alacrity performance. Zero is the default, but we set it | |
2182 // explicitly here in case the default changes. | |
2183 // See runtime/compilationPolicy.*. | |
2184 FLAG_SET_CMDLINE(intx, CompilationPolicyChoice, 0); | |
2185 | |
2186 // Enable parallel GC and adaptive generation sizing | |
2187 FLAG_SET_CMDLINE(bool, UseParallelGC, true); | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2188 FLAG_SET_DEFAULT(ParallelGCThreads, |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2189 Abstract_VM_Version::parallel_worker_threads()); |
0 | 2190 |
2191 // Encourage steady state memory management | |
2192 FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100); | |
2193 | |
2194 // This appears to improve mutator locality | |
2195 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); | |
2196 | |
2197 // Get around early Solaris scheduling bug | |
2198 // (affinity vs other jobs on system) | |
2199 // but disallow DR and offlining (5008695). | |
2200 FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true); | |
2201 | |
2202 } else if (match_option(option, "-XX:+NeverTenure", &tail)) { | |
2203 // The last option must always win. | |
2204 FLAG_SET_CMDLINE(bool, AlwaysTenure, false); | |
2205 FLAG_SET_CMDLINE(bool, NeverTenure, true); | |
2206 } else if (match_option(option, "-XX:+AlwaysTenure", &tail)) { | |
2207 // The last option must always win. | |
2208 FLAG_SET_CMDLINE(bool, NeverTenure, false); | |
2209 FLAG_SET_CMDLINE(bool, AlwaysTenure, true); | |
2210 } else if (match_option(option, "-XX:+CMSPermGenSweepingEnabled", &tail) || | |
2211 match_option(option, "-XX:-CMSPermGenSweepingEnabled", &tail)) { | |
2212 jio_fprintf(defaultStream::error_stream(), | |
2213 "Please use CMSClassUnloadingEnabled in place of " | |
2214 "CMSPermGenSweepingEnabled in the future\n"); | |
2215 } else if (match_option(option, "-XX:+UseGCTimeLimit", &tail)) { | |
2216 FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, true); | |
2217 jio_fprintf(defaultStream::error_stream(), | |
2218 "Please use -XX:+UseGCOverheadLimit in place of " | |
2219 "-XX:+UseGCTimeLimit in the future\n"); | |
2220 } else if (match_option(option, "-XX:-UseGCTimeLimit", &tail)) { | |
2221 FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, false); | |
2222 jio_fprintf(defaultStream::error_stream(), | |
2223 "Please use -XX:-UseGCOverheadLimit in place of " | |
2224 "-XX:-UseGCTimeLimit in the future\n"); | |
2225 // The TLE options are for compatibility with 1.3 and will be | |
2226 // removed without notice in a future release. These options | |
2227 // are not to be documented. | |
2228 } else if (match_option(option, "-XX:MaxTLERatio=", &tail)) { | |
2229 // No longer used. | |
2230 } else if (match_option(option, "-XX:+ResizeTLE", &tail)) { | |
2231 FLAG_SET_CMDLINE(bool, ResizeTLAB, true); | |
2232 } else if (match_option(option, "-XX:-ResizeTLE", &tail)) { | |
2233 FLAG_SET_CMDLINE(bool, ResizeTLAB, false); | |
2234 } else if (match_option(option, "-XX:+PrintTLE", &tail)) { | |
2235 FLAG_SET_CMDLINE(bool, PrintTLAB, true); | |
2236 } else if (match_option(option, "-XX:-PrintTLE", &tail)) { | |
2237 FLAG_SET_CMDLINE(bool, PrintTLAB, false); | |
2238 } else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) { | |
2239 // No longer used. | |
2240 } else if (match_option(option, "-XX:TLESize=", &tail)) { | |
2241 jlong long_tlab_size = 0; | |
2242 ArgsRange errcode = parse_memory_size(tail, &long_tlab_size, 1); | |
2243 if (errcode != arg_in_range) { | |
2244 jio_fprintf(defaultStream::error_stream(), | |
2245 "Invalid TLAB size: %s\n", option->optionString); | |
2246 describe_range_error(errcode); | |
2247 return JNI_EINVAL; | |
2248 } | |
2249 FLAG_SET_CMDLINE(uintx, TLABSize, long_tlab_size); | |
2250 } else if (match_option(option, "-XX:TLEThreadRatio=", &tail)) { | |
2251 // No longer used. | |
2252 } else if (match_option(option, "-XX:+UseTLE", &tail)) { | |
2253 FLAG_SET_CMDLINE(bool, UseTLAB, true); | |
2254 } else if (match_option(option, "-XX:-UseTLE", &tail)) { | |
2255 FLAG_SET_CMDLINE(bool, UseTLAB, false); | |
2256 SOLARIS_ONLY( | |
2257 } else if (match_option(option, "-XX:+UsePermISM", &tail)) { | |
2258 warning("-XX:+UsePermISM is obsolete."); | |
2259 FLAG_SET_CMDLINE(bool, UseISM, true); | |
2260 } else if (match_option(option, "-XX:-UsePermISM", &tail)) { | |
2261 FLAG_SET_CMDLINE(bool, UseISM, false); | |
2262 ) | |
2263 } else if (match_option(option, "-XX:+DisplayVMOutputToStderr", &tail)) { | |
2264 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false); | |
2265 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true); | |
2266 } else if (match_option(option, "-XX:+DisplayVMOutputToStdout", &tail)) { | |
2267 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false); | |
2268 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true); | |
2269 } else if (match_option(option, "-XX:+ExtendedDTraceProbes", &tail)) { | |
2270 #ifdef SOLARIS | |
2271 FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true); | |
2272 FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true); | |
2273 FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true); | |
2274 FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true); | |
2275 #else // ndef SOLARIS | |
2276 jio_fprintf(defaultStream::error_stream(), | |
2277 "ExtendedDTraceProbes flag is only applicable on Solaris\n"); | |
2278 return JNI_EINVAL; | |
2279 #endif // ndef SOLARIS | |
2280 } else | |
2281 #ifdef ASSERT | |
2282 if (match_option(option, "-XX:+FullGCALot", &tail)) { | |
2283 FLAG_SET_CMDLINE(bool, FullGCALot, true); | |
2284 // disable scavenge before parallel mark-compact | |
2285 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); | |
2286 } else | |
2287 #endif | |
2288 if (match_option(option, "-XX:ParCMSPromoteBlocksToClaim=", &tail)) { | |
2289 julong cms_blocks_to_claim = (julong)atol(tail); | |
2290 FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim); | |
2291 jio_fprintf(defaultStream::error_stream(), | |
2292 "Please use -XX:CMSParPromoteBlocksToClaim in place of " | |
2293 "-XX:ParCMSPromoteBlocksToClaim in the future\n"); | |
2294 } else | |
2295 if (match_option(option, "-XX:ParallelGCOldGenAllocBufferSize=", &tail)) { | |
2296 jlong old_plab_size = 0; | |
2297 ArgsRange errcode = parse_memory_size(tail, &old_plab_size, 1); | |
2298 if (errcode != arg_in_range) { | |
2299 jio_fprintf(defaultStream::error_stream(), | |
2300 "Invalid old PLAB size: %s\n", option->optionString); | |
2301 describe_range_error(errcode); | |
2302 return JNI_EINVAL; | |
2303 } | |
2304 FLAG_SET_CMDLINE(uintx, OldPLABSize, (julong)old_plab_size); | |
2305 jio_fprintf(defaultStream::error_stream(), | |
2306 "Please use -XX:OldPLABSize in place of " | |
2307 "-XX:ParallelGCOldGenAllocBufferSize in the future\n"); | |
2308 } else | |
2309 if (match_option(option, "-XX:ParallelGCToSpaceAllocBufferSize=", &tail)) { | |
2310 jlong young_plab_size = 0; | |
2311 ArgsRange errcode = parse_memory_size(tail, &young_plab_size, 1); | |
2312 if (errcode != arg_in_range) { | |
2313 jio_fprintf(defaultStream::error_stream(), | |
2314 "Invalid young PLAB size: %s\n", option->optionString); | |
2315 describe_range_error(errcode); | |
2316 return JNI_EINVAL; | |
2317 } | |
2318 FLAG_SET_CMDLINE(uintx, YoungPLABSize, (julong)young_plab_size); | |
2319 jio_fprintf(defaultStream::error_stream(), | |
2320 "Please use -XX:YoungPLABSize in place of " | |
2321 "-XX:ParallelGCToSpaceAllocBufferSize in the future\n"); | |
2322 } else | |
2323 if (match_option(option, "-XX:", &tail)) { // -XX:xxxx | |
2324 // Skip -XX:Flags= since that case has already been handled | |
2325 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) { | |
2326 if (!process_argument(tail, args->ignoreUnrecognized, origin)) { | |
2327 return JNI_EINVAL; | |
2328 } | |
2329 } | |
2330 // Unknown option | |
2331 } else if (is_bad_option(option, args->ignoreUnrecognized)) { | |
2332 return JNI_ERR; | |
2333 } | |
2334 } | |
449
171e581e8161
6554406: Change switch UseVMInterruptibleIO default to false (sol)
xlu
parents:
420
diff
changeset
|
2335 // Change the default value for flags which have different default values |
171e581e8161
6554406: Change switch UseVMInterruptibleIO default to false (sol)
xlu
parents:
420
diff
changeset
|
2336 // when working with older JDKs. |
171e581e8161
6554406: Change switch UseVMInterruptibleIO default to false (sol)
xlu
parents:
420
diff
changeset
|
2337 if (JDK_Version::current().compare_major(6) <= 0 && |
171e581e8161
6554406: Change switch UseVMInterruptibleIO default to false (sol)
xlu
parents:
420
diff
changeset
|
2338 FLAG_IS_DEFAULT(UseVMInterruptibleIO)) { |
171e581e8161
6554406: Change switch UseVMInterruptibleIO default to false (sol)
xlu
parents:
420
diff
changeset
|
2339 FLAG_SET_DEFAULT(UseVMInterruptibleIO, true); |
171e581e8161
6554406: Change switch UseVMInterruptibleIO default to false (sol)
xlu
parents:
420
diff
changeset
|
2340 } |
0 | 2341 return JNI_OK; |
2342 } | |
2343 | |
2344 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) { | |
2345 // This must be done after all -D arguments have been processed. | |
2346 scp_p->expand_endorsed(); | |
2347 | |
2348 if (scp_assembly_required || scp_p->get_endorsed() != NULL) { | |
2349 // Assemble the bootclasspath elements into the final path. | |
2350 Arguments::set_sysclasspath(scp_p->combined_path()); | |
2351 } | |
2352 | |
2353 // This must be done after all arguments have been processed. | |
2354 // java_compiler() true means set to "NONE" or empty. | |
2355 if (java_compiler() && !xdebug_mode()) { | |
2356 // For backwards compatibility, we switch to interpreted mode if | |
2357 // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was | |
2358 // not specified. | |
2359 set_mode_flags(_int); | |
2360 } | |
2361 if (CompileThreshold == 0) { | |
2362 set_mode_flags(_int); | |
2363 } | |
2364 | |
2365 #ifdef TIERED | |
2366 // If we are using tiered compilation in the tiered vm then c1 will | |
2367 // do the profiling and we don't want to waste that time in the | |
2368 // interpreter. | |
2369 if (TieredCompilation) { | |
2370 ProfileInterpreter = false; | |
2371 } else { | |
2372 // Since we are running vanilla server we must adjust the compile threshold | |
2373 // unless the user has already adjusted it because the default threshold assumes | |
2374 // we will run tiered. | |
2375 | |
2376 if (FLAG_IS_DEFAULT(CompileThreshold)) { | |
2377 CompileThreshold = Tier2CompileThreshold; | |
2378 } | |
2379 } | |
2380 #endif // TIERED | |
2381 | |
2382 #ifndef COMPILER2 | |
2383 // Don't degrade server performance for footprint | |
2384 if (FLAG_IS_DEFAULT(UseLargePages) && | |
2385 MaxHeapSize < LargePageHeapSizeThreshold) { | |
2386 // No need for large granularity pages w/small heaps. | |
2387 // Note that large pages are enabled/disabled for both the | |
2388 // Java heap and the code cache. | |
2389 FLAG_SET_DEFAULT(UseLargePages, false); | |
2390 SOLARIS_ONLY(FLAG_SET_DEFAULT(UseMPSS, false)); | |
2391 SOLARIS_ONLY(FLAG_SET_DEFAULT(UseISM, false)); | |
2392 } | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2393 |
0 | 2394 #else |
2395 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) { | |
2396 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1); | |
2397 } | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2398 // Temporary disable bulk zeroing reduction with G1. See CR 6627983. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2399 if (UseG1GC) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2400 FLAG_SET_DEFAULT(ReduceBulkZeroing, false); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2401 } |
0 | 2402 #endif |
2403 | |
2404 if (!check_vm_args_consistency()) { | |
2405 return JNI_ERR; | |
2406 } | |
2407 | |
2408 return JNI_OK; | |
2409 } | |
2410 | |
2411 jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { | |
2412 return parse_options_environment_variable("_JAVA_OPTIONS", scp_p, | |
2413 scp_assembly_required_p); | |
2414 } | |
2415 | |
2416 jint Arguments::parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) { | |
2417 return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p, | |
2418 scp_assembly_required_p); | |
2419 } | |
2420 | |
2421 jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) { | |
2422 const int N_MAX_OPTIONS = 64; | |
2423 const int OPTION_BUFFER_SIZE = 1024; | |
2424 char buffer[OPTION_BUFFER_SIZE]; | |
2425 | |
2426 // The variable will be ignored if it exceeds the length of the buffer. | |
2427 // Don't check this variable if user has special privileges | |
2428 // (e.g. unix su command). | |
2429 if (os::getenv(name, buffer, sizeof(buffer)) && | |
2430 !os::have_special_privileges()) { | |
2431 JavaVMOption options[N_MAX_OPTIONS]; // Construct option array | |
2432 jio_fprintf(defaultStream::error_stream(), | |
2433 "Picked up %s: %s\n", name, buffer); | |
2434 char* rd = buffer; // pointer to the input string (rd) | |
2435 int i; | |
2436 for (i = 0; i < N_MAX_OPTIONS;) { // repeat for all options in the input string | |
2437 while (isspace(*rd)) rd++; // skip whitespace | |
2438 if (*rd == 0) break; // we re done when the input string is read completely | |
2439 | |
2440 // The output, option string, overwrites the input string. | |
2441 // Because of quoting, the pointer to the option string (wrt) may lag the pointer to | |
2442 // input string (rd). | |
2443 char* wrt = rd; | |
2444 | |
2445 options[i++].optionString = wrt; // Fill in option | |
2446 while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL | |
2447 if (*rd == '\'' || *rd == '"') { // handle a quoted string | |
2448 int quote = *rd; // matching quote to look for | |
2449 rd++; // don't copy open quote | |
2450 while (*rd != quote) { // include everything (even spaces) up until quote | |
2451 if (*rd == 0) { // string termination means unmatched string | |
2452 jio_fprintf(defaultStream::error_stream(), | |
2453 "Unmatched quote in %s\n", name); | |
2454 return JNI_ERR; | |
2455 } | |
2456 *wrt++ = *rd++; // copy to option string | |
2457 } | |
2458 rd++; // don't copy close quote | |
2459 } else { | |
2460 *wrt++ = *rd++; // copy to option string | |
2461 } | |
2462 } | |
2463 // Need to check if we're done before writing a NULL, | |
2464 // because the write could be to the byte that rd is pointing to. | |
2465 if (*rd++ == 0) { | |
2466 *wrt = 0; | |
2467 break; | |
2468 } | |
2469 *wrt = 0; // Zero terminate option | |
2470 } | |
2471 // Construct JavaVMInitArgs structure and parse as if it was part of the command line | |
2472 JavaVMInitArgs vm_args; | |
2473 vm_args.version = JNI_VERSION_1_2; | |
2474 vm_args.options = options; | |
2475 vm_args.nOptions = i; | |
2476 vm_args.ignoreUnrecognized = false; | |
2477 | |
2478 if (PrintVMOptions) { | |
2479 const char* tail; | |
2480 for (int i = 0; i < vm_args.nOptions; i++) { | |
2481 const JavaVMOption *option = vm_args.options + i; | |
2482 if (match_option(option, "-XX:", &tail)) { | |
2483 logOption(tail); | |
2484 } | |
2485 } | |
2486 } | |
2487 | |
2488 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ENVIRON_VAR)); | |
2489 } | |
2490 return JNI_OK; | |
2491 } | |
2492 | |
2493 // Parse entry point called from JNI_CreateJavaVM | |
2494 | |
2495 jint Arguments::parse(const JavaVMInitArgs* args) { | |
2496 | |
2497 // Sharing support | |
2498 // Construct the path to the archive | |
2499 char jvm_path[JVM_MAXPATHLEN]; | |
2500 os::jvm_path(jvm_path, sizeof(jvm_path)); | |
2501 #ifdef TIERED | |
2502 if (strstr(jvm_path, "client") != NULL) { | |
2503 force_client_mode = true; | |
2504 } | |
2505 #endif // TIERED | |
2506 char *end = strrchr(jvm_path, *os::file_separator()); | |
2507 if (end != NULL) *end = '\0'; | |
2508 char *shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(jvm_path) + | |
2509 strlen(os::file_separator()) + 20); | |
2510 if (shared_archive_path == NULL) return JNI_ENOMEM; | |
2511 strcpy(shared_archive_path, jvm_path); | |
2512 strcat(shared_archive_path, os::file_separator()); | |
2513 strcat(shared_archive_path, "classes"); | |
2514 DEBUG_ONLY(strcat(shared_archive_path, "_g");) | |
2515 strcat(shared_archive_path, ".jsa"); | |
2516 SharedArchivePath = shared_archive_path; | |
2517 | |
2518 // Remaining part of option string | |
2519 const char* tail; | |
2520 | |
2521 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. | |
2522 bool settings_file_specified = false; | |
2523 int index; | |
2524 for (index = 0; index < args->nOptions; index++) { | |
2525 const JavaVMOption *option = args->options + index; | |
2526 if (match_option(option, "-XX:Flags=", &tail)) { | |
2527 if (!process_settings_file(tail, true, args->ignoreUnrecognized)) { | |
2528 return JNI_EINVAL; | |
2529 } | |
2530 settings_file_specified = true; | |
2531 } | |
2532 if (match_option(option, "-XX:+PrintVMOptions", &tail)) { | |
2533 PrintVMOptions = true; | |
2534 } | |
253
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
196
diff
changeset
|
2535 if (match_option(option, "-XX:-PrintVMOptions", &tail)) { |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
196
diff
changeset
|
2536 PrintVMOptions = false; |
b0fe4deeb9fb
6726999: nsk/stress/jck12a/jck12a010 assert(n != null,"Bad immediate dominator info.")
kvn
parents:
196
diff
changeset
|
2537 } |
0 | 2538 } |
2539 | |
2540 // Parse default .hotspotrc settings file | |
2541 if (!settings_file_specified) { | |
2542 if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) { | |
2543 return JNI_EINVAL; | |
2544 } | |
2545 } | |
2546 | |
2547 if (PrintVMOptions) { | |
2548 for (index = 0; index < args->nOptions; index++) { | |
2549 const JavaVMOption *option = args->options + index; | |
2550 if (match_option(option, "-XX:", &tail)) { | |
2551 logOption(tail); | |
2552 } | |
2553 } | |
2554 } | |
2555 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2556 |
0 | 2557 // Parse JavaVMInitArgs structure passed in, as well as JAVA_TOOL_OPTIONS and _JAVA_OPTIONS |
2558 jint result = parse_vm_init_args(args); | |
2559 if (result != JNI_OK) { | |
2560 return result; | |
2561 } | |
2562 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2563 // These are hacks until G1 is fully supported and tested |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2564 // but lets you force -XX:+UseG1GC in PRT and get it where it (mostly) works |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2565 if (UseG1GC) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2566 if (UseConcMarkSweepGC || UseParNewGC || UseParallelGC || UseParallelOldGC || UseSerialGC) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2567 #ifndef PRODUCT |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2568 tty->print_cr("-XX:+UseG1GC is incompatible with other collectors, using UseG1GC"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2569 #endif // PRODUCT |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2570 UseConcMarkSweepGC = false; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2571 UseParNewGC = false; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2572 UseParallelGC = false; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2573 UseParallelOldGC = false; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2574 UseSerialGC = false; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2575 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2576 no_shared_spaces(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2577 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2578 |
0 | 2579 #ifndef PRODUCT |
2580 if (TraceBytecodesAt != 0) { | |
2581 TraceBytecodes = true; | |
2582 } | |
2583 if (CountCompiledCalls) { | |
2584 if (UseCounterDecay) { | |
2585 warning("UseCounterDecay disabled because CountCalls is set"); | |
2586 UseCounterDecay = false; | |
2587 } | |
2588 } | |
2589 #endif // PRODUCT | |
2590 | |
2591 if (PrintGCDetails) { | |
2592 // Turn on -verbose:gc options as well | |
2593 PrintGC = true; | |
2594 if (FLAG_IS_DEFAULT(TraceClassUnloading)) { | |
2595 TraceClassUnloading = true; | |
2596 } | |
2597 } | |
2598 | |
2599 #ifdef SERIALGC | |
2600 set_serial_gc_flags(); | |
2601 #endif // SERIALGC | |
2602 #ifdef KERNEL | |
2603 no_shared_spaces(); | |
2604 #endif // KERNEL | |
2605 | |
2606 // Set flags based on ergonomics. | |
2607 set_ergonomics_flags(); | |
2608 | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2609 // Check the GC selections again. |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2610 if (!check_gc_consistency()) { |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2611 return JNI_EINVAL; |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2612 } |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2613 |
13
183f41cf8bfe
6557851: CMS: ergonomics defaults are not set with FLAG_SET_ERGO
jmasa
parents:
10
diff
changeset
|
2614 if (UseParallelGC || UseParallelOldGC) { |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2615 // Set some flags for ParallelGC if needed. |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2616 set_parallel_gc_flags(); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2617 } else if (UseConcMarkSweepGC) { |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2618 // Set some flags for CMS |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2619 set_cms_and_parnew_gc_flags(); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2620 } else if (UseParNewGC) { |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2621 // Set some flags for ParNew |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2622 set_parnew_gc_flags(); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2623 } |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2624 // Temporary; make the "if" an "else-if" before |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2625 // we integrate G1. XXX |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2626 if (UseG1GC) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2627 // Set some flags for garbage-first, if needed. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2628 set_g1_gc_flags(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
135
diff
changeset
|
2629 } |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2630 |
0 | 2631 #ifdef SERIALGC |
2632 assert(verify_serial_gc_flags(), "SerialGC unset"); | |
2633 #endif // SERIALGC | |
2634 | |
2635 // Set bytecode rewriting flags | |
2636 set_bytecode_flags(); | |
2637 | |
2638 // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled. | |
2639 set_aggressive_opts_flags(); | |
2640 | |
2641 #ifdef CC_INTERP | |
2642 // Biased locking is not implemented with c++ interpreter | |
2643 FLAG_SET_DEFAULT(UseBiasedLocking, false); | |
2644 #endif /* CC_INTERP */ | |
2645 | |
420
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
416
diff
changeset
|
2646 #ifdef COMPILER2 |
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
416
diff
changeset
|
2647 if (!UseBiasedLocking || EmitSync != 0) { |
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
416
diff
changeset
|
2648 UseOptoBiasInlining = false; |
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
416
diff
changeset
|
2649 } |
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
416
diff
changeset
|
2650 #endif |
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
416
diff
changeset
|
2651 |
0 | 2652 if (PrintCommandLineFlags) { |
2653 CommandLineFlags::printSetFlags(); | |
2654 } | |
2655 | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2656 #ifdef ASSERT |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2657 if (PrintFlagsFinal) { |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2658 CommandLineFlags::printFlags(); |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2659 } |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2660 #endif |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
2661 |
0 | 2662 return JNI_OK; |
2663 } | |
2664 | |
2665 int Arguments::PropertyList_count(SystemProperty* pl) { | |
2666 int count = 0; | |
2667 while(pl != NULL) { | |
2668 count++; | |
2669 pl = pl->next(); | |
2670 } | |
2671 return count; | |
2672 } | |
2673 | |
2674 const char* Arguments::PropertyList_get_value(SystemProperty *pl, const char* key) { | |
2675 assert(key != NULL, "just checking"); | |
2676 SystemProperty* prop; | |
2677 for (prop = pl; prop != NULL; prop = prop->next()) { | |
2678 if (strcmp(key, prop->key()) == 0) return prop->value(); | |
2679 } | |
2680 return NULL; | |
2681 } | |
2682 | |
2683 const char* Arguments::PropertyList_get_key_at(SystemProperty *pl, int index) { | |
2684 int count = 0; | |
2685 const char* ret_val = NULL; | |
2686 | |
2687 while(pl != NULL) { | |
2688 if(count >= index) { | |
2689 ret_val = pl->key(); | |
2690 break; | |
2691 } | |
2692 count++; | |
2693 pl = pl->next(); | |
2694 } | |
2695 | |
2696 return ret_val; | |
2697 } | |
2698 | |
2699 char* Arguments::PropertyList_get_value_at(SystemProperty* pl, int index) { | |
2700 int count = 0; | |
2701 char* ret_val = NULL; | |
2702 | |
2703 while(pl != NULL) { | |
2704 if(count >= index) { | |
2705 ret_val = pl->value(); | |
2706 break; | |
2707 } | |
2708 count++; | |
2709 pl = pl->next(); | |
2710 } | |
2711 | |
2712 return ret_val; | |
2713 } | |
2714 | |
2715 void Arguments::PropertyList_add(SystemProperty** plist, SystemProperty *new_p) { | |
2716 SystemProperty* p = *plist; | |
2717 if (p == NULL) { | |
2718 *plist = new_p; | |
2719 } else { | |
2720 while (p->next() != NULL) { | |
2721 p = p->next(); | |
2722 } | |
2723 p->set_next(new_p); | |
2724 } | |
2725 } | |
2726 | |
2727 void Arguments::PropertyList_add(SystemProperty** plist, const char* k, char* v) { | |
2728 if (plist == NULL) | |
2729 return; | |
2730 | |
2731 SystemProperty* new_p = new SystemProperty(k, v, true); | |
2732 PropertyList_add(plist, new_p); | |
2733 } | |
2734 | |
2735 // This add maintains unique property key in the list. | |
2736 void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, char* v) { | |
2737 if (plist == NULL) | |
2738 return; | |
2739 | |
2740 // If property key exist then update with new value. | |
2741 SystemProperty* prop; | |
2742 for (prop = *plist; prop != NULL; prop = prop->next()) { | |
2743 if (strcmp(k, prop->key()) == 0) { | |
2744 prop->set_value(v); | |
2745 return; | |
2746 } | |
2747 } | |
2748 | |
2749 PropertyList_add(plist, k, v); | |
2750 } | |
2751 | |
2752 #ifdef KERNEL | |
2753 char *Arguments::get_kernel_properties() { | |
2754 // Find properties starting with kernel and append them to string | |
2755 // We need to find out how long they are first because the URL's that they | |
2756 // might point to could get long. | |
2757 int length = 0; | |
2758 SystemProperty* prop; | |
2759 for (prop = _system_properties; prop != NULL; prop = prop->next()) { | |
2760 if (strncmp(prop->key(), "kernel.", 7 ) == 0) { | |
2761 length += (strlen(prop->key()) + strlen(prop->value()) + 5); // "-D =" | |
2762 } | |
2763 } | |
2764 // Add one for null terminator. | |
2765 char *props = AllocateHeap(length + 1, "get_kernel_properties"); | |
2766 if (length != 0) { | |
2767 int pos = 0; | |
2768 for (prop = _system_properties; prop != NULL; prop = prop->next()) { | |
2769 if (strncmp(prop->key(), "kernel.", 7 ) == 0) { | |
2770 jio_snprintf(&props[pos], length-pos, | |
2771 "-D%s=%s ", prop->key(), prop->value()); | |
2772 pos = strlen(props); | |
2773 } | |
2774 } | |
2775 } | |
2776 // null terminate props in case of null | |
2777 props[length] = '\0'; | |
2778 return props; | |
2779 } | |
2780 #endif // KERNEL | |
2781 | |
2782 // Copies src into buf, replacing "%%" with "%" and "%p" with pid | |
2783 // Returns true if all of the source pointed by src has been copied over to | |
2784 // the destination buffer pointed by buf. Otherwise, returns false. | |
2785 // Notes: | |
2786 // 1. If the length (buflen) of the destination buffer excluding the | |
2787 // NULL terminator character is not long enough for holding the expanded | |
2788 // pid characters, it also returns false instead of returning the partially | |
2789 // expanded one. | |
2790 // 2. The passed in "buflen" should be large enough to hold the null terminator. | |
2791 bool Arguments::copy_expand_pid(const char* src, size_t srclen, | |
2792 char* buf, size_t buflen) { | |
2793 const char* p = src; | |
2794 char* b = buf; | |
2795 const char* src_end = &src[srclen]; | |
2796 char* buf_end = &buf[buflen - 1]; | |
2797 | |
2798 while (p < src_end && b < buf_end) { | |
2799 if (*p == '%') { | |
2800 switch (*(++p)) { | |
2801 case '%': // "%%" ==> "%" | |
2802 *b++ = *p++; | |
2803 break; | |
2804 case 'p': { // "%p" ==> current process id | |
2805 // buf_end points to the character before the last character so | |
2806 // that we could write '\0' to the end of the buffer. | |
2807 size_t buf_sz = buf_end - b + 1; | |
2808 int ret = jio_snprintf(b, buf_sz, "%d", os::current_process_id()); | |
2809 | |
2810 // if jio_snprintf fails or the buffer is not long enough to hold | |
2811 // the expanded pid, returns false. | |
2812 if (ret < 0 || ret >= (int)buf_sz) { | |
2813 return false; | |
2814 } else { | |
2815 b += ret; | |
2816 assert(*b == '\0', "fail in copy_expand_pid"); | |
2817 if (p == src_end && b == buf_end + 1) { | |
2818 // reach the end of the buffer. | |
2819 return true; | |
2820 } | |
2821 } | |
2822 p++; | |
2823 break; | |
2824 } | |
2825 default : | |
2826 *b++ = '%'; | |
2827 } | |
2828 } else { | |
2829 *b++ = *p++; | |
2830 } | |
2831 } | |
2832 *b = '\0'; | |
2833 return (p == src_end); // return false if not all of the source was copied | |
2834 } |