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