(ifconv): Added.
(jni.h): Check for jni.h in GNU Classpath.
(static-classpath): Added.
* src/vm/vm.c, src/vm/vm.h: New files, contain the JVM startup code.
* src/vm/Makefile.am (libvm_la_SOURCES): Added vm.[ch].
* src/cacao/cacao.c: Removed JVM startup code.
* src/cacao/cacao.h: Removed.
* src/cacao/Makefile.am: Replaced ENABLE_STATICVM by
WITH_STATIC_CLASSPATH.
(ENABLE_STATICVM): Build a shared library when not defined.
* src/vm/options.c, src/vm/options.h (mm/memory.h, native/jni.h):
Added.
(native/jni.h): Added.
(opt_ind): Renamed to opt_index.
(opt_jar, opt_run, opt_method, opt_signature, opt_ifconv): Added.
(get_opt): Renamed to options_get.
(options_prepare): New method.
* src/cacaoh/cacaoh.c (main): Use new option handling.
* src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c,
src/vm/jit/i386/codegen.c, src/vm/jit/mips/codegen.c,
src/vm/jit/powerpc/codegen.c (cacao/cacao.h): Removed.
(vm/vm.h): Added.
(createnativestub): Replaced ENABLE_STATICVM with
WITH_STATIC_CLASSPATH and &env by _Jv_env.
* src/vm/jit/patcher.h, src/vm/jit/alpha/patcher.c,
src/vm/jit/arm/patcher.c, src/vm/jit/i386/patcher.c,
src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c,
src/vm/jit/x86_64/patcher.c: Replaced ENABLE_STATICVM by
WITH_STATIC_CLASSPATH.
* src/vm/jit/x86_64/asmpart.S: Rewritten for PIC code.
* src/vm/signal.c (cacao/cacao.h): Removed.
(vm/vm.h): Added.
(signal_handler_sigint): Use vm_* functions.
* src/native/native.c: Replaced ENABLE_STATICVM by
WITH_STATIC_CLASSPATH.
(cacao/cacao.h): Removed.
(native_resolve_function): Smaller changes.
* src/native/vm/VMRuntime.c: Replaced ENABLE_STATICVM by
WITH_STATIC_CLASSPATH.
(cacao/cacao.h): Removed.
(vm/vm.h): Added.
(execInternal): Removed.
(exit): Use vm_shutdown.
* src/native/native.h: Replaced ENABLE_STATICVM by
WITH_STATIC_CLASSPATH.
* src/native/Makefile.am: Likewise.
* src/native/vm/VMSystemProperties.c: Likewise.
* src/threads/native/threads.c (cacao/cacao.h): Removed.
* src/native/jni.h: Removed our JNI stuff and include GNU Classpath's.
* src/native/jni.c: Adapt to the new jni.h header.
(Release<type>ArrayElements): Copy correct element type.
(Get<type>ArrayRegion): Likewise.
(Set<type>ArrayRegion): Likewise.
AC_PROG_LD
AC_PROG_LD_GNU
AC_PROG_RANLIB
-AC_DISABLE_SHARED
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_MKDIR_P
+AC_ENABLE_SHARED
+AC_DISABLE_STATIC
+
dnl libtool stuff
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
fi
+dnl check if if-conversion should be supported
+AC_MSG_CHECKING(whether if-conversion should be supported)
+AC_ARG_ENABLE([ifconv],
+ [AS_HELP_STRING(--disable-ifconv,disable if-conversion [[default=yes]])],
+ [case "${enableval}" in
+ no) ENABLE_IFCONV=no;;
+ *) ENABLE_IFCONV=yes;;
+ esac],
+ [ENABLE_IFCONV=yes])
+AC_MSG_RESULT(${ENABLE_IFCONV})
+AM_CONDITIONAL([ENABLE_IFCONV], test x"${ENABLE_IFCONV}" = "xyes")
+
+if test x"${ENABLE_IFCONV}" = "xyes"; then
+ AC_DEFINE([ENABLE_IFCONV], 1, [enable if-conversion])
+fi
+
+
dnl check if linear scan register allocator(lsra) should be used
AC_MSG_CHECKING(whether lsra should be supported)
AC_ARG_ENABLE([lsra],
- [AS_HELP_STRING(--enable-lsra,enable linear scan register allocator [[default=yes]])],
+ [AS_HELP_STRING(--disable-lsra,disable linear scan register allocator [[default=yes]])],
[case "${enableval}" in
no) ENABLE_LSRA=no;;
*) ENABLE_LSRA=yes;;
dnl check if CACAO should be linked statically
-AC_MSG_CHECKING(whether to link GNU classpath native libraries statically into CACAO)
+AC_MSG_CHECKING(whether to link CACAO statically)
AC_ARG_ENABLE([staticvm],
- [AS_HELP_STRING(--enable-staticvm, link GNU classpath native libraries statically into CACAO [[default=no]])],
+ [AS_HELP_STRING(--enable-staticvm,link CACAO statically [[default=no]])],
[case "${enableval}" in
yes) ENABLE_STATICVM=yes;;
*) ENABLE_STATICVM=no;;
if test x"${ENABLE_STATICVM}" = "xyes"; then
AC_DEFINE([ENABLE_STATICVM], 1, [link CACAO statically])
-
- dnl check for some classpath related stuff when we link statically
- AM_ICONV_LINK
-else
- AC_CHECK_HEADERS([ltdl.h],, [AC_MSG_ERROR(cannot find ltdl.h)])
- AC_CHECK_LIB(ltdl, lt_dlopen,, [AC_MSG_ERROR(cannot find libltdl)])
fi
AM_CONDITIONAL([ENABLE_STATICVM], test x"${ENABLE_STATICVM}" = "xyes")
AC_SUBST(ENABLE_STATICVM)
dnl expand CLASSPATH_LIBDIR to something that is usable in C code
AS_AC_EXPAND([CLASSPATH_LIBDIR], ${CLASSPATH_LIBDIR})
AC_DEFINE_UNQUOTED([CLASSPATH_LIBDIR], "${CLASSPATH_LIBDIR}", [GNU Classpath libraries installation directory])
-
AC_SUBST(CLASSPATH_LIBDIR)
+AC_CHECK_HEADER([${CLASSPATH_PREFIX}/include/jni.h],
+ [AC_DEFINE_UNQUOTED([CLASSPATH_JNI_H], "${CLASSPATH_PREFIX}/include/jni.h", [GNU Classpath jni.h header])],
+ [AC_MSG_ERROR(cannot find jni.h)])
+
+
+dnl check if GNU Classpath should be linked statically into CACAO
+AC_MSG_CHECKING(whether to link GNU Classpath native libraries statically into CACAO)
+AC_ARG_WITH([static-classpath],
+ [AS_HELP_STRING(--with-static-classpath,link GNU classpath native libraries statically into CACAO [[default=no]])],
+ [case "${enableval}" in
+ yes) WITH_STATIC_CLASSPATH=yes;;
+ *) WITH_STATIC_CLASSPATH=no;;
+ esac],
+ [WITH_STATIC_CLASSPATH=no])
+AC_MSG_RESULT(${WITH_STATIC_CLASSPATH})
+
+if test x"${WITH_STATIC_CLASSPATH}" = "xyes"; then
+ AC_DEFINE([WITH_STATIC_CLASSPATH], 1, [link GNU classpath native libraries statically into CACAO])
+
+ dnl check for some classpath related stuff when we link statically
+ AM_ICONV_LINK
+else
+ AC_CHECK_HEADERS([ltdl.h],, [AC_MSG_ERROR(cannot find ltdl.h)])
+ AC_CHECK_LIB(ltdl, lt_dlopen,, [AC_MSG_ERROR(cannot find libltdl)])
+fi
+AM_CONDITIONAL([WITH_STATIC_CLASSPATH], test x"${WITH_STATIC_CLASSPATH}" = "xyes")
+AC_SUBST(WITH_STATIC_CLASSPATH)
dnl Maybe the user has Classpath installed 'flat'.
[src/vm/jit/i386/Makefile]
[src/vm/jit/i386/freebsd/Makefile]
[src/vm/jit/i386/linux/Makefile]
+ [src/vm/jit/ifconv/Makefile]
[src/vm/jit/intrp/Makefile]
[src/vm/jit/inline/Makefile]
[src/vm/jit/loop/Makefile]
##
## Changes:
##
-## $Id: Makefile.am 4409 2006-02-03 19:27:13Z twisti $
+## $Id: Makefile.am 4530 2006-02-21 09:11:53Z twisti $
## Process this file with automake to produce Makefile.in
endif
if ENABLE_STATICVM
+noinst_LTLIBRARIES = \
+ libcacaovm.la
+
+else
+cacao_LDFLAGS = \
+ $(EXPORT_SYMBOLS_FLAGS)
+
+lib_LTLIBRARIES = \
+ libcacaovm.la
+
+libcacaovm_la_LDFLAGS = \
+ -release $(PACKAGE_VERSION)
+endif
+
+if WITH_STATIC_CLASSPATH
cacao_LDFLAGS = \
$(LTLIBICONV)
#CLASSPATH_LIBS += \
# $(CLASSPATH_LIBDIR)/classpath/libgtkpeer.a
#endif
-
-else
-cacao_LDFLAGS = $(EXPORT_SYMBOLS_FLAGS)
-CLASSPATH_LIBS =
endif
-noinst_LTLIBRARIES = libcacao.la
+libcacaovm_la_SOURCES =
-libcacao_la_SOURCES =
-
-libcacao_la_LIBADD = \
+libcacaovm_la_LIBADD = \
+ $(top_builddir)/src/fdlibm/libfdlibm.la \
$(top_builddir)/src/mm/libmm.la \
$(top_builddir)/src/native/libnative.la \
- $(THREAD_LIB) \
$(top_builddir)/src/toolbox/libtoolbox.la \
- $(top_builddir)/src/vm/libvm.la
+ $(top_builddir)/src/vm/libvm.la \
+ $(GC_LIB) \
+ $(THREAD_LIB)
-bin_PROGRAMS = cacao
+bin_PROGRAMS = \
+ cacao
cacao_SOURCES = \
cacao.c \
cacao.h
cacao_LDADD = \
- libcacao.la \
- $(top_builddir)/src/fdlibm/libfdlibm.la \
- $(GC_LIB) \
+ libcacaovm.la \
$(CLASSPATH_LIBS)
cacao_DEPENDENCIES = \
Philipp Tomsich
Christian Thalinger
- This module does the following tasks:
- - Command line option handling
- - Calling initialization routines
- - Calling the class loader
- - Running the main method
-
- $Id: cacao.c 4474 2006-02-06 21:01:54Z twisti $
+ $Id: cacao.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include "vm/types.h"
-#include "cacao/cacao.h"
#include "mm/boehm.h"
#include "mm/memory.h"
#include "native/jni.h"
-#include "native/native.h"
+#include "native/include/java_lang_String.h"
#if defined(ENABLE_JVMTI)
#include "native/jvmti/jvmti.h"
#include "toolbox/logging.h"
#include "vm/classcache.h"
#include "vm/exceptions.h"
-#include "vm/finalizer.h"
#include "vm/global.h"
-#include "vm/initialize.h"
#include "vm/loader.h"
#include "vm/options.h"
-#include "vm/properties.h"
-#include "vm/signallocal.h"
#include "vm/statistics.h"
#include "vm/stringlocal.h"
#include "vm/suck.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/jit.h"
-#include "vm/jit/profile/profile.h"
#ifdef TYPEINFO_DEBUG_TEST
#include "vm/jit/verify/typeinfo.h"
#endif
-/* define heap sizes **********************************************************/
-
-#define HEAP_MAXSIZE 64 * 1024 * 1024 /* default 64MB */
-#define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
-#define STACK_SIZE 128 * 1024 /* default 128kB */
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_main_stack;
-#endif
-
-
-/* CACAO related stuff ********************************************************/
-
-bool cacao_initializing;
-bool cacao_exiting;
-
-
-/* Invocation API variables ***************************************************/
-
-JavaVM *jvm; /* denotes a Java VM */
-JNIEnv *env; /* pointer to native method interface */
-
-JDK1_1InitArgs vm_args; /* JDK 1.1 VM initialization arguments */
-
-
-char *mainstring;
-static classinfo *mainclass;
-
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
-void **stackbottom = 0;
-#endif
-
-
-/* define command line options ************************************************/
-
-enum {
- OPT_CLASSPATH,
- OPT_D,
- OPT_MS,
- OPT_MX,
- OPT_VERBOSE1,
- OPT_VERBOSE,
- OPT_VERBOSESPECIFIC,
- OPT_VERBOSECALL,
- OPT_NOIEEE,
- OPT_SOFTNULL,
- OPT_TIME,
-
-#if defined(ENABLE_STATISTICS)
- OPT_STAT,
-#endif
-
- OPT_LOG,
- OPT_CHECK,
- OPT_LOAD,
- OPT_METHOD,
- OPT_SIGNATURE,
- OPT_SHOW,
- OPT_ALL,
- OPT_OLOOP,
- OPT_INLINING,
-
- OPT_VERBOSETC,
- OPT_NOVERIFY,
- OPT_LIBERALUTF,
- OPT_VERBOSEEXCEPTION,
- OPT_EAGER,
-
-#if defined(ENABLE_LSRA)
- OPT_LSRA,
-#endif
-
- OPT_JAR,
- OPT_BOOTCLASSPATH,
- OPT_BOOTCLASSPATH_A,
- OPT_BOOTCLASSPATH_P,
- OPT_VERSION,
- OPT_SHOWVERSION,
- OPT_FULLVERSION,
-
- OPT_HELP,
- OPT_X,
-
- OPT_JIT,
- OPT_INTRP,
-
- OPT_PROF,
- OPT_PROF_OPTION,
-
-#if defined(ENABLE_INTRP)
- /* interpreter options */
-
- OPT_NO_DYNAMIC,
- OPT_NO_REPLICATION,
- OPT_NO_QUICKSUPER,
- OPT_STATIC_SUPERS,
- OPT_TRACE,
-#endif
-
- OPT_SS,
-
-#ifdef ENABLE_JVMTI
- OPT_DEBUG,
- OPT_AGENTLIB,
- OPT_AGENTPATH,
-#endif
-
- DUMMY
-};
-
-
-opt_struct opts[] = {
- { "classpath", true, OPT_CLASSPATH },
- { "cp", true, OPT_CLASSPATH },
- { "D", true, OPT_D },
- { "noasyncgc", false, OPT_IGNORE },
- { "noverify", false, OPT_NOVERIFY },
- { "liberalutf", false, OPT_LIBERALUTF },
- { "v", false, OPT_VERBOSE1 },
- { "verbose", false, OPT_VERBOSE },
- { "verbose:", true, OPT_VERBOSESPECIFIC },
- { "verbosecall", false, OPT_VERBOSECALL },
- { "verboseexception", false, OPT_VERBOSEEXCEPTION },
-#ifdef TYPECHECK_VERBOSE
- { "verbosetc", false, OPT_VERBOSETC },
-#endif
-#if defined(__ALPHA__)
- { "noieee", false, OPT_NOIEEE },
-#endif
- { "softnull", false, OPT_SOFTNULL },
- { "time", false, OPT_TIME },
-#if defined(ENABLE_STATISTICS)
- { "stat", false, OPT_STAT },
-#endif
- { "log", true, OPT_LOG },
- { "c", true, OPT_CHECK },
- { "l", false, OPT_LOAD },
- { "eager", false, OPT_EAGER },
- { "sig", true, OPT_SIGNATURE },
- { "all", false, OPT_ALL },
- { "oloop", false, OPT_OLOOP },
-#if defined(ENABLE_LSRA)
- { "lsra", false, OPT_LSRA },
-#endif
- { "jar", false, OPT_JAR },
- { "version", false, OPT_VERSION },
- { "showversion", false, OPT_SHOWVERSION },
- { "fullversion", false, OPT_FULLVERSION },
- { "help", false, OPT_HELP },
- { "?", false, OPT_HELP },
-
-#if defined(ENABLE_INTRP)
- /* interpreter options */
-
- { "trace", false, OPT_TRACE },
- { "static-supers", true, OPT_STATIC_SUPERS },
- { "no-dynamic", false, OPT_NO_DYNAMIC },
- { "no-replication", false, OPT_NO_REPLICATION },
- { "no-quicksuper", false, OPT_NO_QUICKSUPER },
-#endif
-
- /* JVMTI Agent Command Line Options */
-#ifdef ENABLE_JVMTI
- { "agentlib:", true, OPT_AGENTLIB },
- { "agentpath:", true, OPT_AGENTPATH },
-#endif
-
- /* X options */
-
- { "X", false, OPT_X },
- { "Xjit", false, OPT_JIT },
- { "Xint", false, OPT_INTRP },
- { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
- { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
- { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
-#ifdef ENABLE_JVMTI
- { "Xdebug", false, OPT_DEBUG },
-#endif
- { "Xms", true, OPT_MS },
- { "Xmx", true, OPT_MX },
- { "Xprof:", true, OPT_PROF_OPTION },
- { "Xprof", false, OPT_PROF },
- { "Xss", true, OPT_SS },
- { "ms", true, OPT_MS },
- { "mx", true, OPT_MX },
- { "ss", true, OPT_SS },
-
- /* keep these at the end of the list */
-
- { "i", true, OPT_INLINING },
- { "m", true, OPT_METHOD },
- { "s", true, OPT_SHOW },
-
- { NULL, false, 0 }
-};
-
-
-/* usage ***********************************************************************
-
- Prints the correct usage syntax to stdout.
-
-*******************************************************************************/
-
-static void usage(void)
-{
- printf("Usage: cacao [-options] classname [arguments]\n");
- printf(" (to run a class file)\n");
- printf(" cacao [-options] -jar jarfile [arguments]\n");
- printf(" (to run a standalone jar file)\n\n");
-
- printf("Java options:\n");
- printf(" -cp <path> specify a path to look for classes\n");
- printf(" -classpath <path> specify a path to look for classes\n");
- printf(" -D<name>=<value> add an entry to the property list\n");
- printf(" -verbose[:class|gc|jni] enable specific verbose output\n");
- printf(" -version print product version and exit\n");
- printf(" -fullversion print jpackage-compatible product version and exit\n");
- printf(" -showversion print product version and continue\n");
- printf(" -help, -? print this help message\n");
- printf(" -X print help on non-standard Java options\n\n");
-
-#ifdef ENABLE_JVMTI
- printf(" -agentlib:<agent-lib-name>=<options> library to load containg JVMTI agent\n");
- printf(" -agentpath:<path-to-agent>=<options> path to library containg JVMTI agent\n");
-#endif
-
- printf("CACAO options:\n");
- printf(" -v write state-information\n");
- printf(" -verbose write more information\n");
- printf(" -verbosegc write message for each GC\n");
- printf(" -verbosecall write message for each call\n");
- printf(" -verboseexception write message for each step of stack unwinding\n");
-#ifdef TYPECHECK_VERBOSE
- printf(" -verbosetc write debug messages while typechecking\n");
-#endif
-#if defined(__ALPHA__)
- printf(" -noieee don't use ieee compliant arithmetic\n");
-#endif
- printf(" -noverify don't verify classfiles\n");
- printf(" -liberalutf don't warn about overlong UTF-8 sequences\n");
- printf(" -softnull use software nullpointer check\n");
- printf(" -time measure the runtime\n");
-#if defined(ENABLE_STATISTICS)
- printf(" -stat detailed compiler statistics\n");
-#endif
- printf(" -log logfile specify a name for the logfile\n");
- printf(" -c(heck)b(ounds) don't check array bounds\n");
- printf(" s(ync) don't check for synchronization\n");
- printf(" -oloop optimize array accesses in loops\n");
- printf(" -l don't start the class after loading\n");
- printf(" -eager perform eager class loading and linking\n");
- printf(" -all compile all methods, no execution\n");
- printf(" -m compile only a specific method\n");
- printf(" -sig specify signature for a specific method\n");
- printf(" -s(how)a(ssembler) show disassembled listing\n");
- printf(" c(onstants) show the constant pool\n");
- printf(" d(atasegment) show data segment listing\n");
- printf(" e(xceptionstubs) show disassembled exception stubs (only with -sa)\n");
- printf(" i(ntermediate) show intermediate representation\n");
- printf(" m(ethods) show class fields and methods\n");
- printf(" n(ative) show disassembled native stubs\n");
- printf(" u(tf) show the utf - hash\n");
- printf(" -i n(line) activate inlining\n");
- printf(" v(irtual) inline virtual methods (uses/turns rt option on)\n");
- printf(" e(exception) inline methods with exceptions\n");
- printf(" p(aramopt) optimize argument renaming\n");
- printf(" o(utsiders) inline methods of foreign classes\n");
-#if defined(ENABLE_LSRA)
- printf(" -lsra use linear scan register allocation\n");
-#endif
-
- /* exit with error code */
-
- exit(1);
-}
-
-
-static void Xusage(void)
-{
-#if defined(ENABLE_JIT)
- printf(" -Xjit JIT mode execution (default)\n");
-#endif
-#if defined(ENABLE_INTRP)
- printf(" -Xint interpreter mode execution\n");
-#endif
- printf(" -Xbootclasspath:<zip/jar files and directories separated by :>\n");
- printf(" value is set as bootstrap class path\n");
- printf(" -Xbootclasspath/a:<zip/jar files and directories separated by :>\n");
- printf(" value is appended to the bootstrap class path\n");
- printf(" -Xbootclasspath/p:<zip/jar files and directories separated by :>\n");
- printf(" value is prepended to the bootstrap class path\n");
- printf(" -Xms<size> set the initial size of the heap (default: 2MB)\n");
- printf(" -Xmx<size> set the maximum size of the heap (default: 64MB)\n");
- printf(" -Xss<size> set the thread stack size (default: 128kB)\n");
- printf(" -Xprof[:bb] collect and print profiling data\n");
-#if defined(ENABLE_JVMTI)
- printf(" -Xdebug<transport> enable remote debugging\n");
-#endif
-
- /* exit with error code */
-
- exit(1);
-}
-
-
-/* version *********************************************************************
-
- Only prints cacao version information.
-
-*******************************************************************************/
-
-static void version(void)
-{
- printf("java version \""JAVA_VERSION"\"\n");
- printf("CACAO version "VERSION"\n");
-
- printf("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,\n");
- printf("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,\n");
- printf("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,\n");
- printf("J. Wenninger, Institut f. Computersprachen - TU Wien\n\n");
-
- printf("This program is free software; you can redistribute it and/or\n");
- printf("modify it under the terms of the GNU General Public License as\n");
- printf("published by the Free Software Foundation; either version 2, or (at\n");
- printf("your option) any later version.\n\n");
-
- printf("This program is distributed in the hope that it will be useful, but\n");
- printf("WITHOUT ANY WARRANTY; without even the implied warranty of\n");
- printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n");
- printf("General Public License for more details.\n");
-}
-
-
-/* fullversion *****************************************************************
-
- Prints a Sun compatible version information (required e.g. by
- jpackage, www.jpackage.org).
-
-*******************************************************************************/
-
-static void fullversion(void)
-{
- printf("java full version \"cacao-"JAVA_VERSION"\"\n");
-
- /* exit normally */
-
- exit(0);
-}
-
-
#ifdef TYPECHECK_STATISTICS
void typecheck_print_statistics(FILE *file);
#endif
ASM_CALLJAVAFUNCTION_ADR(o, m, o, NULL, NULL, NULL);
- if (!o) {
+ if (o == NULL) {
fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
- cacao_exit(1);
+ vm_exit(1);
}
ASM_CALLJAVAFUNCTION_ADR(o, m, o, NULL, NULL, NULL);
- if (!o) {
+ if (o == NULL) {
fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
- cacao_exit(1);
+ vm_exit(1);
}
int main(int argc, char **argv)
{
- s4 i, j, k;
void *dummy;
+ s4 i;
/* local variables ********************************************************/
-
- char logfilename[200] = "";
- u4 heapmaxsize;
- u4 heapstartsize;
- char *cp;
- s4 cplen;
- bool startit = true;
- char *specificmethodname = NULL;
- char *specificsignature = NULL;
- bool jar = false;
+
+ JavaVMInitArgs *vm_args;
+ JavaVM *jvm; /* denotes a Java VM */
+
#if defined(ENABLE_JVMTI)
bool dbg = false;
char *transport;
int waitval;
#endif
-
#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
stackbottom = &dummy;
#endif
- if (atexit(exit_handler))
+ if (atexit(vm_exit_handler))
throw_cacao_exception_exit(string_java_lang_InternalError,
"Unable to register exit_handler");
- /* initialize global variables */
-
- cacao_exiting = false;
-
-
- /************ Collect info from the environment ************************/
-
-#if defined(DISABLE_GC)
- nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
-#endif
-
- /* set the bootclasspath */
-
- cp = getenv("BOOTCLASSPATH");
-
- if (cp) {
- bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
- strcpy(bootclasspath, cp);
-
- } else {
- cplen = strlen(CACAO_VM_ZIP_PATH) +
- strlen(":") +
- strlen(CLASSPATH_GLIBJ_ZIP_PATH) +
- strlen("0");
-
- bootclasspath = MNEW(char, cplen);
- strcat(bootclasspath, CACAO_VM_ZIP_PATH);
- strcat(bootclasspath, ":");
- strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP_PATH);
- }
-
-
- /* set the classpath */
-
- cp = getenv("CLASSPATH");
-
- if (cp) {
- classpath = MNEW(char, strlen(cp) + strlen("0"));
- strcat(classpath, cp);
-
- } else {
- classpath = MNEW(char, strlen(".") + strlen("0"));
- strcpy(classpath, ".");
- }
-
-
- /***************** Interpret the command line *****************/
-
- checknull = false;
- opt_noieee = false;
-
- heapmaxsize = HEAP_MAXSIZE;
- heapstartsize = HEAP_STARTSIZE;
- opt_stacksize = STACK_SIZE;
-
- /* initialize properties before commandline handling */
-
- if (!properties_init())
- throw_cacao_exception_exit(string_java_lang_InternalError,
- "Unable to init properties");
-
- while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
- switch (i) {
- case OPT_IGNORE:
- break;
-
- case OPT_BOOTCLASSPATH:
- /* Forget default bootclasspath and set the argument as new boot */
- /* classpath. */
- MFREE(bootclasspath, char, strlen(bootclasspath));
-
- bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
- strcpy(bootclasspath, opt_arg);
- break;
-
- case OPT_BOOTCLASSPATH_A:
- /* append to end of bootclasspath */
- cplen = strlen(bootclasspath);
-
- bootclasspath = MREALLOC(bootclasspath,
- char,
- cplen,
- cplen + strlen(":") +
- strlen(opt_arg) + strlen("0"));
-
- strcat(bootclasspath, ":");
- strcat(bootclasspath, opt_arg);
- break;
-
- case OPT_BOOTCLASSPATH_P:
- /* prepend in front of bootclasspath */
- cp = bootclasspath;
- cplen = strlen(cp);
-
- bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
- cplen + strlen("0"));
-
- strcpy(bootclasspath, opt_arg);
- strcat(bootclasspath, ":");
- strcat(bootclasspath, cp);
-
- MFREE(cp, char, cplen);
- break;
-
- case OPT_CLASSPATH:
- /* forget old classpath and set the argument as new classpath */
- MFREE(classpath, char, strlen(classpath));
-
- classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
- strcpy(classpath, opt_arg);
- break;
-
- case OPT_JAR:
- jar = true;
- break;
-
-#if defined(ENABLE_JVMTI)
- case OPT_DEBUG:
- dbg = true;
- transport = opt_arg;
- break;
-
- case OPT_AGENTPATH:
- case OPT_AGENTLIB:
- set_jvmti_phase(JVMTI_PHASE_ONLOAD);
- agentload(opt_arg);
- set_jvmti_phase(JVMTI_PHASE_PRIMORDIAL);
- break;
-#endif
-
- case OPT_D:
- {
- for (j = 0; j < strlen(opt_arg); j++) {
- if (opt_arg[j] == '=') {
- opt_arg[j] = '\0';
- properties_add(opt_arg, opt_arg + j + 1);
- goto didit;
- }
- }
-
- /* if no '=' is given, just create an empty property */
-
- properties_add(opt_arg, "");
-
- didit:
- ;
- }
- break;
-
- case OPT_MX:
- case OPT_MS:
- case OPT_SS:
- {
- char c;
- c = opt_arg[strlen(opt_arg) - 1];
-
- if (c == 'k' || c == 'K') {
- j = 1024 * atoi(opt_arg);
-
- } else if (c == 'm' || c == 'M') {
- j = 1024 * 1024 * atoi(opt_arg);
-
- } else
- j = atoi(opt_arg);
-
- if (i == OPT_MX)
- heapmaxsize = j;
- else if (i == OPT_MS)
- heapstartsize = j;
- else
- opt_stacksize = j;
- }
- break;
-
- case OPT_VERBOSE1:
- opt_verbose = true;
- break;
-
- case OPT_VERBOSE:
- opt_verbose = true;
- loadverbose = true;
- linkverbose = true;
- initverbose = true;
- compileverbose = true;
- break;
-
- case OPT_VERBOSESPECIFIC:
- if (strcmp("class", opt_arg) == 0)
- opt_verboseclass = true;
-
- else if (strcmp("gc", opt_arg) == 0)
- opt_verbosegc = true;
-
- else if (strcmp("jni", opt_arg) == 0)
- opt_verbosejni = true;
- break;
-
- case OPT_VERBOSEEXCEPTION:
- opt_verboseexception = true;
- break;
-
-#ifdef TYPECHECK_VERBOSE
- case OPT_VERBOSETC:
- typecheckverbose = true;
- break;
-#endif
-
- case OPT_VERBOSECALL:
- runverbose = true;
- break;
-
- case OPT_VERSION:
- version();
- exit(0);
- break;
-
- case OPT_FULLVERSION:
- fullversion();
- break;
-
- case OPT_SHOWVERSION:
- version();
- break;
-
- case OPT_NOIEEE:
- opt_noieee = true;
- break;
-
- case OPT_NOVERIFY:
- opt_verify = false;
- break;
-
- case OPT_LIBERALUTF:
- opt_liberalutf = true;
- break;
-
- case OPT_SOFTNULL:
- checknull = true;
- break;
-
- case OPT_TIME:
- getcompilingtime = true;
- getloadingtime = true;
- break;
-
-#if defined(ENABLE_STATISTICS)
- case OPT_STAT:
- opt_stat = true;
- break;
-#endif
-
- case OPT_LOG:
- strcpy(logfilename, opt_arg);
- break;
-
- case OPT_CHECK:
- for (j = 0; j < strlen(opt_arg); j++) {
- switch (opt_arg[j]) {
- case 'b':
- checkbounds = false;
- break;
- case 's':
- checksync = false;
- break;
- default:
- usage();
- }
- }
- break;
-
- case OPT_LOAD:
- startit = false;
- makeinitializations = false;
- break;
-
- case OPT_EAGER:
- opt_eager = true;
- break;
-
- case OPT_METHOD:
- startit = false;
- specificmethodname = opt_arg;
- makeinitializations = false;
- break;
-
- case OPT_SIGNATURE:
- specificsignature = opt_arg;
- break;
-
- case OPT_ALL:
- compileall = true;
- startit = false;
- makeinitializations = false;
- break;
-
- case OPT_SHOW: /* Display options */
- for (j = 0; j < strlen(opt_arg); j++) {
- switch (opt_arg[j]) {
- case 'a':
- opt_showdisassemble = true;
- compileverbose = true;
- break;
- case 'c':
- showconstantpool = true;
- break;
- case 'd':
- opt_showddatasegment = true;
- break;
- case 'e':
- opt_showexceptionstubs = true;
- break;
- case 'i':
- opt_showintermediate = true;
- compileverbose = true;
- break;
- case 'm':
- showmethods = true;
- break;
- case 'n':
- opt_shownativestub = true;
- break;
- case 'u':
- showutf = true;
- break;
- default:
- usage();
- }
- }
- break;
-
- case OPT_OLOOP:
- opt_loops = true;
- break;
-
- case OPT_INLINING:
- for (j = 0; j < strlen(opt_arg); j++) {
- switch (opt_arg[j]) {
- case 'n':
- /* define in options.h; Used in main.c, jit.c & inline.c */
- /* inlining is currently deactivated */
- break;
- case 'v':
- inlinevirtuals = true;
- break;
- case 'e':
- inlineexceptions = true;
- break;
- case 'p':
- inlineparamopt = true;
- break;
- case 'o':
- inlineoutsiders = true;
- break;
- default:
- usage();
- }
- }
- break;
-
-#if defined(ENABLE_LSRA)
- case OPT_LSRA:
- opt_lsra = true;
- break;
-#endif
-
- case OPT_HELP:
- usage();
- break;
-
- case OPT_X:
- Xusage();
- break;
-
- case OPT_PROF_OPTION:
- /* use <= to get the last \0 too */
-
- for (j = 0, k = 0; j <= strlen(opt_arg); j++) {
- if (opt_arg[j] == ',')
- opt_arg[j] = '\0';
-
- if (opt_arg[j] == '\0') {
- if (strcmp("bb", opt_arg + k) == 0)
- opt_prof_bb = true;
-
- else {
- printf("Unknown option: -Xprof:%s\n", opt_arg + k);
- usage();
- }
-
- /* set k to next char */
-
- k = j + 1;
- }
- }
- /* fall through */
-
- case OPT_PROF:
- opt_prof = true;
- break;
-
- case OPT_JIT:
-#if defined(ENABLE_JIT)
- opt_jit = true;
-#else
- printf("-Xjit option not enabled.\n");
- exit(1);
-#endif
- break;
-
- case OPT_INTRP:
-#if defined(ENABLE_INTRP)
- opt_intrp = true;
-#else
- printf("-Xint option not enabled.\n");
- exit(1);
-#endif
- break;
-
-#if defined(ENABLE_INTRP)
- case OPT_STATIC_SUPERS:
- opt_static_supers = atoi(opt_arg);
- break;
-
- case OPT_NO_DYNAMIC:
- opt_no_dynamic = true;
- break;
-
- case OPT_NO_REPLICATION:
- opt_no_replication = true;
- break;
-
- case OPT_NO_QUICKSUPER:
- opt_no_quicksuper = true;
- break;
-
- case OPT_TRACE:
- vm_debug = true;
- break;
-#endif
-
- default:
- printf("Unknown option: %s\n", argv[opt_ind]);
- usage();
- }
- }
-
- if (opt_ind >= argc)
- usage();
-
-
- /* transform dots into slashes in the class name */
-
- mainstring = argv[opt_ind++];
-
- if (!jar) {
- /* do not mangle jar filename */
-
- for (i = strlen(mainstring) - 1; i >= 0; i--) {
- if (mainstring[i] == '.') mainstring[i] = '/';
- }
-
- } else {
- /* put jarfile in classpath */
-
- cp = classpath;
-
- classpath = MNEW(char, strlen(mainstring) + strlen(":") +
- strlen(classpath) + strlen("0"));
-
- strcpy(classpath, mainstring);
- strcat(classpath, ":");
- strcat(classpath, cp);
-
- MFREE(cp, char, strlen(cp));
- }
/**************************** Program start *****************************/
- log_init(logfilename);
-
if (opt_verbose)
log_text("CACAO started -------------------------------------------------------");
- /* initialize JavaVM */
-
- vm_args.version = 0x00010001; /* New in 1.1.2: VM version */
-
- /* Get the default initialization arguments and set the class path */
+ /* prepare the options */
- JNI_GetDefaultJavaVMInitArgs(&vm_args);
-
- vm_args.minHeapSize = heapstartsize;
- vm_args.maxHeapSize = heapmaxsize;
-
- vm_args.classpath = classpath;
-
+ vm_args = options_prepare(argc, argv);
+
/* load and initialize a Java VM, return a JNI interface pointer in env */
- JNI_CreateJavaVM(&jvm, &env, &vm_args);
+ JNI_CreateJavaVM(&jvm, (void **) &_Jv_env, vm_args);
#if defined(ENABLE_JVMTI)
set_jvmti_phase(JVMTI_PHASE_START);
#endif
- /* initialize the garbage collector */
-
- gc_init(heapmaxsize, heapstartsize);
-
-#if defined(ENABLE_INTRP)
- /* allocate main thread stack */
-
- if (opt_intrp) {
- intrp_main_stack = (u1 *) alloca(opt_stacksize);
- MSET(intrp_main_stack, 0, u1, opt_stacksize);
- }
-#endif
-
- cacao_initializing = true;
-
-#if defined(USE_THREADS)
-#if defined(NATIVE_THREADS)
- threads_preinit();
-#endif
- initLocks();
-#endif
-
- /* initialize the string hashtable stuff: lock (must be done
- _after_ threads_preinit) */
-
- if (!string_init())
- throw_main_exception_exit();
-
- /* initialize the utf8 hashtable stuff: lock, often used utf8
- strings (must be done _after_ threads_preinit) */
-
- if (!utf8_init())
- throw_main_exception_exit();
-
- /* initialize the classcache hashtable stuff: lock, hashtable
- (must be done _after_ threads_preinit) */
-
- if (!classcache_init())
- throw_main_exception_exit();
-
- /* initialize the loader with bootclasspath (must be done _after_
- thread_preinit) */
-
- if (!suck_init())
- throw_main_exception_exit();
-
- suck_add_from_property("java.endorsed.dirs");
- suck_add(bootclasspath);
-
- /* initialize the memory subsystem (must be done _after_
- threads_preinit) */
-
- if (!memory_init())
- throw_main_exception_exit();
-
- /* initialize the finalizer stuff: lock, linked list (must be done
- _after_ threads_preinit) */
-
- if (!finalizer_init())
- throw_main_exception_exit();
-
- /* install architecture dependent signal handler used for exceptions */
-
- signal_init();
-
- /* initialize the codegen subsystems */
-
- codegen_init();
-
- /* initializes jit compiler */
-
- jit_init();
-
- /* machine dependent initialization */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
- if (opt_intrp)
- intrp_md_init();
- else
-# endif
- md_init();
-#else
- intrp_md_init();
-#endif
-
- /* initialize the loader subsystems (must be done _after_
- classcache_init) */
-
- if (!loader_init((u1 *) &dummy))
- throw_main_exception_exit();
-
- if (!linker_init())
- throw_main_exception_exit();
-
- if (!native_init())
- throw_main_exception_exit();
-
- if (!exceptions_init())
- throw_main_exception_exit();
-
- if (!builtin_init())
- throw_main_exception_exit();
-
-#if defined(USE_THREADS)
- if (!threads_init((u1 *) &dummy))
- throw_main_exception_exit();
-#endif
-
- /* That's important, otherwise we get into trouble, if the Runtime
- static initializer is called before (circular dependency. This
- is with classpath 0.09. Another important thing is, that this
- has to happen after initThreads!!! */
-
- if (!initialize_class(class_java_lang_System))
- throw_main_exception_exit();
-
- /* JNI init creates a Java object (this means running Java code) */
-
- if (!jni_init())
- throw_main_exception_exit();
-
- /* initialize profiling */
-
- if (!profile_init())
- throw_main_exception_exit();
-
-#if defined(USE_THREADS)
- /* finally, start the finalizer thread */
+ /* do we have a main class? */
- if (!finalizer_start_thread())
- throw_main_exception_exit();
-
- /* start the profile sampling thread */
-
-/* if (!profile_start_thread()) */
-/* throw_main_exception_exit(); */
-#endif
-
- cacao_initializing = false;
+ if (mainstring == NULL)
+ usage();
/* start worker routines **************************************************/
- if (startit) {
- classinfo *mainclass; /* java/lang/Class */
+ if (opt_run == true) {
+ classinfo *mainclass;
methodinfo *m;
- java_objectarray *a;
+ java_objectarray *oa;
+ s4 oalength;
+ java_lang_String *s;
s4 status;
/* set return value to OK */
status = 0;
- if (jar) {
+ if (opt_jar == true) {
/* open jar file with java.util.jar.JarFile */
mainstring = getmainclassnamefromjar(mainstring);
}
/* build argument array */
- a = builtin_anewarray(argc - opt_ind, class_java_lang_String);
- for (i = opt_ind; i < argc; i++) {
- a->data[i - opt_ind] =
- (java_objectheader *) javastring_new(utf_new_char(argv[i]));
+ oalength = vm_args->nOptions - opt_index;
+
+ oa = builtin_anewarray(oalength, class_java_lang_String);
+
+ for (i = 0; i < oalength; i++) {
+ s = javastring_new(utf_new_char(vm_args->options[opt_index + i].optionString));
+ oa->data[i] = (java_objectheader *) s;
}
#ifdef TYPEINFO_DEBUG_TEST
#endif
/* here we go... */
- ASM_CALLJAVAFUNCTION(m, a, NULL, NULL, NULL);
+ ASM_CALLJAVAFUNCTION(m, oa, NULL, NULL, NULL);
/* exception occurred? */
status = 1;
}
-#if defined(USE_THREADS)
-#if defined(NATIVE_THREADS)
- joinAllThreads();
-#else
- killThread(currentThread);
-#endif
-#endif
+ /* unload the JavaVM */
- /* now exit the JavaVM */
+ vm_destroy(jvm);
-/* (*jvm)->DestroyJavaVM(jvm); */
+ /* and exit */
- cacao_exit(status);
+ vm_exit(status);
}
/************* If requested, compile all methods ********************/
/******** If requested, compile a specific method ***************/
- if (specificmethodname) {
+ if (opt_method != NULL) {
methodinfo *m;
/* create, load and link the main class */
if (!link_class(mainclass))
throw_main_exception_exit();
- if (specificsignature) {
+ if (opt_signature != NULL) {
m = class_resolveclassmethod(mainclass,
- utf_new_char(specificmethodname),
- utf_new_char(specificsignature),
+ utf_new_char(opt_method),
+ utf_new_char(opt_signature),
mainclass,
false);
} else {
m = class_resolveclassmethod(mainclass,
- utf_new_char(specificmethodname),
+ utf_new_char(opt_method),
NULL,
mainclass,
false);
if (!m) {
char message[MAXLOGTEXT];
- sprintf(message, "%s%s", specificmethodname,
- specificsignature ? specificsignature : "");
+ sprintf(message, "%s%s", opt_method,
+ opt_signature ? opt_signature : "");
*exceptionptr =
new_exception_message(string_java_lang_NoSuchMethodException,
jit_compile(m);
}
- cacao_shutdown(0);
+ vm_shutdown(0);
/* keep compiler happy */
}
-/* cacao_exit ******************************************************************
-
- Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
-
-*******************************************************************************/
-
-void cacao_exit(s4 status)
-{
- methodinfo *m;
-
- assert(class_java_lang_System);
- assert(class_java_lang_System->state & CLASS_LOADED);
-
-#if defined(ENABLE_JVMTI)
- set_jvmti_phase(JVMTI_PHASE_DEAD);
- agentunload();
-#endif
-
- if (!link_class(class_java_lang_System))
- throw_main_exception_exit();
-
- /* signal that we are exiting */
-
- cacao_exiting = true;
-
- /* call java.lang.System.exit(I)V */
-
- m = class_resolveclassmethod(class_java_lang_System,
- utf_new_char("exit"),
- utf_int__void,
- class_java_lang_Object,
- true);
-
- if (!m)
- throw_main_exception_exit();
-
- /* call the exit function with passed exit status */
-
- /* both inlinevirtual and outsiders not allowed on exit */
- /* not sure if permanant or temp restriction */
- if (inlinevirtuals) inlineoutsiders = false;
-
- ASM_CALLJAVAFUNCTION(m, (void *) (ptrint) status, NULL, NULL, NULL);
-
- /* this should never happen */
-
- if (*exceptionptr)
- throw_exception_exit();
-
- throw_cacao_exception_exit(string_java_lang_InternalError,
- "System.exit(I)V returned without exception");
-}
-
-
-/*************************** Shutdown function *********************************
-
- Terminates the system immediately without freeing memory explicitly (to be
- used only for abnormal termination)
-
-*******************************************************************************/
-
-void cacao_shutdown(s4 status)
-{
-
-#if defined(ENABLE_JVMTI)
- agentunload();
-#endif
-
- if (opt_verbose || getcompilingtime || opt_stat) {
- log_text("CACAO terminated by shutdown");
- dolog("Exit status: %d\n", (s4) status);
- }
-
- exit(status);
-}
-
-
-/* exit_handler ****************************************************************
-
- The exit_handler function is called upon program termination.
-
- ATTENTION: Don't free system resources here! Some threads may still
- be running as this is called from VMRuntime.exit(). The OS does the
- cleanup for us.
-
-*******************************************************************************/
-
-void exit_handler(void)
-{
- /********************* Print debug tables ************************/
-
-#if !defined(NDEBUG)
- if (showmethods)
- class_showmethods(mainclass);
-
- if (showconstantpool)
- class_showconstantpool(mainclass);
-
- if (showutf)
- utf_show();
-
- if (opt_prof)
- profile_printstats();
-#endif
-
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
- clear_thread_flags(); /* restores standard file descriptor
- flags */
-#endif
-
- if (opt_verbose || getcompilingtime || opt_stat) {
- log_text("CACAO terminated");
-
-#if defined(ENABLE_STATISTICS)
- if (opt_stat) {
- print_stats();
-#ifdef TYPECHECK_STATISTICS
- typecheck_print_statistics(get_logfile());
-#endif
- }
-
- mem_usagelog(1);
-
- if (getcompilingtime)
- print_times();
-#endif
- }
- /* vm_print_profile(stderr);*/
-}
-
-
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
+++ /dev/null
-/* cacao/cacao.h - main header, contains global variables
-
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
-
- This file is part of CACAO.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-
- Contact: cacao@cacaojvm.org
-
- Authors: Christian Thalinger
-
- $Id: cacao.h 4357 2006-01-22 23:33:38Z twisti $
-
-*/
-
-
-#ifndef _CACAO_H
-#define _CACAO_H
-
-#include "native/jni.h"
-#include "vm/global.h"
-
-
-/* global variables ***********************************************************/
-
-extern u1 *intrp_main_stack;
-
-extern bool cacao_exiting;
-
-extern JavaVM *jvm;
-extern JNIEnv *env;
-
-extern char *mainstring; /* class.method with main method */
-
-
-/* function prototypes ********************************************************/
-
-void cacao_exit(s4 status);
-void cacao_shutdown(s4 status);
-
-#endif /* _CACAO_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
Philipp Tomsich
Christian Thalinger
- $Id: cacaoh.c 4381 2006-01-28 14:18:06Z twisti $
+ $Id: cacaoh.c 4530 2006-02-21 09:11:53Z twisti $
*/
/* define heap sizes **********************************************************/
#define HEAP_MAXSIZE 2 * 1024 * 1024 /* default 2MB */
-#define HEAP_STARTSIZE 100 * 1024 /* default 100kB */
+#define HEAP_STARTSIZE 100 * 1024 /* default 100kB */
/* define cacaoh options ******************************************************/
int main(int argc, char **argv)
{
- s4 i, a;
+ JavaVMInitArgs *vm_args;
+ s4 i, j;
+ s4 opt;
classinfo *c;
char *opt_directory;
void *dummy;
heapmaxsize = HEAP_MAXSIZE;
heapstartsize = HEAP_STARTSIZE;
- while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
- switch (i) {
+
+ /* parse the options ******************************************************/
+
+ vm_args = options_prepare(argc, argv);
+
+ while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
+ switch (opt) {
case OPT_IGNORE:
break;
break;
case OPT_BOOTCLASSPATH:
- /* Forget default bootclasspath and set the argument as new boot */
- /* classpath. */
+ /* Forget default bootclasspath and set the argument as
+ new boot classpath. */
MFREE(bootclasspath, char, strlen(bootclasspath));
bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
throw_main_exception_exit();
- /*********************** Load JAVA classes **************************/
+ /* load Java classes ******************************************************/
- for (a = opt_ind; a < argc; a++) {
- cp = argv[a];
+ for (i = opt_index; i < vm_args->nOptions; i++) {
+ cp = vm_args->options[i].optionString;
/* convert classname */
- for (i = strlen(cp) - 1; i >= 0; i--) {
- switch (cp[i]) {
- case '.': cp[i] = '/';
+ for (j = strlen(cp) - 1; j >= 0; j--) {
+ switch (cp[j]) {
+ case '.':
+ cp[j] = '/';
+ break;
+ case '_':
+ cp[j] = '$';
break;
- case '_': cp[i] = '$';
}
}
##
## Changes:
##
-## $Id: Makefile.am 4425 2006-02-04 00:43:15Z twisti $
+## $Id: Makefile.am 4530 2006-02-21 09:11:53Z twisti $
## Process this file with automake to produce Makefile.in
JVMTI_LIB = jvmti/libjvmti.la
endif
-if ENABLE_STATICVM
+if WITH_STATIC_CLASSPATH
SUBDIRS += tools
VM_ZIP = $(top_builddir)/src/lib/$(VM_ZIP_STRING)
Christian Thalinger
Edwin Steiner
- $Id: jni.c 4522 2006-02-14 20:27:06Z edwin $
+ $Id: jni.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include "vm/jit/asmpart.h"
#include "vm/jit/jit.h"
#include "vm/statistics.h"
+#include "vm/vm.h"
-/* XXX TWISTI hack: define it extern so they can be found in this file */
-
-extern const struct JNIInvokeInterface JNI_JavaVMTable;
-extern struct JNINativeInterface JNI_JNIEnvTable;
-
/* pointers to VM and the environment needed by GetJavaVM and GetEnv */
static JavaVM ptr_jvm = (JavaVM) &JNI_JavaVMTable;
/* accessing instance fields macros *******************************************/
-#define SET_FIELD(obj,type,var,value) \
- *((type *) ((ptrint) (obj) + (ptrint) (var)->offset)) = (type) (value)
+#define SET_FIELD(o,type,f,value) \
+ *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset)) = (type) (value)
-#define GET_FIELD(obj,type,var) \
- *((type *) ((ptrint) (obj) + (ptrint) (var)->offset))
+#define GET_FIELD(o,type,f) \
+ *((type *) ((ptrint) (o) + (ptrint) ((fieldinfo *) (f))->offset))
/* some forward declarations **************************************************/
jni_callblock blk[],
java_objectarray *params)
{
- jobject param;
- s4 paramcount;
- typedesc *paramtypes;
- classinfo *c;
- s4 i;
- s4 j;
+ java_objectheader *param;
+ s4 paramcount;
+ typedesc *paramtypes;
+ classinfo *c;
+ s4 i;
+ s4 j;
paramcount = descr->paramcount;
paramtypes = descr->paramtypes;
*******************************************************************************/
-jobject *_Jv_jni_invokeNative(methodinfo *m, jobject obj,
- java_objectarray *params)
+java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
+ java_objectarray *params)
{
methodinfo *resm;
jni_callblock *blk;
- java_objectheader *o;
+ java_objectheader *ro;
s4 argcount;
s4 paramcount;
if (!(m->flags & ACC_STATIC))
paramcount--;
- /* For instance methods the object has to be an instance of the */
- /* class the method belongs to. For static methods the obj parameter */
- /* is ignored. */
+ /* For instance methods the object has to be an instance of the
+ class the method belongs to. For static methods the obj
+ parameter is ignored. */
- if (!(m->flags & ACC_STATIC) && obj &&
- (!builtin_instanceof((java_objectheader *) obj, m->class)))
+ if (!(m->flags & ACC_STATIC) && o &&
+ (!builtin_instanceof(o, m->class)))
{
*exceptionptr =
new_exception_message(string_java_lang_IllegalArgumentException,
/* for instance methods we need an object */
- if (!(m->flags & ACC_STATIC) && !obj)
- {
+ if (!(m->flags & ACC_STATIC) && (o == NULL)) {
*exceptionptr =
new_exception_message(string_java_lang_NullPointerException,
"Static mismatch in Java_java_lang_reflect_Method_invokeNative");
return NULL;
}
- /* for static methods, zero obj to make subsequent code simpler */
+ /* for static methods, zero object to make subsequent code simpler */
if (m->flags & ACC_STATIC)
- obj = NULL;
+ o = NULL;
- if (obj) {
+ if (o != NULL) {
/* for instance methods we must do a vftbl lookup */
- resm = method_vftbl_lookup(obj->vftbl, m);
- }
- else {
+ resm = method_vftbl_lookup(o->vftbl, m);
+
+ } else {
/* for static methods, just for convenience */
resm = m;
}
blk = MNEW(jni_callblock, argcount);
- if (!fill_callblock_from_objectarray(obj, resm->parseddesc, blk,
- params))
+ if (!fill_callblock_from_objectarray(o, resm->parseddesc, blk, params))
return NULL;
switch (resm->parseddesc->returntype.decltype) {
argcount * sizeof(jni_callblock),
blk);
- o = NULL;
+ ro = NULL;
break;
case PRIMITIVETYPE_BOOLEAN: {
argcount * sizeof(jni_callblock),
blk);
- o = builtin_new(class_java_lang_Boolean);
+ ro = builtin_new(class_java_lang_Boolean);
/* setting the value of the object direct */
- bo = (java_lang_Boolean *) o;
+ bo = (java_lang_Boolean *) ro;
bo->value = i;
}
break;
argcount * sizeof(jni_callblock),
blk);
- o = builtin_new(class_java_lang_Byte);
+ ro = builtin_new(class_java_lang_Byte);
/* setting the value of the object direct */
- bo = (java_lang_Byte *) o;
+ bo = (java_lang_Byte *) ro;
bo->value = i;
}
break;
argcount * sizeof(jni_callblock),
blk);
- o = builtin_new(class_java_lang_Character);
+ ro = builtin_new(class_java_lang_Character);
/* setting the value of the object direct */
- co = (java_lang_Character *) o;
+ co = (java_lang_Character *) ro;
co->value = i;
}
break;
argcount * sizeof(jni_callblock),
blk);
- o = builtin_new(class_java_lang_Short);
+ ro = builtin_new(class_java_lang_Short);
/* setting the value of the object direct */
- so = (java_lang_Short *) o;
+ so = (java_lang_Short *) ro;
so->value = i;
}
break;
argcount * sizeof(jni_callblock),
blk);
- o = builtin_new(class_java_lang_Integer);
+ ro = builtin_new(class_java_lang_Integer);
/* setting the value of the object direct */
- io = (java_lang_Integer *) o;
+ io = (java_lang_Integer *) ro;
io->value = i;
}
break;
argcount * sizeof(jni_callblock),
blk);
- o = builtin_new(class_java_lang_Long);
+ ro = builtin_new(class_java_lang_Long);
/* setting the value of the object direct */
- lo = (java_lang_Long *) o;
+ lo = (java_lang_Long *) ro;
lo->value = l;
}
break;
argcount * sizeof(jni_callblock),
blk);
- o = builtin_new(class_java_lang_Float);
+ ro = builtin_new(class_java_lang_Float);
/* setting the value of the object direct */
- fo = (java_lang_Float *) o;
+ fo = (java_lang_Float *) ro;
fo->value = f;
}
break;
argcount * sizeof(jni_callblock),
blk);
- o = builtin_new(class_java_lang_Double);
+ ro = builtin_new(class_java_lang_Double);
/* setting the value of the object direct */
- _do = (java_lang_Double *) o;
+ _do = (java_lang_Double *) ro;
_do->value = d;
}
break;
case TYPE_ADR:
- ASM_CALLJAVAFUNCTION2_ADR(o, resm, argcount,
+ ASM_CALLJAVAFUNCTION2_ADR(ro, resm, argcount,
argcount * sizeof(jni_callblock),
blk);
break;
MFREE(blk, jni_callblock, argcount);
- return (jobject *) 0;
+ return NULL;
}
MFREE(blk, jni_callblock, argcount);
(java_lang_Throwable *) cause);
}
- return (jobject *) o;
+ return ro;
}
jclass FindClass(JNIEnv *env, const char *name)
{
- utf *u;
- classinfo *c;
- java_objectheader *cl;
+ utf *u;
+ classinfo *cc;
+ classinfo *c;
STATISTICS(jniinvokation());
u = utf_new_char_classname((char *) name);
/* Check stacktrace for classloader, if one found use it,
- otherwise use the system classloader. */
+ otherwise use the system classloader. */
+
+ /* Quote from the JNI documentation:
+
+ In the Java 2 Platform, FindClass locates the class loader
+ associated with the current native method. If the native code
+ belongs to a system class, no class loader will be
+ involved. Otherwise, the proper class loader will be invoked to
+ load and link the named class. When FindClass is called through
+ the Invocation Interface, there is no current native method or
+ its associated class loader. In that case, the result of
+ ClassLoader.getBaseClassLoader is used." */
#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__X86_64__)
/* these JITs support stacktraces, and so does the interpreter */
- cl = stacktrace_getCurrentClassLoader();
+ cc = stacktrace_getCurrentClass();
#else
# if defined(ENABLE_INTRP)
/* the interpreter supports stacktraces, even if the JIT does not */
if (opt_intrp)
- cl = stacktrace_getCurrentClassLoader();
+ cc = stacktrace_getCurrentClass();
else
# endif
- cl = NULL;
+ cc = NULL;
#endif
- if (!(c = load_class_from_classloader(u, cl)))
+ /* if no Java method was found, use the system classloader */
+
+ if (cc == NULL)
+ c = load_class_from_sysloader(u);
+ else
+ c = load_class_from_classloader(u, cc->classloader);
+
+ if (c == NULL)
return NULL;
if (!link_class(c))
}
-/* FromReflectedMethod *********************************************************
-
- Converts java.lang.reflect.Method or java.lang.reflect.Constructor
- object to a method ID.
-
-*******************************************************************************/
-
-jmethodID FromReflectedMethod(JNIEnv *env, jobject method)
-{
- methodinfo *mi;
- classinfo *c;
- s4 slot;
-
- STATISTICS(jniinvokation());
-
- if (method == NULL)
- return NULL;
-
- if (builtin_instanceof(method, class_java_lang_reflect_Method)) {
- java_lang_reflect_Method *rm;
-
- rm = (java_lang_reflect_Method *) method;
- c = (classinfo *) (rm->declaringClass);
- slot = rm->slot;
-
- } else if (builtin_instanceof(method, class_java_lang_reflect_Constructor)) {
- java_lang_reflect_Constructor *rc;
-
- rc = (java_lang_reflect_Constructor *) method;
- c = (classinfo *) (rc->clazz);
- slot = rc->slot;
-
- } else
- return NULL;
-
- if ((slot < 0) || (slot >= c->methodscount)) {
- /* this usually means a severe internal cacao error or somebody
- tempered around with the reflected method */
- log_text("error illegal slot for method in class(FromReflectedMethod)");
- assert(0);
- }
-
- mi = &(c->methods[slot]);
-
- return mi;
-}
-
-
/* GetSuperclass ***************************************************************
If clazz represents any class other than the class Object, then
jobject AllocObject(JNIEnv *env, jclass clazz)
{
+ classinfo *c;
java_objectheader *o;
STATISTICS(jniinvokation());
- if ((clazz->flags & ACC_INTERFACE) || (clazz->flags & ACC_ABSTRACT)) {
+ c = (classinfo *) clazz;
+
+ if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) {
*exceptionptr =
new_exception_utfmessage(string_java_lang_InstantiationException,
- clazz->name);
+ c->name);
return NULL;
}
- o = builtin_new(clazz);
+ o = builtin_new(c);
return NewLocalRef(env, o);
}
jobject NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
java_objectheader *o;
+ methodinfo *m;
va_list ap;
STATISTICS(jniinvokation());
+ m = (methodinfo *) methodID;
+
/* create object */
o = builtin_new(clazz);
/* call constructor */
va_start(ap, methodID);
- _Jv_jni_CallVoidMethod(o, o->vftbl, methodID, ap);
+ _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
va_end(ap);
return NewLocalRef(env, o);
jobject NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args)
{
java_objectheader *o;
+ methodinfo *m;
STATISTICS(jniinvokation());
+ m = (methodinfo *) methodID;
+
/* create object */
o = builtin_new(clazz);
/* call constructor */
- _Jv_jni_CallVoidMethod(o, o->vftbl, methodID, args);
+ _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
return NewLocalRef(env, o);
}
jclass GetObjectClass(JNIEnv *env, jobject obj)
{
- classinfo *c;
+ java_objectheader *o;
+ classinfo *c;
STATISTICS(jniinvokation());
-
- if (!obj || !obj->vftbl)
+
+ o = (java_objectheader *) obj;
+
+ if ((o == NULL) || (o->vftbl == NULL))
return NULL;
- c = obj->vftbl->class;
+ c = o->vftbl->class;
return (jclass) NewLocalRef(env, (jobject) c);
}
}
-/***************** converts a java.lang.reflect.Field to a field ID ***************/
+/* Reflection Support *********************************************************/
+
+/* FromReflectedMethod *********************************************************
+
+ Converts java.lang.reflect.Method or java.lang.reflect.Constructor
+ object to a method ID.
+
+*******************************************************************************/
+
+jmethodID FromReflectedMethod(JNIEnv *env, jobject method)
+{
+ methodinfo *mi;
+ classinfo *c;
+ s4 slot;
+
+ STATISTICS(jniinvokation());
+
+ if (method == NULL)
+ return NULL;
+
+ if (builtin_instanceof(method, class_java_lang_reflect_Method)) {
+ java_lang_reflect_Method *rm;
+
+ rm = (java_lang_reflect_Method *) method;
+ c = (classinfo *) (rm->declaringClass);
+ slot = rm->slot;
+
+ } else if (builtin_instanceof(method, class_java_lang_reflect_Constructor)) {
+ java_lang_reflect_Constructor *rc;
+
+ rc = (java_lang_reflect_Constructor *) method;
+ c = (classinfo *) (rc->clazz);
+ slot = rc->slot;
+
+ } else
+ return NULL;
+
+ mi = &(c->methods[slot]);
+
+ return (jmethodID) mi;
+}
+
+
+/* FromReflectedField **********************************************************
+
+ Converts a java.lang.reflect.Field to a field ID.
+
+*******************************************************************************/
jfieldID FromReflectedField(JNIEnv* env, jobject field)
{
- java_lang_reflect_Field *f;
- classinfo *c;
- jfieldID fid; /* the JNI-fieldid of the wrapping object */
+ java_lang_reflect_Field *rf;
+ classinfo *c;
+ fieldinfo *f;
STATISTICS(jniinvokation());
- /*log_text("JNI-Call: FromReflectedField");*/
+ rf = (java_lang_reflect_Field *) field;
- f=(java_lang_reflect_Field *)field;
- if (f==0) return 0;
- c=(classinfo*)(f->declaringClass);
- if ( (f->slot<0) || (f->slot>=c->fieldscount)) {
- /*this usually means a severe internal cacao error or somebody
- tempered around with the reflected method*/
- log_text("error illegal slot for field in class(FromReflectedField)");
- assert(0);
- }
- fid=&(c->fields[f->slot]);
- return fid;
+ if (rf == NULL)
+ return NULL;
+
+ c = (classinfo *) rf->declaringClass;
+
+ f = &(c->fields[rf->slot]);
+
+ return (jfieldID) f;
}
return NULL;
}
- return m;
+ return (jmethodID) m;
}
jobject CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- java_objectheader* ret;
+ java_objectheader *o;
+ methodinfo *m;
+ java_objectheader *ret;
va_list ap;
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
va_start(ap, methodID);
- ret = _Jv_jni_CallObjectMethod(obj, obj->vftbl, methodID, ap);
+ ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, ap);
va_end(ap);
return NewLocalRef(env, ret);
jobject CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- java_objectheader* ret;
+ java_objectheader *o;
+ methodinfo *m;
+ java_objectheader *ret;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- ret = _Jv_jni_CallObjectMethod(obj, obj->vftbl, methodID, args);
+ ret = _Jv_jni_CallObjectMethod(o, o->vftbl, m, args);
return NewLocalRef(env, ret);
}
jboolean CallBooleanMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
- jboolean ret;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jboolean b;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, ap,
- PRIMITIVETYPE_BOOLEAN);
+ b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap, PRIMITIVETYPE_BOOLEAN);
va_end(ap);
- return ret;
+ return b;
}
jboolean CallBooleanMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- jboolean ret;
+ java_objectheader *o;
+ methodinfo *m;
+ jboolean b;
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, args,
- PRIMITIVETYPE_BOOLEAN);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args, PRIMITIVETYPE_BOOLEAN);
+
+ return b;
}
jbyte CallByteMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
- jbyte ret;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jbyte b;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, ap,
- PRIMITIVETYPE_BYTE);
+ b = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap, PRIMITIVETYPE_BYTE);
va_end(ap);
- return ret;
+ return b;
}
jbyte CallByteMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- jbyte ret;
+ java_objectheader *o;
+ methodinfo *m;
+ jbyte b;
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, args,
- PRIMITIVETYPE_BYTE);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ b = _Jv_jni_CallIntMethod(o, o->vftbl, m, args, PRIMITIVETYPE_BYTE);
+
+ return b;
}
jchar CallCharMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
- jchar ret;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jchar c;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, ap,
- PRIMITIVETYPE_CHAR);
+ c = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap, PRIMITIVETYPE_CHAR);
va_end(ap);
- return ret;
+ return c;
}
jchar CallCharMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- jchar ret;
+ java_objectheader *o;
+ methodinfo *m;
+ jchar c;
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, args,
- PRIMITIVETYPE_CHAR);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ c = _Jv_jni_CallIntMethod(o, o->vftbl, m, args, PRIMITIVETYPE_CHAR);
+
+ return c;
}
jshort CallShortMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
- jshort ret;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jshort s;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, ap,
- PRIMITIVETYPE_SHORT);
+ s = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap, PRIMITIVETYPE_SHORT);
va_end(ap);
- return ret;
+ return s;
}
jshort CallShortMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- jshort ret;
+ java_objectheader *o;
+ methodinfo *m;
+ jshort s;
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, args,
- PRIMITIVETYPE_SHORT);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ s = _Jv_jni_CallIntMethod(o, o->vftbl, m, args, PRIMITIVETYPE_SHORT);
+
+ return s;
}
jint CallIntMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
- jint ret;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jint i;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, ap,
- PRIMITIVETYPE_INT);
+ i = _Jv_jni_CallIntMethod(o, o->vftbl, m, ap, PRIMITIVETYPE_INT);
va_end(ap);
- return ret;
+ return i;
}
jint CallIntMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- jint ret;
+ java_objectheader *o;
+ methodinfo *m;
+ jint i;
- ret = _Jv_jni_CallIntMethod(obj, obj->vftbl, methodID, args,
- PRIMITIVETYPE_INT);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ i = _Jv_jni_CallIntMethod(o, o->vftbl, m, args, PRIMITIVETYPE_INT);
+
+ return i;
}
jlong CallLongMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
- jlong ret;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jlong l;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallLongMethod(obj, obj->vftbl, methodID, ap);
+ l = _Jv_jni_CallLongMethod(o, o->vftbl, m, ap);
va_end(ap);
- return ret;
+ return l;
}
jlong CallLongMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- jlong ret;
+ java_objectheader *o;
+ methodinfo *m;
+ jlong l;
- ret = _Jv_jni_CallLongMethod(obj, obj->vftbl, methodID, args);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ l = _Jv_jni_CallLongMethod(o, o->vftbl, m, args);
+
+ return l;
}
jfloat CallFloatMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
- jfloat ret;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jfloat f;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallFloatMethod(obj, obj->vftbl, methodID, ap);
+ f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, ap);
va_end(ap);
- return ret;
+ return f;
}
jfloat CallFloatMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- jfloat ret;
+ java_objectheader *o;
+ methodinfo *m;
+ jfloat f;
- ret = _Jv_jni_CallFloatMethod(obj, obj->vftbl, methodID, args);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ f = _Jv_jni_CallFloatMethod(o, o->vftbl, m, args);
+
+ return f;
}
jdouble CallDoubleMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
- jdouble ret;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+ jdouble d;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallDoubleMethod(obj, obj->vftbl, methodID, ap);
+ d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, ap);
va_end(ap);
- return ret;
+ return d;
}
jdouble CallDoubleMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- jdouble ret;
+ java_objectheader *o;
+ methodinfo *m;
+ jdouble d;
- ret = _Jv_jni_CallDoubleMethod(obj, obj->vftbl, methodID, args);
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
- return ret;
+ d = _Jv_jni_CallDoubleMethod(o, o->vftbl, m, args);
+
+ return d;
}
void CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)
{
- va_list ap;
+ java_objectheader *o;
+ methodinfo *m;
+ va_list ap;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- _Jv_jni_CallVoidMethod(obj, obj->vftbl, methodID, ap);
+ _Jv_jni_CallVoidMethod(o, o->vftbl, m, ap);
va_end(ap);
}
void CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)
{
- _Jv_jni_CallVoidMethod(obj, obj->vftbl, methodID, args);
+ java_objectheader *o;
+ methodinfo *m;
+
+ o = (java_objectheader *) obj;
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethod(o, o->vftbl, m, args);
}
jobject CallNonvirtualObjectMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- java_objectheader *ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ java_objectheader *r;
va_list ap;
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
va_start(ap, methodID);
- ret = _Jv_jni_CallObjectMethod(obj, clazz->vftbl, methodID, ap);
+ r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap);
va_end(ap);
- return NewLocalRef(env, ret);
+ return NewLocalRef(env, r);
}
jobject CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- java_objectheader* ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ java_objectheader *r;
- ret = _Jv_jni_CallObjectMethod(obj, clazz->vftbl, methodID, args);
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- return NewLocalRef(env, ret);
+ r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
+
+ return NewLocalRef(env, r);
}
jboolean CallNonvirtualBooleanMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jboolean ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jboolean b;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, ap,
- PRIMITIVETYPE_BOOLEAN);
+ b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap, PRIMITIVETYPE_BOOLEAN);
va_end(ap);
- return ret;
-
+ return b;
}
jboolean CallNonvirtualBooleanMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- jboolean ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jboolean b;
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, args,
- PRIMITIVETYPE_BOOLEAN);
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- return ret;
+ b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args, PRIMITIVETYPE_BOOLEAN);
+
+ return b;
}
jbyte CallNonvirtualByteMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jbyte ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jbyte b;
- va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, ap,
- PRIMITIVETYPE_BYTE);
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ va_start(ap, methodID);
+ b = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap, PRIMITIVETYPE_BYTE);
va_end(ap);
- return ret;
+ return b;
}
-jbyte CallNonvirtualByteMethodV (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
+jbyte CallNonvirtualByteMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- jbyte ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jbyte b;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, args,
- PRIMITIVETYPE_BYTE);
+ b = _Jv_jni_CallIntMethod(o, c->vftbl, m, args, PRIMITIVETYPE_BYTE);
- return ret;
+ return b;
}
jchar CallNonvirtualCharMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jchar ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jchar ch;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, ap,
- PRIMITIVETYPE_CHAR);
+ ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap, PRIMITIVETYPE_CHAR);
va_end(ap);
- return ret;
+ return ch;
}
jchar CallNonvirtualCharMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- jchar ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jchar ch;
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, args,
- PRIMITIVETYPE_CHAR);
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- return ret;
+ ch = _Jv_jni_CallIntMethod(o, c->vftbl, m, args, PRIMITIVETYPE_CHAR);
+
+ return ch;
}
jshort CallNonvirtualShortMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jshort ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jshort s;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, ap,
- PRIMITIVETYPE_SHORT);
+ s = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap, PRIMITIVETYPE_SHORT);
va_end(ap);
- return ret;
+ return s;
}
jshort CallNonvirtualShortMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- jshort ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jshort s;
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, args,
- PRIMITIVETYPE_SHORT);
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- return ret;
+ s = _Jv_jni_CallIntMethod(o, c->vftbl, m, args, PRIMITIVETYPE_SHORT);
+
+ return s;
}
jint CallNonvirtualIntMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jint ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jint i;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, ap,
- PRIMITIVETYPE_INT);
+ i = _Jv_jni_CallIntMethod(o, c->vftbl, m, ap, PRIMITIVETYPE_INT);
va_end(ap);
- return ret;
+ return i;
}
jint CallNonvirtualIntMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- jint ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jint i;
- ret = _Jv_jni_CallIntMethod(obj, clazz->vftbl, methodID, args,
- PRIMITIVETYPE_INT);
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- return ret;
+ i = _Jv_jni_CallIntMethod(o, c->vftbl, m, args, PRIMITIVETYPE_INT);
+
+ return i;
}
jlong CallNonvirtualLongMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jlong ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jlong l;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallLongMethod(obj, clazz->vftbl, methodID, ap);
+ l = _Jv_jni_CallLongMethod(o, c->vftbl, m, ap);
va_end(ap);
- return ret;
+ return l;
}
jlong CallNonvirtualLongMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- jlong ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jlong l;
- ret = _Jv_jni_CallLongMethod(obj, clazz->vftbl, methodID, args);
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- return 0;
+ l = _Jv_jni_CallLongMethod(o, c->vftbl, m, args);
+
+ return l;
}
jfloat CallNonvirtualFloatMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jfloat ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jfloat f;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallFloatMethod(obj, clazz->vftbl, methodID, ap);
+ f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, ap);
va_end(ap);
- return ret;
+ return f;
}
jfloat CallNonvirtualFloatMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- jfloat ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jfloat f;
- ret = _Jv_jni_CallFloatMethod(obj, clazz->vftbl, methodID, args);
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- return ret;
+ f = _Jv_jni_CallFloatMethod(o, c->vftbl, m, args);
+
+ return f;
}
jfloat CallNonvirtualFloatMethodA(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, jvalue *args)
{
- STATISTICS(jniinvokation());
-
log_text("JNI-Call: CallNonvirtualFloatMethodA: IMPLEMENT ME!");
return 0;
jdouble CallNonvirtualDoubleMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jdouble ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+ jdouble d;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallDoubleMethod(obj, clazz->vftbl, methodID, ap);
+ d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, ap);
va_end(ap);
- return ret;
+ return d;
}
jdouble CallNonvirtualDoubleMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- jdouble ret;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ jdouble d;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
- ret = _Jv_jni_CallDoubleMethod(obj, clazz->vftbl, methodID, args);
+ d = _Jv_jni_CallDoubleMethod(o, c->vftbl, m, args);
- return ret;
+ return d;
}
void CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+ va_list ap;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- _Jv_jni_CallVoidMethod(obj, clazz->vftbl, methodID, ap);
+ _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap);
va_end(ap);
}
void CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
- _Jv_jni_CallVoidMethod(obj, clazz->vftbl, methodID, args);
+ java_objectheader *o;
+ classinfo *c;
+ methodinfo *m;
+
+ o = (java_objectheader *) obj;
+ c = (classinfo *) clazz;
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethod(o, c->vftbl, m, args);
}
if (!f)
*exceptionptr = new_exception(string_java_lang_NoSuchFieldError);
- return f;
+ return (jfieldID) f;
}
jint GetIntField(JNIEnv *env, jobject obj, jfieldID fieldID)
{
- s4 i;
+ java_objectheader *o;
+ fieldinfo *f;
+ s4 i;
STATISTICS(jniinvokation());
- i = GET_FIELD(obj, s4, fieldID);
+ o = (java_objectheader *) obj;
+ f = (fieldinfo *) fieldID;
+
+ i = GET_FIELD(o, s4, f);
return i;
}
return NULL;
}
- return m;
+ return (jmethodID) m;
}
jobject CallStaticObjectMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- java_objectheader *ret;
+ methodinfo *m;
+ java_objectheader *o;
va_list ap;
+ m = (methodinfo *) methodID;
+
va_start(ap, methodID);
- ret = _Jv_jni_CallObjectMethod(NULL, NULL, methodID, ap);
+ o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap);
va_end(ap);
- return NewLocalRef(env, ret);
+ return NewLocalRef(env, o);
}
jobject CallStaticObjectMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- java_objectheader *ret;
+ methodinfo *m;
+ java_objectheader *o;
- ret = _Jv_jni_CallObjectMethod(NULL, NULL, methodID, args);
+ m = (methodinfo *) methodID;
- return NewLocalRef(env, ret);
+ o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args);
+
+ return NewLocalRef(env, o);
}
jboolean CallStaticBooleanMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jboolean ret;
+ methodinfo *m;
+ va_list ap;
+ jboolean b;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, ap,
- PRIMITIVETYPE_BOOLEAN);
+ b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap, PRIMITIVETYPE_BOOLEAN);
va_end(ap);
- return ret;
+ return b;
}
jboolean CallStaticBooleanMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- jboolean ret;
+ methodinfo *m;
+ jboolean b;
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, args,
- PRIMITIVETYPE_BOOLEAN);
+ m = (methodinfo *) methodID;
- return ret;
+ b = _Jv_jni_CallIntMethod(NULL, NULL, m, args, PRIMITIVETYPE_BOOLEAN);
+
+ return b;
}
jbyte CallStaticByteMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jbyte ret;
+ methodinfo *m;
+ va_list ap;
+ jbyte b;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, ap, PRIMITIVETYPE_BYTE);
+ b = _Jv_jni_CallIntMethod(NULL, NULL, m, ap, PRIMITIVETYPE_BYTE);
va_end(ap);
- return ret;
+ return b;
}
jbyte CallStaticByteMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- jbyte ret;
+ methodinfo *m;
+ jbyte b;
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, args, PRIMITIVETYPE_BYTE);
+ m = (methodinfo *) methodID;
- return ret;
+ b = _Jv_jni_CallIntMethod(NULL, NULL, m, args, PRIMITIVETYPE_BYTE);
+
+ return b;
}
jchar CallStaticCharMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jchar ret;
+ methodinfo *m;
+ va_list ap;
+ jchar c;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, ap, PRIMITIVETYPE_CHAR);
+ c = _Jv_jni_CallIntMethod(NULL, NULL, m, ap, PRIMITIVETYPE_CHAR);
va_end(ap);
- return ret;
+ return c;
}
jchar CallStaticCharMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- jchar ret;
+ methodinfo *m;
+ jchar c;
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, args, PRIMITIVETYPE_CHAR);
+ m = (methodinfo *) methodID;
- return ret;
+ c = _Jv_jni_CallIntMethod(NULL, NULL, m, args, PRIMITIVETYPE_CHAR);
+
+ return c;
}
jshort CallStaticShortMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jshort ret;
+ methodinfo *m;
+ va_list ap;
+ jshort s;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, ap, PRIMITIVETYPE_SHORT);
+ s = _Jv_jni_CallIntMethod(NULL, NULL, m, ap, PRIMITIVETYPE_SHORT);
va_end(ap);
- return ret;
+ return s;
}
jshort CallStaticShortMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- jshort ret;
+ methodinfo *m;
+ jshort s;
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, args,
- PRIMITIVETYPE_SHORT);
+ m = (methodinfo *) methodID;
- return ret;
+ s = _Jv_jni_CallIntMethod(NULL, NULL, m, args, PRIMITIVETYPE_SHORT);
+
+ return s;
}
jint CallStaticIntMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jint ret;
+ methodinfo *m;
+ va_list ap;
+ jint i;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, ap, PRIMITIVETYPE_INT);
+ i = _Jv_jni_CallIntMethod(NULL, NULL, m, ap, PRIMITIVETYPE_INT);
va_end(ap);
- return ret;
+ return i;
}
jint CallStaticIntMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- jint ret;
+ methodinfo *m;
+ jint i;
- ret = _Jv_jni_CallIntMethod(NULL, NULL, methodID, args, PRIMITIVETYPE_INT);
+ m = (methodinfo *) methodID;
- return ret;
+ i = _Jv_jni_CallIntMethod(NULL, NULL, m, args, PRIMITIVETYPE_INT);
+
+ return i;
}
jlong CallStaticLongMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jlong ret;
+ methodinfo *m;
+ va_list ap;
+ jlong l;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallLongMethod(NULL, NULL, methodID, ap);
+ l = _Jv_jni_CallLongMethod(NULL, NULL, m, ap);
va_end(ap);
- return ret;
+ return l;
}
jlong CallStaticLongMethodV(JNIEnv *env, jclass clazz, jmethodID methodID,
va_list args)
{
- jlong ret;
+ methodinfo *m;
+ jlong l;
- ret = _Jv_jni_CallLongMethod(NULL, NULL, methodID, args);
+ m = (methodinfo *) methodID;
- return ret;
+ l = _Jv_jni_CallLongMethod(NULL, NULL, m, args);
+
+ return l;
}
jfloat CallStaticFloatMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jfloat ret;
+ methodinfo *m;
+ va_list ap;
+ jfloat f;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallFloatMethod(NULL, NULL, methodID, ap);
+ f = _Jv_jni_CallFloatMethod(NULL, NULL, m, ap);
va_end(ap);
- return ret;
+ return f;
}
jfloat CallStaticFloatMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- jfloat ret;
+ methodinfo *m;
+ jfloat f;
- ret = _Jv_jni_CallFloatMethod(NULL, NULL, methodID, args);
+ m = (methodinfo *) methodID;
- return ret;
+ f = _Jv_jni_CallFloatMethod(NULL, NULL, m, args);
+
+ return f;
}
jdouble CallStaticDoubleMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
- jdouble ret;
+ methodinfo *m;
+ va_list ap;
+ jdouble d;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- ret = _Jv_jni_CallDoubleMethod(NULL, NULL, methodID, ap);
+ d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, ap);
va_end(ap);
- return ret;
+ return d;
}
jdouble CallStaticDoubleMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- jdouble ret;
+ methodinfo *m;
+ jdouble d;
- ret = _Jv_jni_CallDoubleMethod(NULL, NULL, methodID, args);
+ m = (methodinfo *) methodID;
- return ret;
+ d = _Jv_jni_CallDoubleMethod(NULL, NULL, m, args);
+
+ return d;
}
void CallStaticVoidMethod(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
{
- va_list ap;
+ methodinfo *m;
+ va_list ap;
+
+ m = (methodinfo *) methodID;
va_start(ap, methodID);
- _Jv_jni_CallVoidMethod(NULL, NULL, methodID, ap);
+ _Jv_jni_CallVoidMethod(NULL, NULL, m, ap);
va_end(ap);
}
void CallStaticVoidMethodV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)
{
- _Jv_jni_CallVoidMethod(NULL, NULL, methodID, args);
+ methodinfo *m;
+
+ m = (methodinfo *) methodID;
+
+ _Jv_jni_CallVoidMethod(NULL, NULL, m, args);
}
jfieldID GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig)
{
- jfieldID f;
+ fieldinfo *f;
STATISTICS(jniinvokation());
utf_new_char((char *) name),
utf_new_char((char *) sig));
- if (!f)
+ if (f == NULL)
*exceptionptr = new_exception(string_java_lang_NoSuchFieldError);
- return f;
+ return (jfieldID) f;
}
jobject GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return NULL;
- return NewLocalRef(env, fieldID->value.a);
+ return NewLocalRef(env, f->value.a);
}
jboolean GetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return false;
- return fieldID->value.i;
+ return f->value.i;
}
jbyte GetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return 0;
- return fieldID->value.i;
+ return f->value.i;
}
jchar GetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return 0;
- return fieldID->value.i;
+ return f->value.i;
}
jshort GetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return 0;
- return fieldID->value.i;
+ return f->value.i;
}
jint GetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return 0;
- return fieldID->value.i;
+ return f->value.i;
}
jlong GetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return 0;
- return fieldID->value.l;
+ return f->value.l;
}
jfloat GetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return 0.0;
- return fieldID->value.f;
+ return f->value.f;
}
jdouble GetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return 0.0;
- return fieldID->value.d;
+ return f->value.d;
}
void SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.a = value;
+ f->value.a = value;
}
void SetStaticBooleanField(JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.i = value;
+ f->value.i = value;
}
void SetStaticByteField(JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.i = value;
+ f->value.i = value;
}
void SetStaticCharField(JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.i = value;
+ f->value.i = value;
}
void SetStaticShortField(JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.i = value;
+ f->value.i = value;
}
void SetStaticIntField(JNIEnv *env, jclass clazz, jfieldID fieldID, jint value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.i = value;
+ f->value.i = value;
}
void SetStaticLongField(JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.l = value;
+ f->value.l = value;
}
void SetStaticFloatField(JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.f = value;
+ f->value.f = value;
}
void SetStaticDoubleField(JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value)
{
+ classinfo *c;
+ fieldinfo *f;
+
STATISTICS(jniinvokation());
- if (!(clazz->state & CLASS_INITIALIZED))
- if (!initialize_class(clazz))
+ c = (classinfo *) clazz;
+ f = (fieldinfo *) fieldID;
+
+ if (!(c->state & CLASS_INITIALIZED))
+ if (!initialize_class(c))
return;
- fieldID->value.d = value;
+ f->value.d = value;
}
jsize GetArrayLength(JNIEnv *env, jarray array)
{
+ java_arrayheader *a;
+
STATISTICS(jniinvokation());
- return array->size;
+ a = (java_arrayheader *) array;
+
+ return a->size;
}
jobject GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index)
{
- jobject o;
+ java_objectarray *oa;
+ jobject o;
STATISTICS(jniinvokation());
- if (index >= array->header.size) {
+ oa = (java_objectarray *) array;
+
+ if (index >= oa->header.size) {
exceptions_throw_arrayindexoutofboundsexception();
return NULL;
}
- o = array->data[index];
-
- return NewLocalRef(env, o);
+ o = oa->data[index];
+
+ return NewLocalRef(env, o);
}
oa = (java_objectarray *) array;
o = (java_objectheader *) val;
- if (index >= array->header.size) {
+ if (index >= oa->header.size) {
exceptions_throw_arrayindexoutofboundsexception();
return;
}
return;
}
- array->data[index] = val;
+ oa->data[index] = val;
}
jboolean *GetBooleanArrayElements(JNIEnv *env, jbooleanArray array,
jboolean *isCopy)
{
+ java_booleanarray *ba;
+
STATISTICS(jniinvokation());
- if (isCopy)
+ ba = (java_booleanarray *) array;
+
+ if (isCopy)
*isCopy = JNI_FALSE;
- return array->data;
+ return ba->data;
}
jbyte *GetByteArrayElements(JNIEnv *env, jbyteArray array, jboolean *isCopy)
{
+ java_bytearray *ba;
+
STATISTICS(jniinvokation());
- if (isCopy)
+ ba = (java_bytearray *) array;
+
+ if (isCopy)
*isCopy = JNI_FALSE;
- return array->data;
+ return ba->data;
}
jchar *GetCharArrayElements(JNIEnv *env, jcharArray array, jboolean *isCopy)
{
+ java_chararray *ca;
+
STATISTICS(jniinvokation());
- if (isCopy)
+ ca = (java_chararray *) array;
+
+ if (isCopy)
*isCopy = JNI_FALSE;
- return array->data;
+ return ca->data;
}
jshort *GetShortArrayElements(JNIEnv *env, jshortArray array, jboolean *isCopy)
{
+ java_shortarray *sa;
+
STATISTICS(jniinvokation());
- if (isCopy)
+ sa = (java_shortarray *) array;
+
+ if (isCopy)
*isCopy = JNI_FALSE;
- return array->data;
+ return sa->data;
}
jint *GetIntArrayElements(JNIEnv *env, jintArray array, jboolean *isCopy)
{
+ java_intarray *ia;
+
STATISTICS(jniinvokation());
- if (isCopy)
+ ia = (java_intarray *) array;
+
+ if (isCopy)
*isCopy = JNI_FALSE;
- return array->data;
+ return ia->data;
}
jlong *GetLongArrayElements(JNIEnv *env, jlongArray array, jboolean *isCopy)
{
+ java_longarray *la;
+
STATISTICS(jniinvokation());
- if (isCopy)
+ la = (java_longarray *) array;
+
+ if (isCopy)
*isCopy = JNI_FALSE;
- return array->data;
+ /* We cast this one to prevent a compiler warning on 64-bit
+ systems since GNU Classpath typedef jlong to long long. */
+
+ return (jlong *) la->data;
}
jfloat *GetFloatArrayElements(JNIEnv *env, jfloatArray array, jboolean *isCopy)
{
+ java_floatarray *fa;
+
STATISTICS(jniinvokation());
- if (isCopy)
+ fa = (java_floatarray *) array;
+
+ if (isCopy)
*isCopy = JNI_FALSE;
- return array->data;
+ return fa->data;
}
jdouble *GetDoubleArrayElements(JNIEnv *env, jdoubleArray array,
jboolean *isCopy)
{
+ java_doublearray *da;
+
STATISTICS(jniinvokation());
- if (isCopy)
+ da = (java_doublearray *) array;
+
+ if (isCopy)
*isCopy = JNI_FALSE;
- return array->data;
+ return da->data;
}
void ReleaseBooleanArrayElements(JNIEnv *env, jbooleanArray array,
jboolean *elems, jint mode)
{
+ java_booleanarray *ba;
+
STATISTICS(jniinvokation());
- if (elems != array->data) {
+ ba = (java_booleanarray *) array;
+
+ if (elems != ba->data) {
switch (mode) {
case JNI_COMMIT:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(ba->data, elems, u1, ba->header.size);
break;
case 0:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(ba->data, elems, u1, ba->header.size);
/* XXX TWISTI how should it be freed? */
break;
case JNI_ABORT:
void ReleaseByteArrayElements(JNIEnv *env, jbyteArray array, jbyte *elems,
jint mode)
{
+ java_bytearray *ba;
+
STATISTICS(jniinvokation());
- if (elems != array->data) {
+ ba = (java_bytearray *) array;
+
+ if (elems != ba->data) {
switch (mode) {
case JNI_COMMIT:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(ba->data, elems, s1, ba->header.size);
break;
case 0:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(ba->data, elems, s1, ba->header.size);
/* XXX TWISTI how should it be freed? */
break;
case JNI_ABORT:
void ReleaseCharArrayElements(JNIEnv *env, jcharArray array, jchar *elems,
jint mode)
{
+ java_chararray *ca;
+
STATISTICS(jniinvokation());
- if (elems != array->data) {
+ ca = (java_chararray *) array;
+
+ if (elems != ca->data) {
switch (mode) {
case JNI_COMMIT:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(ca->data, elems, u2, ca->header.size);
break;
case 0:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(ca->data, elems, u2, ca->header.size);
/* XXX TWISTI how should it be freed? */
break;
case JNI_ABORT:
void ReleaseShortArrayElements(JNIEnv *env, jshortArray array, jshort *elems,
jint mode)
{
+ java_shortarray *sa;
+
STATISTICS(jniinvokation());
- if (elems != array->data) {
+ sa = (java_shortarray *) array;
+
+ if (elems != sa->data) {
switch (mode) {
case JNI_COMMIT:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(sa->data, elems, s2, sa->header.size);
break;
case 0:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(sa->data, elems, s2, sa->header.size);
/* XXX TWISTI how should it be freed? */
break;
case JNI_ABORT:
void ReleaseIntArrayElements(JNIEnv *env, jintArray array, jint *elems,
jint mode)
{
+ java_intarray *ia;
+
STATISTICS(jniinvokation());
- if (elems != array->data) {
+ ia = (java_intarray *) array;
+
+ if (elems != ia->data) {
switch (mode) {
case JNI_COMMIT:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(ia->data, elems, s4, ia->header.size);
break;
case 0:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(ia->data, elems, s4, ia->header.size);
/* XXX TWISTI how should it be freed? */
break;
case JNI_ABORT:
void ReleaseLongArrayElements(JNIEnv *env, jlongArray array, jlong *elems,
jint mode)
{
+ java_longarray *la;
+
STATISTICS(jniinvokation());
- if (elems != array->data) {
+ la = (java_longarray *) array;
+
+ /* We cast this one to prevent a compiler warning on 64-bit
+ systems since GNU Classpath typedef jlong to long long. */
+
+ if ((s8 *) elems != la->data) {
switch (mode) {
case JNI_COMMIT:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(la->data, elems, s8, la->header.size);
break;
case 0:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(la->data, elems, s8, la->header.size);
/* XXX TWISTI how should it be freed? */
break;
case JNI_ABORT:
void ReleaseFloatArrayElements(JNIEnv *env, jfloatArray array, jfloat *elems,
jint mode)
{
+ java_floatarray *fa;
+
STATISTICS(jniinvokation());
- if (elems != array->data) {
+ fa = (java_floatarray *) array;
+
+ if (elems != fa->data) {
switch (mode) {
case JNI_COMMIT:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(fa->data, elems, float, fa->header.size);
break;
case 0:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(fa->data, elems, float, fa->header.size);
/* XXX TWISTI how should it be freed? */
break;
case JNI_ABORT:
void ReleaseDoubleArrayElements(JNIEnv *env, jdoubleArray array,
jdouble *elems, jint mode)
{
+ java_doublearray *da;
+
STATISTICS(jniinvokation());
- if (elems != array->data) {
+ da = (java_doublearray *) array;
+
+ if (elems != da->data) {
switch (mode) {
case JNI_COMMIT:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(da->data, elems, double, da->header.size);
break;
case 0:
- MCOPY(array->data, elems, jboolean, array->header.size);
+ MCOPY(da->data, elems, double, da->header.size);
/* XXX TWISTI how should it be freed? */
break;
case JNI_ABORT:
void GetBooleanArrayRegion(JNIEnv *env, jbooleanArray array, jsize start,
jsize len, jboolean *buf)
{
+ java_booleanarray *ba;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ ba = (java_booleanarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ba->header.size))
exceptions_throw_arrayindexoutofboundsexception();
else
- MCOPY(buf, &array->data[start], jboolean, len);
+ MCOPY(buf, &ba->data[start], u1, len);
}
void GetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start, jsize len,
jbyte *buf)
{
+ java_bytearray *ba;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ ba = (java_bytearray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ba->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(buf, &array->data[start], jbyte, len);
+ else
+ MCOPY(buf, &ba->data[start], s1, len);
}
void GetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start, jsize len,
jchar *buf)
{
+ java_chararray *ca;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ ca = (java_chararray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ca->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(buf, &array->data[start], jchar, len);
+ else
+ MCOPY(buf, &ca->data[start], u2, len);
}
void GetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
jsize len, jshort *buf)
{
+ java_shortarray *sa;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ sa = (java_shortarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > sa->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(buf, &array->data[start], jshort, len);
+ else
+ MCOPY(buf, &sa->data[start], s2, len);
}
void GetIntArrayRegion(JNIEnv *env, jintArray array, jsize start, jsize len,
jint *buf)
{
+ java_intarray *ia;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ ia = (java_intarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ia->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(buf, &array->data[start], jint, len);
+ else
+ MCOPY(buf, &ia->data[start], s4, len);
}
void GetLongArrayRegion(JNIEnv *env, jlongArray array, jsize start, jsize len,
jlong *buf)
{
+ java_longarray *la;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ la = (java_longarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > la->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(buf, &array->data[start], jlong, len);
+ else
+ MCOPY(buf, &la->data[start], s8, len);
}
void GetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
jsize len, jfloat *buf)
{
+ java_floatarray *fa;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ fa = (java_floatarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > fa->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(buf, &array->data[start], jfloat, len);
+ else
+ MCOPY(buf, &fa->data[start], float, len);
}
void GetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
jsize len, jdouble *buf)
{
+ java_doublearray *da;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start+len>array->header.size)
+ da = (java_doublearray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > da->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(buf, &array->data[start], jdouble, len);
+ else
+ MCOPY(buf, &da->data[start], double, len);
}
void SetBooleanArrayRegion(JNIEnv *env, jbooleanArray array, jsize start,
jsize len, jboolean *buf)
{
+ java_booleanarray *ba;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ ba = (java_booleanarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ba->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(&array->data[start], buf, jboolean, len);
+ else
+ MCOPY(&ba->data[start], buf, u1, len);
}
void SetByteArrayRegion(JNIEnv *env, jbyteArray array, jsize start, jsize len,
jbyte *buf)
{
+ java_bytearray *ba;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ ba = (java_bytearray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ba->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(&array->data[start], buf, jbyte, len);
+ else
+ MCOPY(&ba->data[start], buf, s1, len);
}
void SetCharArrayRegion(JNIEnv *env, jcharArray array, jsize start, jsize len,
jchar *buf)
{
+ java_chararray *ca;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ ca = (java_chararray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ca->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(&array->data[start], buf, jchar, len);
+ else
+ MCOPY(&ca->data[start], buf, u2, len);
}
void SetShortArrayRegion(JNIEnv *env, jshortArray array, jsize start,
jsize len, jshort *buf)
{
+ java_shortarray *sa;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ sa = (java_shortarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > sa->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(&array->data[start], buf, jshort, len);
+ else
+ MCOPY(&sa->data[start], buf, s2, len);
}
void SetIntArrayRegion(JNIEnv *env, jintArray array, jsize start, jsize len,
jint *buf)
{
+ java_intarray *ia;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ ia = (java_intarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > ia->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(&array->data[start], buf, jint, len);
+ else
+ MCOPY(&ia->data[start], buf, s4, len);
}
void SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len,
jlong *buf)
{
+ java_longarray *la;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ la = (java_longarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > la->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(&array->data[start], buf, jlong, len);
+ else
+ MCOPY(&la->data[start], buf, s8, len);
}
void SetFloatArrayRegion(JNIEnv *env, jfloatArray array, jsize start,
jsize len, jfloat *buf)
{
+ java_floatarray *fa;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ fa = (java_floatarray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > fa->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(&array->data[start], buf, jfloat, len);
+ else
+ MCOPY(&fa->data[start], buf, float, len);
}
void SetDoubleArrayRegion(JNIEnv *env, jdoubleArray array, jsize start,
jsize len, jdouble *buf)
{
+ java_doublearray *da;
+
STATISTICS(jniinvokation());
- if (start < 0 || len < 0 || start + len > array->header.size)
+ da = (java_doublearray *) array;
+
+ if ((start < 0) || (len < 0) || (start + len > da->header.size))
exceptions_throw_arrayindexoutofboundsexception();
- else
- MCOPY(&array->data[start], buf, jdouble, len);
+ else
+ MCOPY(&da->data[start], buf, double, len);
}
/* create a java.nio.DirectByteBufferImpl$ReadWrite object */
nbuf = (*env)->NewObject(env, class_java_nio_DirectByteBufferImpl_ReadWrite,
- dbbirw_init, NULL, paddress,
+ (jmethodID) dbbirw_init, NULL, paddress,
(jint) capacity, (jint) capacity, (jint) 0);
/* add local reference and return the value */
}
+/* DestroyJavaVM ***************************************************************
+
+ Unloads a Java VM and reclaims its resources. Only the main thread
+ can unload the VM. The system waits until the main thread is only
+ remaining user thread before it destroys the VM.
+
+*******************************************************************************/
+
jint DestroyJavaVM(JavaVM *vm)
{
+ s4 status;
+
STATISTICS(jniinvokation());
- log_text("JNI-Call: DestroyJavaVM: IMPLEMENT ME!");
+ status = vm_destroy(vm);
- return 0;
+ return status;
}
NULL,
NULL,
NULL,
- &GetVersion,
-
- &DefineClass,
- &FindClass,
- &FromReflectedMethod,
- &FromReflectedField,
- &ToReflectedMethod,
- &GetSuperclass,
- &IsAssignableFrom,
- &ToReflectedField,
-
- &Throw,
- &ThrowNew,
- &ExceptionOccurred,
- &ExceptionDescribe,
- &ExceptionClear,
- &FatalError,
- &PushLocalFrame,
- &PopLocalFrame,
-
- &NewGlobalRef,
- &DeleteGlobalRef,
- &DeleteLocalRef,
- &IsSameObject,
- &NewLocalRef,
- &EnsureLocalCapacity,
-
- &AllocObject,
- &NewObject,
- &NewObjectV,
- &NewObjectA,
-
- &GetObjectClass,
- &IsInstanceOf,
-
- &GetMethodID,
-
- &CallObjectMethod,
- &CallObjectMethodV,
- &CallObjectMethodA,
- &CallBooleanMethod,
- &CallBooleanMethodV,
- &CallBooleanMethodA,
- &CallByteMethod,
- &CallByteMethodV,
- &CallByteMethodA,
- &CallCharMethod,
- &CallCharMethodV,
- &CallCharMethodA,
- &CallShortMethod,
- &CallShortMethodV,
- &CallShortMethodA,
- &CallIntMethod,
- &CallIntMethodV,
- &CallIntMethodA,
- &CallLongMethod,
- &CallLongMethodV,
- &CallLongMethodA,
- &CallFloatMethod,
- &CallFloatMethodV,
- &CallFloatMethodA,
- &CallDoubleMethod,
- &CallDoubleMethodV,
- &CallDoubleMethodA,
- &CallVoidMethod,
- &CallVoidMethodV,
- &CallVoidMethodA,
-
- &CallNonvirtualObjectMethod,
- &CallNonvirtualObjectMethodV,
- &CallNonvirtualObjectMethodA,
- &CallNonvirtualBooleanMethod,
- &CallNonvirtualBooleanMethodV,
- &CallNonvirtualBooleanMethodA,
- &CallNonvirtualByteMethod,
- &CallNonvirtualByteMethodV,
- &CallNonvirtualByteMethodA,
- &CallNonvirtualCharMethod,
- &CallNonvirtualCharMethodV,
- &CallNonvirtualCharMethodA,
- &CallNonvirtualShortMethod,
- &CallNonvirtualShortMethodV,
- &CallNonvirtualShortMethodA,
- &CallNonvirtualIntMethod,
- &CallNonvirtualIntMethodV,
- &CallNonvirtualIntMethodA,
- &CallNonvirtualLongMethod,
- &CallNonvirtualLongMethodV,
- &CallNonvirtualLongMethodA,
- &CallNonvirtualFloatMethod,
- &CallNonvirtualFloatMethodV,
- &CallNonvirtualFloatMethodA,
- &CallNonvirtualDoubleMethod,
- &CallNonvirtualDoubleMethodV,
- &CallNonvirtualDoubleMethodA,
- &CallNonvirtualVoidMethod,
- &CallNonvirtualVoidMethodV,
- &CallNonvirtualVoidMethodA,
-
- &GetFieldID,
-
- &GetObjectField,
- &GetBooleanField,
- &GetByteField,
- &GetCharField,
- &GetShortField,
- &GetIntField,
- &GetLongField,
- &GetFloatField,
- &GetDoubleField,
- &SetObjectField,
- &SetBooleanField,
- &SetByteField,
- &SetCharField,
- &SetShortField,
- &SetIntField,
- &SetLongField,
- &SetFloatField,
- &SetDoubleField,
-
- &GetStaticMethodID,
-
- &CallStaticObjectMethod,
- &CallStaticObjectMethodV,
- &CallStaticObjectMethodA,
- &CallStaticBooleanMethod,
- &CallStaticBooleanMethodV,
- &CallStaticBooleanMethodA,
- &CallStaticByteMethod,
- &CallStaticByteMethodV,
- &CallStaticByteMethodA,
- &CallStaticCharMethod,
- &CallStaticCharMethodV,
- &CallStaticCharMethodA,
- &CallStaticShortMethod,
- &CallStaticShortMethodV,
- &CallStaticShortMethodA,
- &CallStaticIntMethod,
- &CallStaticIntMethodV,
- &CallStaticIntMethodA,
- &CallStaticLongMethod,
- &CallStaticLongMethodV,
- &CallStaticLongMethodA,
- &CallStaticFloatMethod,
- &CallStaticFloatMethodV,
- &CallStaticFloatMethodA,
- &CallStaticDoubleMethod,
- &CallStaticDoubleMethodV,
- &CallStaticDoubleMethodA,
- &CallStaticVoidMethod,
- &CallStaticVoidMethodV,
- &CallStaticVoidMethodA,
-
- &GetStaticFieldID,
-
- &GetStaticObjectField,
- &GetStaticBooleanField,
- &GetStaticByteField,
- &GetStaticCharField,
- &GetStaticShortField,
- &GetStaticIntField,
- &GetStaticLongField,
- &GetStaticFloatField,
- &GetStaticDoubleField,
- &SetStaticObjectField,
- &SetStaticBooleanField,
- &SetStaticByteField,
- &SetStaticCharField,
- &SetStaticShortField,
- &SetStaticIntField,
- &SetStaticLongField,
- &SetStaticFloatField,
- &SetStaticDoubleField,
-
- &NewString,
- &GetStringLength,
- &GetStringChars,
- &ReleaseStringChars,
-
- &NewStringUTF,
- &GetStringUTFLength,
- &GetStringUTFChars,
- &ReleaseStringUTFChars,
-
- &GetArrayLength,
-
- &NewObjectArray,
- &GetObjectArrayElement,
- &SetObjectArrayElement,
-
- &NewBooleanArray,
- &NewByteArray,
- &NewCharArray,
- &NewShortArray,
- &NewIntArray,
- &NewLongArray,
- &NewFloatArray,
- &NewDoubleArray,
-
- &GetBooleanArrayElements,
- &GetByteArrayElements,
- &GetCharArrayElements,
- &GetShortArrayElements,
- &GetIntArrayElements,
- &GetLongArrayElements,
- &GetFloatArrayElements,
- &GetDoubleArrayElements,
-
- &ReleaseBooleanArrayElements,
- &ReleaseByteArrayElements,
- &ReleaseCharArrayElements,
- &ReleaseShortArrayElements,
- &ReleaseIntArrayElements,
- &ReleaseLongArrayElements,
- &ReleaseFloatArrayElements,
- &ReleaseDoubleArrayElements,
-
- &GetBooleanArrayRegion,
- &GetByteArrayRegion,
- &GetCharArrayRegion,
- &GetShortArrayRegion,
- &GetIntArrayRegion,
- &GetLongArrayRegion,
- &GetFloatArrayRegion,
- &GetDoubleArrayRegion,
- &SetBooleanArrayRegion,
- &SetByteArrayRegion,
- &SetCharArrayRegion,
- &SetShortArrayRegion,
- &SetIntArrayRegion,
- &SetLongArrayRegion,
- &SetFloatArrayRegion,
- &SetDoubleArrayRegion,
-
- &RegisterNatives,
- &UnregisterNatives,
-
- &MonitorEnter,
- &MonitorExit,
-
- &GetJavaVM,
+ GetVersion,
+
+ DefineClass,
+ FindClass,
+ FromReflectedMethod,
+ FromReflectedField,
+ ToReflectedMethod,
+ GetSuperclass,
+ IsAssignableFrom,
+ ToReflectedField,
+
+ Throw,
+ ThrowNew,
+ ExceptionOccurred,
+ ExceptionDescribe,
+ ExceptionClear,
+ FatalError,
+ PushLocalFrame,
+ PopLocalFrame,
+
+ NewGlobalRef,
+ DeleteGlobalRef,
+ DeleteLocalRef,
+ IsSameObject,
+ NewLocalRef,
+ EnsureLocalCapacity,
+
+ AllocObject,
+ NewObject,
+ NewObjectV,
+ NewObjectA,
+
+ GetObjectClass,
+ IsInstanceOf,
+
+ GetMethodID,
+
+ CallObjectMethod,
+ CallObjectMethodV,
+ CallObjectMethodA,
+ CallBooleanMethod,
+ CallBooleanMethodV,
+ CallBooleanMethodA,
+ CallByteMethod,
+ CallByteMethodV,
+ CallByteMethodA,
+ CallCharMethod,
+ CallCharMethodV,
+ CallCharMethodA,
+ CallShortMethod,
+ CallShortMethodV,
+ CallShortMethodA,
+ CallIntMethod,
+ CallIntMethodV,
+ CallIntMethodA,
+ CallLongMethod,
+ CallLongMethodV,
+ CallLongMethodA,
+ CallFloatMethod,
+ CallFloatMethodV,
+ CallFloatMethodA,
+ CallDoubleMethod,
+ CallDoubleMethodV,
+ CallDoubleMethodA,
+ CallVoidMethod,
+ CallVoidMethodV,
+ CallVoidMethodA,
+
+ CallNonvirtualObjectMethod,
+ CallNonvirtualObjectMethodV,
+ CallNonvirtualObjectMethodA,
+ CallNonvirtualBooleanMethod,
+ CallNonvirtualBooleanMethodV,
+ CallNonvirtualBooleanMethodA,
+ CallNonvirtualByteMethod,
+ CallNonvirtualByteMethodV,
+ CallNonvirtualByteMethodA,
+ CallNonvirtualCharMethod,
+ CallNonvirtualCharMethodV,
+ CallNonvirtualCharMethodA,
+ CallNonvirtualShortMethod,
+ CallNonvirtualShortMethodV,
+ CallNonvirtualShortMethodA,
+ CallNonvirtualIntMethod,
+ CallNonvirtualIntMethodV,
+ CallNonvirtualIntMethodA,
+ CallNonvirtualLongMethod,
+ CallNonvirtualLongMethodV,
+ CallNonvirtualLongMethodA,
+ CallNonvirtualFloatMethod,
+ CallNonvirtualFloatMethodV,
+ CallNonvirtualFloatMethodA,
+ CallNonvirtualDoubleMethod,
+ CallNonvirtualDoubleMethodV,
+ CallNonvirtualDoubleMethodA,
+ CallNonvirtualVoidMethod,
+ CallNonvirtualVoidMethodV,
+ CallNonvirtualVoidMethodA,
+
+ GetFieldID,
+
+ GetObjectField,
+ GetBooleanField,
+ GetByteField,
+ GetCharField,
+ GetShortField,
+ GetIntField,
+ GetLongField,
+ GetFloatField,
+ GetDoubleField,
+ SetObjectField,
+ SetBooleanField,
+ SetByteField,
+ SetCharField,
+ SetShortField,
+ SetIntField,
+ SetLongField,
+ SetFloatField,
+ SetDoubleField,
+
+ GetStaticMethodID,
+
+ CallStaticObjectMethod,
+ CallStaticObjectMethodV,
+ CallStaticObjectMethodA,
+ CallStaticBooleanMethod,
+ CallStaticBooleanMethodV,
+ CallStaticBooleanMethodA,
+ CallStaticByteMethod,
+ CallStaticByteMethodV,
+ CallStaticByteMethodA,
+ CallStaticCharMethod,
+ CallStaticCharMethodV,
+ CallStaticCharMethodA,
+ CallStaticShortMethod,
+ CallStaticShortMethodV,
+ CallStaticShortMethodA,
+ CallStaticIntMethod,
+ CallStaticIntMethodV,
+ CallStaticIntMethodA,
+ CallStaticLongMethod,
+ CallStaticLongMethodV,
+ CallStaticLongMethodA,
+ CallStaticFloatMethod,
+ CallStaticFloatMethodV,
+ CallStaticFloatMethodA,
+ CallStaticDoubleMethod,
+ CallStaticDoubleMethodV,
+ CallStaticDoubleMethodA,
+ CallStaticVoidMethod,
+ CallStaticVoidMethodV,
+ CallStaticVoidMethodA,
+
+ GetStaticFieldID,
+
+ GetStaticObjectField,
+ GetStaticBooleanField,
+ GetStaticByteField,
+ GetStaticCharField,
+ GetStaticShortField,
+ GetStaticIntField,
+ GetStaticLongField,
+ GetStaticFloatField,
+ GetStaticDoubleField,
+ SetStaticObjectField,
+ SetStaticBooleanField,
+ SetStaticByteField,
+ SetStaticCharField,
+ SetStaticShortField,
+ SetStaticIntField,
+ SetStaticLongField,
+ SetStaticFloatField,
+ SetStaticDoubleField,
+
+ NewString,
+ GetStringLength,
+ GetStringChars,
+ ReleaseStringChars,
+
+ NewStringUTF,
+ GetStringUTFLength,
+ GetStringUTFChars,
+ ReleaseStringUTFChars,
+
+ GetArrayLength,
+
+ NewObjectArray,
+ GetObjectArrayElement,
+ SetObjectArrayElement,
+
+ NewBooleanArray,
+ NewByteArray,
+ NewCharArray,
+ NewShortArray,
+ NewIntArray,
+ NewLongArray,
+ NewFloatArray,
+ NewDoubleArray,
+
+ GetBooleanArrayElements,
+ GetByteArrayElements,
+ GetCharArrayElements,
+ GetShortArrayElements,
+ GetIntArrayElements,
+ GetLongArrayElements,
+ GetFloatArrayElements,
+ GetDoubleArrayElements,
+
+ ReleaseBooleanArrayElements,
+ ReleaseByteArrayElements,
+ ReleaseCharArrayElements,
+ ReleaseShortArrayElements,
+ ReleaseIntArrayElements,
+ ReleaseLongArrayElements,
+ ReleaseFloatArrayElements,
+ ReleaseDoubleArrayElements,
+
+ GetBooleanArrayRegion,
+ GetByteArrayRegion,
+ GetCharArrayRegion,
+ GetShortArrayRegion,
+ GetIntArrayRegion,
+ GetLongArrayRegion,
+ GetFloatArrayRegion,
+ GetDoubleArrayRegion,
+ SetBooleanArrayRegion,
+ SetByteArrayRegion,
+ SetCharArrayRegion,
+ SetShortArrayRegion,
+ SetIntArrayRegion,
+ SetLongArrayRegion,
+ SetFloatArrayRegion,
+ SetDoubleArrayRegion,
+
+ RegisterNatives,
+ UnregisterNatives,
+
+ MonitorEnter,
+ MonitorExit,
+
+ GetJavaVM,
/* new JNI 1.2 functions */
- &GetStringRegion,
- &GetStringUTFRegion,
+ GetStringRegion,
+ GetStringUTFRegion,
- &GetPrimitiveArrayCritical,
- &ReleasePrimitiveArrayCritical,
+ GetPrimitiveArrayCritical,
+ ReleasePrimitiveArrayCritical,
- &GetStringCritical,
- &ReleaseStringCritical,
+ GetStringCritical,
+ ReleaseStringCritical,
- &NewWeakGlobalRef,
- &DeleteWeakGlobalRef,
+ NewWeakGlobalRef,
+ DeleteWeakGlobalRef,
- &ExceptionCheck,
+ ExceptionCheck,
/* new JNI 1.4 functions */
- &NewDirectByteBuffer,
- &GetDirectBufferAddress,
- &GetDirectBufferCapacity
+ NewDirectByteBuffer,
+ GetDirectBufferAddress,
+ GetDirectBufferCapacity
};
jint JNI_GetDefaultJavaVMInitArgs(void *vm_args)
{
- JDK1_1InitArgs *_vm_args = (JDK1_1InitArgs *) vm_args;
+ JavaVMInitArgs *_vm_args;
+
+ _vm_args = (JavaVMInitArgs *) vm_args;
/* GNU classpath currently supports JNI 1.2 */
- _vm_args->version = JNI_VERSION_1_2;
+ switch (_vm_args->version) {
+ case JNI_VERSION_1_1:
+ _vm_args->version = JNI_VERSION_1_1;
+ break;
+
+ case JNI_VERSION_1_2:
+ case JNI_VERSION_1_4:
+ _vm_args->ignoreUnrecognized = JNI_FALSE;
+ _vm_args->options = NULL;
+ _vm_args->nOptions = 0;
+ break;
+ default:
+ return -1;
+ }
+
return 0;
}
*******************************************************************************/
-jint JNI_CreateJavaVM(JavaVM **p_vm, JNIEnv **p_env, void *vm_args)
+jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args)
{
- const struct JNIInvokeInterface *vm;
- struct JNINativeInterface *env;
+ JavaVMInitArgs *_vm_args;
+ _Jv_JNIEnv *env;
+ localref_table *lrt;
+
+ /* get the arguments for the new JVM */
+
+ _vm_args = (JavaVMInitArgs *) vm_args;
+
+ /* get the VM and Env tables (must be set before vm_create) */
+
+ env = NEW(_Jv_JNIEnv);
+
+ env->env = &JNI_JNIEnvTable;
+
+ *p_vm = (JavaVM *) &JNI_JavaVMTable;
+ *p_env = (void *) env;
+
+ /* XXX Set the global env variable. Maybe we should do that differently. */
+
+ _Jv_env = env;
+
+ /* actually create the JVM */
+
+ if (!vm_create(_vm_args))
+ return -1;
+
+ /* setup the local ref table (must be created after vm_create) */
+
+ lrt = GCNEW(localref_table);
+
+ lrt->capacity = LOCALREFTABLE_CAPACITY;
+ lrt->used = 0;
+ lrt->localframes = 1;
+ lrt->prev = LOCALREFTABLE;
+
+ /* clear the references array (memset is faster then a for-loop) */
- vm = &JNI_JavaVMTable;
- env = &JNI_JNIEnvTable;
+ MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY);
- *p_vm = (JavaVM *) vm;
- *p_env = (JNIEnv *) env;
+ LOCALREFTABLE = lrt;
return 0;
}
Changes: Christian Thalinger
- $Id: jni.h 4357 2006-01-22 23:33:38Z twisti $
+ $Id: jni.h 4530 2006-02-21 09:11:53Z twisti $
*/
#ifndef _JNI_H
#define _JNI_H
-#include <stdio.h>
-#include <stdarg.h>
-
+#include "config.h"
#include "vm/types.h"
-#include "vm/field.h"
#include "vm/global.h"
#include "vm/method.h"
-/* JNI versions */
-
-#define JNI_VERSION_1_1 0x00010001
-#define JNI_VERSION_1_2 0x00010002
-#define JNI_VERSION_1_4 0x00010004
-
-#define JNIEXPORT
-#define JNICALL
-
-
-/* JNI-Boolean */
-
-#define JNI_FALSE 0
-#define JNI_TRUE 1
-
-
-/* Error codes */
-
-#define JNI_OK 0
-#define JNI_ERR (-1)
-#define JNI_EDETACHED (-2) /* thread detached from the VM */
-#define JNI_EVERSION (-3) /* JNI version error */
-
-
-/* Release<PrimitiveType>ArrayElements modes */
-
-#define JNI_COMMIT 1
-#define JNI_ABORT 2
-
-
-/* JNI datatypes */
-
-#define jboolean u1
-#define jbyte s1
-#define jchar u2
-#define jshort s2
-#define jint s4
-#define jlong s8
-#define jfloat float
-#define jdouble double
-
-#define jobject java_objectheader*
-#define jclass struct classinfo*
-#define jthrowable jobject
-#define jweak jobject
-#define jarray java_arrayheader*
-#define jlongArray java_longarray*
-#define jbooleanArray java_booleanarray*
-#define jintArray java_intarray*
-#define jcharArray java_chararray*
-#define jbyteArray java_bytearray*
-#define jshortArray java_shortarray*
-#define jdoubleArray java_doublearray*
-#define jfloatArray java_floatarray*
-#define jobjectArray java_objectarray*
-#define jstring jobject
-
-#define jsize jint
-#define jfieldID fieldinfo*
-#define jmethodID methodinfo*
-
-
-typedef union jvalue {
- jboolean z;
- jbyte b;
- jchar c;
- jshort s;
- jint i;
- jlong j;
- jfloat f;
- jdouble d;
- jobject l;
-} jvalue;
-
-
-typedef struct JDK1_1InitArgs JDK1_1InitArgs;
-
-struct JDK1_1InitArgs {
- /* The first two fields were reserved in JDK 1.1, and
- formally introduced in JDK 1.1.2. */
- /* Java VM version */
- jint version;
-
- /* System properties. */
- char **properties;
-
- /* whether to check the Java source files are newer than
- * compiled class files. */
- jint checkSource;
-
- /* maximum native stack size of Java-created threads. */
- jint nativeStackSize;
-
- /* maximum Java stack size. */
- jint javaStackSize;
-
- /* initial heap size. */
- jint minHeapSize;
-
- /* maximum heap size. */
- jint maxHeapSize;
-
- /* controls whether Java byte code should be verified:
- * 0 -- none, 1 -- remotely loaded code, 2 -- all code. */
- jint verifyMode;
-
- /* the local directory path for class loading. */
- const char *classpath;
-
- /* a hook for a function that redirects all VM messages. */
- jint (*vfprintf)(FILE *fp, const char *format,
- va_list args);
-
- /* a VM exit hook. */
- void (*exit)(jint code);
-
- /* a VM abort hook. */
- void (*abort)();
-
- /* whether to enable class GC. */
- jint enableClassGC;
-
- /* whether GC messages will appear. */
- jint enableVerboseGC;
-
- /* whether asynchronous GC is allowed. */
- jint disableAsyncGC;
-
- /* Three reserved fields. */
- jint reserved0;
- jint reserved1;
- jint reserved2;
-};
-
-
-typedef struct JDK1_1AttachArgs {
- /*
- * JDK 1.1 does not need any arguments to attach a
- * native thread. The padding is here to satisfy the C
- * compiler which does not permit empty structures.
- */
- void *__padding;
-} JDK1_1AttachArgs;
-
-
-typedef struct JNIInvokeInterface *JavaVM;
-/* typedef struct _JavaVM *JavaVM; */
-
-/* struct _JavaVM { */
-struct JNIInvokeInterface {
- void *(*reserved0) ();
- void *(*reserved1) ();
- void *(*reserved2) ();
- jint (*DestroyJavaVM) (JavaVM *);
- jint (*AttachCurrentThread) (JavaVM *, void **, void *);
- jint (*DetachCurrentThread) (JavaVM *);
- jint (*GetEnv) (JavaVM *, void **, jint);
- jint (*AttachCurrentThreadAsDaemon) (JavaVM *, void **, void *);
-};
-
-
-/* native method name, signature and function pointer for use in RegisterNatives */
-
-typedef struct {
- char *name;
- char *signature;
- void *fnPtr;
-} JNINativeMethod;
-
-
-/*
- JNI function table, contains functions for the following usages:
-
- Version Information
- Class Operations
- Exceptions
- Global and Local References
- Object Operations
- Accessing Fields of Objects
- Calling Instance Methods
- Accessing Static Fields
- Calling Static Methods
- String Operations
- Array Operations
- Registering Native Methods
- Monitor Operations
- Java VM Interface
-*/
-
-typedef struct JNINativeInterface *JNIEnv;
-/* typedef struct JNI_Table *JNIEnv; */
-
-/* struct JNI_Table { */
-struct JNINativeInterface {
- /* reserverd for future JNI-functions */
- void *unused0;
- void *unused1;
- void *unused2;
- void *unused3;
-
- /* version information */
-
- jint (*GetVersion) (JNIEnv*);
-
- /* class operations */
-
- jclass (*DefineClass) (JNIEnv*, const char *name, jobject loader, const jbyte *buf, jsize len);
- jclass (*FindClass) (JNIEnv*, const char *name);
-
- jmethodID (*FromReflectedMethod) (JNIEnv*, jobject method);
- jfieldID (*FromReflectedField) (JNIEnv*, jobject field);
-
- jobject (*ToReflectedMethod) (JNIEnv*, jclass cls, jmethodID methodID, jboolean isStatic);
-
- jclass (*GetSuperclass) (JNIEnv*, jclass sub);
- jboolean (*IsAssignableFrom) (JNIEnv*, jclass sub, jclass sup);
-
- jobject (*ToReflectedField) (JNIEnv*, jclass cls, jfieldID fieldID, jboolean isStatic);
-
- /* exceptions */
-
- jint (*Throw) (JNIEnv*, jthrowable obj);
- jint (*ThrowNew) (JNIEnv*, jclass clazz, const char *msg);
- jthrowable (*ExceptionOccurred) (JNIEnv*);
- void (*ExceptionDescribe) (JNIEnv*);
- void (*ExceptionClear) (JNIEnv*);
- void (*FatalError) (JNIEnv*, const char *msg);
-
- /* global and local references */
-
- jint (*PushLocalFrame) (JNIEnv*, jint capacity);
- jobject (*PopLocalFrame) (JNIEnv*, jobject result);
-
- jobject (*NewGlobalRef) (JNIEnv*, jobject lobj);
- void (*DeleteGlobalRef) (JNIEnv*, jobject gref);
- void (*DeleteLocalRef) (JNIEnv*, jobject obj);
- jboolean (*IsSameObject) (JNIEnv*, jobject obj1, jobject obj2);
- jobject (*NewLocalRef) (JNIEnv*, jobject ref);
- jint (*EnsureLocalCapacity) (JNIEnv*, jint capacity);
-
- /* object operations */
-
- jobject (*AllocObject) (JNIEnv*, jclass clazz);
- jobject (*NewObject) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jobject (*NewObjectV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jobject (*NewObjectA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
+/* include the JNI header from GNU Classpath */
- jclass (*GetObjectClass) (JNIEnv*, jobject obj);
- jboolean (*IsInstanceOf) (JNIEnv*, jobject obj, jclass clazz);
+#include CLASSPATH_JNI_H
- jmethodID (*GetMethodID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
- /* calling instance methods */
+/* _Jv_JNIEnv *****************************************************************/
- jobject (*CallObjectMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jobject (*CallObjectMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jobject (*CallObjectMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
+typedef struct _Jv_JNIEnv _Jv_JNIEnv;
- jboolean (*CallBooleanMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jboolean (*CallBooleanMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jboolean (*CallBooleanMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
-
- jbyte (*CallByteMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jbyte (*CallByteMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jbyte (*CallByteMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
-
- jchar (*CallCharMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jchar (*CallCharMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jchar (*CallCharMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
-
- jshort (*CallShortMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jshort (*CallShortMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jshort (*CallShortMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
-
- jint (*CallIntMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jint (*CallIntMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jint (*CallIntMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
-
- jlong (*CallLongMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jlong (*CallLongMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jlong (*CallLongMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
-
- jfloat (*CallFloatMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jfloat (*CallFloatMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jfloat (*CallFloatMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
-
- jdouble (*CallDoubleMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- jdouble (*CallDoubleMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- jdouble (*CallDoubleMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue *args);
-
- void (*CallVoidMethod) (JNIEnv*, jobject obj, jmethodID methodID, ...);
- void (*CallVoidMethodV) (JNIEnv*, jobject obj, jmethodID methodID, va_list args);
- void (*CallVoidMethodA) (JNIEnv*, jobject obj, jmethodID methodID, jvalue * args);
-
- jobject (*CallNonvirtualObjectMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jobject (*CallNonvirtualObjectMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jobject (*CallNonvirtualObjectMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
-
- jboolean (*CallNonvirtualBooleanMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jboolean (*CallNonvirtualBooleanMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jboolean (*CallNonvirtualBooleanMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
-
- jbyte (*CallNonvirtualByteMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jbyte (*CallNonvirtualByteMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jbyte (*CallNonvirtualByteMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
-
- jchar (*CallNonvirtualCharMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jchar (*CallNonvirtualCharMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jchar (*CallNonvirtualCharMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
-
- jshort (*CallNonvirtualShortMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jshort (*CallNonvirtualShortMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jshort (*CallNonvirtualShortMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
-
- jint (*CallNonvirtualIntMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jint (*CallNonvirtualIntMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jint (*CallNonvirtualIntMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
-
- jlong (*CallNonvirtualLongMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jlong (*CallNonvirtualLongMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jlong (*CallNonvirtualLongMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
-
- jfloat (*CallNonvirtualFloatMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jfloat (*CallNonvirtualFloatMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jfloat (*CallNonvirtualFloatMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
-
- jdouble (*CallNonvirtualDoubleMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- jdouble (*CallNonvirtualDoubleMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- jdouble (*CallNonvirtualDoubleMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
-
- void (*CallNonvirtualVoidMethod) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, ...);
- void (*CallNonvirtualVoidMethodV) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, va_list args);
- void (*CallNonvirtualVoidMethodA) (JNIEnv*, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
-
- /* accessing fields */
-
- jfieldID (*GetFieldID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
-
- jobject (*GetObjectField) (JNIEnv*, jobject obj, jfieldID fieldID);
- jboolean (*GetBooleanField) (JNIEnv*, jobject obj, jfieldID fieldID);
- jbyte (*GetByteField) (JNIEnv*, jobject obj, jfieldID fieldID);
- jchar (*GetCharField) (JNIEnv*, jobject obj, jfieldID fieldID);
- jshort (*GetShortField) (JNIEnv*, jobject obj, jfieldID fieldID);
- jint (*GetIntField) (JNIEnv*, jobject obj, jfieldID fieldID);
- jlong (*GetLongField) (JNIEnv*, jobject obj, jfieldID fieldID);
- jfloat (*GetFloatField) (JNIEnv*, jobject obj, jfieldID fieldID);
- jdouble (*GetDoubleField) (JNIEnv*, jobject obj, jfieldID fieldID);
-
- void (*SetObjectField) (JNIEnv*, jobject obj, jfieldID fieldID, jobject val);
- void (*SetBooleanField) (JNIEnv*, jobject obj, jfieldID fieldID, jboolean val);
- void (*SetByteField) (JNIEnv*, jobject obj, jfieldID fieldID, jbyte val);
- void (*SetCharField) (JNIEnv*, jobject obj, jfieldID fieldID, jchar val);
- void (*SetShortField) (JNIEnv*, jobject obj, jfieldID fieldID, jshort val);
- void (*SetIntField) (JNIEnv*, jobject obj, jfieldID fieldID, jint val);
- void (*SetLongField) (JNIEnv*, jobject obj, jfieldID fieldID, jlong val);
- void (*SetFloatField) (JNIEnv*, jobject obj, jfieldID fieldID, jfloat val);
- void (*SetDoubleField) (JNIEnv*, jobject obj, jfieldID fieldID, jdouble val);
-
- /* calling static methods */
-
- jmethodID (*GetStaticMethodID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
-
- jobject (*CallStaticObjectMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jobject (*CallStaticObjectMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jobject (*CallStaticObjectMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- jboolean (*CallStaticBooleanMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jboolean (*CallStaticBooleanMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jboolean (*CallStaticBooleanMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- jbyte (*CallStaticByteMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jbyte (*CallStaticByteMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jbyte (*CallStaticByteMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- jchar (*CallStaticCharMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jchar (*CallStaticCharMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jchar (*CallStaticCharMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- jshort (*CallStaticShortMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jshort (*CallStaticShortMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jshort (*CallStaticShortMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- jint (*CallStaticIntMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jint (*CallStaticIntMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jint (*CallStaticIntMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- jlong (*CallStaticLongMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jlong (*CallStaticLongMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jlong (*CallStaticLongMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- jfloat (*CallStaticFloatMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jfloat (*CallStaticFloatMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jfloat (*CallStaticFloatMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- jdouble (*CallStaticDoubleMethod) (JNIEnv*, jclass clazz, jmethodID methodID, ...);
- jdouble (*CallStaticDoubleMethodV) (JNIEnv*, jclass clazz, jmethodID methodID, va_list args);
- jdouble (*CallStaticDoubleMethodA) (JNIEnv*, jclass clazz, jmethodID methodID, jvalue *args);
-
- void (*CallStaticVoidMethod) (JNIEnv*, jclass cls, jmethodID methodID, ...);
- void (*CallStaticVoidMethodV) (JNIEnv*, jclass cls, jmethodID methodID, va_list args);
- void (*CallStaticVoidMethodA) (JNIEnv*, jclass cls, jmethodID methodID, jvalue * args);
-
- /* accessing static fields */
-
- jfieldID (*GetStaticFieldID) (JNIEnv*, jclass clazz, const char *name, const char *sig);
- jobject (*GetStaticObjectField) (JNIEnv*, jclass clazz, jfieldID fieldID);
- jboolean (*GetStaticBooleanField) (JNIEnv*, jclass clazz, jfieldID fieldID);
- jbyte (*GetStaticByteField) (JNIEnv*, jclass clazz, jfieldID fieldID);
- jchar (*GetStaticCharField) (JNIEnv*, jclass clazz, jfieldID fieldID);
- jshort (*GetStaticShortField) (JNIEnv*, jclass clazz, jfieldID fieldID);
- jint (*GetStaticIntField) (JNIEnv*, jclass clazz, jfieldID fieldID);
- jlong (*GetStaticLongField) (JNIEnv*, jclass clazz, jfieldID fieldID);
- jfloat (*GetStaticFloatField) (JNIEnv*, jclass clazz, jfieldID fieldID);
- jdouble (*GetStaticDoubleField) (JNIEnv*, jclass clazz, jfieldID fieldID);
-
- void (*SetStaticObjectField) (JNIEnv*, jclass clazz, jfieldID fieldID, jobject value);
- void (*SetStaticBooleanField) (JNIEnv*, jclass clazz, jfieldID fieldID, jboolean value);
- void (*SetStaticByteField) (JNIEnv*, jclass clazz, jfieldID fieldID, jbyte value);
- void (*SetStaticCharField) (JNIEnv*, jclass clazz, jfieldID fieldID, jchar value);
- void (*SetStaticShortField) (JNIEnv*, jclass clazz, jfieldID fieldID, jshort value);
- void (*SetStaticIntField) (JNIEnv*, jclass clazz, jfieldID fieldID, jint value);
- void (*SetStaticLongField) (JNIEnv*, jclass clazz, jfieldID fieldID, jlong value);
- void (*SetStaticFloatField) (JNIEnv*, jclass clazz, jfieldID fieldID, jfloat value);
- void (*SetStaticDoubleField) (JNIEnv*, jclass clazz, jfieldID fieldID, jdouble value);
-
- /* string operations */
-
- jstring (*NewString) (JNIEnv*, const jchar *unicode, jsize len);
- jsize (*GetStringLength) (JNIEnv*, jstring str);
- const jchar *(*GetStringChars) (JNIEnv*, jstring str, jboolean *isCopy);
- void (*ReleaseStringChars) (JNIEnv*, jstring str, const jchar *chars);
-
- jstring (*NewStringUTF) (JNIEnv*, const char *bytes);
- jsize (*GetStringUTFLength) (JNIEnv*, jstring str);
- const char* (*GetStringUTFChars) (JNIEnv*, jstring str, jboolean *isCopy);
- void (*ReleaseStringUTFChars) (JNIEnv*, jstring str, const char* chars);
-
- /* array operations */
-
- jsize (*GetArrayLength) (JNIEnv*, jarray array);
-
- jobjectArray (*NewObjectArray) (JNIEnv*, jsize len, jclass clazz, jobject init);
- jobject (*GetObjectArrayElement) (JNIEnv*, jobjectArray array, jsize index);
- void (*SetObjectArrayElement) (JNIEnv*, jobjectArray array, jsize index, jobject val);
-
- jbooleanArray (*NewBooleanArray) (JNIEnv*, jsize len);
- jbyteArray (*NewByteArray) (JNIEnv*, jsize len);
- jcharArray (*NewCharArray) (JNIEnv*, jsize len);
- jshortArray (*NewShortArray) (JNIEnv*, jsize len);
- jintArray (*NewIntArray) (JNIEnv*, jsize len);
- jlongArray (*NewLongArray) (JNIEnv*, jsize len);
- jfloatArray (*NewFloatArray) (JNIEnv*, jsize len);
- jdoubleArray (*NewDoubleArray) (JNIEnv*, jsize len);
-
- jboolean * (*GetBooleanArrayElements) (JNIEnv*, jbooleanArray array, jboolean *isCopy);
- jbyte * (*GetByteArrayElements) (JNIEnv*, jbyteArray array, jboolean *isCopy);
- jchar * (*GetCharArrayElements) (JNIEnv*, jcharArray array, jboolean *isCopy);
- jshort * (*GetShortArrayElements) (JNIEnv*, jshortArray array, jboolean *isCopy);
- jint * (*GetIntArrayElements) (JNIEnv*, jintArray array, jboolean *isCopy);
- jlong * (*GetLongArrayElements) (JNIEnv*, jlongArray array, jboolean *isCopy);
- jfloat * (*GetFloatArrayElements) (JNIEnv*, jfloatArray array, jboolean *isCopy);
- jdouble * (*GetDoubleArrayElements) (JNIEnv*, jdoubleArray array, jboolean *isCopy);
-
- void (*ReleaseBooleanArrayElements) (JNIEnv*, jbooleanArray array, jboolean *elems, jint mode);
- void (*ReleaseByteArrayElements) (JNIEnv*, jbyteArray array, jbyte *elems, jint mode);
- void (*ReleaseCharArrayElements) (JNIEnv*, jcharArray array, jchar *elems, jint mode);
- void (*ReleaseShortArrayElements) (JNIEnv*, jshortArray array, jshort *elems, jint mode);
- void (*ReleaseIntArrayElements) (JNIEnv*, jintArray array, jint *elems, jint mode);
- void (*ReleaseLongArrayElements) (JNIEnv*, jlongArray array, jlong *elems, jint mode);
- void (*ReleaseFloatArrayElements) (JNIEnv*, jfloatArray array, jfloat *elems, jint mode);
- void (*ReleaseDoubleArrayElements) (JNIEnv*, jdoubleArray array, jdouble *elems, jint mode);
-
- void (*GetBooleanArrayRegion) (JNIEnv*, jbooleanArray array, jsize start, jsize l, jboolean *buf);
- void (*GetByteArrayRegion) (JNIEnv*, jbyteArray array, jsize start, jsize len, jbyte *buf);
- void (*GetCharArrayRegion) (JNIEnv*, jcharArray array, jsize start, jsize len, jchar *buf);
- void (*GetShortArrayRegion) (JNIEnv*, jshortArray array, jsize start, jsize len, jshort *buf);
- void (*GetIntArrayRegion) (JNIEnv*, jintArray array, jsize start, jsize len, jint *buf);
- void (*GetLongArrayRegion) (JNIEnv*, jlongArray array, jsize start, jsize len, jlong *buf);
- void (*GetFloatArrayRegion) (JNIEnv*, jfloatArray array, jsize start, jsize len, jfloat *buf);
- void (*GetDoubleArrayRegion) (JNIEnv*, jdoubleArray array, jsize start, jsize len, jdouble *buf);
-
- void (*SetBooleanArrayRegion) (JNIEnv*, jbooleanArray array, jsize start, jsize l, jboolean *buf);
- void (*SetByteArrayRegion) (JNIEnv*, jbyteArray array, jsize start, jsize len, jbyte *buf);
- void (*SetCharArrayRegion) (JNIEnv*, jcharArray array, jsize start, jsize len, jchar *buf);
- void (*SetShortArrayRegion) (JNIEnv*, jshortArray array, jsize start, jsize len, jshort *buf);
- void (*SetIntArrayRegion) (JNIEnv*, jintArray array, jsize start, jsize len, jint *buf);
- void (*SetLongArrayRegion) (JNIEnv*, jlongArray array, jsize start, jsize len, jlong *buf);
- void (*SetFloatArrayRegion) (JNIEnv*, jfloatArray array, jsize start, jsize len, jfloat *buf);
- void (*SetDoubleArrayRegion) (JNIEnv*, jdoubleArray array, jsize start, jsize len, jdouble *buf);
-
- /* registering native methods */
-
- jint (*RegisterNatives) (JNIEnv*, jclass clazz, const JNINativeMethod *methods, jint nMethods);
- jint (*UnregisterNatives) (JNIEnv*, jclass clazz);
-
- /* monitor operations */
-
- jint (*MonitorEnter) (JNIEnv*, jobject obj);
- jint (*MonitorExit) (JNIEnv*, jobject obj);
-
- /* JavaVM interface */
-
- jint (*GetJavaVM) (JNIEnv*, JavaVM **vm);
-
- /* new JNI 1.2 functions */
-
- void (*GetStringRegion) (JNIEnv*, jstring str, jsize start, jsize len, jchar *buf);
- void (*GetStringUTFRegion) (JNIEnv*, jstring str, jsize start, jsize len, char *buf);
-
- void * (*GetPrimitiveArrayCritical) (JNIEnv*, jarray array, jboolean *isCopy);
- void (*ReleasePrimitiveArrayCritical) (JNIEnv*, jarray array, void *carray, jint mode);
-
- const jchar * (*GetStringCritical) (JNIEnv*, jstring string, jboolean *isCopy);
- void (*ReleaseStringCritical) (JNIEnv*, jstring string, const jchar *cstring);
-
- jweak (*NewWeakGlobalRef) (JNIEnv*, jobject obj);
- void (*DeleteWeakGlobalRef) (JNIEnv*, jweak ref);
-
- jboolean (*ExceptionCheck) (JNIEnv*);
-
- /* new JNI 1.4 functions */
-
- jobject (*NewDirectByteBuffer) (JNIEnv *env, void* address, jlong capacity);
- void* (*GetDirectBufferAddress) (JNIEnv *env, jobject buf);
- jlong (*GetDirectBufferCapacity) (JNIEnv *env, jobject buf);
+struct _Jv_JNIEnv {
+ const struct JNINativeInterface *env; /* This must be first for JNI */
};
-/* function prototypes ********************************************************/
-
-jint JNI_GetDefaultJavaVMInitArgs(void *vm_args);
-jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs);
-jint JNI_CreateJavaVM(JavaVM **p_vm, JNIEnv **p_env, void *vm_args);
-
-jfieldID getFieldID_critical(JNIEnv *env, jclass clazz, char *name, char *sig);
-
-jobject GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID);
-jboolean GetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID);
-jbyte GetByteField(JNIEnv *env, jobject obj, jfieldID fieldID);
-jchar GetCharField(JNIEnv *env, jobject obj, jfieldID fieldID);
-jshort GetShortField(JNIEnv *env, jobject obj, jfieldID fieldID);
-jint GetIntField(JNIEnv *env, jobject obj, jfieldID fieldID);
-jlong GetLongField(JNIEnv *env, jobject obj, jfieldID fieldID);
-jfloat GetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID);
-jdouble GetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID);
-
-void SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, jobject val);
-void SetBooleanField(JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val);
-void SetByteField(JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val);
-void SetCharField(JNIEnv *env, jobject obj, jfieldID fieldID, jchar val);
-void SetShortField(JNIEnv *env, jobject obj, jfieldID fieldID, jshort val);
-void SetIntField(JNIEnv *env, jobject obj, jfieldID fieldID, jint val);
-void SetLongField(JNIEnv *env, jobject obj, jfieldID fieldID, jlong val);
-void SetFloatField(JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val);
-void SetDoubleField(JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val);
+/* CACAO related stuff ********************************************************/
+extern const struct JNIInvokeInterface JNI_JavaVMTable;
+extern struct JNINativeInterface JNI_JNIEnvTable;
-/* CACAO related stuff ********************************************************/
/* local reference table ******************************************************/
#endif
-#define setField(obj,typ,var,val) *((typ*) ((long int) obj + (long int) var->offset))=val;
-#define getField(obj,typ,var) *((typ*) ((long int) obj + (long int) var->offset))
-#define setfield_critical(clazz,obj,name,sig,jdatatype,val) setField(obj,jdatatype,getFieldID_critical(env,clazz,name,sig),val);
-
/* initialize JNI subsystem */
bool jni_init(void);
-jobject *_Jv_jni_invokeNative(methodinfo *m, jobject obj,
- java_objectarray *params);
+java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
+ java_objectarray *params);
extern void* ptr_env;
extern struct JNINativeInterface JNI_JNIEnvTable;
Changes: Christian Thalinger
- $Id: native.c 4432 2006-02-04 19:09:16Z twisti $
+ $Id: native.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include <assert.h>
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
# include <ltdl.h>
#endif
#include "vm/types.h"
-#include "cacao/cacao.h"
#include "mm/memory.h"
#include "native/jni.h"
#include "native/native.h"
#include "native/include/java_lang_reflect_VMProxy.h"
#include "native/include/java_security_VMAccessController.h"
-#if defined(ENABLE_STATICVM)
+#if defined(WITH_STATIC_CLASSPATH)
/* these are required to prevent compiler warnings */
#include "native/nativetable.inc"
-#else /* defined(ENABLE_STATICVM) */
+#else /* defined(WITH_STATIC_CLASSPATH) */
/* Ensure that symbols for functions implemented within CACAO are used
and exported to dlopen. */
(functionptr) Java_java_security_VMAccessController_getStack,
};
-#endif /* defined(ENABLE_STATICVM) */
+#endif /* defined(WITH_STATIC_CLASSPATH) */
/* tables for methods *********************************************************/
-#ifdef ENABLE_STATICVM
+#ifdef WITH_STATIC_CLASSPATH
#define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
/* table for fast string comparison */
/* global variables ***********************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
static hashtable hashtable_library;
static lt_dlhandle mainhandle;
#endif
bool native_init(void)
{
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
void *p;
/* We need to access the dummy native table, not only to remove a warning */
/* initialize library hashtable, 10 entries should be enough */
hashtable_create(&hashtable_library, 10);
-
#endif
/* everything's ok */
*******************************************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
void native_hashtable_library_add(utf *filename, java_objectheader *loader,
lt_dlhandle handle)
{
ne->hashlink = le->namelink;
le->namelink = ne;
}
-#endif /* !defined(ENABLE_STATICVM) */
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
/* native_hashtable_library_find ***********************************************
*******************************************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
java_objectheader *loader)
{
return ne;
}
-#endif /* !defined(ENABLE_STATICVM) */
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
/* native_findfunction *********************************************************
*******************************************************************************/
-#if defined(ENABLE_STATICVM)
+#if defined(WITH_STATIC_CLASSPATH)
functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
bool isstatic)
{
return NULL;
}
-#endif /* defined(ENABLE_STATICVM) */
+#endif /* defined(WITH_STATIC_CLASSPATH) */
/* native_make_overloaded_function *********************************************
*******************************************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
static char *native_make_overloaded_function(char *name, utf *desc)
{
char *newname;
/* iterate through loaders in this hash slot */
- while (le && !sym) {
+ while ((le != NULL) && (sym == NULL)) {
/* iterate through names in this loader */
ne = le->namelink;
- while (ne && !sym) {
+ while ((ne != NULL) && (sym == NULL)) {
sym = lt_dlsym(ne->handle, name);
- if (!sym)
+ if (sym == NULL)
sym = lt_dlsym(ne->handle, newname);
ne = ne->hashlink;
le = le->hashlink;
}
- if (sym)
+ if (sym != NULL)
if (opt_verbosejni)
printf("JNI ]\n");
/* If not found, try to find the native function symbol in the
main program. */
- if (!sym) {
+ if (sym == NULL) {
sym = lt_dlsym(mainhandle, name);
- if (!sym)
+ if (sym == NULL)
sym = lt_dlsym(mainhandle, newname);
- if (sym)
+ if (sym != NULL)
if (opt_verbosejni)
printf("internal ]\n");
}
/* no symbol found? throw exception */
- if (!sym) {
+ if (sym == NULL) {
if (opt_verbosejni)
printf("failed ]\n");
return (functionptr) (ptrint) sym;
}
-#endif /* !defined(ENABLE_STATICVM) */
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
/* native_new_and_init *********************************************************
Changes: Christian Thalinger
- $Id: native.h 4357 2006-01-22 23:33:38Z twisti $
+ $Id: native.h 4530 2006-02-21 09:11:53Z twisti $
*/
#include "config.h"
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
# include <ltdl.h>
#endif
typedef struct nativecompref nativecompref;
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
typedef struct hashtable_library_name_entry hashtable_library_name_entry;
/* initialize native subsystem */
bool native_init(void);
-#if defined(ENABLE_STATICVM)
+#if defined(WITH_STATIC_CLASSPATH)
/* find native function */
functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
bool isstatic);
-#else /* defined(ENABLE_STATICVM) */
+#else /* defined(WITH_STATIC_CLASSPATH) */
/* add a library to the library hash */
void native_hashtable_library_add(utf *filename, java_objectheader *loader,
/* resolve native function */
functionptr native_resolve_function(methodinfo *m);
-#endif /* defined(ENABLE_STATICVM) */
+#endif /* defined(WITH_STATIC_CLASSPATH) */
/* create new object on the heap and call the initializer */
java_objectheader *native_new_and_init(classinfo *c);
Changes: Joseph Wenninger
Christian Thalinger
- $Id: VMRuntime.c 4418 2006-02-03 22:53:45Z twisti $
+ $Id: VMRuntime.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include <stdlib.h>
#include <sys/utsname.h>
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
# include <ltdl.h>
#endif
#include "vm/types.h"
-#include "cacao/cacao.h"
#include "mm/boehm.h"
#include "mm/memory.h"
#include "native/jni.h"
#include "vm/exceptions.h"
#include "vm/loader.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
/* this should work on BSD */
static bool finalizeOnExit = false;
-/*
- * Class: java/lang/VMRuntime
- * Method: execInternal
- * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/io/File;)Ljava/lang/Process;
- */
-JNIEXPORT java_lang_Process* JNICALL Java_java_lang_VMRuntime_execInternal(JNIEnv *env, jclass clazz, java_objectarray *cmd, java_objectarray *shellenv, java_io_File *workingdir)
-{
- log_text("Java_java_lang_Runtime_execInternal called");
-
- return NULL;
-}
-
-
/*
* Class: java/lang/VMRuntime
* Method: exitInternal
if (finalizeOnExit)
gc_finalize_all();
- cacao_shutdown(par1);
+ vm_shutdown(par1);
}
}
+/*
+ * Class: java/lang/VMRuntime
+ * Method: totalMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
+{
+ return gc_get_heap_size();
+}
+
+
+/*
+ * Class: java_lang_VMRuntime
+ * Method: maxMemory
+ * Signature: ()J
+ */
+JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz)
+{
+ return gc_get_max_heap_size();
+}
+
+
/*
* Class: java/lang/VMRuntime
* Method: gc
}
-/*
- * Class: java/lang/VMRuntime
- * Method: totalMemory
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz)
-{
- return gc_get_heap_size();
-}
-
-
/*
* Class: java/lang/VMRuntime
* Method: traceInstructions
*/
JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *filename, java_lang_ClassLoader *loader)
{
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
utf *name;
lt_dlhandle handle;
lt_ptr onload;
s4 version;
#endif
- if (!filename) {
+ if (filename == NULL) {
exceptions_throw_nullpointerexception();
return 0;
}
-#if defined(ENABLE_STATICVM)
+#if defined(WITH_STATIC_CLASSPATH)
return 1;
-#else
+#else /* defined(WITH_STATIC_CLASSPATH) */
name = javastring_toutf(filename, 0);
/* is the library already loaded? */
/* if the version is not 1.2 and not 1.4 the library cannot be loaded */
- if (version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4) {
+ if ((version != JNI_VERSION_1_2) && (version != JNI_VERSION_1_4)) {
lt_dlclose(handle);
return 0;
native_hashtable_library_add(name, (java_objectheader *) loader, handle);
return 1;
-#endif
+#endif /* defined(WITH_STATIC_CLASSPATH) */
}
dumpsize = dump_size();
buffer = DMNEW(char, buffer_len);
- /* generate library name, we use lt_dlopenext so we don't need an */
- /* extension */
+ /* generate library name */
strcpy(buffer, "lib");
utf_strcat(buffer, u);
}
-/*
- * Class: java_lang_VMRuntime
- * Method: maxMemory
- * Signature: ()J
- */
-JNIEXPORT s8 JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz)
-{
- return gc_get_max_heap_size();
-}
-
-
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Changes:
- $Id: VMSystemProperties.c 4374 2006-01-27 16:32:58Z twisti $
+ $Id: VMSystemProperties.c 4530 2006-02-21 09:11:53Z twisti $
*/
char *country;
struct utsname utsnamebuf;
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
char *ld_library_path;
char *libpath;
s4 libpathlen;
#endif
- if (!p) {
+ if (p == NULL) {
exceptions_throw_nullpointerexception();
return;
}
properties_system_add("java.boot.class.path", bootclasspath);
properties_system_add("sun.boot.class.path", bootclasspath);
-#if defined(ENABLE_STATICVM)
+#if defined(WITH_STATIC_CLASSPATH)
properties_system_add("gnu.classpath.boot.library.path", ".");
properties_system_add("java.library.path" , ".");
-#else /* defined(ENABLE_STATICVM) */
+#else /* defined(WITH_STATIC_CLASSPATH) */
/* fill gnu.classpath.boot.library.path with GNU Classpath library
path */
} else {
properties_system_add("java.library.path", "");
}
-#endif /* defined(ENABLE_STATICVM) */
+#endif /* defined(WITH_STATIC_CLASSPATH) */
properties_system_add("java.io.tmpdir", "/tmp");
/* Are we little or big endian? */
-#if defined(ENABLE_STATICVM)
+#if defined(WITH_STATIC_CLASSPATH)
/* This is just for debugging purposes and can cause troubles in
GNU Classpath. */
Changes: Christian Thalinger
Edwin Steiner
- $Id: threads.c 4496 2006-02-12 22:08:13Z edwin $
+ $Id: threads.c 4530 2006-02-21 09:11:53Z twisti $
*/
+#include "config.h"
+
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>
#include <semaphore.h>
-#include "config.h"
#include "vm/types.h"
#include "arch.h"
#include "threads/native/generic-primitives.h"
#endif
-#include "cacao/cacao.h"
#include "mm/boehm.h"
#include "mm/memory.h"
#include "native/native.h"
##
## Changes:
##
-## $Id: Makefile.am 4357 2006-01-22 23:33:38Z twisti $
+## $Id: Makefile.am 4530 2006-02-21 09:11:53Z twisti $
## Process this file with automake to produce Makefile.in
libvm_la_SOURCES = \
exceptions.c \
- exceptions.h
+ exceptions.h \
+ vm.c \
+ vm.h
libvm_la_LIBADD = \
libvmcore.la \
Christian Ullrich
Edwin Steiner
- $Id: codegen.c 4498 2006-02-12 23:43:09Z twisti $
+ $Id: codegen.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include "vm/jit/alpha/arch.h"
#include "vm/jit/alpha/codegen.h"
-#include "cacao/cacao.h"
#include "native/jni.h"
#include "native/native.h"
#include "vm/builtin.h"
#include "vm/loader.h"
#include "vm/options.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/codegen-common.h"
#include "vm/jit/dseg.h"
funcdisp = dseg_addaddress(cd, f);
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
if (f == NULL) {
codegen_addpatchref(cd, mcodeptr, PATCHER_resolve_native, m, funcdisp);
/* put env into first argument register */
- disp = dseg_addaddress(cd, &env);
+ disp = dseg_addaddress(cd, _Jv_env);
M_ALD(rd->argintregs[0], REG_PV, disp);
/* do the native function call */
Changes:
- $Id: patcher.c 4357 2006-01-22 23:33:38Z twisti $
+ $Id: patcher.c 4530 2006-02-21 09:11:53Z twisti $
*/
*******************************************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
bool patcher_resolve_native(u1 *sp)
{
u1 *ra;
return true;
}
-#endif /* !defined(ENABLE_STATICVM) */
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
/*
Changes: Joseph Wenninger
Christian Ullrich
- $Id: codegen.c 4493 2006-02-12 16:28:35Z twisti $
+ $Id: codegen.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include "vm/jit/i386/codegen.h"
#include "vm/jit/i386/emitfuncs.h"
-#include "cacao/cacao.h"
#include "native/jni.h"
#include "native/native.h"
#include "vm/builtin.h"
#include "vm/options.h"
#include "vm/stringlocal.h"
#include "vm/utf8.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/codegen-common.h"
#include "vm/jit/dseg.h"
/* get function address (this must happen before the stackframeinfo) */
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
if (f == NULL) {
codegen_addpatchref(cd, cd->mcodeptr, PATCHER_resolve_native, m, 0);
/* put env into first argument */
- M_AST_IMM((ptrint) &env, REG_SP, 0 * 4);
+ M_AST_IMM((ptrint) _Jv_env, REG_SP, 0 * 4);
/* call the native function */
Changes:
- $Id: patcher.c 4357 2006-01-22 23:33:38Z twisti $
+ $Id: patcher.c 4530 2006-02-21 09:11:53Z twisti $
*/
*******************************************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
bool patcher_resolve_native(u1 *sp)
{
u1 *ra;
return true;
}
-#endif /* !defined(ENABLE_STATICVM) */
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
/*
This module generates MIPS machine code for a sequence of
intermediate code commands (ICMDs).
- $Id: codegen.c 4499 2006-02-13 00:12:24Z twisti $
+ $Id: codegen.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include "vm/jit/mips/arch.h"
#include "vm/jit/mips/codegen.h"
-#include "cacao/cacao.h"
#include "native/native.h"
#include "vm/builtin.h"
#include "vm/class.h"
#include "vm/exceptions.h"
#include "vm/options.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/codegen-common.h"
#include "vm/jit/dseg.h"
funcdisp = dseg_addaddress(cd, f);
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
if (f == NULL) {
codegen_addpatchref(cd, mcodeptr, PATCHER_resolve_native, m, funcdisp);
/* put env into first argument register */
- disp = dseg_addaddress(cd, &env);
+ disp = dseg_addaddress(cd, _Jv_env);
M_ALD(rd->argintregs[0], REG_PV, disp);
/* do the native function call */
Changes:
- $Id: patcher.c 4357 2006-01-22 23:33:38Z twisti $
+ $Id: patcher.c 4530 2006-02-21 09:11:53Z twisti $
*/
+#include "config.h"
+
#include <sys/cachectl.h>
-#include "config.h"
#include "vm/types.h"
#include "mm/memory.h"
*******************************************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
bool patcher_resolve_native(u1 *sp)
{
u1 *ra;
return true;
}
-#endif /* !defined(ENABLE_STATICVM) */
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
/*
Changes:
- $Id: patcher.h 4357 2006-01-22 23:33:38Z twisti $
+ $Id: patcher.h 4530 2006-02-21 09:11:53Z twisti $
*/
bool patcher_athrow_areturn(u1 *sp);
#define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
bool patcher_resolve_native(u1 *sp);
#define PATCHER_resolve_native (functionptr) patcher_resolve_native
-#endif /* !defined(ENABLE_STATICVM) */
+#endif
/* stuff for the interpreter **************************************************/
Changes: Christian Thalinger
Christian Ullrich
- $Id: codegen.c 4497 2006-02-12 23:22:36Z twisti $
+ $Id: codegen.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include "vm/jit/powerpc/arch.h"
#include "vm/jit/powerpc/codegen.h"
-#include "cacao/cacao.h"
#include "native/native.h"
#include "vm/builtin.h"
#include "vm/exceptions.h"
#include "vm/loader.h"
#include "vm/options.h"
#include "vm/stringlocal.h"
+#include "vm/vm.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/codegen-common.h"
#include "vm/jit/dseg.h"
funcdisp = dseg_addaddress(cd, f);
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
if (f == NULL) {
codegen_addpatchref(cd, mcodeptr, PATCHER_resolve_native, m, funcdisp);
/* put env into first argument register */
- disp = dseg_addaddress(cd, &env);
+ disp = dseg_addaddress(cd, _Jv_env);
M_ALD(rd->argintregs[0], REG_PV, disp);
/* generate the actual native call */
Changes:
- $Id: patcher.c 4357 2006-01-22 23:33:38Z twisti $
+ $Id: patcher.c 4530 2006-02-21 09:11:53Z twisti $
*/
*******************************************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
bool patcher_resolve_native(u1 *sp)
{
u1 *ra;
return true;
}
-#endif /* !defined(ENABLE_STATICVM) */
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
/*
Changes:
- $Id: asmpart.S 4440 2006-02-05 12:03:43Z twisti $
+ $Id: asmpart.S 4530 2006-02-21 09:11:53Z twisti $
*/
.text
-/********************* exported functions and variables ***********************/
+/* exported functions and variables *******************************************/
.globl asm_calljavafunction
+ .type asm_calljavafunction, @function
+
.globl asm_calljavafunction_int
.globl asm_calljavafunction2
.quad 0 /* catch type all */
.quad calljava_xhandler /* handler pc */
.quad calljava_xhandler /* end pc */
- .quad asm_calljavafunction /* start pc */
+ .quad L_asm_calljavafunction /* start pc */
.long 1 /* extable size */
.long 0
.quad 0 /* line number table start */
asm_calljavafunction:
asm_calljavafunction_int:
+L_asm_calljavafunction: /* required for PIC code */
sub $(3*8),sp /* keep stack 16-byte aligned */
mov bp,0*8(sp)
mov %rbx,1*8(sp) /* %rbx is not a callee saved in CACAO*/
mov a3,a2
mov a4,a3
- lea asm_call_jit_compiler,itmp3
+ lea L_asm_call_jit_compiler(%rip),itmp3
call *itmp3 /* call JIT compiler */
L_asm_calljavafunction_return:
calljava_xhandler:
mov xptr,a0 /* pass exception pointer */
- call builtin_throw_exception
+ call builtin_throw_exception@PLT
xor v0,v0 /* return NULL */
jmp L_asm_calljavafunction_return
.quad 0 /* catch type all */
.quad calljava_xhandler2 /* handler pc */
.quad calljava_xhandler2 /* end pc */
- .quad asm_calljavafunction2 /* start pc */
+ .quad L_asm_calljavafunction2 /* start pc */
.long 1 /* extable size */
.long 0
.quad 0 /* line number table start */
asm_calljavafunction2long:
asm_calljavafunction2float:
asm_calljavafunction2double:
+L_asm_calljavafunction2: /* required for PIC code */
sub $(7*8),sp /* keep stack 16-byte aligned */
mov %rbx,0*8(sp) /* %rbx is not a callee saved in cacao*/
mov s0,1*8(sp)
cmp $INT_ARG_CNT,%r12 /* are we out of integer argument */
je L_register_copy /* register? yes, next loop */
- lea jumptable_integer,%rbp
+ lea jumptable_integer(%rip),%rbp
mov 0(%rbp,%r12,8),%rbx
inc %r12 /* integer argument counter + 1 */
jmp *%rbx
cmp $FLT_ARG_CNT,%r13 /* are we out of float argument */
je L_register_copy /* register? yes, next loop */
- lea jumptable_float,%rbp
+ lea jumptable_float(%rip),%rbp
mov 0(%rbp,%r13,8),%rbx
inc %r13 /* float argument counter + 1 */
jmp *%rbx
jmp L_stack_copy_loop
L_copy_done:
- lea asm_call_jit_compiler,itmp3 /* %rax still contains method pointer */
- call *itmp3 /* call JIT compiler */
+ /* itmp1 still contains method pointer*/
+ lea L_asm_call_jit_compiler(%rip),itmp3
+ call *itmp3 /* call JIT compiler */
- add bp,sp /* remove argument stack frame if any */
+ add bp,sp /* remove argument stack frame if any */
L_asm_calljavafunction2_return:
mov 0*8(sp),%rbx /* restore callee saved registers */
calljava_xhandler2:
mov xptr,a0 /* pass exception pointer */
- call builtin_throw_exception
+ call builtin_throw_exception@PLT
xor v0,v0 /* return NULL */
jmp L_asm_calljavafunction2_return
*******************************************************************************/
asm_call_jit_compiler:
+L_asm_call_jit_compiler: /* required for PIC code */
/* keep stack 16-byte aligned */
sub $((3+ARG_CNT)*8+sizestackframeinfo),sp
/* pass ra to java function */
mov ((3+ARG_CNT)*8+sizestackframeinfo)(sp),a3
mov a3,a4 /* xpc is equal to ra */
- call stacktrace_create_extern_stackframeinfo
+ call stacktrace_create_extern_stackframeinfo@PLT
mov 1*8(sp),a0 /* pass method pointer */
- call jit_compile
+ call jit_compile@PLT
mov v0,1*8(sp) /* save return value */
mov sp,a0 /* remove stackframe info */
add $((3+ARG_CNT)*8),a0 /* pass sfi */
- call stacktrace_remove_stackframeinfo
+ call stacktrace_remove_stackframeinfo@PLT
mov 0*8(sp),itmp3 /* restore address for method pointer */
mov 1*8(sp),v0 /* restore return value */
L_asm_call_jit_compiler_exception:
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
- call builtin_asm_get_exceptionptrptr
+ call builtin_asm_get_exceptionptrptr@PLT
mov v0,itmp2 /* v0 == xptr */
#else
lea _no_threads_exceptionptr,itmp2
pop xpc /* delete return address */
sub $5,xpc /* faulting address is ra - 5 */
- jmp asm_handle_exception
+ jmp L_asm_handle_exception
/* asm_handle_exception ********************************************************
add $8,sp /* clear return address of native stub*/
asm_handle_exception:
+L_asm_handle_exception: /* required for PIC code */
sub $((ARG_CNT+TMP_CNT)*8),sp /* create maybe-leaf stackframe */
SAVE_ARGUMENT_REGISTERS(0) /* we save arg and temp registers in */
mov t0,4*8(sp) /* save maybe-leaf flag */
mov xpc,a0 /* exception pc */
- call codegen_findmethod
+ call codegen_findmethod@PLT
mov v0,2*8(sp) /* save data segment pointer */
mov 0*8(sp),a0 /* pass exception pointer */
mov 1*8(sp),a1 /* pass exception pc */
mov v0,a2 /* pass data segment pointer */
mov 3*8(sp),a3 /* pass Java stack pointer */
- call exceptions_handle_exception
+ call exceptions_handle_exception@PLT
test v0,v0
jz L_asm_handle_exception_not_catched
add $((6+1)*8),a2
mov ((5+1)*8)(bp),a3 /* pass ra to java function */
mov a3,a4 /* xpc is equal to ra */
- call stacktrace_create_extern_stackframeinfo
+ call stacktrace_create_extern_stackframeinfo@PLT
mov bp,a0 /* pass stack pointer */
add $((1+1)*8),a0 /* skip function pointer */
mov sp,a0 /* remove stackframe info */
add $((3+ARG_CNT+TMP_CNT)*8),a0
- call stacktrace_remove_stackframeinfo
+ call stacktrace_remove_stackframeinfo@PLT
RESTORE_ARGUMENT_REGISTERS(3)
RESTORE_TEMPORARY_REGISTERS(3+ARG_CNT)
L_asm_wrapper_patcher_exception:
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
- call builtin_asm_get_exceptionptrptr
+ call builtin_asm_get_exceptionptrptr@PLT
mov v0,itmp2 /* v0 == xptr */
#else
lea _no_threads_exceptionptr,itmp2
movl $0,(itmp2) /* clear exception pointer */
pop xpc /* get and remove return address */
- jmp asm_handle_exception
+ jmp L_asm_handle_exception
/* asm_builtin_x2x *************************************************************
SAVE_ARGUMENT_REGISTERS(0)
movq ftmp1,fa0
- call builtin_f2i
+ call builtin_f2i@PLT
RESTORE_ARGUMENT_REGISTERS(0)
SAVE_ARGUMENT_REGISTERS(0)
movq ftmp1,fa0
- call builtin_f2l
+ call builtin_f2l@PLT
RESTORE_ARGUMENT_REGISTERS(0)
SAVE_ARGUMENT_REGISTERS(0)
movq ftmp1,fa0
- call builtin_d2i
+ call builtin_d2i@PLT
RESTORE_ARGUMENT_REGISTERS(0)
SAVE_ARGUMENT_REGISTERS(0)
movq ftmp1,fa0
- call builtin_d2l
+ call builtin_d2l@PLT
RESTORE_ARGUMENT_REGISTERS(0)
Changes:
- $Id: patcher.c 4357 2006-01-22 23:33:38Z twisti $
+ $Id: patcher.c 4530 2006-02-21 09:11:53Z twisti $
*/
*******************************************************************************/
-#if !defined(ENABLE_STATICVM)
+#if !defined(WITH_STATIC_CLASSPATH)
bool patcher_resolve_native(u1 *sp)
{
u1 *ra;
return true;
}
-#endif /* !defined(ENABLE_STATICVM) */
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
/*
Changes:
- $Id: options.c 4396 2006-01-31 23:27:41Z twisti $
+ $Id: options.c 4530 2006-02-21 09:11:53Z twisti $
*/
+#include "config.h"
+
#include <string.h>
-#include "config.h"
#include "vm/types.h"
+#include "mm/memory.h"
+#include "native/jni.h"
#include "vm/options.h"
/* command line option ********************************************************/
-s4 opt_ind = 1; /* index of processed arguments */
+s4 opt_index = 0; /* index of processed arguments */
char *opt_arg; /* this one exports the option argument */
#if defined(ENABLE_JIT)
bool opt_intrp = true; /* interpreter mode execution (default) */
#endif
+bool opt_jar = false;
+bool opt_run = true;
+
s4 opt_stacksize = 0; /* thread stack size */
bool opt_verbose = false;
bool showconstantpool = false;
bool showutf = false;
+char *opt_method = NULL;
+char *opt_signature = NULL;
+
bool compileverbose = false; /* trace compiler actions */
bool showstack = false;
bool opt_showdisassemble = false; /* generate disassembler listing */
bool opt_prof = false;
bool opt_prof_bb = false;
+
+/* optimization options *******************************************************/
+
+#if defined(ENABLE_IFCONV)
+bool opt_ifconv = false;
+#endif
+
#if defined(ENABLE_LSRA)
bool opt_lsra = false;
#endif
#endif
-/* get_opt *********************************************************************
+/* options_get *****************************************************************
DOCUMENT ME!!!
*******************************************************************************/
-int get_opt(int argc, char **argv, opt_struct *opts)
+s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
{
- char *a;
+ char *option;
s4 i;
-
- if (opt_ind >= argc)
+
+ if (opt_index >= vm_args->nOptions)
return OPT_DONE;
-
- a = argv[opt_ind];
- if (a[0] != '-')
+ /* get the current option */
+
+ option = vm_args->options[opt_index].optionString;
+
+ if ((option == NULL) || (option[0] != '-'))
return OPT_DONE;
for (i = 0; opts[i].name; i++) {
if (!opts[i].arg) {
/* boolean option found */
- if (strcmp(a + 1, opts[i].name) == 0) {
- opt_ind++;
+ if (strcmp(option + 1, opts[i].name) == 0) {
+ opt_index++;
return opts[i].value;
}
/* with a space between */
- if (strcmp(a + 1, opts[i].name) == 0) {
- opt_ind++;
+ if (strcmp(option + 1, opts[i].name) == 0) {
+ opt_index++;
- if (opt_ind < argc) {
- opt_arg = argv[opt_ind];
- opt_ind++;
+ if (opt_index < vm_args->nOptions) {
+ opt_arg = strdup(vm_args->options[opt_index].optionString);
+ opt_index++;
return opts[i].value;
}
/* parameter and option have no space between */
size_t l = strlen(opts[i].name);
- if (strlen(a + 1) > l) {
- if (memcmp(a + 1, opts[i].name, l) == 0) {
- opt_ind++;
- opt_arg = a + 1 + l;
+
+ if (strlen(option + 1) > l) {
+ if (memcmp(option + 1, opts[i].name, l) == 0) {
+ opt_index++;
+ opt_arg = strdup(option + 1 + l);
return opts[i].value;
}
}
}
}
- } /* end for */
+ }
return OPT_ERROR;
}
+/* options_prepare *************************************************************
+
+ Prepare the JavaVMInitArgs.
+
+*******************************************************************************/
+
+JavaVMInitArgs *options_prepare(int argc, char **argv)
+{
+ JavaVMInitArgs *vm_args;
+ s4 i;
+
+ vm_args = NEW(JavaVMInitArgs);
+
+ vm_args->version = JNI_VERSION_1_2;
+ vm_args->nOptions = argc - 1;
+ vm_args->options = MNEW(JavaVMOption, argc);
+ vm_args->ignoreUnrecognized = JNI_FALSE;
+
+ for (i = 1; i < argc; i++)
+ vm_args->options[i - 1].optionString = argv[i];
+
+ return vm_args;
+}
+
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Changes:
- $Id: options.h 4396 2006-01-31 23:27:41Z twisti $
+ $Id: options.h 4530 2006-02-21 09:11:53Z twisti $
*/
#include "config.h"
#include "vm/types.h"
+#include "native/jni.h"
#include "vm/global.h"
/* global variables ***********************************************************/
-extern s4 opt_ind;
+extern s4 opt_index;
extern char *opt_arg;
extern bool opt_jit;
extern bool opt_intrp;
+extern bool opt_jar;
+extern bool opt_run;
+
extern s4 opt_stacksize;
extern bool opt_verbose;
extern bool compileall;
extern bool showconstantpool;
extern bool showutf;
+extern char *opt_method;
+extern char *opt_signature;
+
extern bool compileverbose;
extern bool showstack;
extern bool opt_showdisassemble;
extern bool opt_prof;
extern bool opt_prof_bb;
+
+/* optimization options *******************************************************/
+
+#if defined(ENABLE_IFCONV)
+extern bool opt_ifconv;
+#endif
+
#if defined(ENABLE_LSRA)
extern bool opt_lsra;
#endif
/* function prototypes ********************************************************/
-int get_opt(int argc, char **argv, opt_struct *opts);
-
+s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args);
+JavaVMInitArgs *options_prepare(int argc, char **argv);
#endif /* _OPTIONS_H */
Changes:
- $Id: signal.c 4390 2006-01-31 14:24:43Z twisti $
+ $Id: signal.c 4530 2006-02-21 09:11:53Z twisti $
*/
#include "vm/types.h"
-#include "cacao/cacao.h"
-
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
# include "threads/native/threads.h"
#endif
#include "vm/signallocal.h"
#include "vm/options.h"
+#include "vm/vm.h"
#include "vm/jit/stacktrace.h"
{
/* if we are already in Runtime.exit(), just do it hardcore */
- if (cacao_exiting) {
+ if (vm_exiting) {
fprintf(stderr, "Caught SIGINT while already shutting down. Shutdown aborted...\n");
exit(0);
}
/* exit the vm properly */
- cacao_exit(0);
+ vm_exit(0);
}
--- /dev/null
+/* src/vm/finalizer.c - finalizer linked list and thread
+
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Contact: cacao@cacaojvm.org
+
+ Authors: Christian Thalinger
+
+ Changes:
+
+ $Id: finalizer.c 4357 2006-01-22 23:33:38Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "vm/types.h"
+
+#include "mm/boehm.h"
+#include "native/jni.h"
+#include "native/native.h"
+
+#if defined(USE_THREADS)
+# if defined(NATIVE_THREADS)
+# include "threads/native/threads.h"
+# else
+# include "threads/green/threads.h"
+# include "threads/green/locks.h"
+# endif
+#endif
+
+#include "vm/classcache.h"
+#include "vm/exceptions.h"
+#include "vm/finalizer.h"
+#include "vm/global.h"
+#include "vm/initialize.h"
+#include "vm/options.h"
+#include "vm/properties.h"
+#include "vm/signallocal.h"
+#include "vm/stringlocal.h"
+#include "vm/suck.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/profile/profile.h"
+
+
+/* Invocation API variables ***************************************************/
+
+JavaVM *_Jv_jvm; /* denotes a Java VM */
+_Jv_JNIEnv *_Jv_env; /* pointer to native method interface */
+
+
+/* global variables ***********************************************************/
+
+s4 vms = 0; /* number of VMs created */
+
+bool vm_initializing = false;
+bool vm_exiting = false;
+
+#if defined(ENABLE_INTRP)
+u1 *intrp_main_stack = NULL;
+#endif
+
+void **stackbottom = NULL;
+
+char *mainstring = NULL;
+classinfo *mainclass = NULL;
+
+char *specificmethodname = NULL;
+char *specificsignature = NULL;
+
+bool startit = true;
+
+
+/* define heap sizes **********************************************************/
+
+#define HEAP_MAXSIZE 64 * 1024 * 1024 /* default 64MB */
+#define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
+#define STACK_SIZE 128 * 1024 /* default 128kB */
+
+
+/* define command line options ************************************************/
+
+enum {
+ OPT_CLASSPATH,
+ OPT_D,
+ OPT_MS,
+ OPT_MX,
+ OPT_VERBOSE1,
+ OPT_VERBOSE,
+ OPT_VERBOSESPECIFIC,
+ OPT_VERBOSECALL,
+ OPT_NOIEEE,
+ OPT_SOFTNULL,
+ OPT_TIME,
+
+#if defined(ENABLE_STATISTICS)
+ OPT_STAT,
+#endif
+
+ OPT_LOG,
+ OPT_CHECK,
+ OPT_LOAD,
+ OPT_METHOD,
+ OPT_SIGNATURE,
+ OPT_SHOW,
+ OPT_ALL,
+ OPT_OLOOP,
+ OPT_INLINING,
+
+ OPT_VERBOSETC,
+ OPT_NOVERIFY,
+ OPT_LIBERALUTF,
+ OPT_VERBOSEEXCEPTION,
+ OPT_EAGER,
+
+ /* optimization options */
+
+#if defined(ENABLE_IFCONV)
+ OPT_IFCONV,
+#endif
+
+#if defined(ENABLE_LSRA)
+ OPT_LSRA,
+#endif
+
+ OPT_JAR,
+ OPT_BOOTCLASSPATH,
+ OPT_BOOTCLASSPATH_A,
+ OPT_BOOTCLASSPATH_P,
+ OPT_VERSION,
+ OPT_SHOWVERSION,
+ OPT_FULLVERSION,
+
+ OPT_HELP,
+ OPT_X,
+
+ OPT_JIT,
+ OPT_INTRP,
+
+ OPT_PROF,
+ OPT_PROF_OPTION,
+
+#if defined(ENABLE_INTRP)
+ /* interpreter options */
+
+ OPT_NO_DYNAMIC,
+ OPT_NO_REPLICATION,
+ OPT_NO_QUICKSUPER,
+ OPT_STATIC_SUPERS,
+ OPT_TRACE,
+#endif
+
+ OPT_SS,
+
+#ifdef ENABLE_JVMTI
+ OPT_DEBUG,
+ OPT_AGENTLIB,
+ OPT_AGENTPATH,
+#endif
+
+ DUMMY
+};
+
+
+opt_struct opts[] = {
+ { "classpath", true, OPT_CLASSPATH },
+ { "cp", true, OPT_CLASSPATH },
+ { "D", true, OPT_D },
+ { "noasyncgc", false, OPT_IGNORE },
+ { "noverify", false, OPT_NOVERIFY },
+ { "liberalutf", false, OPT_LIBERALUTF },
+ { "v", false, OPT_VERBOSE1 },
+ { "verbose", false, OPT_VERBOSE },
+ { "verbose:", true, OPT_VERBOSESPECIFIC },
+ { "verbosecall", false, OPT_VERBOSECALL },
+ { "verboseexception", false, OPT_VERBOSEEXCEPTION },
+#ifdef TYPECHECK_VERBOSE
+ { "verbosetc", false, OPT_VERBOSETC },
+#endif
+#if defined(__ALPHA__)
+ { "noieee", false, OPT_NOIEEE },
+#endif
+ { "softnull", false, OPT_SOFTNULL },
+ { "time", false, OPT_TIME },
+#if defined(ENABLE_STATISTICS)
+ { "stat", false, OPT_STAT },
+#endif
+ { "log", true, OPT_LOG },
+ { "c", true, OPT_CHECK },
+ { "l", false, OPT_LOAD },
+ { "eager", false, OPT_EAGER },
+ { "sig", true, OPT_SIGNATURE },
+ { "all", false, OPT_ALL },
+ { "oloop", false, OPT_OLOOP },
+#if defined(ENABLE_IFCONV)
+ { "ifconv", false, OPT_IFCONV },
+#endif
+#if defined(ENABLE_LSRA)
+ { "lsra", false, OPT_LSRA },
+#endif
+ { "jar", false, OPT_JAR },
+ { "version", false, OPT_VERSION },
+ { "showversion", false, OPT_SHOWVERSION },
+ { "fullversion", false, OPT_FULLVERSION },
+ { "help", false, OPT_HELP },
+ { "?", false, OPT_HELP },
+
+#if defined(ENABLE_INTRP)
+ /* interpreter options */
+
+ { "trace", false, OPT_TRACE },
+ { "static-supers", true, OPT_STATIC_SUPERS },
+ { "no-dynamic", false, OPT_NO_DYNAMIC },
+ { "no-replication", false, OPT_NO_REPLICATION },
+ { "no-quicksuper", false, OPT_NO_QUICKSUPER },
+#endif
+
+ /* JVMTI Agent Command Line Options */
+#ifdef ENABLE_JVMTI
+ { "agentlib:", true, OPT_AGENTLIB },
+ { "agentpath:", true, OPT_AGENTPATH },
+#endif
+
+ /* X options */
+
+ { "X", false, OPT_X },
+ { "Xjit", false, OPT_JIT },
+ { "Xint", false, OPT_INTRP },
+ { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
+ { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
+ { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
+#ifdef ENABLE_JVMTI
+ { "Xdebug", false, OPT_DEBUG },
+#endif
+ { "Xms", true, OPT_MS },
+ { "Xmx", true, OPT_MX },
+ { "Xprof:", true, OPT_PROF_OPTION },
+ { "Xprof", false, OPT_PROF },
+ { "Xss", true, OPT_SS },
+ { "ms", true, OPT_MS },
+ { "mx", true, OPT_MX },
+ { "ss", true, OPT_SS },
+
+ /* keep these at the end of the list */
+
+ { "i", true, OPT_INLINING },
+ { "m", true, OPT_METHOD },
+ { "s", true, OPT_SHOW },
+
+ { NULL, false, 0 }
+};
+
+
+/* usage ***********************************************************************
+
+ Prints the correct usage syntax to stdout.
+
+*******************************************************************************/
+
+void usage(void)
+{
+ printf("Usage: cacao [-options] classname [arguments]\n");
+ printf(" (to run a class file)\n");
+ printf(" cacao [-options] -jar jarfile [arguments]\n");
+ printf(" (to run a standalone jar file)\n\n");
+
+ printf("Java options:\n");
+ printf(" -cp <path> specify a path to look for classes\n");
+ printf(" -classpath <path> specify a path to look for classes\n");
+ printf(" -D<name>=<value> add an entry to the property list\n");
+ printf(" -verbose[:class|gc|jni] enable specific verbose output\n");
+ printf(" -version print product version and exit\n");
+ printf(" -fullversion print jpackage-compatible product version and exit\n");
+ printf(" -showversion print product version and continue\n");
+ printf(" -help, -? print this help message\n");
+ printf(" -X print help on non-standard Java options\n\n");
+
+#ifdef ENABLE_JVMTI
+ printf(" -agentlib:<agent-lib-name>=<options> library to load containg JVMTI agent\n");
+ printf(" -agentpath:<path-to-agent>=<options> path to library containg JVMTI agent\n");
+#endif
+
+ printf("CACAO options:\n");
+ printf(" -v write state-information\n");
+ printf(" -verbose write more information\n");
+ printf(" -verbosegc write message for each GC\n");
+ printf(" -verbosecall write message for each call\n");
+ printf(" -verboseexception write message for each step of stack unwinding\n");
+#ifdef TYPECHECK_VERBOSE
+ printf(" -verbosetc write debug messages while typechecking\n");
+#endif
+#if defined(__ALPHA__)
+ printf(" -noieee don't use ieee compliant arithmetic\n");
+#endif
+ printf(" -noverify don't verify classfiles\n");
+ printf(" -liberalutf don't warn about overlong UTF-8 sequences\n");
+ printf(" -softnull use software nullpointer check\n");
+ printf(" -time measure the runtime\n");
+#if defined(ENABLE_STATISTICS)
+ printf(" -stat detailed compiler statistics\n");
+#endif
+ printf(" -log logfile specify a name for the logfile\n");
+ printf(" -c(heck)b(ounds) don't check array bounds\n");
+ printf(" s(ync) don't check for synchronization\n");
+ printf(" -oloop optimize array accesses in loops\n");
+ printf(" -l don't start the class after loading\n");
+ printf(" -eager perform eager class loading and linking\n");
+ printf(" -all compile all methods, no execution\n");
+ printf(" -m compile only a specific method\n");
+ printf(" -sig specify signature for a specific method\n");
+ printf(" -s(how)a(ssembler) show disassembled listing\n");
+ printf(" c(onstants) show the constant pool\n");
+ printf(" d(atasegment) show data segment listing\n");
+ printf(" e(xceptionstubs) show disassembled exception stubs (only with -sa)\n");
+ printf(" i(ntermediate) show intermediate representation\n");
+ printf(" m(ethods) show class fields and methods\n");
+ printf(" n(ative) show disassembled native stubs\n");
+ printf(" u(tf) show the utf - hash\n");
+ printf(" -i n(line) activate inlining\n");
+ printf(" v(irtual) inline virtual methods (uses/turns rt option on)\n");
+ printf(" e(exception) inline methods with exceptions\n");
+ printf(" p(aramopt) optimize argument renaming\n");
+ printf(" o(utsiders) inline methods of foreign classes\n");
+#if defined(ENABLE_IFCONV)
+ printf(" -ifconv use if-conversion\n");
+#endif
+#if defined(ENABLE_LSRA)
+ printf(" -lsra use linear scan register allocation\n");
+#endif
+
+ /* exit with error code */
+
+ exit(1);
+}
+
+
+static void Xusage(void)
+{
+#if defined(ENABLE_JIT)
+ printf(" -Xjit JIT mode execution (default)\n");
+#endif
+#if defined(ENABLE_INTRP)
+ printf(" -Xint interpreter mode execution\n");
+#endif
+ printf(" -Xbootclasspath:<zip/jar files and directories separated by :>\n");
+ printf(" value is set as bootstrap class path\n");
+ printf(" -Xbootclasspath/a:<zip/jar files and directories separated by :>\n");
+ printf(" value is appended to the bootstrap class path\n");
+ printf(" -Xbootclasspath/p:<zip/jar files and directories separated by :>\n");
+ printf(" value is prepended to the bootstrap class path\n");
+ printf(" -Xms<size> set the initial size of the heap (default: 2MB)\n");
+ printf(" -Xmx<size> set the maximum size of the heap (default: 64MB)\n");
+ printf(" -Xss<size> set the thread stack size (default: 128kB)\n");
+ printf(" -Xprof[:bb] collect and print profiling data\n");
+#if defined(ENABLE_JVMTI)
+ printf(" -Xdebug<transport> enable remote debugging\n");
+#endif
+
+ /* exit with error code */
+
+ exit(1);
+}
+
+
+/* version *********************************************************************
+
+ Only prints cacao version information.
+
+*******************************************************************************/
+
+static void version(void)
+{
+ printf("java version \""JAVA_VERSION"\"\n");
+ printf("CACAO version "VERSION"\n");
+
+ printf("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,\n");
+ printf("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,\n");
+ printf("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,\n");
+ printf("J. Wenninger, Institut f. Computersprachen - TU Wien\n\n");
+
+ printf("This program is free software; you can redistribute it and/or\n");
+ printf("modify it under the terms of the GNU General Public License as\n");
+ printf("published by the Free Software Foundation; either version 2, or (at\n");
+ printf("your option) any later version.\n\n");
+
+ printf("This program is distributed in the hope that it will be useful, but\n");
+ printf("WITHOUT ANY WARRANTY; without even the implied warranty of\n");
+ printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n");
+ printf("General Public License for more details.\n");
+}
+
+
+/* fullversion *****************************************************************
+
+ Prints a Sun compatible version information (required e.g. by
+ jpackage, www.jpackage.org).
+
+*******************************************************************************/
+
+static void fullversion(void)
+{
+ printf("java full version \"cacao-"JAVA_VERSION"\"\n");
+
+ /* exit normally */
+
+ exit(0);
+}
+
+
+/* vm_create *******************************************************************
+
+ Creates a JVM. Called by JNI_CreateJavaVM.
+
+*******************************************************************************/
+
+bool vm_create(JavaVMInitArgs *vm_args)
+{
+ char *cp;
+ s4 cplen;
+ u4 heapmaxsize;
+ u4 heapstartsize;
+ s4 opt;
+ s4 i, j, k;
+
+ /* check the JNI version requested */
+
+ switch (vm_args->version) {
+ case JNI_VERSION_1_1:
+ break;
+ case JNI_VERSION_1_2:
+ case JNI_VERSION_1_4:
+ break;
+ default:
+ return false;
+ }
+
+ /* we only support 1 JVM instance */
+
+ if (vms > 0)
+ return false;
+
+
+ /* get stuff from the environment *****************************************/
+
+#if defined(DISABLE_GC)
+ nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
+#endif
+
+ /* set the bootclasspath */
+
+ cp = getenv("BOOTCLASSPATH");
+
+ if (cp) {
+ bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
+ strcpy(bootclasspath, cp);
+
+ } else {
+ cplen = strlen(CACAO_VM_ZIP_PATH) +
+ strlen(":") +
+ strlen(CLASSPATH_GLIBJ_ZIP_PATH) +
+ strlen("0");
+
+ bootclasspath = MNEW(char, cplen);
+ strcat(bootclasspath, CACAO_VM_ZIP_PATH);
+ strcat(bootclasspath, ":");
+ strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP_PATH);
+ }
+
+
+ /* set the classpath */
+
+ cp = getenv("CLASSPATH");
+
+ if (cp) {
+ classpath = MNEW(char, strlen(cp) + strlen("0"));
+ strcat(classpath, cp);
+
+ } else {
+ classpath = MNEW(char, strlen(".") + strlen("0"));
+ strcpy(classpath, ".");
+ }
+
+
+ /* interpret the options **************************************************/
+
+ checknull = false;
+ opt_noieee = false;
+
+ heapmaxsize = HEAP_MAXSIZE;
+ heapstartsize = HEAP_STARTSIZE;
+ opt_stacksize = STACK_SIZE;
+
+ /* initialize properties before commandline handling */
+
+ if (!properties_init())
+ throw_cacao_exception_exit(string_java_lang_InternalError,
+ "Unable to init properties");
+
+ /* iterate over all passed options */
+
+ while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
+ switch (opt) {
+ case OPT_IGNORE:
+ break;
+
+ case OPT_BOOTCLASSPATH:
+ /* Forget default bootclasspath and set the argument as
+ new boot classpath. */
+ MFREE(bootclasspath, char, strlen(bootclasspath));
+
+ bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
+ strcpy(bootclasspath, opt_arg);
+ break;
+
+ case OPT_BOOTCLASSPATH_A:
+ /* append to end of bootclasspath */
+ cplen = strlen(bootclasspath);
+
+ bootclasspath = MREALLOC(bootclasspath,
+ char,
+ cplen,
+ cplen + strlen(":") +
+ strlen(opt_arg) + strlen("0"));
+
+ strcat(bootclasspath, ":");
+ strcat(bootclasspath, opt_arg);
+ break;
+
+ case OPT_BOOTCLASSPATH_P:
+ /* prepend in front of bootclasspath */
+ cp = bootclasspath;
+ cplen = strlen(cp);
+
+ bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
+ cplen + strlen("0"));
+
+ strcpy(bootclasspath, opt_arg);
+ strcat(bootclasspath, ":");
+ strcat(bootclasspath, cp);
+
+ MFREE(cp, char, cplen);
+ break;
+
+ case OPT_CLASSPATH:
+ /* forget old classpath and set the argument as new classpath */
+ MFREE(classpath, char, strlen(classpath));
+
+ classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
+ strcpy(classpath, opt_arg);
+ break;
+
+ case OPT_JAR:
+ opt_jar = true;
+ break;
+
+#if defined(ENABLE_JVMTI)
+ case OPT_DEBUG:
+ dbg = true;
+ transport = opt_arg;
+ break;
+
+ case OPT_AGENTPATH:
+ case OPT_AGENTLIB:
+ set_jvmti_phase(JVMTI_PHASE_ONLOAD);
+ agentload(opt_arg);
+ set_jvmti_phase(JVMTI_PHASE_PRIMORDIAL);
+ break;
+#endif
+
+ case OPT_D:
+ for (j = 0; j < strlen(opt_arg); j++) {
+ if (opt_arg[j] == '=') {
+ opt_arg[j] = '\0';
+ properties_add(opt_arg, opt_arg + j + 1);
+ goto didit;
+ }
+ }
+
+ /* if no '=' is given, just create an empty property */
+
+ properties_add(opt_arg, "");
+
+ didit:
+ break;
+
+ case OPT_MX:
+ case OPT_MS:
+ case OPT_SS:
+ {
+ char c;
+ c = opt_arg[strlen(opt_arg) - 1];
+
+ if ((c == 'k') || (c == 'K')) {
+ j = atoi(opt_arg) * 1024;
+
+ } else if ((c == 'm') || (c == 'M')) {
+ j = atoi(opt_arg) * 1024 * 1024;
+
+ } else
+ j = atoi(opt_arg);
+
+ if (opt == OPT_MX)
+ heapmaxsize = j;
+ else if (opt == OPT_MS)
+ heapstartsize = j;
+ else
+ opt_stacksize = j;
+ }
+ break;
+
+ case OPT_VERBOSE1:
+ opt_verbose = true;
+ break;
+
+ case OPT_VERBOSE:
+ opt_verbose = true;
+ loadverbose = true;
+ linkverbose = true;
+ initverbose = true;
+ compileverbose = true;
+ break;
+
+ case OPT_VERBOSESPECIFIC:
+ if (strcmp("class", opt_arg) == 0)
+ opt_verboseclass = true;
+
+ else if (strcmp("gc", opt_arg) == 0)
+ opt_verbosegc = true;
+
+ else if (strcmp("jni", opt_arg) == 0)
+ opt_verbosejni = true;
+ break;
+
+ case OPT_VERBOSEEXCEPTION:
+ opt_verboseexception = true;
+ break;
+
+#ifdef TYPECHECK_VERBOSE
+ case OPT_VERBOSETC:
+ typecheckverbose = true;
+ break;
+#endif
+
+ case OPT_VERBOSECALL:
+ runverbose = true;
+ break;
+
+ case OPT_VERSION:
+ version();
+ exit(0);
+ break;
+
+ case OPT_FULLVERSION:
+ fullversion();
+ break;
+
+ case OPT_SHOWVERSION:
+ version();
+ break;
+
+ case OPT_NOIEEE:
+ opt_noieee = true;
+ break;
+
+ case OPT_NOVERIFY:
+ opt_verify = false;
+ break;
+
+ case OPT_LIBERALUTF:
+ opt_liberalutf = true;
+ break;
+
+ case OPT_SOFTNULL:
+ checknull = true;
+ break;
+
+ case OPT_TIME:
+ getcompilingtime = true;
+ getloadingtime = true;
+ break;
+
+#if defined(ENABLE_STATISTICS)
+ case OPT_STAT:
+ opt_stat = true;
+ break;
+#endif
+
+ case OPT_LOG:
+ log_init(opt_arg);
+ break;
+
+ case OPT_CHECK:
+ for (j = 0; j < strlen(opt_arg); j++) {
+ switch (opt_arg[j]) {
+ case 'b':
+ checkbounds = false;
+ break;
+ case 's':
+ checksync = false;
+ break;
+ default:
+ usage();
+ }
+ }
+ break;
+
+ case OPT_LOAD:
+ opt_run = false;
+ makeinitializations = false;
+ break;
+
+ case OPT_EAGER:
+ opt_eager = true;
+ break;
+
+ case OPT_METHOD:
+ opt_run = false;
+ opt_method = opt_arg;
+ makeinitializations = false;
+ break;
+
+ case OPT_SIGNATURE:
+ opt_signature = opt_arg;
+ break;
+
+ case OPT_ALL:
+ compileall = true;
+ opt_run = false;
+ makeinitializations = false;
+ break;
+
+ case OPT_SHOW: /* Display options */
+ for (j = 0; j < strlen(opt_arg); j++) {
+ switch (opt_arg[j]) {
+ case 'a':
+ opt_showdisassemble = true;
+ compileverbose = true;
+ break;
+ case 'c':
+ showconstantpool = true;
+ break;
+ case 'd':
+ opt_showddatasegment = true;
+ break;
+ case 'e':
+ opt_showexceptionstubs = true;
+ break;
+ case 'i':
+ opt_showintermediate = true;
+ compileverbose = true;
+ break;
+ case 'm':
+ showmethods = true;
+ break;
+ case 'n':
+ opt_shownativestub = true;
+ break;
+ case 'u':
+ showutf = true;
+ break;
+ default:
+ usage();
+ }
+ }
+ break;
+
+ case OPT_OLOOP:
+ opt_loops = true;
+ break;
+
+ case OPT_INLINING:
+ for (j = 0; j < strlen(opt_arg); j++) {
+ switch (opt_arg[j]) {
+ case 'n':
+ /* define in options.h; Used in main.c, jit.c
+ & inline.c inlining is currently
+ deactivated */
+ break;
+ case 'v':
+ inlinevirtuals = true;
+ break;
+ case 'e':
+ inlineexceptions = true;
+ break;
+ case 'p':
+ inlineparamopt = true;
+ break;
+ case 'o':
+ inlineoutsiders = true;
+ break;
+ default:
+ usage();
+ }
+ }
+ break;
+
+#if defined(ENABLE_IFCONV)
+ case OPT_IFCONV:
+ opt_ifconv = true;
+ break;
+#endif
+
+#if defined(ENABLE_LSRA)
+ case OPT_LSRA:
+ opt_lsra = true;
+ break;
+#endif
+
+ case OPT_HELP:
+ usage();
+ break;
+
+ case OPT_X:
+ Xusage();
+ break;
+
+ case OPT_PROF_OPTION:
+ /* use <= to get the last \0 too */
+
+ for (j = 0, k = 0; j <= strlen(opt_arg); j++) {
+ if (opt_arg[j] == ',')
+ opt_arg[j] = '\0';
+
+ if (opt_arg[j] == '\0') {
+ if (strcmp("bb", opt_arg + k) == 0)
+ opt_prof_bb = true;
+
+ else {
+ printf("Unknown option: -Xprof:%s\n", opt_arg + k);
+ usage();
+ }
+
+ /* set k to next char */
+
+ k = j + 1;
+ }
+ }
+ /* fall through */
+
+ case OPT_PROF:
+ opt_prof = true;
+ break;
+
+ case OPT_JIT:
+#if defined(ENABLE_JIT)
+ opt_jit = true;
+#else
+ printf("-Xjit option not enabled.\n");
+ exit(1);
+#endif
+ break;
+
+ case OPT_INTRP:
+#if defined(ENABLE_INTRP)
+ opt_intrp = true;
+#else
+ printf("-Xint option not enabled.\n");
+ exit(1);
+#endif
+ break;
+
+#if defined(ENABLE_INTRP)
+ case OPT_STATIC_SUPERS:
+ opt_static_supers = atoi(opt_arg);
+ break;
+
+ case OPT_NO_DYNAMIC:
+ opt_no_dynamic = true;
+ break;
+
+ case OPT_NO_REPLICATION:
+ opt_no_replication = true;
+ break;
+
+ case OPT_NO_QUICKSUPER:
+ opt_no_quicksuper = true;
+ break;
+
+ case OPT_TRACE:
+ vm_debug = true;
+ break;
+#endif
+
+ default:
+ printf("Unknown option: %s\n",
+ vm_args->options[opt_index].optionString);
+ usage();
+ }
+ }
+
+
+ /* get the main class *****************************************************/
+
+ if (opt_index < vm_args->nOptions) {
+ mainstring = vm_args->options[opt_index++].optionString;
+
+ if (opt_jar == true) {
+
+ /* prepend the jar file to the classpath (if any) */
+
+ if (opt_jar == true) {
+ /* put jarfile in classpath */
+
+ cp = classpath;
+
+ classpath = MNEW(char, strlen(mainstring) + strlen(":") +
+ strlen(classpath) + strlen("0"));
+
+ strcpy(classpath, mainstring);
+ strcat(classpath, ":");
+ strcat(classpath, cp);
+
+ MFREE(cp, char, strlen(cp));
+
+ } else {
+ /* replace .'s with /'s in classname */
+
+ for (i = strlen(mainstring) - 1; i >= 0; i--)
+ if (mainstring[i] == '.')
+ mainstring[i] = '/';
+ }
+ }
+ }
+
+
+ /* initialize this JVM ****************************************************/
+
+ vm_initializing = true;
+
+ /* initialize the garbage collector */
+
+ gc_init(heapmaxsize, heapstartsize);
+
+#if defined(ENABLE_INTRP)
+ /* allocate main thread stack */
+
+ if (opt_intrp) {
+ intrp_main_stack = (u1 *) alloca(opt_stacksize);
+ MSET(intrp_main_stack, 0, u1, opt_stacksize);
+ }
+#endif
+
+#if defined(USE_THREADS)
+#if defined(NATIVE_THREADS)
+ threads_preinit();
+#endif
+ initLocks();
+#endif
+
+ /* initialize the string hashtable stuff: lock (must be done
+ _after_ threads_preinit) */
+
+ if (!string_init())
+ throw_main_exception_exit();
+
+ /* initialize the utf8 hashtable stuff: lock, often used utf8
+ strings (must be done _after_ threads_preinit) */
+
+ if (!utf8_init())
+ throw_main_exception_exit();
+
+ /* initialize the classcache hashtable stuff: lock, hashtable
+ (must be done _after_ threads_preinit) */
+
+ if (!classcache_init())
+ throw_main_exception_exit();
+
+ /* initialize the loader with bootclasspath (must be done _after_
+ thread_preinit) */
+
+ if (!suck_init())
+ throw_main_exception_exit();
+
+ suck_add_from_property("java.endorsed.dirs");
+ suck_add(bootclasspath);
+
+ /* initialize the memory subsystem (must be done _after_
+ threads_preinit) */
+
+ if (!memory_init())
+ throw_main_exception_exit();
+
+ /* initialize the finalizer stuff (must be done _after_
+ threads_preinit) */
+
+ if (!finalizer_init())
+ throw_main_exception_exit();
+
+ /* install architecture dependent signal handler used for exceptions */
+
+ signal_init();
+
+ /* initialize the codegen subsystems */
+
+ codegen_init();
+
+ /* initializes jit compiler */
+
+ jit_init();
+
+ /* machine dependent initialization */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ intrp_md_init();
+ else
+# endif
+ md_init();
+#else
+ intrp_md_init();
+#endif
+
+ /* initialize the loader subsystems (must be done _after_
+ classcache_init) */
+
+ if (!loader_init((u1 *) stackbottom))
+ throw_main_exception_exit();
+
+ if (!linker_init())
+ throw_main_exception_exit();
+
+ if (!native_init())
+ throw_main_exception_exit();
+
+ if (!exceptions_init())
+ throw_main_exception_exit();
+
+ if (!builtin_init())
+ throw_main_exception_exit();
+
+#if defined(USE_THREADS)
+ if (!threads_init((u1 *) stackbottom))
+ throw_main_exception_exit();
+#endif
+
+ /* That's important, otherwise we get into trouble, if the Runtime
+ static initializer is called before (circular dependency. This
+ is with classpath 0.09. Another important thing is, that this
+ has to happen after initThreads!!! */
+
+ if (!initialize_class(class_java_lang_System))
+ throw_main_exception_exit();
+
+ /* JNI init creates a Java object (this means running Java code) */
+
+ if (!jni_init())
+ throw_main_exception_exit();
+
+ /* initialize profiling */
+
+ if (!profile_init())
+ throw_main_exception_exit();
+
+#if defined(USE_THREADS)
+ /* finally, start the finalizer thread */
+
+ if (!finalizer_start_thread())
+ throw_main_exception_exit();
+
+ /* start the profile sampling thread */
+
+/* if (!profile_start_thread()) */
+/* throw_main_exception_exit(); */
+#endif
+
+ /* increment the number of VMs */
+
+ vms++;
+
+ /* initialization is done */
+
+ vm_initializing = false;
+
+ /* everything's ok */
+
+ return true;
+}
+
+
+/* vm_destroy ******************************************************************
+
+ Unloads a Java VM and reclaims its resources.
+
+*******************************************************************************/
+
+s4 vm_destroy(JavaVM *vm)
+{
+#if defined(USE_THREADS)
+#if defined(NATIVE_THREADS)
+ joinAllThreads();
+#else
+ killThread(currentThread);
+#endif
+#endif
+
+ /* everything's ok */
+
+ return 0;
+}
+
+
+/* vm_exit *********************************************************************
+
+ Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
+
+*******************************************************************************/
+
+void vm_exit(s4 status)
+{
+ methodinfo *m;
+
+ /* signal that we are exiting */
+
+ vm_exiting = true;
+
+ assert(class_java_lang_System);
+ assert(class_java_lang_System->state & CLASS_LOADED);
+
+#if defined(ENABLE_JVMTI)
+ set_jvmti_phase(JVMTI_PHASE_DEAD);
+ agentunload();
+#endif
+
+ if (!link_class(class_java_lang_System))
+ throw_main_exception_exit();
+
+ /* call java.lang.System.exit(I)V */
+
+ m = class_resolveclassmethod(class_java_lang_System,
+ utf_new_char("exit"),
+ utf_int__void,
+ class_java_lang_Object,
+ true);
+
+ if (!m)
+ throw_main_exception_exit();
+
+ /* call the exit function with passed exit status */
+
+ ASM_CALLJAVAFUNCTION(m, (void *) (ptrint) status, NULL, NULL, NULL);
+
+ /* this should never happen */
+
+ if (*exceptionptr)
+ throw_exception_exit();
+
+ throw_cacao_exception_exit(string_java_lang_InternalError,
+ "System.exit(I)V returned without exception");
+}
+
+
+/* vm_shutdown *****************************************************************
+
+ Terminates the system immediately without freeing memory explicitly
+ (to be used only for abnormal termination).
+
+*******************************************************************************/
+
+void vm_shutdown(s4 status)
+{
+#if defined(ENABLE_JVMTI)
+ agentunload();
+#endif
+
+ if (opt_verbose || getcompilingtime || opt_stat) {
+ log_text("CACAO terminated by shutdown");
+ dolog("Exit status: %d\n", (s4) status);
+ }
+
+ exit(status);
+}
+
+
+/* vm_exit_handler *************************************************************
+
+ The exit_handler function is called upon program termination.
+
+ ATTENTION: Don't free system resources here! Some threads may still
+ be running as this is called from VMRuntime.exit(). The OS does the
+ cleanup for us.
+
+*******************************************************************************/
+
+void vm_exit_handler(void)
+{
+#if !defined(NDEBUG)
+ if (showmethods)
+ class_showmethods(mainclass);
+
+ if (showconstantpool)
+ class_showconstantpool(mainclass);
+
+ if (showutf)
+ utf_show();
+
+ if (opt_prof)
+ profile_printstats();
+#endif
+
+#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
+ clear_thread_flags(); /* restores standard file descriptor
+ flags */
+#endif
+
+ if (opt_verbose || getcompilingtime || opt_stat) {
+ log_text("CACAO terminated");
+
+#if defined(ENABLE_STATISTICS)
+ if (opt_stat) {
+ print_stats();
+#ifdef TYPECHECK_STATISTICS
+ typecheck_print_statistics(get_logfile());
+#endif
+ }
+
+ mem_usagelog(1);
+
+ if (getcompilingtime)
+ print_times();
+#endif
+ }
+ /* vm_print_profile(stderr);*/
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
--- /dev/null
+/* src/vm/vm.h - basic JVM functions
+
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Contact: cacao@cacaojvm.org
+
+ Authors: Christian Thalinger
+
+ Changes:
+
+ $Id: finalizer.c 4357 2006-01-22 23:33:38Z twisti $
+
+*/
+
+
+#ifndef _VM_H
+#define _VM_H
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "native/jni.h"
+#include "vm/global.h"
+
+
+/* export global variables ****************************************************/
+
+extern _Jv_JNIEnv *_Jv_env;
+
+extern bool vm_initializing;
+extern bool vm_exiting;
+
+extern u1 *intrp_main_stack;
+
+extern void **stackbottom;
+
+extern char *mainstring;
+extern classinfo *mainclass;
+
+
+/* function prototypes ********************************************************/
+
+void usage(void);
+
+bool vm_create(JavaVMInitArgs *vm_args);
+s4 vm_destroy(JavaVM *vm);
+void vm_exit(s4 status);
+void vm_shutdown(s4 status);
+
+void vm_exit_handler(void);
+
+#endif /* _VM_H */
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */