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