* src/vmcore/options.c (opt_verbosethreads): Added.
[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 7894 2007-05-10 14:04:05Z twisti $
26
27 */
28
29
30 #include "config.h"
31
32 #if defined(HAVE_STRING_H)
33 # include <string.h>
34 #endif
35
36 #include <limits.h>
37
38 #include "vm/types.h"
39
40 #include "mm/memory.h"
41 #include "native/jni.h"
42 #include "vmcore/options.h"
43
44
45 /* command line option ********************************************************/
46
47 s4    opt_index = 0;            /* index of processed arguments               */
48 char *opt_arg;                  /* this one exports the option argument       */
49
50 bool opt_foo = false;           /* option for development                     */
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 opt_debugcolor = false;    /* use ANSI terminal sequences                */
70 bool compileall = false;
71
72 bool loadverbose = false;
73 bool linkverbose = false;
74 bool initverbose = false;
75
76 bool opt_verboseclass     = false;
77 bool opt_verbosegc        = false;
78 bool opt_verbosejni       = false;
79 bool opt_verbosecall      = false;      /* trace all method invocation        */
80 bool opt_verboseexception = false;
81 bool opt_verbosememory    = false;
82 bool opt_verbosethreads   = false;
83
84 bool showmethods = false;
85 bool showconstantpool = false;
86 bool showutf = false;
87
88 char *opt_method = NULL;
89 char *opt_signature = NULL;
90
91 bool compileverbose =  false;           /* trace compiler actions             */
92 bool showstack = false;
93
94 bool opt_showdisassemble    = false;    /* generate disassembler listing      */
95 bool opt_shownops           = false;
96 bool opt_showddatasegment   = false;    /* generate data segment listing      */
97 bool opt_showintermediate   = false;    /* generate intermediate code listing */
98 bool opt_showexceptionstubs = false;
99 bool opt_shownativestub     = false;
100
101 bool checkbounds = true;       /* check array bounds                         */
102 bool opt_noieee = false;       /* don't implement ieee compliant floats      */
103 bool checksync = true;         /* do synchronization                         */
104 #if defined(ENABLE_LOOP)
105 bool opt_loops = false;        /* optimize array accesses in loops           */
106 #endif
107
108 bool makeinitializations = true;
109
110 #if defined(ENABLE_STATISTICS)
111 bool opt_stat    = false;
112 bool opt_getloadingtime = false;   /* to measure the runtime                 */
113 bool opt_getcompilingtime = false; /* compute compile time                   */
114 #endif
115 #if defined(ENABLE_VERIFIER)
116 bool opt_verify  = true;       /* true if classfiles should be verified      */
117 #endif
118 bool opt_eager   = false;
119
120 #if defined(ENABLE_PROFILING)
121 bool opt_prof    = false;
122 bool opt_prof_bb = false;
123 #endif
124
125
126 /* inlining options ***********************************************************/
127
128 #if defined(ENABLE_INLINING)
129 bool opt_inlining = false;
130 #if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
131 s4 opt_replace_verbose = 0;
132 s4 opt_inline_debug_min_size = 0;
133 s4 opt_inline_debug_max_size = INT_MAX;
134 s4 opt_inline_debug_end_counter = INT_MAX;
135 bool opt_inline_debug_all = false;
136 #endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */
137 #if !defined(NDEBUG)
138 bool opt_inline_debug_log = false;
139 #endif /* !defined(NDEBUG) */
140 #endif /* defined(ENABLE_INLINING) */
141
142
143 /* optimization options *******************************************************/
144
145 #if defined(ENABLE_IFCONV)
146 bool opt_ifconv = false;
147 #endif
148
149 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
150 bool opt_lsra = false;
151 #endif
152
153
154 /* interpreter options ********************************************************/
155
156 #if defined(ENABLE_INTRP)
157 bool opt_no_dynamic = false;            /* suppress dynamic superinstructions */
158 bool opt_no_replication = false;        /* don't use replication in intrp     */
159 bool opt_no_quicksuper = false;         /* instructions for quickening cannot be
160                                                                                    part of dynamic superinstructions */
161
162 s4   opt_static_supers = 0x7fffffff;
163 bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
164 #endif
165
166
167 /* options_get *****************************************************************
168
169    DOCUMENT ME!!!
170
171 *******************************************************************************/
172
173 s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
174 {
175         char *option;
176         s4    i;
177
178         if (opt_index >= vm_args->nOptions)
179                 return OPT_DONE;
180
181         /* get the current option */
182
183         option = vm_args->options[opt_index].optionString;
184
185         if ((option == NULL) || (option[0] != '-'))
186                 return OPT_DONE;
187
188         for (i = 0; opts[i].name; i++) {
189                 if (!opts[i].arg) {
190                         /* boolean option found */
191
192                         if (strcmp(option + 1, opts[i].name) == 0) {
193                                 opt_index++;
194                                 return opts[i].value;
195                         }
196
197                 } else {
198                         /* parameter option found */
199
200                         /* with a space between */
201
202                         if (strcmp(option + 1, opts[i].name) == 0) {
203                                 opt_index++;
204
205                                 if (opt_index < vm_args->nOptions) {
206
207 #if defined(HAVE_STRDUP)
208                                         opt_arg = strdup(vm_args->options[opt_index].optionString);
209 #else
210 # error !HAVE_STRDUP
211 #endif
212
213                                         opt_index++;
214                                         return opts[i].value;
215                                 }
216
217                                 return OPT_ERROR;
218
219                         } else {
220                                 /* parameter and option have no space between */
221
222                                 /* FIXME: this assumption is plain wrong, hits you if there is a
223                                  * parameter with no argument starting with same letter as param with argument
224                                  * but named after that one, ouch! */
225
226                                 size_t l = strlen(opts[i].name);
227
228                                 if (strlen(option + 1) > l) {
229                                         if (memcmp(option + 1, opts[i].name, l) == 0) {
230                                                 opt_index++;
231
232 #if defined(HAVE_STRDUP)
233                                                 opt_arg = strdup(option + 1 + l);
234 #else
235 # error !HAVE_STRDUP
236 #endif
237
238                                                 return opts[i].value;
239                                         }
240                                 }
241                         }
242                 }
243         }
244
245         return OPT_ERROR;
246 }
247
248
249 /*
250  * These are local overrides for various environment variables in Emacs.
251  * Please do not remove this and leave it at the end of the file, where
252  * Emacs will automagically detect them.
253  * ---------------------------------------------------------------------
254  * Local variables:
255  * mode: c
256  * indent-tabs-mode: t
257  * c-basic-offset: 4
258  * tab-width: 4
259  * End:
260  */