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