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