* src/vm/options.h, src/vm/method.c, src/vm/jit/inline/inline.c,
[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 7228 2007-01-19 01:13:48Z edwin $
32
33 */
34
35
36 #include "config.h"
37
38 #include <string.h>
39 #include <limits.h>
40
41 #include "vm/types.h"
42
43 #include "mm/memory.h"
44 #include "native/jni.h"
45 #include "vm/options.h"
46
47
48 /* command line option ********************************************************/
49
50 s4    opt_index = 0;            /* index of processed arguments               */
51 char *opt_arg;                  /* this one exports the option argument       */
52
53 bool opt_foo = false;           /* option for development                     */
54
55 bool opt_jar = false;
56
57 #if defined(ENABLE_JIT)
58 bool opt_jit = true;            /* JIT mode execution (default)               */
59 bool opt_intrp = false;         /* interpreter mode execution                 */
60 #else
61 bool opt_jit = false;           /* JIT mode execution                         */
62 bool opt_intrp = true;          /* interpreter mode execution (default)       */
63 #endif
64
65 bool opt_run = true;
66
67 s4   opt_heapmaxsize   = 0;     /* maximum heap size                          */
68 s4   opt_heapstartsize = 0;     /* initial heap size                          */
69 s4   opt_stacksize     = 0;     /* thread stack size                          */
70
71 bool opt_verbose = false;
72 bool opt_debugcolor = false;    /* use ANSI terminal sequences                */
73 bool compileall = false;
74
75 bool loadverbose = false;
76 bool linkverbose = false;
77 bool initverbose = false;
78
79 bool opt_verboseclass     = false;
80 bool opt_verbosegc        = false;
81 bool opt_verbosejni       = false;
82 bool opt_verbosecall      = false;      /* trace all method invocation        */
83 bool opt_verboseexception = false;
84
85 bool showmethods = false;
86 bool showconstantpool = false;
87 bool showutf = false;
88
89 char *opt_method = NULL;
90 char *opt_signature = NULL;
91
92 bool compileverbose =  false;           /* trace compiler actions             */
93 bool showstack = false;
94
95 bool opt_showdisassemble    = false;    /* generate disassembler listing      */
96 bool opt_shownops           = false;
97 bool opt_showddatasegment   = false;    /* generate data segment listing      */
98 bool opt_showintermediate   = false;    /* generate intermediate code listing */
99 bool opt_showexceptionstubs = false;
100 bool opt_shownativestub     = false;
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 #if defined(ENABLE_PROFILING)
123 bool opt_prof    = false;
124 bool opt_prof_bb = false;
125 #endif
126
127
128 /* inlining options ***********************************************************/
129
130 #if defined(ENABLE_INLINING)
131 bool opt_inlining = false;
132 #if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
133 s4 opt_replace_verbose = 0;
134 s4 opt_inline_debug_min_size = 0;
135 s4 opt_inline_debug_max_size = INT_MAX;
136 s4 opt_inline_debug_end_counter = INT_MAX;
137 bool opt_inline_debug_all = false;
138 #endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */
139 #if !defined(NDEBUG)
140 bool opt_inline_debug_log = false;
141 #endif /* !defined(NDEBUG) */
142 #endif /* defined(ENABLE_INLINING) */
143
144
145 /* optimization options *******************************************************/
146
147 #if defined(ENABLE_IFCONV)
148 bool opt_ifconv = false;
149 #endif
150
151 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
152 bool opt_lsra = false;
153 #endif
154
155
156 /* interpreter options ********************************************************/
157
158 #if defined(ENABLE_INTRP)
159 bool opt_no_dynamic = false;            /* suppress dynamic superinstructions */
160 bool opt_no_replication = false;        /* don't use replication in intrp     */
161 bool opt_no_quicksuper = false;         /* instructions for quickening cannot be
162                                                                                    part of dynamic superinstructions */
163
164 s4   opt_static_supers = 0x7fffffff;
165 bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
166 #endif
167
168
169 /* options_get *****************************************************************
170
171    DOCUMENT ME!!!
172
173 *******************************************************************************/
174
175 s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
176 {
177         char *option;
178         s4    i;
179
180         if (opt_index >= vm_args->nOptions)
181                 return OPT_DONE;
182
183         /* get the current option */
184
185         option = vm_args->options[opt_index].optionString;
186
187         if ((option == NULL) || (option[0] != '-'))
188                 return OPT_DONE;
189
190         for (i = 0; opts[i].name; i++) {
191                 if (!opts[i].arg) {
192                         /* boolean option found */
193
194                         if (strcmp(option + 1, opts[i].name) == 0) {
195                                 opt_index++;
196                                 return opts[i].value;
197                         }
198
199                 } else {
200                         /* parameter option found */
201
202                         /* with a space between */
203
204                         if (strcmp(option + 1, opts[i].name) == 0) {
205                                 opt_index++;
206
207                                 if (opt_index < vm_args->nOptions) {
208                                         opt_arg = strdup(vm_args->options[opt_index].optionString);
209                                         opt_index++;
210                                         return opts[i].value;
211                                 }
212
213                                 return OPT_ERROR;
214
215                         } else {
216                                 /* parameter and option have no space between */
217
218                                 /* FIXME: this assumption is plain wrong, hits you if there is a
219                                  * parameter with no argument starting with same letter as param with argument
220                                  * but named after that one, ouch! */
221
222                                 size_t l = strlen(opts[i].name);
223
224                                 if (strlen(option + 1) > l) {
225                                         if (memcmp(option + 1, opts[i].name, l) == 0) {
226                                                 opt_index++;
227                                                 opt_arg = strdup(option + 1 + l);
228                                                 return opts[i].value;
229                                         }
230                                 }
231                         }
232                 }
233         }
234
235         return OPT_ERROR;
236 }
237
238
239 /*
240  * These are local overrides for various environment variables in Emacs.
241  * Please do not remove this and leave it at the end of the file, where
242  * Emacs will automagically detect them.
243  * ---------------------------------------------------------------------
244  * Local variables:
245  * mode: c
246  * indent-tabs-mode: t
247  * c-basic-offset: 4
248  * tab-width: 4
249  * End:
250  */