* opt_stacksize, opt_static_supers: Added.
[cacao.git] / src / vm / options.c
1 /* src/vm/options.c - contains global options
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    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., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Thalinger
28
29    Changes:
30
31    $Id: options.c 3243 2005-09-21 14:55:34Z 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 verboseexception = false;
63
64 bool loadverbose = false;
65 bool linkverbose = false;
66 bool initverbose = false;
67 bool opt_verbosegc = false;
68 bool opt_verbosejni = false;
69
70 bool opt_rt = false;           /* true if RTA parse should be used     RT-CO  */
71 bool opt_xta = false;          /* true if XTA parse should be used    XTA-CO  */
72 bool opt_vta = false;          /* true if VTA parse should be used    VTA-CO  */
73
74 bool opt_liberalutf = false;   /* Don't check overlong UTF-8 sequences        */
75
76 bool showmethods = false;
77 bool showconstantpool = false;
78 bool showutf = false;
79
80 bool compileverbose =  false;           /* trace compiler actions             */
81 bool showstack = false;
82 bool opt_showdisassemble = false;       /* generate disassembler listing      */
83 bool opt_showddatasegment = false;      /* generate data segment listing      */
84 bool opt_showintermediate = false;      /* generate intermediate code listing */
85 bool opt_showexceptionstubs = false;
86 bool opt_shownativestub = false;
87
88 bool useinliningm = false;      /* use method inlining                        */
89 bool useinlining = false;      /* use method inlining                        */
90 bool inlinevirtuals = false;   /* inline unique virtual methods              */
91 bool inlineexceptions = false; /* inline methods, that contain excptions     */
92 bool inlineparamopt = false;   /* optimize parameter passing to inlined methods */
93 bool inlineoutsiders = false;  /* inline methods, that are not member of the invoker's class */
94
95 bool checkbounds = true;       /* check array bounds                         */
96 bool checknull = true;         /* check null pointers                        */
97 bool opt_noieee = false;       /* don't implement ieee compliant floats      */
98 bool checksync = true;         /* do synchronization                         */
99 bool opt_loops = false;        /* optimize array accesses in loops           */
100
101 bool makeinitializations = true;
102
103 bool getloadingtime = false;   /* to measure the runtime                     */
104 bool getcompilingtime = false; /* compute compile time                       */
105
106 int has_ext_instr_set = 0;     /* has instruction set extensions */
107
108 bool opt_stat = false;
109 bool opt_verify = true;        /* true if classfiles should be verified      */
110 bool opt_eager = false;
111 #ifdef LSRA
112 bool opt_lsra = false;
113 #endif
114
115 s4 opt_static_supers = 0x7fffffff;
116 bool vm_debug = false;          /* XXX this should be called `opt_trace'      */
117
118
119 /* get_opt *********************************************************************
120
121    DOCUMENT ME!!!
122
123 *******************************************************************************/
124
125 int get_opt(int argc, char **argv, opt_struct *opts)
126 {
127         char *a;
128         s4    i;
129         
130         if (opt_ind >= argc)
131                 return OPT_DONE;
132         
133         a = argv[opt_ind];
134
135         if (a[0] != '-')
136                 return OPT_DONE;
137
138         for (i = 0; opts[i].name; i++) {
139                 if (!opts[i].arg) {
140                         /* boolean option found */
141
142                         if (strcmp(a + 1, opts[i].name) == 0) {
143                                 opt_ind++;
144                                 return opts[i].value;
145                         }
146
147                 } else {
148                         /* parameter option found */
149
150                         /* with a space between */
151
152                         if (strcmp(a + 1, opts[i].name) == 0) {
153                                 opt_ind++;
154
155                                 if (opt_ind < argc) {
156                                         opt_arg = argv[opt_ind];
157                                         opt_ind++;
158                                         return opts[i].value;
159                                 }
160
161                                 return OPT_ERROR;
162
163                         } else {
164                                 /* parameter and option have no space between */
165
166                                 size_t l = strlen(opts[i].name);
167                                 if (strlen(a + 1) > l) {
168                                         if (memcmp(a + 1, opts[i].name, l) == 0) {
169                                                 opt_ind++;
170                                                 opt_arg = a + 1 + l;
171                                                 return opts[i].value;
172                                         }
173                                 }
174                         }
175                 }
176         } /* end for */ 
177
178         return OPT_ERROR;
179 }
180
181
182 /*
183  * These are local overrides for various environment variables in Emacs.
184  * Please do not remove this and leave it at the end of the file, where
185  * Emacs will automagically detect them.
186  * ---------------------------------------------------------------------
187  * Local variables:
188  * mode: c
189  * indent-tabs-mode: t
190  * c-basic-offset: 4
191  * tab-width: 4
192  * End:
193  */