* configure.ac,
[cacao.git] / src / vm / vm.h
1 /* src/vm/vm.h - basic JVM functions
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: finalizer.c 4357 2006-01-22 23:33:38Z twisti $
26
27 */
28
29
30 #ifndef _VM_H
31 #define _VM_H
32
33 #include "config.h"
34
35 #include <stdarg.h>
36
37 #include "vm/types.h"
38
39 #include "native/jni.h"
40
41 #include "vm/global.h"
42
43 #include "vmcore/class.h"
44 #include "vmcore/method.h"
45
46
47 /* export global variables ****************************************************/
48
49 extern _Jv_JavaVM *_Jv_jvm;
50 extern _Jv_JNIEnv *_Jv_env;
51
52 extern bool vm_initializing;
53 extern bool vm_exiting;
54
55 extern char      *cacao_prefix;
56 extern char      *cacao_libjvm;
57 extern char      *classpath_libdir;
58
59 extern char      *_Jv_bootclasspath;
60 extern char      *_Jv_classpath;
61 extern char      *_Jv_java_library_path;
62
63 extern char      *mainstring;
64 extern classinfo *mainclass;
65
66 #if defined(ENABLE_INTRP)
67 extern u1 *intrp_main_stack;
68 #endif
69
70
71 /* vm_arg **********************************************************************
72
73    Datastructure for arguments to call Java methods via vm_call_method
74    functions.
75
76 *******************************************************************************/
77
78 typedef struct vm_arg vm_arg;
79
80 struct vm_arg {
81         u8 type;
82
83         union {
84                 u8     l;
85                 float  f;
86                 double d;
87         } data;
88 };
89
90
91 /* function prototypes ********************************************************/
92
93 void usage(void);
94
95 bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args);
96 bool vm_create(JavaVMInitArgs *vm_args);
97 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args);
98 s4   vm_destroy(JavaVM *vm);
99 void vm_exit(s4 status);
100 void vm_shutdown(s4 status);
101
102 void vm_exit_handler(void);
103
104 void vm_abort(const char *text, ...);
105
106 /* Java method calling functions */
107 #if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
108 bool vm_vmargs_from_objectarray(methodinfo *m, java_objectheader *o,
109                                                                 vm_arg *vmargs, java_objectarray *params);
110 #else
111 uint64_t *vm_array_from_objectarray(methodinfo *m, java_objectheader *o,
112                                                                         java_objectarray *params);
113 #endif
114
115 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...);
116 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
117                                                                                  va_list ap);
118 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
119                                                                                  const jvalue *args);
120
121 #if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) & !defined(__ARM__)
122 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
123                                                                                 vm_arg *vmargs);
124 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
125 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
126 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
127 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
128 #else
129 java_objectheader *vm_call_array(methodinfo *m, uint64_t *array);
130 int32_t            vm_call_int_array(methodinfo *m, uint64_t *array);
131 int64_t            vm_call_long_array(methodinfo *m, uint64_t *array);
132 float              vm_call_float_array(methodinfo *m, uint64_t *array);
133 double             vm_call_double_array(methodinfo *m, uint64_t *array);
134 #endif
135
136 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...);
137 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap);
138 s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o,
139                                                          const jvalue *args);
140
141 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...);
142 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap);
143 s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o,
144                                                           const jvalue *args);
145
146 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...);
147 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
148                                                                   va_list ap);
149 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
150                                                                   const jvalue *args);
151
152 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...);
153 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
154                                                                         va_list ap);
155 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
156                                                                         const jvalue *args);
157
158 #endif /* _VM_H */
159
160 /*
161  * These are local overrides for various environment variables in Emacs.
162  * Please do not remove this and leave it at the end of the file, where
163  * Emacs will automagically detect them.
164  * ---------------------------------------------------------------------
165  * Local variables:
166  * mode: c
167  * indent-tabs-mode: t
168  * c-basic-offset: 4
169  * tab-width: 4
170  * End:
171  */