Mercurial > hg > graal-jvmci-8
annotate src/share/vm/runtime/arguments.hpp @ 94:0834225a7916
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
Summary: The option CMSInitiatingPermOccupancyFraction now controls perm triggering threshold. Even though the actual value of the threshold has not yet been changed, so there is no change in policy, we now have the infrastructure in place for dynamically deciding when to collect the perm gen, an issue that will be addressed in the near future.
Reviewed-by: jmasa
author | ysr |
---|---|
date | Sun, 16 Mar 2008 21:57:25 -0700 |
parents | 28372612af5e |
children | d1605aabd0a1 37f87013dfd8 |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. | |
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 // Arguments parses the command line and recognizes options | |
26 | |
27 // Invocation API hook typedefs (these should really be defined in jni.hpp) | |
28 extern "C" { | |
29 typedef void (JNICALL *abort_hook_t)(void); | |
30 typedef void (JNICALL *exit_hook_t)(jint code); | |
31 typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args); | |
32 } | |
33 | |
34 // Forward declarations | |
35 | |
36 class SysClassPath; | |
37 | |
38 // Element describing System and User (-Dkey=value flags) defined property. | |
39 | |
40 class SystemProperty: public CHeapObj { | |
41 private: | |
42 char* _key; | |
43 char* _value; | |
44 SystemProperty* _next; | |
45 bool _writeable; | |
46 bool writeable() { return _writeable; } | |
47 | |
48 public: | |
49 // Accessors | |
50 const char* key() const { return _key; } | |
51 char* value() const { return _value; } | |
52 SystemProperty* next() const { return _next; } | |
53 void set_next(SystemProperty* next) { _next = next; } | |
54 bool set_value(char *value) { | |
55 if (writeable()) { | |
56 if (_value != NULL) { | |
57 FreeHeap(_value); | |
58 } | |
59 _value = AllocateHeap(strlen(value)+1); | |
60 if (_value != NULL) { | |
61 strcpy(_value, value); | |
62 } | |
63 return true; | |
64 } | |
65 return false; | |
66 } | |
67 | |
68 void append_value(const char *value) { | |
69 char *sp; | |
70 size_t len = 0; | |
71 if (value != NULL) { | |
72 len = strlen(value); | |
73 if (_value != NULL) { | |
74 len += strlen(_value); | |
75 } | |
76 sp = AllocateHeap(len+2); | |
77 if (sp != NULL) { | |
78 if (_value != NULL) { | |
79 strcpy(sp, _value); | |
80 strcat(sp, os::path_separator()); | |
81 strcat(sp, value); | |
82 FreeHeap(_value); | |
83 } else { | |
84 strcpy(sp, value); | |
85 } | |
86 _value = sp; | |
87 } | |
88 } | |
89 } | |
90 | |
91 // Constructor | |
92 SystemProperty(const char* key, const char* value, bool writeable) { | |
93 if (key == NULL) { | |
94 _key = NULL; | |
95 } else { | |
96 _key = AllocateHeap(strlen(key)+1); | |
97 strcpy(_key, key); | |
98 } | |
99 if (value == NULL) { | |
100 _value = NULL; | |
101 } else { | |
102 _value = AllocateHeap(strlen(value)+1); | |
103 strcpy(_value, value); | |
104 } | |
105 _next = NULL; | |
106 _writeable = writeable; | |
107 } | |
108 }; | |
109 | |
110 | |
111 // For use by -agentlib, -agentpath and -Xrun | |
112 class AgentLibrary : public CHeapObj { | |
113 friend class AgentLibraryList; | |
114 private: | |
115 char* _name; | |
116 char* _options; | |
117 void* _os_lib; | |
118 bool _is_absolute_path; | |
119 AgentLibrary* _next; | |
120 | |
121 public: | |
122 // Accessors | |
123 const char* name() const { return _name; } | |
124 char* options() const { return _options; } | |
125 bool is_absolute_path() const { return _is_absolute_path; } | |
126 void* os_lib() const { return _os_lib; } | |
127 void set_os_lib(void* os_lib) { _os_lib = os_lib; } | |
128 AgentLibrary* next() const { return _next; } | |
129 | |
130 // Constructor | |
131 AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) { | |
132 _name = AllocateHeap(strlen(name)+1); | |
133 strcpy(_name, name); | |
134 if (options == NULL) { | |
135 _options = NULL; | |
136 } else { | |
137 _options = AllocateHeap(strlen(options)+1); | |
138 strcpy(_options, options); | |
139 } | |
140 _is_absolute_path = is_absolute_path; | |
141 _os_lib = os_lib; | |
142 _next = NULL; | |
143 } | |
144 }; | |
145 | |
146 // maintain an order of entry list of AgentLibrary | |
147 class AgentLibraryList VALUE_OBJ_CLASS_SPEC { | |
148 private: | |
149 AgentLibrary* _first; | |
150 AgentLibrary* _last; | |
151 public: | |
152 bool is_empty() const { return _first == NULL; } | |
153 AgentLibrary* first() const { return _first; } | |
154 | |
155 // add to the end of the list | |
156 void add(AgentLibrary* lib) { | |
157 if (is_empty()) { | |
158 _first = _last = lib; | |
159 } else { | |
160 _last->_next = lib; | |
161 _last = lib; | |
162 } | |
163 lib->_next = NULL; | |
164 } | |
165 | |
166 // search for and remove a library known to be in the list | |
167 void remove(AgentLibrary* lib) { | |
168 AgentLibrary* curr; | |
169 AgentLibrary* prev = NULL; | |
170 for (curr = first(); curr != NULL; prev = curr, curr = curr->next()) { | |
171 if (curr == lib) { | |
172 break; | |
173 } | |
174 } | |
175 assert(curr != NULL, "always should be found"); | |
176 | |
177 if (curr != NULL) { | |
178 // it was found, by-pass this library | |
179 if (prev == NULL) { | |
180 _first = curr->_next; | |
181 } else { | |
182 prev->_next = curr->_next; | |
183 } | |
184 if (curr == _last) { | |
185 _last = prev; | |
186 } | |
187 curr->_next = NULL; | |
188 } | |
189 } | |
190 | |
191 AgentLibraryList() { | |
192 _first = NULL; | |
193 _last = NULL; | |
194 } | |
195 }; | |
196 | |
197 | |
198 class Arguments : AllStatic { | |
199 friend class VMStructs; | |
200 friend class JvmtiExport; | |
201 public: | |
202 // Operation modi | |
203 enum Mode { | |
204 _int, // corresponds to -Xint | |
205 _mixed, // corresponds to -Xmixed | |
206 _comp // corresponds to -Xcomp | |
207 }; | |
208 | |
209 enum ArgsRange { | |
210 arg_unreadable = -3, | |
211 arg_too_small = -2, | |
212 arg_too_big = -1, | |
213 arg_in_range = 0 | |
214 }; | |
215 | |
216 private: | |
217 | |
218 // an array containing all flags specified in the .hotspotrc file | |
219 static char** _jvm_flags_array; | |
220 static int _num_jvm_flags; | |
221 // an array containing all jvm arguments specified in the command line | |
222 static char** _jvm_args_array; | |
223 static int _num_jvm_args; | |
224 // string containing all java command (class/jarfile name and app args) | |
225 static char* _java_command; | |
226 | |
227 // Property list | |
228 static SystemProperty* _system_properties; | |
229 | |
230 // Quick accessor to System properties in the list: | |
231 static SystemProperty *_java_ext_dirs; | |
232 static SystemProperty *_java_endorsed_dirs; | |
233 static SystemProperty *_sun_boot_library_path; | |
234 static SystemProperty *_java_library_path; | |
235 static SystemProperty *_java_home; | |
236 static SystemProperty *_java_class_path; | |
237 static SystemProperty *_sun_boot_class_path; | |
238 | |
239 // Meta-index for knowing what packages are in the boot class path | |
240 static char* _meta_index_path; | |
241 static char* _meta_index_dir; | |
242 | |
243 // java.vendor.url.bug, bug reporting URL for fatal errors. | |
244 static const char* _java_vendor_url_bug; | |
245 | |
246 // sun.java.launcher, private property to provide information about | |
247 // java/gamma launcher | |
248 static const char* _sun_java_launcher; | |
249 | |
250 // sun.java.launcher.pid, private property | |
251 static int _sun_java_launcher_pid; | |
252 | |
253 // Option flags | |
254 static bool _has_profile; | |
255 static bool _has_alloc_profile; | |
256 static const char* _gc_log_filename; | |
257 static uintx _initial_heap_size; | |
258 static uintx _min_heap_size; | |
259 | |
260 // -Xrun arguments | |
261 static AgentLibraryList _libraryList; | |
262 static void add_init_library(const char* name, char* options) | |
263 { _libraryList.add(new AgentLibrary(name, options, false, NULL)); } | |
264 | |
265 // -agentlib and -agentpath arguments | |
266 static AgentLibraryList _agentList; | |
267 static void add_init_agent(const char* name, char* options, bool absolute_path) | |
268 { _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); } | |
269 | |
270 // Late-binding agents not started via arguments | |
271 static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib) | |
272 { _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); } | |
273 | |
274 // Operation modi | |
275 static Mode _mode; | |
276 static void set_mode_flags(Mode mode); | |
277 static bool _java_compiler; | |
278 static void set_java_compiler(bool arg) { _java_compiler = arg; } | |
279 static bool java_compiler() { return _java_compiler; } | |
280 | |
281 // -Xdebug flag | |
282 static bool _xdebug_mode; | |
283 static void set_xdebug_mode(bool arg) { _xdebug_mode = arg; } | |
284 static bool xdebug_mode() { return _xdebug_mode; } | |
285 | |
286 // Used to save default settings | |
287 static bool _AlwaysCompileLoopMethods; | |
288 static bool _UseOnStackReplacement; | |
289 static bool _BackgroundCompilation; | |
290 static bool _ClipInlining; | |
291 static bool _CIDynamicCompilePriority; | |
292 static intx _Tier2CompileThreshold; | |
293 | |
294 // CMS/ParNew garbage collectors | |
295 static void set_parnew_gc_flags(); | |
296 static void set_cms_and_parnew_gc_flags(); | |
297 // UseParallelGC | |
298 static void set_parallel_gc_flags(); | |
299 // GC ergonomics | |
300 static void set_ergonomics_flags(); | |
301 // Based on automatic selection criteria, should the | |
302 // low pause collector be used. | |
303 static bool should_auto_select_low_pause_collector(); | |
304 | |
305 // Bytecode rewriting | |
306 static void set_bytecode_flags(); | |
307 | |
308 // Invocation API hooks | |
309 static abort_hook_t _abort_hook; | |
310 static exit_hook_t _exit_hook; | |
311 static vfprintf_hook_t _vfprintf_hook; | |
312 | |
313 // System properties | |
314 static bool add_property(const char* prop); | |
315 | |
316 // Aggressive optimization flags. | |
317 static void set_aggressive_opts_flags(); | |
318 | |
319 // Argument parsing | |
320 static void do_pd_flag_adjustments(); | |
321 static bool parse_argument(const char* arg, FlagValueOrigin origin); | |
322 static bool process_argument(const char* arg, jboolean ignore_unrecognized, FlagValueOrigin origin); | |
323 static void process_java_launcher_argument(const char*, void*); | |
324 static void process_java_compiler_argument(char* arg); | |
325 static jint parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p); | |
326 static jint parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p); | |
327 static jint parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p); | |
328 static jint parse_vm_init_args(const JavaVMInitArgs* args); | |
329 static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, SysClassPath* scp_p, bool* scp_assembly_required_p, FlagValueOrigin origin); | |
330 static jint finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required); | |
331 static bool is_bad_option(const JavaVMOption* option, jboolean ignore, | |
332 const char* option_type); | |
333 static bool is_bad_option(const JavaVMOption* option, jboolean ignore) { | |
334 return is_bad_option(option, ignore, NULL); | |
335 } | |
336 static bool verify_percentage(uintx value, const char* name); | |
337 static void describe_range_error(ArgsRange errcode); | |
338 static ArgsRange check_memory_size(jlong size, jlong min_size); | |
339 static ArgsRange parse_memory_size(const char* s, jlong* long_arg, | |
340 jlong min_size); | |
341 | |
342 // methods to build strings from individual args | |
343 static void build_jvm_args(const char* arg); | |
344 static void build_jvm_flags(const char* arg); | |
345 static void add_string(char*** bldarray, int* count, const char* arg); | |
346 static const char* build_resource_string(char** args, int count); | |
347 | |
348 static bool methodExists( | |
349 char* className, char* methodName, | |
350 int classesNum, char** classes, bool* allMethods, | |
351 int methodsNum, char** methods, bool* allClasses | |
352 ); | |
353 | |
354 static void parseOnlyLine( | |
355 const char* line, | |
356 short* classesNum, short* classesMax, char*** classes, bool** allMethods, | |
357 short* methodsNum, short* methodsMax, char*** methods, bool** allClasses | |
358 ); | |
359 | |
360 // Returns true if the string s is in the list of | |
361 // flags made obsolete in 1.5.0. | |
362 static bool made_obsolete_in_1_5_0(const char* s); | |
363 | |
364 static short CompileOnlyClassesNum; | |
365 static short CompileOnlyClassesMax; | |
366 static char** CompileOnlyClasses; | |
367 static bool* CompileOnlyAllMethods; | |
368 | |
369 static short CompileOnlyMethodsNum; | |
370 static short CompileOnlyMethodsMax; | |
371 static char** CompileOnlyMethods; | |
372 static bool* CompileOnlyAllClasses; | |
373 | |
374 static short InterpretOnlyClassesNum; | |
375 static short InterpretOnlyClassesMax; | |
376 static char** InterpretOnlyClasses; | |
377 static bool* InterpretOnlyAllMethods; | |
378 | |
379 static bool CheckCompileOnly; | |
380 | |
381 static char* SharedArchivePath; | |
382 | |
383 public: | |
384 // Parses the arguments | |
385 static jint parse(const JavaVMInitArgs* args); | |
10
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
386 // Check for consistency in the selection of the garbage collector. |
28372612af5e
6362677: Change parallel GC collector default number of parallel GC threads.
jmasa
parents:
0
diff
changeset
|
387 static bool check_gc_consistency(); |
0 | 388 // Check consistecy or otherwise of VM argument settings |
389 static bool check_vm_args_consistency(); | |
390 // Used by os_solaris | |
391 static bool process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized); | |
392 | |
393 // return a char* array containing all options | |
394 static char** jvm_flags_array() { return _jvm_flags_array; } | |
395 static char** jvm_args_array() { return _jvm_args_array; } | |
396 static int num_jvm_flags() { return _num_jvm_flags; } | |
397 static int num_jvm_args() { return _num_jvm_args; } | |
398 // return the arguments passed to the Java application | |
399 static const char* java_command() { return _java_command; } | |
400 | |
401 // print jvm_flags, jvm_args and java_command | |
402 static void print_on(outputStream* st); | |
403 | |
404 // convenient methods to obtain / print jvm_flags and jvm_args | |
405 static const char* jvm_flags() { return build_resource_string(_jvm_flags_array, _num_jvm_flags); } | |
406 static const char* jvm_args() { return build_resource_string(_jvm_args_array, _num_jvm_args); } | |
407 static void print_jvm_flags_on(outputStream* st); | |
408 static void print_jvm_args_on(outputStream* st); | |
409 | |
410 // -Dkey=value flags | |
411 static SystemProperty* system_properties() { return _system_properties; } | |
412 static const char* get_property(const char* key); | |
413 | |
414 // -Djava.vendor.url.bug | |
415 static const char* java_vendor_url_bug() { return _java_vendor_url_bug; } | |
416 | |
417 // -Dsun.java.launcher | |
418 static const char* sun_java_launcher() { return _sun_java_launcher; } | |
419 // Was VM created by a Java launcher? | |
420 static bool created_by_java_launcher(); | |
421 // -Dsun.java.launcher.pid | |
422 static int sun_java_launcher_pid() { return _sun_java_launcher_pid; } | |
423 | |
424 // -Xloggc:<file>, if not specified will be NULL | |
425 static const char* gc_log_filename() { return _gc_log_filename; } | |
426 | |
427 // -Xprof/-Xaprof | |
428 static bool has_profile() { return _has_profile; } | |
429 static bool has_alloc_profile() { return _has_alloc_profile; } | |
430 | |
431 // -Xms , -Xmx | |
432 static uintx initial_heap_size() { return _initial_heap_size; } | |
433 static void set_initial_heap_size(uintx v) { _initial_heap_size = v; } | |
434 static uintx min_heap_size() { return _min_heap_size; } | |
435 static void set_min_heap_size(uintx v) { _min_heap_size = v; } | |
436 | |
437 // -Xrun | |
438 static AgentLibrary* libraries() { return _libraryList.first(); } | |
439 static bool init_libraries_at_startup() { return !_libraryList.is_empty(); } | |
440 static void convert_library_to_agent(AgentLibrary* lib) | |
441 { _libraryList.remove(lib); | |
442 _agentList.add(lib); } | |
443 | |
444 // -agentlib -agentpath | |
445 static AgentLibrary* agents() { return _agentList.first(); } | |
446 static bool init_agents_at_startup() { return !_agentList.is_empty(); } | |
447 | |
448 // abort, exit, vfprintf hooks | |
449 static abort_hook_t abort_hook() { return _abort_hook; } | |
450 static exit_hook_t exit_hook() { return _exit_hook; } | |
451 static vfprintf_hook_t vfprintf_hook() { return _vfprintf_hook; } | |
452 | |
453 static bool GetCheckCompileOnly () { return CheckCompileOnly; } | |
454 | |
455 static const char* GetSharedArchivePath() { return SharedArchivePath; } | |
456 | |
457 static bool CompileMethod(char* className, char* methodName) { | |
458 return | |
459 methodExists( | |
460 className, methodName, | |
461 CompileOnlyClassesNum, CompileOnlyClasses, CompileOnlyAllMethods, | |
462 CompileOnlyMethodsNum, CompileOnlyMethods, CompileOnlyAllClasses | |
463 ); | |
464 } | |
465 | |
466 // Java launcher properties | |
467 static void process_sun_java_launcher_properties(JavaVMInitArgs* args); | |
468 | |
469 // System properties | |
470 static void init_system_properties(); | |
471 | |
472 // Proptery List manipulation | |
473 static void PropertyList_add(SystemProperty** plist, SystemProperty *element); | |
474 static void PropertyList_add(SystemProperty** plist, const char* k, char* v); | |
475 static void PropertyList_unique_add(SystemProperty** plist, const char* k, char* v); | |
476 static const char* PropertyList_get_value(SystemProperty* plist, const char* key); | |
477 static int PropertyList_count(SystemProperty* pl); | |
478 static const char* PropertyList_get_key_at(SystemProperty* pl,int index); | |
479 static char* PropertyList_get_value_at(SystemProperty* pl,int index); | |
480 | |
481 // Miscellaneous System property value getter and setters. | |
482 static void set_dll_dir(char *value) { _sun_boot_library_path->set_value(value); } | |
483 static void set_java_home(char *value) { _java_home->set_value(value); } | |
484 static void set_library_path(char *value) { _java_library_path->set_value(value); } | |
485 static void set_ext_dirs(char *value) { _java_ext_dirs->set_value(value); } | |
486 static void set_endorsed_dirs(char *value) { _java_endorsed_dirs->set_value(value); } | |
487 static void set_sysclasspath(char *value) { _sun_boot_class_path->set_value(value); } | |
488 static void append_sysclasspath(const char *value) { _sun_boot_class_path->append_value(value); } | |
489 static void set_meta_index_path(char* meta_index_path, char* meta_index_dir) { | |
490 _meta_index_path = meta_index_path; | |
491 _meta_index_dir = meta_index_dir; | |
492 } | |
493 | |
494 static char *get_java_home() { return _java_home->value(); } | |
495 static char *get_dll_dir() { return _sun_boot_library_path->value(); } | |
496 static char *get_endorsed_dir() { return _java_endorsed_dirs->value(); } | |
497 static char *get_sysclasspath() { return _sun_boot_class_path->value(); } | |
498 static char* get_meta_index_path() { return _meta_index_path; } | |
499 static char* get_meta_index_dir() { return _meta_index_dir; } | |
500 | |
501 // Operation modi | |
502 static Mode mode() { return _mode; } | |
503 | |
504 // Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid. | |
505 static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen); | |
506 | |
507 #ifdef KERNEL | |
508 // For java kernel vm, return property string for kernel properties. | |
509 static char *get_kernel_properties(); | |
510 #endif // KERNEL | |
511 }; |