1 /* src/vm/vm.hpp - basic JVM functions
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
34 // We need the JNI types for the VM class.
35 #include "native/jni.hpp"
36 #include "native/native.hpp"
38 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
39 # include "native/vm/openjdk/hpi.hpp"
40 # include "native/vm/openjdk/management.hpp"
43 #include "vm/properties.hpp"
44 #include "vm/suck.hpp"
46 #include "vm/jit/optimizing/recompiler.hpp"
52 * Represent an instance of a VM.
56 // This is _the_ VM instance.
70 Properties _properties; ///< Commandline properties.
71 #if defined(ENABLE_THREADS)
72 Recompiler _recompiler; ///< JIT recompilation framework.
74 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
75 HPI _hpi; ///< Host Porting Interface.
76 Management _management; ///< Java management interface.
78 NativeLibraries _nativelibraries; ///< Native library table.
79 NativeMethods _nativemethods; ///< Native methods table.
80 #if defined(ENABLE_JVMTI)
81 NativeAgents _nativeagents; ///< Native agents table.
83 SuckClasspath _suckclasspath; ///< Classpath entries list.
86 // Constructor, Destructor.
91 static bool create(JavaVM** p_vm, void** p_env, void* vm_args);
92 static VM* get_current() { return _vm; }
94 static void print_build_time_config();
95 void print_run_time_config();
97 // Getters for private members.
98 JavaVM* get_javavm() { return _javavm; }
99 JNIEnv* get_jnienv() { return _jnienv; }
100 bool is_initializing() { return _initializing; }
101 bool is_created() { return _created; }
102 bool is_exiting() { return _exiting; }
103 int64_t get_starttime() { return _starttime; }
105 Properties& get_properties () { return _properties; }
106 Recompiler& get_recompiler () { return _recompiler; } // REMOVEME
107 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
108 HPI& get_hpi () { return _hpi; }
109 Management& get_management () { return _management; }
111 NativeLibraries& get_nativelibraries() { return _nativelibraries; }
112 NativeMethods& get_nativemethods () { return _nativemethods; }
113 SuckClasspath& get_suckclasspath () { return _suckclasspath; }
118 JavaVM* VM_get_javavm();
119 JNIEnv* VM_get_jnienv();
120 bool VM_is_initializing();
121 bool VM_is_created();
122 int64_t VM_get_starttime();
128 #include "vm/global.h"
129 #include "vm/method.hpp"
132 /* These C methods are the exported interface. ********************************/
138 bool VM_create(JavaVM** p_vm, void** p_env, void* vm_args);
145 /* export global variables ****************************************************/
147 #if defined(ENABLE_INTRP)
148 extern uint8_t* intrp_main_stack;
152 /* function prototypes ********************************************************/
160 bool vm_create(JavaVMInitArgs *vm_args);
161 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args);
162 int32_t vm_destroy(JavaVM *vm);
163 void vm_exit(int32_t status);
164 void vm_shutdown(int32_t status);
166 void vm_exit_handler(void);
168 void vm_abort_disassemble(void *pc, int count, const char *text, ...);
170 /* Java method calling functions */
172 java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...);
173 java_handle_t *vm_call_method_valist(methodinfo *m, java_handle_t *o,
175 java_handle_t *vm_call_method_jvalue(methodinfo *m, java_handle_t *o,
178 int32_t vm_call_method_int(methodinfo *m, java_handle_t *o, ...);
179 int32_t vm_call_method_int_valist(methodinfo *m, java_handle_t *o, va_list ap);
180 int32_t vm_call_method_int_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
182 int64_t vm_call_method_long(methodinfo *m, java_handle_t *o, ...);
183 int64_t vm_call_method_long_valist(methodinfo *m, java_handle_t *o, va_list ap);
184 int64_t vm_call_method_long_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
186 float vm_call_method_float(methodinfo *m, java_handle_t *o, ...);
187 float vm_call_method_float_valist(methodinfo *m, java_handle_t *o, va_list ap);
188 float vm_call_method_float_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
190 double vm_call_method_double(methodinfo *m, java_handle_t *o, ...);
191 double vm_call_method_double_valist(methodinfo *m, java_handle_t *o, va_list ap);
192 double vm_call_method_double_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args);
194 java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params);
197 // Legacy C interface.
198 void vm_abort(const char* text, ...);
208 * These are local overrides for various environment variables in Emacs.
209 * Please do not remove this and leave it at the end of the file, where
210 * Emacs will automagically detect them.
211 * ---------------------------------------------------------------------
214 * indent-tabs-mode: t
218 * vim:noexpandtab:sw=4:ts=4: