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