* src/vm/options.c, src/vm/options.h (opt_rt, opt_xta, opt_vta):
[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 4396 2006-01-31 23:27:41Z twisti $
32
33 */
34
35
36 #include <string.h>
37
38 #include "config.h"
39 #include "vm/types.h"
40
41 #include "vm/options.h"
42
43
44 /* command line option ********************************************************/
45
46 s4   opt_ind = 1;               /* index of processed arguments               */
47 char *opt_arg;                  /* this one exports the option argument       */
48
49 #if defined(ENABLE_JIT)
50 bool opt_jit = true;            /* JIT mode execution (default)               */
51 bool opt_intrp = false;         /* interpreter mode execution                 */
52 #else
53 bool opt_jit = false;           /* JIT mode execution                         */
54 bool opt_intrp = true;          /* interpreter mode execution (default)       */
55 #endif
56
57 s4   opt_stacksize = 0;         /* thread stack size                          */
58
59 bool opt_verbose = false;
60 bool compileall = false;
61 bool runverbose = false;        /* trace all method invocation                */
62 bool opt_verboseexception = false;
63
64 bool loadverbose = false;
65 bool linkverbose = false;
66 bool initverbose = false;
67
68 bool opt_verboseclass = false;
69 bool opt_verbosegc = false;
70 bool opt_verbosejni = false;
71
72 bool opt_liberalutf = false;   /* Don't check overlong UTF-8 sequences        */
73
74 bool showmethods = false;
75 bool showconstantpool = false;
76 bool showutf = false;
77
78 bool compileverbose =  false;           /* trace compiler actions             */
79 bool showstack = false;
80 bool opt_showdisassemble = false;       /* generate disassembler listing      */
81 bool opt_showddatasegment = false;      /* generate data segment listing      */
82 bool opt_showintermediate = false;      /* generate intermediate code listing */
83 bool opt_showexceptionstubs = false;
84 bool opt_shownativestub = false;
85
86 bool useinlining = false;      /* use method inlining                        */
87 bool inlinevirtuals = false;   /* inline unique virtual methods              */
88 bool inlineexceptions = false; /* inline methods, that contain excptions     */
89 bool inlineparamopt = false;   /* optimize parameter passing to inlined methods */
90 bool inlineoutsiders = false;  /* inline methods, that are not member of the invoker's class */
91
92 bool checkbounds = true;       /* check array bounds                         */
93 bool checknull = true;         /* check null pointers                        */
94 bool opt_noieee = false;       /* don't implement ieee compliant floats      */
95 bool checksync = true;         /* do synchronization                         */
96 bool opt_loops = false;        /* optimize array accesses in loops           */
97
98 bool makeinitializations = true;
99
100 bool getloadingtime = false;   /* to measure the runtime                     */
101 bool getcompilingtime = false; /* compute compile time                       */
102
103 bool opt_stat    = false;
104 bool opt_verify  = true;       /* true if classfiles should be verified      */
105 bool opt_eager   = false;
106
107 bool opt_prof    = false;
108 bool opt_prof_bb = false;
109
110 #if defined(ENABLE_LSRA)
111 bool opt_lsra = false;
112 #endif
113
114
115 /* interpreter options ********************************************************/
116
117 #if defined(ENABLE_INTRP)
118 bool opt_no_dynamic = false;            /* suppress dynamic superinstructions */
119 bool opt_no_replication = false;        /* don't use replication in intrp     */
120 bool opt_no_quicksuper = false;         /* instructions for quickening cannot be
121                                                                                    part of dynamic superinstructions */
122
123 s4   opt_static_supers = 0x7fffffff;
124 bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
125 #endif
126
127
128 /* get_opt *********************************************************************
129
130    DOCUMENT ME!!!
131
132 *******************************************************************************/
133
134 int get_opt(int argc, char **argv, opt_struct *opts)
135 {
136         char *a;
137         s4    i;
138         
139         if (opt_ind >= argc)
140                 return OPT_DONE;
141         
142         a = argv[opt_ind];
143
144         if (a[0] != '-')
145                 return OPT_DONE;
146
147         for (i = 0; opts[i].name; i++) {
148                 if (!opts[i].arg) {
149                         /* boolean option found */
150
151                         if (strcmp(a + 1, opts[i].name) == 0) {
152                                 opt_ind++;
153                                 return opts[i].value;
154                         }
155
156                 } else {
157                         /* parameter option found */
158
159                         /* with a space between */
160
161                         if (strcmp(a + 1, opts[i].name) == 0) {
162                                 opt_ind++;
163
164                                 if (opt_ind < argc) {
165                                         opt_arg = argv[opt_ind];
166                                         opt_ind++;
167                                         return opts[i].value;
168                                 }
169
170                                 return OPT_ERROR;
171
172                         } else {
173                                 /* parameter and option have no space between */
174
175                                 size_t l = strlen(opts[i].name);
176                                 if (strlen(a + 1) > l) {
177                                         if (memcmp(a + 1, opts[i].name, l) == 0) {
178                                                 opt_ind++;
179                                                 opt_arg = a + 1 + l;
180                                                 return opts[i].value;
181                                         }
182                                 }
183                         }
184                 }
185         } /* end for */ 
186
187         return OPT_ERROR;
188 }
189
190
191 /*
192  * These are local overrides for various environment variables in Emacs.
193  * Please do not remove this and leave it at the end of the file, where
194  * Emacs will automagically detect them.
195  * ---------------------------------------------------------------------
196  * Local variables:
197  * mode: c
198  * indent-tabs-mode: t
199  * c-basic-offset: 4
200  * tab-width: 4
201  * End:
202  */