* configure.ac: Default to AC_ENABLE_SHARED and AC_DISABLE_STATIC.
[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 4530 2006-02-21 09:11:53Z twisti $
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 #if defined(ENABLE_JIT)
53 bool opt_jit = true;            /* JIT mode execution (default)               */
54 bool opt_intrp = false;         /* interpreter mode execution                 */
55 #else
56 bool opt_jit = false;           /* JIT mode execution                         */
57 bool opt_intrp = true;          /* interpreter mode execution (default)       */
58 #endif
59
60 bool opt_jar = false;
61 bool opt_run = true;
62
63 s4   opt_stacksize = 0;         /* thread stack size                          */
64
65 bool opt_verbose = false;
66 bool compileall = false;
67 bool runverbose = false;        /* trace all method invocation                */
68 bool opt_verboseexception = false;
69
70 bool loadverbose = false;
71 bool linkverbose = false;
72 bool initverbose = false;
73
74 bool opt_verboseclass = false;
75 bool opt_verbosegc = false;
76 bool opt_verbosejni = false;
77
78 bool opt_liberalutf = false;   /* Don't check overlong UTF-8 sequences        */
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 bool opt_showdisassemble = false;       /* generate disassembler listing      */
90 bool opt_showddatasegment = false;      /* generate data segment listing      */
91 bool opt_showintermediate = false;      /* generate intermediate code listing */
92 bool opt_showexceptionstubs = false;
93 bool opt_shownativestub = false;
94
95 bool useinlining = false;      /* use method inlining                        */
96 bool inlinevirtuals = false;   /* inline unique virtual methods              */
97 bool inlineexceptions = false; /* inline methods, that contain excptions     */
98 bool inlineparamopt = false;   /* optimize parameter passing to inlined methods */
99 bool inlineoutsiders = false;  /* inline methods, that are not member of the invoker's class */
100
101 bool checkbounds = true;       /* check array bounds                         */
102 bool checknull = true;         /* check null pointers                        */
103 bool opt_noieee = false;       /* don't implement ieee compliant floats      */
104 bool checksync = true;         /* do synchronization                         */
105 bool opt_loops = false;        /* optimize array accesses in loops           */
106
107 bool makeinitializations = true;
108
109 bool getloadingtime = false;   /* to measure the runtime                     */
110 bool getcompilingtime = false; /* compute compile time                       */
111
112 bool opt_stat    = false;
113 bool opt_verify  = true;       /* true if classfiles should be verified      */
114 bool opt_eager   = false;
115
116 bool opt_prof    = false;
117 bool opt_prof_bb = false;
118
119
120 /* optimization options *******************************************************/
121
122 #if defined(ENABLE_IFCONV)
123 bool opt_ifconv = false;
124 #endif
125
126 #if defined(ENABLE_LSRA)
127 bool opt_lsra = false;
128 #endif
129
130
131 /* interpreter options ********************************************************/
132
133 #if defined(ENABLE_INTRP)
134 bool opt_no_dynamic = false;            /* suppress dynamic superinstructions */
135 bool opt_no_replication = false;        /* don't use replication in intrp     */
136 bool opt_no_quicksuper = false;         /* instructions for quickening cannot be
137                                                                                    part of dynamic superinstructions */
138
139 s4   opt_static_supers = 0x7fffffff;
140 bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
141 #endif
142
143
144 /* options_get *****************************************************************
145
146    DOCUMENT ME!!!
147
148 *******************************************************************************/
149
150 s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
151 {
152         char *option;
153         s4    i;
154
155         if (opt_index >= vm_args->nOptions)
156                 return OPT_DONE;
157
158         /* get the current option */
159
160         option = vm_args->options[opt_index].optionString;
161
162         if ((option == NULL) || (option[0] != '-'))
163                 return OPT_DONE;
164
165         for (i = 0; opts[i].name; i++) {
166                 if (!opts[i].arg) {
167                         /* boolean option found */
168
169                         if (strcmp(option + 1, opts[i].name) == 0) {
170                                 opt_index++;
171                                 return opts[i].value;
172                         }
173
174                 } else {
175                         /* parameter option found */
176
177                         /* with a space between */
178
179                         if (strcmp(option + 1, opts[i].name) == 0) {
180                                 opt_index++;
181
182                                 if (opt_index < vm_args->nOptions) {
183                                         opt_arg = strdup(vm_args->options[opt_index].optionString);
184                                         opt_index++;
185                                         return opts[i].value;
186                                 }
187
188                                 return OPT_ERROR;
189
190                         } else {
191                                 /* parameter and option have no space between */
192
193                                 size_t l = strlen(opts[i].name);
194
195                                 if (strlen(option + 1) > l) {
196                                         if (memcmp(option + 1, opts[i].name, l) == 0) {
197                                                 opt_index++;
198                                                 opt_arg = strdup(option + 1 + l);
199                                                 return opts[i].value;
200                                         }
201                                 }
202                         }
203                 }
204         }
205
206         return OPT_ERROR;
207 }
208
209
210 /* options_prepare *************************************************************
211
212    Prepare the JavaVMInitArgs.
213
214 *******************************************************************************/
215
216 JavaVMInitArgs *options_prepare(int argc, char **argv)
217 {
218         JavaVMInitArgs *vm_args;
219         s4              i;
220
221         vm_args = NEW(JavaVMInitArgs);
222
223         vm_args->version            = JNI_VERSION_1_2;
224         vm_args->nOptions           = argc - 1;
225         vm_args->options            = MNEW(JavaVMOption, argc);
226         vm_args->ignoreUnrecognized = JNI_FALSE;
227
228         for (i = 1; i < argc; i++)
229                 vm_args->options[i - 1].optionString = argv[i];
230
231         return vm_args;
232 }
233
234
235 /*
236  * These are local overrides for various environment variables in Emacs.
237  * Please do not remove this and leave it at the end of the file, where
238  * Emacs will automagically detect them.
239  * ---------------------------------------------------------------------
240  * Local variables:
241  * mode: c
242  * indent-tabs-mode: t
243  * c-basic-offset: 4
244  * tab-width: 4
245  * End:
246  */