* Added opt_jit, opt_intrp
[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 3152 2005-09-05 21:39:50Z twisti $
32
33 */
34
35
36 #include <string.h>
37
38 #include "config.h"
39 #include "types.h"
40
41 #include "vm/options.h"
42
43
44 /* command line option */
45
46 bool vm_debug = false;
47
48 #if defined(ENABLE_JIT)
49 bool opt_jit = true;            /* JIT mode execution (default)               */
50 bool opt_intrp = false;         /* interpreter mode execution                 */
51 #else
52 bool opt_jit = false;           /* JIT mode execution                         */
53 bool opt_intrp = true;          /* interpreter mode execution (default)       */
54 #endif
55
56 bool opt_verbose = false;
57 bool compileall = false;
58 bool runverbose = false;        /* trace all method invocation                */
59 bool verboseexception = false;
60
61 bool loadverbose = false;
62 bool linkverbose = false;
63 bool initverbose = false;
64 bool opt_verbosegc = false;
65 bool opt_verbosejni = false;
66
67 bool opt_rt = false;           /* true if RTA parse should be used     RT-CO  */
68 bool opt_xta = false;          /* true if XTA parse should be used    XTA-CO  */
69 bool opt_vta = false;          /* true if VTA parse should be used    VTA-CO  */
70
71 bool opt_liberalutf = false;   /* Don't check overlong UTF-8 sequences        */
72
73 bool showmethods = false;
74 bool showconstantpool = false;
75 bool showutf = false;
76
77 bool compileverbose =  false;           /* trace compiler actions             */
78 bool showstack = false;
79 bool opt_showdisassemble = false;       /* generate disassembler listing      */
80 bool opt_showddatasegment = false;      /* generate data segment listing      */
81 bool opt_showintermediate = false;      /* generate intermediate code listing */
82 bool opt_showexceptionstubs = false;
83 bool opt_shownativestub = false;
84
85 bool useinliningm = false;      /* use method inlining                        */
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 int has_ext_instr_set = 0;     /* has instruction set extensions */
104
105 bool opt_stat = false;
106 bool opt_verify = true;        /* true if classfiles should be verified      */
107 bool opt_eager = false;
108 #ifdef LSRA
109 bool opt_lsra = false;
110 #endif
111 int opt_ind = 1;               /* index of processed arguments               */
112 char *opt_arg;                 /* this one exports the option argument       */
113
114
115 /* get_opt *********************************************************************
116
117    DOCUMENT ME!!!
118
119 *******************************************************************************/
120
121 int get_opt(int argc, char **argv, opt_struct *opts)
122 {
123         char *a;
124         s4    i;
125         
126         if (opt_ind >= argc)
127                 return OPT_DONE;
128         
129         a = argv[opt_ind];
130
131         if (a[0] != '-')
132                 return OPT_DONE;
133
134         for (i = 0; opts[i].name; i++) {
135                 if (!opts[i].arg) {
136                         /* boolean option found */
137
138                         if (strcmp(a + 1, opts[i].name) == 0) {
139                                 opt_ind++;
140                                 return opts[i].value;
141                         }
142
143                 } else {
144                         /* parameter option found */
145
146                         /* with a space between */
147
148                         if (strcmp(a + 1, opts[i].name) == 0) {
149                                 opt_ind++;
150
151                                 if (opt_ind < argc) {
152                                         opt_arg = argv[opt_ind];
153                                         opt_ind++;
154                                         return opts[i].value;
155                                 }
156
157                                 return OPT_ERROR;
158
159                         } else {
160                                 /* parameter and option have no space between */
161
162                                 size_t l = strlen(opts[i].name);
163                                 if (strlen(a + 1) > l) {
164                                         if (memcmp(a + 1, opts[i].name, l) == 0) {
165                                                 opt_ind++;
166                                                 opt_arg = a + 1 + l;
167                                                 return opts[i].value;
168                                         }
169                                 }
170                         }
171                 }
172         } /* end for */ 
173
174         return OPT_ERROR;
175 }
176
177
178 /*
179  * These are local overrides for various environment variables in Emacs.
180  * Please do not remove this and leave it at the end of the file, where
181  * Emacs will automagically detect them.
182  * ---------------------------------------------------------------------
183  * Local variables:
184  * mode: c
185  * indent-tabs-mode: t
186  * c-basic-offset: 4
187  * tab-width: 4
188  * End:
189  */