* merged default branch into jitcache-arm-x86 branch
[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.h"
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 bool compileall = false;
66
67 bool loadverbose = false;
68 bool initverbose = false;
69
70 bool opt_verboseclass     = false;
71 bool opt_verbosegc        = false;
72 bool opt_verbosejni       = false;
73 bool opt_verbosecall      = false;      /* trace all method invocation        */
74
75 bool showmethods = false;
76 bool showconstantpool = false;
77 bool showutf = false;
78
79 char *opt_method = NULL;
80 char *opt_signature = NULL;
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 int      opt_DebugExceptions              = 0;
165 int      opt_DebugFinalizer               = 0;
166 #if defined(ENABLE_JITCACHE)
167 int      opt_DebugJitCache                = 0;
168 #endif
169 int      opt_DebugLocalReferences         = 0;
170 int      opt_DebugLocks                   = 0;
171 int      opt_DebugPackage                 = 0;
172 int      opt_DebugPatcher                 = 0;
173 int      opt_DebugProperties              = 0;
174 int      opt_DebugStackFrameInfo          = 0;
175 int      opt_DebugStackTrace              = 0;
176 int      opt_DebugThreads                 = 0;
177 #if defined(ENABLE_DISASSEMBLER)
178 int      opt_DisassembleStubs             = 0;
179 #endif
180 #if defined(ENABLE_OPAGENT)
181 int      opt_EnableOpagent                = 0;
182 #endif
183 #if defined(ENABLE_GC_CACAO)
184 int      opt_GCDebugRootSet               = 0;
185 int      opt_GCStress                     = 0;
186 #endif
187 #if defined(ENABLE_INLINING)
188 int      opt_Inline                       = 0;
189 #if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
190 int      opt_InlineAll                    = 0;
191 int      opt_InlineCount                  = INT_MAX;
192 int      opt_InlineMaxSize                = INT_MAX;
193 int      opt_InlineMinSize                = 0;
194 #endif
195 #endif
196 int      opt_PrintConfig                  = 0;
197 int      opt_ProfileGCMemoryUsage         = 0;
198 int      opt_ProfileMemoryUsage           = 0;
199 FILE    *opt_ProfileMemoryUsageGNUPlot    = NULL;
200 #if defined(ENABLE_REPLACEMENT)
201 int      opt_TestReplacement              = 0;
202 #endif
203 int      opt_TraceCompilerCalls           = 0;
204 int      opt_TraceExceptions              = 0;
205 int      opt_TraceHPI                     = 0;
206 #if defined(ENABLE_INLINING) && !defined(NDEBUG)
207 int      opt_TraceInlining                = 0;
208 #endif
209 int      opt_TraceJavaCalls               = 0;
210 int      opt_TraceJNICalls                = 0;
211 int      opt_TraceJVMCalls                = 0;
212 int      opt_TraceJVMCallsVerbose         = 0;
213 int      opt_TraceLinkClass               = 0;
214 #if defined(ENABLE_REPLACEMENT)
215 int      opt_TraceReplacement             = 0;
216 #endif
217 int      opt_TraceSubsystemInitialization = 0;
218 int      opt_TraceTraps                   = 0;
219
220
221 enum {
222         OPT_TYPE_BOOLEAN,
223         OPT_TYPE_VALUE
224 };
225
226 enum {
227         /* Options which must always be available (production options in
228            HotSpot). */
229
230         OPT_MaxDirectMemorySize,
231         OPT_MaxPermSize,
232         OPT_PermSize,
233         OPT_ThreadStackSize,
234
235         /* Debugging options which can be turned off. */
236
237         OPT_AlwaysEmitLongBranches,
238         OPT_DebugExceptions,
239         OPT_DebugFinalizer,
240   OPT_DebugJitCache,
241         OPT_DebugLocalReferences,
242         OPT_DebugLocks,
243         OPT_DebugPackage,
244         OPT_DebugPatcher,
245         OPT_DebugProperties,
246         OPT_DebugStackFrameInfo,
247         OPT_DebugStackTrace,
248         OPT_DebugThreads,
249         OPT_DisassembleStubs,
250         OPT_EnableOpagent,
251         OPT_GCDebugRootSet,
252         OPT_GCStress,
253         OPT_Inline,
254         OPT_InlineAll,
255         OPT_InlineCount,
256         OPT_InlineMaxSize,
257         OPT_InlineMinSize,
258         OPT_PrintConfig,
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         { "DebugExceptions",              OPT_DebugExceptions,              OPT_TYPE_BOOLEAN, "debug exceptions" },
294         { "DebugFinalizer",               OPT_DebugFinalizer,               OPT_TYPE_BOOLEAN, "debug finalizer thread" },
295 #if defined (ENABLE_JITCACHE)
296   { "DebugJitCache",                OPT_DebugJitCache,                OPT_TYPE_BOOLEAN, "debug JIT cache actions" },
297 #endif
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         { "ProfileGCMemoryUsage",         OPT_ProfileGCMemoryUsage,         OPT_TYPE_VALUE,   "profiles GC memory usage in the given interval, <value> is in seconds (default: 5)" },
327         { "ProfileMemoryUsage",           OPT_ProfileMemoryUsage,           OPT_TYPE_VALUE,   "TODO" },
328         { "ProfileMemoryUsageGNUPlot",    OPT_ProfileMemoryUsageGNUPlot,    OPT_TYPE_VALUE,   "TODO" },
329 #if defined(ENABLE_REPLACEMENT)
330         { "TestReplacement",              OPT_TestReplacement,              OPT_TYPE_BOOLEAN, "activate all replacement points during code generation" },
331 #endif
332         { "TraceCompilerCalls",           OPT_TraceCompilerCalls,           OPT_TYPE_BOOLEAN, "trace JIT compiler calls" },
333         { "TraceExceptions",              OPT_TraceExceptions,              OPT_TYPE_BOOLEAN, "trace Exception throwing" },
334         { "TraceHPI",                     OPT_TraceHPI,                     OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" },
335 #if defined(ENABLE_INLINING) && !defined(NDEBUG)
336         { "TraceInlining",                OPT_TraceInlining,                OPT_TYPE_VALUE,   "trace method inlining with the given verbosity level (default: 1)" },
337 #endif
338 #if !defined(ENABLE_VMLOG)
339         { "TraceJavaCalls",               OPT_TraceJavaCalls,               OPT_TYPE_BOOLEAN, "trace Java method calls" },
340 #endif
341         { "TraceJNICalls",                OPT_TraceJNICalls,                OPT_TYPE_BOOLEAN, "trace JNI method calls" },
342         { "TraceJVMCalls",                OPT_TraceJVMCalls,                OPT_TYPE_BOOLEAN, "trace JVM method calls but omit very frequent ones" },
343         { "TraceJVMCallsVerbose",         OPT_TraceJVMCallsVerbose,         OPT_TYPE_BOOLEAN, "trace all JVM method calls" },
344         { "TraceLinkClass",               OPT_TraceLinkClass,               OPT_TYPE_BOOLEAN, "trace class linking" },
345 #if defined(ENABLE_REPLACEMENT)
346         { "TraceReplacement",             OPT_TraceReplacement,             OPT_TYPE_VALUE,   "trace on-stack replacement with the given verbosity level (default: 1)" },
347 #endif
348         { "TraceSubsystemInitialization", OPT_TraceSubsystemInitialization, OPT_TYPE_BOOLEAN, "trace initialization of subsystems" },
349         { "TraceTraps",                   OPT_TraceTraps,                   OPT_TYPE_BOOLEAN, "trace traps generated by JIT code" },
350 #if defined(ENABLE_VMLOG)
351         { "Vmlog",                        OPT_Vmlog,                        OPT_TYPE_VALUE,   "prefix for vmlog trace files (enables vmlog)" },
352         { "VmlogStrings",                 OPT_VmlogStrings,                 OPT_TYPE_VALUE,   "prefix of vmlog string file to load" },
353         { "VmlogIgnore",                  OPT_VmlogIgnore,                  OPT_TYPE_VALUE,   "prefix of vmlog ignore file to load" },
354 #endif
355
356         /* end marker */
357
358         { NULL,                           -1,                               -1,               NULL }
359 };
360
361
362 /* options_get *****************************************************************
363
364    DOCUMENT ME!!!
365
366 *******************************************************************************/
367
368 int options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
369 {
370         char *option;
371         int   i;
372
373         if (opt_index >= vm_args->nOptions)
374                 return OPT_DONE;
375
376         /* get the current option */
377
378         option = vm_args->options[opt_index].optionString;
379
380         if ((option == NULL) || (option[0] != '-'))
381                 return OPT_DONE;
382
383         for (i = 0; opts[i].name; i++) {
384                 if (!opts[i].arg) {
385                         /* boolean option found */
386
387                         if (strcmp(option + 1, opts[i].name) == 0) {
388                                 opt_index++;
389                                 return opts[i].value;
390                         }
391
392                 } else {
393                         /* parameter option found */
394
395                         /* with a space between */
396
397                         if (strcmp(option + 1, opts[i].name) == 0) {
398                                 opt_index++;
399
400                                 if (opt_index < vm_args->nOptions) {
401                                         opt_arg = os_strdup(vm_args->options[opt_index].optionString);
402                                         opt_index++;
403                                         return opts[i].value;
404                                 }
405
406                                 return OPT_ERROR;
407
408                         } else {
409                                 /* parameter and option have no space between */
410
411                                 /* FIXME: this assumption is plain wrong, hits you if there is a
412                                  * parameter with no argument starting with same letter as param with argument
413                                  * but named after that one, ouch! */
414
415                                 size_t l = os_strlen(opts[i].name);
416
417                                 if (os_strlen(option + 1) > l) {
418                                         if (memcmp(option + 1, opts[i].name, l) == 0) {
419                                                 opt_index++;
420                                                 opt_arg = os_strdup(option + 1 + l);
421                                                 return opts[i].value;
422                                         }
423                                 }
424                         }
425                 }
426         }
427
428         return OPT_ERROR;
429 }
430
431
432 /* options_xxusage *************************************************************
433
434    Print usage message for debugging options.
435
436 *******************************************************************************/
437
438 static void options_xxusage(void)
439 {
440         option_t   *opt;
441         int         length;
442         int         i;
443         const char *c;
444
445         /* Prevent compiler warning. */
446
447         length = 0;
448
449         for (opt = options_XX; opt->name != NULL; opt++) {
450                 printf("    -XX:");
451
452                 switch (opt->type) {
453                 case OPT_TYPE_BOOLEAN:
454                         printf("+%s", opt->name);
455                         length = os_strlen("    -XX:+") + os_strlen(opt->name);
456                         break;
457
458                 case OPT_TYPE_VALUE:
459                         printf("%s=<value>", opt->name);
460                         length = os_strlen("    -XX:") + os_strlen(opt->name) +
461                                 os_strlen("=<value>");
462                         break;
463
464                 default:
465                         vm_abort("options_xxusage: unkown option type %d", opt->type);
466                 }
467
468                 /* Check if the help fits into one 80-column line.
469                    Documentation starts at column 29. */
470
471                 if (length < (29 - 1)) {
472                         /* Print missing spaces up to column 29. */
473
474                         for (i = length; i < 29; i++)
475                                 printf(" ");
476                 }
477                 else {
478                         printf("\n");
479                         printf("                             "); /* 29 spaces */
480                 }
481
482                 /* Check documentation length. */
483
484                 length = os_strlen(opt->doc);
485
486                 if (length < (80 - 29)) {
487                         printf("%s", opt->doc);
488                 }
489                 else {
490                         for (c = opt->doc, i = 29; *c != 0; c++, i++) {
491                                 /* If we are at the end of the line, break it. */
492
493                                 if (i == 80) {
494                                         printf("\n");
495                                         printf("                             "); /* 29 spaces */
496                                         i = 29;
497                                 }
498
499                                 printf("%c", *c);
500                         }
501                 }
502
503                 printf("\n");
504         }
505
506         /* exit with error code */
507
508         exit(1);
509 }
510
511
512 /* options_xx ******************************************************************
513
514    Handle -XX: options.
515
516 *******************************************************************************/
517
518 void options_xx(JavaVMInitArgs *vm_args)
519 {
520         const char *name;
521         const char *start;
522         char       *end;
523         int         length;
524         int         enable;
525         char       *value;
526         option_t   *opt;
527         char       *filename;
528         FILE       *file;
529         int         i;
530
531         /* Iterate over all passed options. */
532
533         for (i = 0; i < vm_args->nOptions; i++) {
534                 /* Get the current option. */
535
536                 name = vm_args->options[i].optionString;
537
538                 /* Check for help (-XX). */
539
540                 if (strcmp(name, "-XX") == 0)
541                         options_xxusage();
542
543                 /* Check if the option start with -XX. */
544
545                 start = strstr(name, "-XX:");
546
547                 if ((start == NULL) || (start != name))
548                         continue;
549
550                 /* Check if the option is a boolean option. */
551
552                 if (name[4] == '+') {
553                         start  = name + 4 + 1;
554                         enable = 1;
555                 }
556                 else if (name[4] == '-') {
557                         start  = name + 4 + 1;
558                         enable = 0;
559                 }
560                 else {
561                         start  = name + 4;
562                         enable = -1;
563                 }
564
565                 /* Search for a '=' in the option name and get the option name
566                    length and the value of the option. */
567
568                 end = strchr(start, '=');
569
570                 if (end == NULL) {
571                         length = os_strlen(start);
572                         value  = NULL;
573                 }
574                 else {
575                         length = end - start;
576                         value  = end + 1;
577                 }
578
579                 /* Search the option in the option array. */
580
581                 for (opt = options_XX; opt->name != NULL; opt++) {
582                         if (strncmp(opt->name, start, length) == 0) {
583                                 /* Check if the options passed fits to the type. */
584
585                                 switch (opt->type) {
586                                 case OPT_TYPE_BOOLEAN:
587                                         if ((enable == -1) || (value != NULL))
588                                                 options_xxusage();
589                                         break;
590                                 case OPT_TYPE_VALUE:
591                                         if ((enable != -1) || (value == NULL))
592                                                 options_xxusage();
593                                         break;
594                                 default:
595                                         vm_abort("options_xx: unknown option type %d for option %s",
596                                                          opt->type, opt->name);
597                                 }
598
599                                 break;
600                         }
601                 }
602
603                 /* Process the option. */
604
605                 switch (opt->value) {
606
607                 /* Options which must always be available (production options
608                    in HotSpot). */
609
610                 case OPT_MaxDirectMemorySize:
611                         opt_MaxDirectMemorySize = os_atoi(value);
612                         break;
613
614                 case OPT_MaxPermSize:
615                         /* Currently ignored. */
616                         break;
617
618                 case OPT_PermSize:
619                         /* Currently ignored. */
620                         break;
621
622                 case OPT_ThreadStackSize:
623                         /* currently ignored */
624                         break;
625
626                 /* Debugging options which can be turned off. */
627
628                 case OPT_AlwaysEmitLongBranches:
629                         opt_AlwaysEmitLongBranches = enable;
630                         break;
631
632                 case OPT_DebugExceptions:
633                         opt_DebugExceptions = enable;
634                         break;
635
636                 case OPT_DebugFinalizer:
637                         opt_DebugFinalizer = enable;
638                         break;
639
640 #if defined(ENABLE_JITCACHE)
641     case OPT_DebugJitCache:
642       opt_DebugJitCache = enable;
643       break;
644 #endif
645
646                 case OPT_DebugLocalReferences:
647                         opt_DebugLocalReferences = enable;
648                         break;
649
650                 case OPT_DebugLocks:
651                         opt_DebugLocks = enable;
652                         break;
653
654                 case OPT_DebugPackage:
655                         opt_DebugPackage = enable;
656                         break;
657
658                 case OPT_DebugPatcher:
659                         opt_DebugPatcher = enable;
660                         break;
661
662                 case OPT_DebugProperties:
663                         opt_DebugProperties = enable;
664                         break;
665
666                 case OPT_DebugStackFrameInfo:
667                         opt_DebugStackFrameInfo = enable;
668                         break;
669
670                 case OPT_DebugStackTrace:
671                         opt_DebugStackTrace = enable;
672                         break;
673
674                 case OPT_DebugThreads:
675                         opt_DebugThreads = enable;
676                         break;
677
678 #if defined(ENABLE_DISASSEMBLER)
679                 case OPT_DisassembleStubs:
680                         opt_DisassembleStubs = enable;
681                         break;
682 #endif
683
684 #if defined(ENABLE_OPAGENT)
685                 case OPT_EnableOpagent:
686                         opt_EnableOpagent = enable;
687                         break;
688 #endif
689
690 #if defined(ENABLE_GC_CACAO)
691                 case OPT_GCDebugRootSet:
692                         opt_GCDebugRootSet = enable;
693                         break;
694
695                 case OPT_GCStress:
696                         opt_GCStress = enable;
697                         break;
698 #endif
699
700 #if defined(ENABLE_INLINING)
701                 case OPT_Inline:
702                         opt_Inline = enable;
703                         break;
704 #if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
705                 case OPT_InlineAll:
706                         opt_InlineAll = enable;
707                         break;
708
709                 case OPT_InlineCount:
710                         if (value != NULL)
711                                 opt_InlineCount = os_atoi(value);
712                         break;
713
714                 case OPT_InlineMaxSize:
715                         if (value != NULL)
716                                 opt_InlineMaxSize = os_atoi(value);
717                         break;
718
719                 case OPT_InlineMinSize:
720                         if (value != NULL)
721                                 opt_InlineMinSize = os_atoi(value);
722                         break;
723 #endif
724 #endif
725
726                 case OPT_PrintConfig:
727                         opt_PrintConfig = enable;
728                         break;
729
730                 case OPT_ProfileGCMemoryUsage:
731                         if (value == NULL)
732                                 opt_ProfileGCMemoryUsage = 5;
733                         else
734                                 opt_ProfileGCMemoryUsage = os_atoi(value);
735                         break;
736
737                 case OPT_ProfileMemoryUsage:
738                         if (value == NULL)
739                                 opt_ProfileMemoryUsage = 5;
740                         else
741                                 opt_ProfileMemoryUsage = os_atoi(value);
742
743 # if defined(ENABLE_STATISTICS)
744                         /* we also need statistics */
745
746                         opt_stat = true;
747 # endif
748                         break;
749
750                 case OPT_ProfileMemoryUsageGNUPlot:
751                         if (value == NULL)
752                                 filename = "profile.dat";
753                         else
754                                 filename = value;
755
756                         file = fopen(filename, "w");
757
758                         if (file == NULL)
759                                 vm_abort_errno("options_xx: fopen failed");
760
761                         opt_ProfileMemoryUsageGNUPlot = file;
762                         break;
763
764 #if defined(ENABLE_REPLACEMENT)
765                 case OPT_TestReplacement:
766                         opt_TestReplacement = enable;
767                         break;
768 #endif
769
770                 case OPT_TraceCompilerCalls:
771                         opt_TraceCompilerCalls = enable;
772                         break;
773
774                 case OPT_TraceExceptions:
775                         opt_TraceExceptions = enable;
776                         break;
777
778                 case OPT_TraceHPI:
779                         opt_TraceHPI = enable;
780                         break;
781
782 #if defined(ENABLE_INLINING) && !defined(NDEBUG)
783                 case OPT_TraceInlining:
784                         if (value == NULL)
785                                 opt_TraceInlining = 1;
786                         else
787                                 opt_TraceInlining = os_atoi(value);
788                         break;
789 #endif
790
791                 case OPT_TraceJavaCalls:
792                         opt_verbosecall = enable;
793                         opt_TraceJavaCalls = enable;
794                         break;
795
796                 case OPT_TraceJNICalls:
797                         opt_TraceJNICalls = enable;
798                         break;
799
800                 case OPT_TraceJVMCalls:
801                         opt_TraceJVMCalls = enable;
802                         break;
803
804                 case OPT_TraceJVMCallsVerbose:
805                         opt_TraceJVMCallsVerbose = enable;
806                         break;
807
808                 case OPT_TraceLinkClass:
809                         opt_TraceLinkClass = enable;
810                         break;
811
812 #if defined(ENABLE_REPLACEMENT)
813                 case OPT_TraceReplacement:
814                         if (value == NULL)
815                                 opt_TraceReplacement = 1;
816                         else
817                                 opt_TraceReplacement = os_atoi(value);
818                         break;
819 #endif
820
821                 case OPT_TraceSubsystemInitialization:
822                         opt_TraceSubsystemInitialization = enable;
823                         break;
824
825                 case OPT_TraceTraps:
826                         opt_TraceTraps = enable;
827                         break;
828
829 #if defined(ENABLE_VMLOG)
830                 case OPT_Vmlog:
831                         if (value == NULL)
832                                 vmlog_cacao_set_prefix("vmlog");
833                         else
834                                 vmlog_cacao_set_prefix(value);
835                         opt_verbosecall = 1;
836                         opt_TraceJavaCalls = 1;
837                         break;
838
839                 case OPT_VmlogStrings:
840                         if (value != NULL)
841                                 vmlog_cacao_set_stringprefix(value);
842                         break;
843
844                 case OPT_VmlogIgnore:
845                         if (value != NULL)
846                                 vmlog_cacao_set_ignoreprefix(value);
847                         break;
848 #endif
849
850                 default:
851                         printf("Unknown -XX option: %s\n", name);
852                         break;
853                 }
854         }
855 }
856
857
858 /*
859  * These are local overrides for various environment variables in Emacs.
860  * Please do not remove this and leave it at the end of the file, where
861  * Emacs will automagically detect them.
862  * ---------------------------------------------------------------------
863  * Local variables:
864  * mode: c
865  * indent-tabs-mode: t
866  * c-basic-offset: 4
867  * tab-width: 4
868  * End:
869  */