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