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