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