Line data Source code
1 : /* src/vm/options.cpp - contains global options
2 :
3 : Copyright (C) 1996-2013
4 : CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 :
6 : This file is part of CACAO.
7 :
8 : This program is free software; you can redistribute it and/or
9 : modify it under the terms of the GNU General Public License as
10 : published by the Free Software Foundation; either version 2, or (at
11 : your option) any later version.
12 :
13 : This program is distributed in the hope that it will be useful, but
14 : WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 : General Public License for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with this program; if not, write to the Free Software
20 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 : 02110-1301, USA.
22 :
23 : */
24 :
25 :
26 : #include "config.h"
27 :
28 : #include <limits.h>
29 : #include <stdint.h>
30 : #include <stdio.h>
31 : #include <stdlib.h>
32 :
33 : #include "mm/dumpmemory.hpp"
34 :
35 : #include "vm/options.hpp"
36 : #include "vm/os.hpp"
37 : #include "vm/vm.hpp"
38 :
39 : #include "toolbox/Debug.hpp"
40 : #include "toolbox/logging.hpp"
41 : #include "toolbox/Option.hpp"
42 :
43 :
44 : /* command line option ********************************************************/
45 :
46 : s4 opt_index = 0; /* index of processed arguments */
47 : char *opt_arg; /* this one exports the option argument */
48 :
49 : bool opt_foo = false; /* option for development */
50 :
51 : bool opt_jar = false;
52 :
53 : #if defined(ENABLE_JIT)
54 : bool opt_jit = true; /* JIT mode execution (default) */
55 : bool opt_intrp = false; /* interpreter mode execution */
56 : #else
57 : bool opt_jit = false; /* JIT mode execution */
58 : bool opt_intrp = true; /* interpreter mode execution (default) */
59 : #endif
60 :
61 : bool opt_run = true;
62 :
63 : s4 opt_heapmaxsize = 0; /* maximum heap size */
64 : s4 opt_heapstartsize = 0; /* initial heap size */
65 : s4 opt_stacksize = 0; /* thread stack size */
66 :
67 : bool opt_verbose = false;
68 : bool opt_debugcolor = false; /* use ANSI terminal sequences */
69 :
70 : bool loadverbose = false;
71 : bool initverbose = false;
72 :
73 : bool opt_verboseclass = false;
74 : bool opt_verbosegc = false;
75 : bool opt_verbosejni = false;
76 : bool opt_verbosecall = false; /* trace all method invocation */
77 :
78 : bool showmethods = false;
79 : bool showconstantpool = false;
80 : bool showutf = false;
81 :
82 : bool compileverbose = false; /* trace compiler actions */
83 : bool showstack = false;
84 :
85 : bool opt_showdisassemble = false; /* generate disassembler listing */
86 : bool opt_showddatasegment = false; /* generate data segment listing */
87 : bool opt_showintermediate = false; /* generate intermediate code listing */
88 :
89 : bool checkbounds = true; /* check array bounds */
90 : bool checksync = true; /* do synchronization */
91 : #if defined(ENABLE_LOOP)
92 : bool opt_loops = false; /* optimize array accesses in loops */
93 : #endif
94 :
95 : bool makeinitializations = true;
96 :
97 : #if defined(ENABLE_STATISTICS)
98 : bool opt_stat = false;
99 : bool opt_getloadingtime = false; /* to measure the runtime */
100 : bool opt_getcompilingtime = false; /* compute compile time */
101 : #endif
102 : #if defined(ENABLE_VERIFIER)
103 : bool opt_verify = true; /* true if classfiles should be verified */
104 : #endif
105 :
106 : #if defined(ENABLE_PROFILING)
107 : bool opt_prof = false;
108 : bool opt_prof_bb = false;
109 : #endif
110 :
111 : #if defined(ENABLE_OPAGENT)
112 : bool opt_opagent = false;
113 : #endif
114 :
115 : /* optimization options *******************************************************/
116 :
117 : #if defined(ENABLE_IFCONV)
118 : bool opt_ifconv = false;
119 : #endif
120 :
121 : #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
122 : bool opt_lsra = false;
123 : #endif
124 : #if defined(ENABLE_SSA)
125 : bool opt_ssa_dce = false; /* enable dead code elemination */
126 : bool opt_ssa_cp = false; /* enable copy propagation */
127 : #endif
128 :
129 :
130 : /* interpreter options ********************************************************/
131 :
132 : #if defined(ENABLE_INTRP)
133 : bool opt_no_dynamic = false; /* suppress dynamic superinstructions */
134 : bool opt_no_replication = false; /* don't use replication in intrp */
135 : bool opt_no_quicksuper = false; /* instructions for quickening cannot be
136 : part of dynamic superinstructions */
137 :
138 : s4 opt_static_supers = 0x7fffffff;
139 : bool vm_debug = false; /* XXX this should be called `opt_trace' */
140 : #endif
141 :
142 : #if defined(ENABLE_DEBUG_FILTER)
143 : const char *opt_filter_verbosecall_include = 0;
144 : const char *opt_filter_verbosecall_exclude = 0;
145 : const char *opt_filter_show_method = 0;
146 : #endif
147 :
148 :
149 : /* -XX options ****************************************************************/
150 :
151 : /* NOTE: For better readability keep these alpha-sorted. */
152 :
153 : /* Options which must always be available (production options in
154 : HotSpot). */
155 :
156 : int64_t opt_MaxDirectMemorySize = -1;
157 : int opt_MaxPermSize = 0;
158 : int opt_PermSize = 0;
159 : int opt_ThreadStackSize = 0;
160 :
161 : /* Debugging options which can be turned off. */
162 :
163 : bool opt_AlwaysEmitLongBranches = false;
164 : bool opt_AlwaysMmapFirstPage = false;
165 : int opt_CompileAll = 0;
166 : char* opt_CompileMethod = NULL;
167 : char* opt_CompileSignature = NULL;
168 : int opt_DebugLocalReferences = 0;
169 : int opt_DebugLocks = 0;
170 : int opt_DebugPackage = 0;
171 : int opt_DebugPatcher = 0;
172 : int opt_DebugProperties = 0;
173 : int opt_DebugStackFrameInfo = 0;
174 : int opt_DebugStackTrace = 0;
175 : int opt_DebugThreads = 0;
176 : #if defined(ENABLE_DISASSEMBLER)
177 : int opt_DisassembleStubs = 0;
178 : #endif
179 : #if defined(ENABLE_OPAGENT)
180 : int opt_EnableOpagent = 0;
181 : #endif
182 : #if defined(ENABLE_GC_CACAO)
183 : int opt_GCDebugRootSet = 0;
184 : int opt_GCStress = 0;
185 : #endif
186 : #if defined(ENABLE_INLINING)
187 : int opt_Inline = 0;
188 : #if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
189 : int opt_InlineAll = 0;
190 : int opt_InlineCount = INT_MAX;
191 : int opt_InlineMaxSize = INT_MAX;
192 : int opt_InlineMinSize = 0;
193 : #endif
194 : #endif
195 : int opt_PrintConfig = 0;
196 : int opt_PrintWarnings = 0;
197 : int opt_ProfileGCMemoryUsage = 0;
198 : int opt_ProfileMemoryUsage = 0;
199 : FILE *opt_ProfileMemoryUsageGNUPlot = NULL;
200 : int opt_RegallocSpillAll = 0;
201 : #if defined(ENABLE_REPLACEMENT)
202 : int opt_TestReplacement = 0;
203 : #endif
204 : int opt_TraceBuiltinCalls = 0;
205 : int opt_TraceCompilerCalls = 0;
206 : int opt_TraceExceptions = 0;
207 : int opt_TraceHPI = 0;
208 : #if defined(ENABLE_INLINING) && !defined(NDEBUG)
209 : int opt_TraceInlining = 0;
210 : #endif
211 : int opt_TraceJavaCalls = 0;
212 : bool opt_TraceJMMCalls = false;
213 : int opt_TraceJNICalls = 0;
214 : int opt_TraceJVMCalls = 0;
215 : int opt_TraceJVMCallsVerbose = 0;
216 : #if defined(ENABLE_RT_TIMING)
217 : FILE *opt_RtTimingLogfile = NULL;
218 : #endif
219 : #if defined(ENABLE_STATISTICS)
220 : FILE *opt_StatisticsLogfile = NULL;
221 : #endif
222 : #if defined(ENABLE_JVMTI)
223 : int opt_TraceJVMTICalls = 0;
224 : #endif
225 : int opt_TraceLinkClass = 0;
226 : #if defined(ENABLE_REPLACEMENT)
227 : int opt_TraceReplacement = 0;
228 : #endif
229 : int opt_TraceSubsystemInitialization = 0;
230 : int opt_TraceTraps = 0;
231 :
232 :
233 : enum {
234 : OPT_TYPE_BOOLEAN,
235 : OPT_TYPE_VALUE
236 : };
237 :
238 : enum {
239 : /* Options which must always be available (production options in
240 : HotSpot). */
241 :
242 : OPT_MaxDirectMemorySize,
243 : OPT_MaxPermSize,
244 : OPT_PermSize,
245 : OPT_ThreadStackSize,
246 :
247 : /* Debugging options which can be turned off. */
248 :
249 : OPT_AlwaysEmitLongBranches,
250 : OPT_AlwaysMmapFirstPage,
251 : OPT_CompileAll,
252 : OPT_CompileMethod,
253 : OPT_CompileSignature,
254 : OPT_DebugLocalReferences,
255 : OPT_DebugLocks,
256 : OPT_DebugPackage,
257 : OPT_DebugPatcher,
258 : OPT_DebugStackFrameInfo,
259 : OPT_DebugStackTrace,
260 : OPT_DebugThreads,
261 : OPT_DisassembleStubs,
262 : OPT_EnableOpagent,
263 : OPT_GCDebugRootSet,
264 : OPT_GCStress,
265 : OPT_Inline,
266 : OPT_InlineAll,
267 : OPT_InlineCount,
268 : OPT_InlineMaxSize,
269 : OPT_InlineMinSize,
270 : OPT_PrintConfig,
271 : OPT_PrintWarnings,
272 : OPT_ProfileGCMemoryUsage,
273 : OPT_ProfileMemoryUsage,
274 : OPT_ProfileMemoryUsageGNUPlot,
275 : OPT_RegallocSpillAll,
276 : OPT_TestReplacement,
277 : OPT_TraceBuiltinCalls,
278 : OPT_TraceCompilerCalls,
279 : OPT_TraceExceptions,
280 : OPT_TraceHPI,
281 : OPT_TraceInlining,
282 : OPT_TraceJavaCalls,
283 : OPT_TraceJMMCalls,
284 : OPT_TraceJNICalls,
285 : OPT_TraceJVMCalls,
286 : OPT_TraceJVMCallsVerbose,
287 : OPT_TraceJVMTICalls,
288 : OPT_TraceLinkClass,
289 : OPT_TraceReplacement,
290 : OPT_TraceSubsystemInitialization,
291 : OPT_TraceTraps,
292 : OPT_RtTimingLogfile,
293 : OPT_StatisticsLogfile
294 : };
295 :
296 :
297 : option_t options_XX[] = {
298 : /* Options which must always be available (production options in
299 : HotSpot). */
300 :
301 : { "MaxDirectMemorySize", OPT_MaxDirectMemorySize, OPT_TYPE_VALUE, "Maximum total size of NIO direct-buffer allocations" },
302 : { "MaxPermSize", OPT_MaxPermSize, OPT_TYPE_VALUE, "not implemented" },
303 : { "PermSize", OPT_PermSize, OPT_TYPE_VALUE, "not implemented" },
304 : { "ThreadStackSize", OPT_ThreadStackSize, OPT_TYPE_VALUE, "TODO" },
305 :
306 : /* Debugging options which can be turned off. */
307 :
308 : { "AlwaysEmitLongBranches", OPT_AlwaysEmitLongBranches, OPT_TYPE_BOOLEAN, "Always emit long-branches." },
309 : { "AlwaysMmapFirstPage", OPT_AlwaysMmapFirstPage, OPT_TYPE_BOOLEAN, "Always mmap memory page at address 0x0." },
310 : { "CompileAll", OPT_CompileAll, OPT_TYPE_BOOLEAN, "compile all methods, no execution" },
311 : { "CompileMethod", OPT_CompileMethod, OPT_TYPE_VALUE, "compile only a specific method" },
312 : { "CompileSignature", OPT_CompileSignature, OPT_TYPE_VALUE, "specify signature for a specific method" },
313 : { "DebugLocalReferences", OPT_DebugLocalReferences, OPT_TYPE_BOOLEAN, "print debug information for local reference tables" },
314 : { "DebugLocks", OPT_DebugLocks, OPT_TYPE_BOOLEAN, "print debug information for locks" },
315 : { "DebugPackage", OPT_DebugPackage, OPT_TYPE_BOOLEAN, "debug Java boot-packages" },
316 : { "DebugPatcher", OPT_DebugPatcher, OPT_TYPE_BOOLEAN, "debug JIT code patching" },
317 : { "DebugStackFrameInfo", OPT_DebugStackFrameInfo, OPT_TYPE_BOOLEAN, "TODO" },
318 : { "DebugStackTrace", OPT_DebugStackTrace, OPT_TYPE_BOOLEAN, "debug stacktrace creation" },
319 : { "DebugThreads", OPT_DebugThreads, OPT_TYPE_BOOLEAN, "print debug information for threads" },
320 : #if defined(ENABLE_DISASSEMBLER)
321 : { "DisassembleStubs", OPT_DisassembleStubs, OPT_TYPE_BOOLEAN, "disassemble builtin and native stubs when generated" },
322 : #endif
323 : #if defined(ENABLE_OPAGENT)
324 : { "EnableOpagent", OPT_EnableOpagent, OPT_TYPE_BOOLEAN, "enable providing JIT output to Oprofile" },
325 : #endif
326 : #if defined(ENABLE_GC_CACAO)
327 : { "GCDebugRootSet", OPT_GCDebugRootSet, OPT_TYPE_BOOLEAN, "GC: print root-set at collection" },
328 : { "GCStress", OPT_GCStress, OPT_TYPE_BOOLEAN, "GC: forced collection at every allocation" },
329 : #endif
330 : #if defined(ENABLE_INLINING)
331 : { "Inline", OPT_Inline, OPT_TYPE_BOOLEAN, "enable method inlining" },
332 : #if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
333 : { "InlineAll", OPT_InlineAll, OPT_TYPE_BOOLEAN, "use inlining in all compilations" },
334 : { "InlineCount", OPT_InlineCount, OPT_TYPE_VALUE, "stop inlining after the given number of roots" },
335 : { "InlineMaxSize", OPT_InlineMaxSize, OPT_TYPE_VALUE, "maximum size for inlined result" },
336 : { "InlineMinSize", OPT_InlineMinSize, OPT_TYPE_VALUE, "minimum size for inlined result" },
337 : #endif
338 : #endif
339 : { "PrintConfig", OPT_PrintConfig, OPT_TYPE_BOOLEAN, "print VM configuration" },
340 : { "PrintWarnings", OPT_PrintWarnings, OPT_TYPE_BOOLEAN, "print warnings about suspicious behavior"},
341 : { "ProfileGCMemoryUsage", OPT_ProfileGCMemoryUsage, OPT_TYPE_VALUE, "profiles GC memory usage in the given interval, <value> is in seconds (default: 5)" },
342 : { "ProfileMemoryUsage", OPT_ProfileMemoryUsage, OPT_TYPE_VALUE, "TODO" },
343 : { "ProfileMemoryUsageGNUPlot", OPT_ProfileMemoryUsageGNUPlot, OPT_TYPE_VALUE, "TODO" },
344 : { "RegallocSpillAll", OPT_RegallocSpillAll, OPT_TYPE_BOOLEAN, "spill all variables to the stack" },
345 : #if defined(ENABLE_REPLACEMENT)
346 : { "TestReplacement", OPT_TestReplacement, OPT_TYPE_BOOLEAN, "activate all replacement points during code generation" },
347 : #endif
348 : { "TraceBuiltinCalls", OPT_TraceBuiltinCalls, OPT_TYPE_BOOLEAN, "trace calls to VM builtin functions" },
349 : { "TraceCompilerCalls", OPT_TraceCompilerCalls, OPT_TYPE_BOOLEAN, "trace JIT compiler calls" },
350 : { "TraceExceptions", OPT_TraceExceptions, OPT_TYPE_BOOLEAN, "trace Exception throwing" },
351 : { "TraceHPI", OPT_TraceHPI, OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" },
352 : #if defined(ENABLE_INLINING) && !defined(NDEBUG)
353 : { "TraceInlining", OPT_TraceInlining, OPT_TYPE_VALUE, "trace method inlining with the given verbosity level (default: 1)" },
354 : #endif
355 : { "TraceJavaCalls", OPT_TraceJavaCalls, OPT_TYPE_BOOLEAN, "trace Java method calls" },
356 : { "TraceJMMCalls", OPT_TraceJMMCalls, OPT_TYPE_BOOLEAN, "trace JMM method calls" },
357 : { "TraceJNICalls", OPT_TraceJNICalls, OPT_TYPE_BOOLEAN, "trace JNI method calls" },
358 : { "TraceJVMCalls", OPT_TraceJVMCalls, OPT_TYPE_BOOLEAN, "trace JVM method calls but omit very frequent ones" },
359 : { "TraceJVMCallsVerbose", OPT_TraceJVMCallsVerbose, OPT_TYPE_BOOLEAN, "trace all JVM method calls" },
360 : #if defined(ENABLE_JVMTI)
361 : { "TraceJVMTICalls", OPT_TraceJVMTICalls, OPT_TYPE_BOOLEAN, "trace JVMTI method calls" },
362 : #endif
363 : { "TraceLinkClass", OPT_TraceLinkClass, OPT_TYPE_BOOLEAN, "trace class linking" },
364 : #if defined(ENABLE_REPLACEMENT)
365 : { "TraceReplacement", OPT_TraceReplacement, OPT_TYPE_VALUE, "trace on-stack replacement with the given verbosity level (default: 1)" },
366 : #endif
367 : { "TraceSubsystemInitialization", OPT_TraceSubsystemInitialization, OPT_TYPE_BOOLEAN, "trace initialization of subsystems" },
368 : { "TraceTraps", OPT_TraceTraps, OPT_TYPE_BOOLEAN, "trace traps generated by JIT code" },
369 : #if defined(ENABLE_RT_TIMING)
370 : { "RtTimingLogfile", OPT_RtTimingLogfile, OPT_TYPE_VALUE, "rt-timing logfile (default: rt-timing.log, use - for stdout)" },
371 : #endif
372 : #if defined(ENABLE_STATISTICS)
373 : { "StatisticsLogfile", OPT_StatisticsLogfile, OPT_TYPE_VALUE, "statistics logfile (default: statistics.log, use - for stdout)" },
374 : #endif
375 :
376 : /* end marker */
377 :
378 : { NULL, -1, -1, NULL }
379 : };
380 :
381 :
382 : /* options_get *****************************************************************
383 :
384 : DOCUMENT ME!!!
385 :
386 : *******************************************************************************/
387 :
388 403 : int options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
389 : {
390 : char *option;
391 : int i;
392 :
393 403 : if (opt_index >= vm_args->nOptions)
394 22 : return OPT_DONE;
395 :
396 : /* get the current option */
397 :
398 381 : option = vm_args->options[opt_index].optionString;
399 :
400 381 : if ((option == NULL) || (option[0] != '-'))
401 141 : return OPT_DONE;
402 :
403 8719 : for (i = 0; opts[i].name; i++) {
404 8719 : if (!opts[i].arg) {
405 : /* boolean option found */
406 :
407 6275 : if (strcmp(option + 1, opts[i].name) == 0) {
408 24 : opt_index++;
409 24 : return opts[i].value;
410 : }
411 :
412 : } else {
413 : /* parameter option found */
414 :
415 : /* with a space between */
416 :
417 2444 : if (strcmp(option + 1, opts[i].name) == 0) {
418 5 : opt_index++;
419 :
420 5 : if (opt_index < vm_args->nOptions) {
421 5 : opt_arg = os::strdup(vm_args->options[opt_index].optionString);
422 5 : opt_index++;
423 5 : return opts[i].value;
424 : }
425 :
426 0 : return OPT_ERROR;
427 :
428 : } else {
429 : /* parameter and option have no space between */
430 :
431 : /* FIXME: this assumption is plain wrong, hits you if there is a
432 : * parameter with no argument starting with same letter as param with argument
433 : * but named after that one, ouch! */
434 :
435 2439 : size_t l = os::strlen(opts[i].name);
436 :
437 2439 : if (os::strlen(option + 1) > l) {
438 2329 : if (memcmp(option + 1, opts[i].name, l) == 0) {
439 211 : opt_index++;
440 211 : opt_arg = os::strdup(option + 1 + l);
441 211 : return opts[i].value;
442 : }
443 : }
444 : }
445 : }
446 : }
447 :
448 0 : return OPT_ERROR;
449 : }
450 :
451 :
452 : /* options_xxusage *************************************************************
453 :
454 : Print usage message for debugging options.
455 :
456 : *******************************************************************************/
457 :
458 0 : static void options_xxusage(void)
459 : {
460 : option_t *opt;
461 : int length;
462 : int i;
463 : const char *c;
464 :
465 : /* Prevent compiler warning. */
466 :
467 0 : length = 0;
468 :
469 0 : for (opt = options_XX; opt->name != NULL; opt++) {
470 0 : printf(" -XX:");
471 :
472 0 : switch (opt->type) {
473 : case OPT_TYPE_BOOLEAN:
474 0 : printf("+%s", opt->name);
475 0 : length = os::strlen(" -XX:+") + os::strlen(opt->name);
476 0 : break;
477 :
478 : case OPT_TYPE_VALUE:
479 0 : printf("%s=<value>", opt->name);
480 : length = os::strlen(" -XX:") + os::strlen(opt->name) +
481 0 : os::strlen("=<value>");
482 0 : break;
483 :
484 : default:
485 0 : vm_abort("options_xxusage: unkown option type %d", opt->type);
486 : }
487 :
488 : /* Check if the help fits into one 80-column line.
489 : Documentation starts at column 29. */
490 :
491 0 : if (length < (29 - 1)) {
492 : /* Print missing spaces up to column 29. */
493 :
494 0 : for (i = length; i < 29; i++)
495 0 : printf(" ");
496 : }
497 : else {
498 0 : printf("\n");
499 0 : printf(" "); /* 29 spaces */
500 : }
501 :
502 : /* Check documentation length. */
503 :
504 0 : length = os::strlen(opt->doc);
505 :
506 0 : if (length < (80 - 29)) {
507 0 : printf("%s", opt->doc);
508 : }
509 : else {
510 0 : for (c = opt->doc, i = 29; *c != 0; c++, i++) {
511 : /* If we are at the end of the line, break it. */
512 :
513 0 : if (i == 80) {
514 0 : printf("\n");
515 0 : printf(" "); /* 29 spaces */
516 0 : i = 29;
517 : }
518 :
519 0 : printf("%c", *c);
520 : }
521 : }
522 :
523 0 : printf("\n");
524 : }
525 :
526 0 : cacao::OptionParser::print_usage(cacao::option::xx_root());
527 :
528 : /* exit with error code */
529 :
530 0 : exit(1);
531 : }
532 :
533 :
534 : /* options_xx ******************************************************************
535 :
536 : Handle -XX: options.
537 :
538 : *******************************************************************************/
539 :
540 165 : void options_xx(JavaVMInitArgs *vm_args)
541 : {
542 : const char *name;
543 : const char *start;
544 : const char *end;
545 : int length;
546 : int enable;
547 : char *value;
548 : option_t *opt;
549 : const char *filename;
550 : FILE *file;
551 : int i;
552 :
553 : /* Iterate over all passed options. */
554 :
555 647 : for (i = 0; i < vm_args->nOptions; i++) {
556 : /* Get the current option. */
557 :
558 482 : name = vm_args->options[i].optionString;
559 :
560 : /* Check for help (-XX). */
561 :
562 482 : if (strcmp(name, "-XX") == 0)
563 0 : options_xxusage();
564 :
565 : /* Check if the option start with -XX. */
566 :
567 482 : start = strstr(name, "-XX:");
568 :
569 482 : if ((start == NULL) || (start != name))
570 460 : continue;
571 :
572 : /* Check if the option is a boolean option. */
573 :
574 22 : if (name[4] == '+') {
575 22 : start = name + 4 + 1;
576 22 : enable = 1;
577 : }
578 0 : else if (name[4] == '-') {
579 0 : start = name + 4 + 1;
580 0 : enable = 0;
581 : }
582 : else {
583 0 : start = name + 4;
584 0 : enable = -1;
585 : }
586 :
587 : /* Search for a '=' in the option name and get the option name
588 : length and the value of the option. */
589 :
590 22 : end = strchr(start, '=');
591 :
592 22 : if (end == NULL) {
593 22 : length = os::strlen(start);
594 22 : value = NULL;
595 : }
596 : else {
597 0 : length = end - start;
598 0 : value = (char*) (end + 1);
599 : }
600 :
601 : /* Search the option in the option array. */
602 :
603 374 : for (opt = options_XX; opt->name != NULL; opt++) {
604 374 : if (strncmp(opt->name, start, length) == 0) {
605 : /* Check if the options passed fits to the type. */
606 :
607 22 : switch (opt->type) {
608 : case OPT_TYPE_BOOLEAN:
609 22 : if ((enable == -1) || (value != NULL))
610 0 : options_xxusage();
611 22 : break;
612 : case OPT_TYPE_VALUE:
613 0 : if ((enable != -1) || (value == NULL))
614 0 : options_xxusage();
615 0 : break;
616 : default:
617 : vm_abort("options_xx: unknown option type %d for option %s",
618 0 : opt->type, opt->name);
619 : }
620 :
621 22 : break;
622 : }
623 : }
624 :
625 : /* Process the option. */
626 :
627 22 : switch (opt->value) {
628 :
629 : /* Options which must always be available (production options
630 : in HotSpot). */
631 :
632 : case OPT_MaxDirectMemorySize:
633 0 : opt_MaxDirectMemorySize = os::atoi(value);
634 0 : break;
635 :
636 : case OPT_MaxPermSize:
637 : /* Currently ignored. */
638 0 : break;
639 :
640 : case OPT_PermSize:
641 : /* Currently ignored. */
642 0 : break;
643 :
644 : case OPT_ThreadStackSize:
645 : /* currently ignored */
646 0 : break;
647 :
648 : /* Debugging options which can be turned off. */
649 :
650 : case OPT_AlwaysEmitLongBranches:
651 0 : opt_AlwaysEmitLongBranches = enable;
652 0 : break;
653 :
654 : case OPT_AlwaysMmapFirstPage:
655 0 : opt_AlwaysMmapFirstPage = enable;
656 0 : break;
657 :
658 : case OPT_CompileAll:
659 0 : opt_CompileAll = enable;
660 0 : opt_run = false;
661 0 : makeinitializations = false;
662 0 : break;
663 :
664 : case OPT_CompileMethod:
665 0 : opt_CompileMethod = value;
666 0 : opt_run = false;
667 0 : makeinitializations = false;
668 0 : break;
669 :
670 : case OPT_CompileSignature:
671 0 : opt_CompileSignature = value;
672 0 : break;
673 :
674 : case OPT_DebugLocalReferences:
675 0 : opt_DebugLocalReferences = enable;
676 0 : break;
677 :
678 : case OPT_DebugLocks:
679 0 : opt_DebugLocks = enable;
680 0 : break;
681 :
682 : case OPT_DebugPackage:
683 0 : opt_DebugPackage = enable;
684 0 : break;
685 :
686 : case OPT_DebugPatcher:
687 0 : opt_DebugPatcher = enable;
688 0 : break;
689 :
690 : case OPT_DebugStackFrameInfo:
691 0 : opt_DebugStackFrameInfo = enable;
692 0 : break;
693 :
694 : case OPT_DebugStackTrace:
695 0 : opt_DebugStackTrace = enable;
696 0 : break;
697 :
698 : case OPT_DebugThreads:
699 0 : opt_DebugThreads = enable;
700 0 : break;
701 :
702 : #if defined(ENABLE_DISASSEMBLER)
703 : case OPT_DisassembleStubs:
704 : opt_DisassembleStubs = enable;
705 : break;
706 : #endif
707 :
708 : #if defined(ENABLE_OPAGENT)
709 : case OPT_EnableOpagent:
710 : opt_EnableOpagent = enable;
711 : break;
712 : #endif
713 :
714 : #if defined(ENABLE_GC_CACAO)
715 : case OPT_GCDebugRootSet:
716 : opt_GCDebugRootSet = enable;
717 : break;
718 :
719 : case OPT_GCStress:
720 : opt_GCStress = enable;
721 : break;
722 : #endif
723 :
724 : #if defined(ENABLE_INLINING)
725 : case OPT_Inline:
726 : opt_Inline = enable;
727 : break;
728 : #if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
729 : case OPT_InlineAll:
730 : opt_InlineAll = enable;
731 : break;
732 :
733 : case OPT_InlineCount:
734 : if (value != NULL)
735 : opt_InlineCount = os::atoi(value);
736 : break;
737 :
738 : case OPT_InlineMaxSize:
739 : if (value != NULL)
740 : opt_InlineMaxSize = os::atoi(value);
741 : break;
742 :
743 : case OPT_InlineMinSize:
744 : if (value != NULL)
745 : opt_InlineMinSize = os::atoi(value);
746 : break;
747 : #endif
748 : #endif
749 :
750 : case OPT_PrintConfig:
751 22 : opt_PrintConfig = enable;
752 22 : break;
753 :
754 : case OPT_PrintWarnings:
755 0 : opt_PrintWarnings = enable;
756 0 : break;
757 :
758 : case OPT_ProfileGCMemoryUsage:
759 0 : if (value == NULL)
760 0 : opt_ProfileGCMemoryUsage = 5;
761 : else
762 0 : opt_ProfileGCMemoryUsage = os::atoi(value);
763 0 : break;
764 :
765 : case OPT_ProfileMemoryUsage:
766 0 : if (value == NULL)
767 0 : opt_ProfileMemoryUsage = 5;
768 : else
769 0 : opt_ProfileMemoryUsage = os::atoi(value);
770 :
771 : # if defined(ENABLE_STATISTICS)
772 : /* we also need statistics */
773 :
774 : opt_stat = true;
775 : # endif
776 0 : break;
777 :
778 : case OPT_ProfileMemoryUsageGNUPlot:
779 0 : if (value == NULL)
780 0 : filename = "profile.dat";
781 : else
782 0 : filename = value;
783 :
784 0 : file = fopen(filename, "w");
785 :
786 0 : if (file == NULL)
787 : /* FIXME Use below method instead! */
788 : //os::abort_errno("options_xx: fopen failed");
789 0 : vm_abort("options_xx: fopen failed");
790 :
791 0 : opt_ProfileMemoryUsageGNUPlot = file;
792 0 : break;
793 :
794 : case OPT_RegallocSpillAll:
795 0 : opt_RegallocSpillAll = enable;
796 0 : break;
797 :
798 : #if defined(ENABLE_REPLACEMENT)
799 : case OPT_TestReplacement:
800 : opt_TestReplacement = enable;
801 : break;
802 : #endif
803 :
804 : case OPT_TraceBuiltinCalls:
805 0 : opt_TraceBuiltinCalls = enable;
806 0 : break;
807 :
808 : case OPT_TraceCompilerCalls:
809 0 : opt_TraceCompilerCalls = enable;
810 0 : break;
811 :
812 : case OPT_TraceExceptions:
813 0 : opt_TraceExceptions = enable;
814 0 : break;
815 :
816 : case OPT_TraceHPI:
817 0 : opt_TraceHPI = enable;
818 0 : break;
819 :
820 : #if defined(ENABLE_INLINING) && !defined(NDEBUG)
821 : case OPT_TraceInlining:
822 : if (value == NULL)
823 : opt_TraceInlining = 1;
824 : else
825 : opt_TraceInlining = os::atoi(value);
826 : break;
827 : #endif
828 :
829 : case OPT_TraceJavaCalls:
830 0 : opt_verbosecall = enable;
831 0 : opt_TraceJavaCalls = enable;
832 0 : break;
833 :
834 : case OPT_TraceJMMCalls:
835 0 : opt_TraceJMMCalls = enable;
836 0 : break;
837 :
838 : case OPT_TraceJNICalls:
839 0 : opt_TraceJNICalls = enable;
840 0 : break;
841 :
842 : case OPT_TraceJVMCalls:
843 0 : opt_TraceJVMCalls = enable;
844 0 : break;
845 :
846 : case OPT_TraceJVMCallsVerbose:
847 0 : opt_TraceJVMCallsVerbose = enable;
848 0 : break;
849 :
850 : #if defined(ENABLE_JVMTI)
851 : case OPT_TraceJVMTICalls:
852 : opt_TraceJVMTICalls = enable;
853 : break;
854 : #endif
855 :
856 : case OPT_TraceLinkClass:
857 0 : opt_TraceLinkClass = enable;
858 0 : break;
859 :
860 : #if defined(ENABLE_REPLACEMENT)
861 : case OPT_TraceReplacement:
862 : if (value == NULL)
863 : opt_TraceReplacement = 1;
864 : else
865 : opt_TraceReplacement = os::atoi(value);
866 : break;
867 : #endif
868 :
869 : case OPT_TraceSubsystemInitialization:
870 0 : opt_TraceSubsystemInitialization = enable;
871 0 : break;
872 :
873 : case OPT_TraceTraps:
874 0 : opt_TraceTraps = enable;
875 0 : break;
876 :
877 : #if defined(ENABLE_RT_TIMING)
878 : case OPT_RtTimingLogfile:
879 : if (value == NULL)
880 : break;
881 : else
882 : filename = value;
883 :
884 : if ( (strnlen(filename, 2) == 1) && (filename[0] == '-') ) {
885 : file = stdout;
886 : } else {
887 : file = fopen(filename, "w");
888 :
889 : if (file == NULL)
890 : os::abort_errno("options_xx: fopen failed");
891 : }
892 :
893 : opt_RtTimingLogfile = file;
894 : break;
895 : #endif
896 :
897 : #if defined(ENABLE_STATISTICS)
898 : case OPT_StatisticsLogfile:
899 : if (value == NULL)
900 : break;
901 : else
902 : filename = value;
903 :
904 : if ( (strnlen(filename, 2) == 1) && (filename[0] == '-') ) {
905 : file = stdout;
906 : } else {
907 : file = fopen(filename, "w");
908 :
909 : if (file == NULL)
910 : os::abort_errno("options_xx: fopen failed");
911 : }
912 :
913 : opt_StatisticsLogfile = file;
914 : break;
915 : #endif
916 :
917 : default: {
918 :
919 0 : size_t name_len = strlen(name);
920 0 : size_t value_len = 0;
921 0 : if (value) {
922 0 : size_t tmp_name_len = (value - name) / sizeof(char);
923 0 : value_len = name_len - tmp_name_len;
924 0 : name_len = tmp_name_len - 1;
925 0 : assert(name[name_len] == '=');
926 : }
927 : else {
928 0 : assert(name[name_len] == '\0');
929 : }
930 :
931 0 : if(!cacao::OptionParser::parse_option(cacao::option::xx_root(),
932 : name, name_len, value, value_len)) {
933 0 : fprintf(stderr, "Unknown -XX option: %s\n", name);
934 : }
935 : break;
936 : }
937 : }
938 : }
939 165 : }
940 :
941 :
942 : /*
943 : * These are local overrides for various environment variables in Emacs.
944 : * Please do not remove this and leave it at the end of the file, where
945 : * Emacs will automagically detect them.
946 : * ---------------------------------------------------------------------
947 : * Local variables:
948 : * mode: c++
949 : * indent-tabs-mode: t
950 : * c-basic-offset: 4
951 : * tab-width: 4
952 : * End:
953 : * vim:noexpandtab:sw=4:ts=4:
954 : */
|