* src/vm/jit/optimizing/: New directory for optimizing compiler (SSA
[cacao.git] / src / vm / options.c
1 /* src/vm/options.c - contains global options
2
3    Copyright (C) 1996-2005, 2006 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    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    Changes:
30
31    $Id: options.c 5234 2006-08-14 17:50:12Z christian $
32
33 */
34
35
36 #include "config.h"
37
38 #include <string.h>
39
40 #include "vm/types.h"
41
42 #include "mm/memory.h"
43 #include "native/jni.h"
44 #include "vm/options.h"
45
46
47 /* command line option ********************************************************/
48
49 s4    opt_index = 0;            /* index of processed arguments               */
50 char *opt_arg;                  /* this one exports the option argument       */
51
52 bool opt_foo = false;           /* option for development                     */
53
54 bool opt_jar = false;
55
56 #if defined(ENABLE_JIT)
57 bool opt_jit = true;            /* JIT mode execution (default)               */
58 bool opt_intrp = false;         /* interpreter mode execution                 */
59 #else
60 bool opt_jit = false;           /* JIT mode execution                         */
61 bool opt_intrp = true;          /* interpreter mode execution (default)       */
62 #endif
63
64 bool opt_run = true;
65
66 s4   opt_heapmaxsize   = 0;     /* maximum heap size                          */
67 s4   opt_heapstartsize = 0;     /* initial heap size                          */
68 s4   opt_stacksize     = 0;     /* thread stack size                          */
69
70 bool opt_verbose = false;
71 bool compileall = false;
72
73 bool loadverbose = false;
74 bool linkverbose = false;
75 bool initverbose = false;
76
77 bool opt_verboseclass     = false;
78 bool opt_verbosegc        = false;
79 bool opt_verbosejni       = false;
80 bool opt_verbosecall      = false;      /* trace all method invocation        */
81 bool opt_verboseexception = false;
82
83 bool showmethods = false;
84 bool showconstantpool = false;
85 bool showutf = false;
86
87 char *opt_method = NULL;
88 char *opt_signature = NULL;
89
90 bool compileverbose =  false;           /* trace compiler actions             */
91 bool showstack = false;
92 bool opt_showdisassemble = false;       /* generate disassembler listing      */
93 bool opt_showddatasegment = false;      /* generate data segment listing      */
94 bool opt_showintermediate = false;      /* generate intermediate code listing */
95 bool opt_showexceptionstubs = false;
96 bool opt_shownativestub = false;
97
98 bool useinlining = false;      /* use method inlining                        */
99 bool inlinevirtuals = false;   /* inline unique virtual methods              */
100 bool inlineexceptions = false; /* inline methods, that contain excptions     */
101 bool inlineparamopt = false;   /* optimize parameter passing to inlined methods */
102 bool inlineoutsiders = false;  /* inline methods, that are not member of the invoker's class */
103
104 bool checkbounds = true;       /* check array bounds                         */
105 bool checknull = true;         /* check null pointers                        */
106 bool opt_noieee = false;       /* don't implement ieee compliant floats      */
107 bool checksync = true;         /* do synchronization                         */
108 #if defined(ENABLE_LOOP)
109 bool opt_loops = false;        /* optimize array accesses in loops           */
110 #endif
111
112 bool makeinitializations = true;
113
114 #if defined(ENABLE_STATISTICS)
115 bool opt_stat    = false;
116 bool opt_getloadingtime = false;   /* to measure the runtime                 */
117 bool opt_getcompilingtime = false; /* compute compile time                   */
118 #endif
119 #if defined(ENABLE_VERIFIER)
120 bool opt_verify  = true;       /* true if classfiles should be verified      */
121 #endif
122 bool opt_eager   = false;
123
124 bool opt_prof    = false;
125 bool opt_prof_bb = false;
126
127
128 /* optimization options *******************************************************/
129
130 #if defined(ENABLE_IFCONV)
131 bool opt_ifconv = false;
132 #endif
133
134 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
135 bool opt_lsra = false;
136 #endif
137
138
139 /* interpreter options ********************************************************/
140
141 #if defined(ENABLE_INTRP)
142 bool opt_no_dynamic = false;            /* suppress dynamic superinstructions */
143 bool opt_no_replication = false;        /* don't use replication in intrp     */
144 bool opt_no_quicksuper = false;         /* instructions for quickening cannot be
145                                                                                    part of dynamic superinstructions */
146
147 s4   opt_static_supers = 0x7fffffff;
148 bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
149 #endif
150
151
152 /* options_get *****************************************************************
153
154    DOCUMENT ME!!!
155
156 *******************************************************************************/
157
158 s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
159 {
160         char *option;
161         s4    i;
162
163         if (opt_index >= vm_args->nOptions)
164                 return OPT_DONE;
165
166         /* get the current option */
167
168         option = vm_args->options[opt_index].optionString;
169
170         if ((option == NULL) || (option[0] != '-'))
171                 return OPT_DONE;
172
173         for (i = 0; opts[i].name; i++) {
174                 if (!opts[i].arg) {
175                         /* boolean option found */
176
177                         if (strcmp(option + 1, opts[i].name) == 0) {
178                                 opt_index++;
179                                 return opts[i].value;
180                         }
181
182                 } else {
183                         /* parameter option found */
184
185                         /* with a space between */
186
187                         if (strcmp(option + 1, opts[i].name) == 0) {
188                                 opt_index++;
189
190                                 if (opt_index < vm_args->nOptions) {
191                                         opt_arg = strdup(vm_args->options[opt_index].optionString);
192                                         opt_index++;
193                                         return opts[i].value;
194                                 }
195
196                                 return OPT_ERROR;
197
198                         } else {
199                                 /* parameter and option have no space between */
200
201                                 size_t l = strlen(opts[i].name);
202
203                                 if (strlen(option + 1) > l) {
204                                         if (memcmp(option + 1, opts[i].name, l) == 0) {
205                                                 opt_index++;
206                                                 opt_arg = strdup(option + 1 + l);
207                                                 return opts[i].value;
208                                         }
209                                 }
210                         }
211                 }
212         }
213
214         return OPT_ERROR;
215 }
216
217
218 /* options_prepare *************************************************************
219
220    Prepare the JavaVMInitArgs.
221
222 *******************************************************************************/
223
224 JavaVMInitArgs *options_prepare(int argc, char **argv)
225 {
226         JavaVMInitArgs *vm_args;
227         s4              i;
228
229         vm_args = NEW(JavaVMInitArgs);
230
231         vm_args->version            = JNI_VERSION_1_2;
232         vm_args->nOptions           = argc - 1;
233         vm_args->options            = MNEW(JavaVMOption, argc);
234         vm_args->ignoreUnrecognized = JNI_FALSE;
235
236         for (i = 1; i < argc; i++)
237                 vm_args->options[i - 1].optionString = argv[i];
238
239         return vm_args;
240 }
241
242
243 /*
244  * These are local overrides for various environment variables in Emacs.
245  * Please do not remove this and leave it at the end of the file, where
246  * Emacs will automagically detect them.
247  * ---------------------------------------------------------------------
248  * Local variables:
249  * mode: c
250  * indent-tabs-mode: t
251  * c-basic-offset: 4
252  * tab-width: 4
253  * End:
254  */