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