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