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