1bc4a9b9190b6a580ae7fdad614b3831aa9dafac
[cacao.git] / src / vmcore / options.c
1 /* src/vmcore/options.c - contains global options
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: options.c 7450 2007-03-04 19:13:29Z edwin $
26
27 */
28
29
30 #include "config.h"
31
32 #include <string.h>
33 #include <limits.h>
34
35 #include "vm/types.h"
36
37 #include "mm/memory.h"
38 #include "native/jni.h"
39 #include "vmcore/options.h"
40
41
42 /* command line option ********************************************************/
43
44 s4    opt_index = 0;            /* index of processed arguments               */
45 char *opt_arg;                  /* this one exports the option argument       */
46
47 bool opt_foo = false;           /* option for development                     */
48
49 bool opt_jar = false;
50
51 #if defined(ENABLE_JIT)
52 bool opt_jit = true;            /* JIT mode execution (default)               */
53 bool opt_intrp = false;         /* interpreter mode execution                 */
54 #else
55 bool opt_jit = false;           /* JIT mode execution                         */
56 bool opt_intrp = true;          /* interpreter mode execution (default)       */
57 #endif
58
59 bool opt_run = true;
60
61 s4   opt_heapmaxsize   = 0;     /* maximum heap size                          */
62 s4   opt_heapstartsize = 0;     /* initial heap size                          */
63 s4   opt_stacksize     = 0;     /* thread stack size                          */
64
65 bool opt_verbose = false;
66 bool opt_debugcolor = false;    /* use ANSI terminal sequences                */
67 bool compileall = false;
68
69 bool loadverbose = false;
70 bool linkverbose = false;
71 bool initverbose = false;
72
73 bool opt_verboseclass     = false;
74 bool opt_verbosegc        = false;
75 bool opt_verbosejni       = false;
76 bool opt_verbosecall      = false;      /* trace all method invocation        */
77 bool opt_verboseexception = false;
78 bool opt_verbosememory    = false;
79
80 bool showmethods = false;
81 bool showconstantpool = false;
82 bool showutf = false;
83
84 char *opt_method = NULL;
85 char *opt_signature = NULL;
86
87 bool compileverbose =  false;           /* trace compiler actions             */
88 bool showstack = false;
89
90 bool opt_showdisassemble    = false;    /* generate disassembler listing      */
91 bool opt_shownops           = false;
92 bool opt_showddatasegment   = false;    /* generate data segment listing      */
93 bool opt_showintermediate   = false;    /* generate intermediate code listing */
94 bool opt_showexceptionstubs = false;
95 bool opt_shownativestub     = false;
96
97 bool checkbounds = true;       /* check array bounds                         */
98 bool checknull = true;         /* check null pointers                        */
99 bool opt_noieee = false;       /* don't implement ieee compliant floats      */
100 bool checksync = true;         /* do synchronization                         */
101 #if defined(ENABLE_LOOP)
102 bool opt_loops = false;        /* optimize array accesses in loops           */
103 #endif
104
105 bool makeinitializations = true;
106
107 #if defined(ENABLE_STATISTICS)
108 bool opt_stat    = false;
109 bool opt_getloadingtime = false;   /* to measure the runtime                 */
110 bool opt_getcompilingtime = false; /* compute compile time                   */
111 #endif
112 #if defined(ENABLE_VERIFIER)
113 bool opt_verify  = true;       /* true if classfiles should be verified      */
114 #endif
115 bool opt_eager   = false;
116
117 #if defined(ENABLE_PROFILING)
118 bool opt_prof    = false;
119 bool opt_prof_bb = false;
120 #endif
121
122
123 /* inlining options ***********************************************************/
124
125 #if defined(ENABLE_INLINING)
126 bool opt_inlining = false;
127 #if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
128 s4 opt_replace_verbose = 0;
129 s4 opt_inline_debug_min_size = 0;
130 s4 opt_inline_debug_max_size = INT_MAX;
131 s4 opt_inline_debug_end_counter = INT_MAX;
132 bool opt_inline_debug_all = false;
133 #endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */
134 #if !defined(NDEBUG)
135 bool opt_inline_debug_log = false;
136 #endif /* !defined(NDEBUG) */
137 #endif /* defined(ENABLE_INLINING) */
138
139
140 /* optimization options *******************************************************/
141
142 #if defined(ENABLE_IFCONV)
143 bool opt_ifconv = false;
144 #endif
145
146 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
147 bool opt_lsra = false;
148 #endif
149
150
151 /* interpreter options ********************************************************/
152
153 #if defined(ENABLE_INTRP)
154 bool opt_no_dynamic = false;            /* suppress dynamic superinstructions */
155 bool opt_no_replication = false;        /* don't use replication in intrp     */
156 bool opt_no_quicksuper = false;         /* instructions for quickening cannot be
157                                                                                    part of dynamic superinstructions */
158
159 s4   opt_static_supers = 0x7fffffff;
160 bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
161 #endif
162
163
164 /* options_get *****************************************************************
165
166    DOCUMENT ME!!!
167
168 *******************************************************************************/
169
170 s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
171 {
172         char *option;
173         s4    i;
174
175         if (opt_index >= vm_args->nOptions)
176                 return OPT_DONE;
177
178         /* get the current option */
179
180         option = vm_args->options[opt_index].optionString;
181
182         if ((option == NULL) || (option[0] != '-'))
183                 return OPT_DONE;
184
185         for (i = 0; opts[i].name; i++) {
186                 if (!opts[i].arg) {
187                         /* boolean option found */
188
189                         if (strcmp(option + 1, opts[i].name) == 0) {
190                                 opt_index++;
191                                 return opts[i].value;
192                         }
193
194                 } else {
195                         /* parameter option found */
196
197                         /* with a space between */
198
199                         if (strcmp(option + 1, opts[i].name) == 0) {
200                                 opt_index++;
201
202                                 if (opt_index < vm_args->nOptions) {
203                                         opt_arg = strdup(vm_args->options[opt_index].optionString);
204                                         opt_index++;
205                                         return opts[i].value;
206                                 }
207
208                                 return OPT_ERROR;
209
210                         } else {
211                                 /* parameter and option have no space between */
212
213                                 /* FIXME: this assumption is plain wrong, hits you if there is a
214                                  * parameter with no argument starting with same letter as param with argument
215                                  * but named after that one, ouch! */
216
217                                 size_t l = strlen(opts[i].name);
218
219                                 if (strlen(option + 1) > l) {
220                                         if (memcmp(option + 1, opts[i].name, l) == 0) {
221                                                 opt_index++;
222                                                 opt_arg = strdup(option + 1 + l);
223                                                 return opts[i].value;
224                                         }
225                                 }
226                         }
227                 }
228         }
229
230         return OPT_ERROR;
231 }
232
233
234 /*
235  * These are local overrides for various environment variables in Emacs.
236  * Please do not remove this and leave it at the end of the file, where
237  * Emacs will automagically detect them.
238  * ---------------------------------------------------------------------
239  * Local variables:
240  * mode: c
241  * indent-tabs-mode: t
242  * c-basic-offset: 4
243  * tab-width: 4
244  * End:
245  */