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