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