* m4/jre-layout.m4 (AC_CHECK_WITH_JRE_LAYOUT): Renamed to
[cacao.git] / src / vm / vm.c
index 56d41a7ce0334c4d6812e7160a6fffc671f1cdf0..ea79bcc71946caef7fadd6fa1f59dd49e9eb0432 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/vm.c - VM startup and shutdown functions
 
-   Copyright (C) 1996-2005, 2006, 2007 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
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -22,8 +20,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: vm.c 8288 2007-08-10 15:12:00Z twisti $
-
 */
 
 
 #include <stdint.h>
 #include <stdlib.h>
 
-#if defined(WITH_JRE_LAYOUT)
-# include <libgen.h>
-# include <unistd.h>
-#endif
-
 #include "vm/types.h"
 
 #include "arch.h"
 
 #include "vm/jit/abi-asm.h"
 
+#include "mm/codememory.h"
 #include "mm/gc-common.h"
 #include "mm/memory.h"
 
 #include "native/jni.h"
 #include "native/llni.h"
+#include "native/localref.h"
 #include "native/native.h"
 
 #include "native/include/java_lang_Object.h"             /* required by j.l.C */
 
 #include "native/include/java_lang_Class.h"
 
-#include "native/include/java_lang_Byte.h"
-#include "native/include/java_lang_Character.h"
-#include "native/include/java_lang_Short.h"
-#include "native/include/java_lang_Integer.h"
-#include "native/include/java_lang_Boolean.h"
-#include "native/include/java_lang_Long.h"
-#include "native/include/java_lang_Float.h"
-#include "native/include/java_lang_Double.h"
-
 #include "native/vm/nativevm.h"
 
-#include "threads/threads-common.h"
+#include "threads/lock-common.h"
+#include "threads/mutex.h"
+#include "threads/threadlist.h"
+#include "threads/thread.h"
 
 #include "toolbox/logging.h"
 
+#include "vm/array.h"
+
+#if defined(ENABLE_ASSERTION)
+#include "vm/assertion.h"
+#endif
+
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/finalizer.h"
 #include "vm/global.h"
 #include "vm/initialize.h"
+#include "vm/package.h"
 #include "vm/primitive.h"
 #include "vm/properties.h"
 #include "vm/signallocal.h"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
 
-#include "vm/jit/jit.h"
-#include "vm/jit/md.h"
+#include "vm/jit/argument.h"
 #include "vm/jit/asmpart.h"
+#include "vm/jit/code.h"
+
+#if defined(ENABLE_DISASSEMBLER)
+# include "vm/jit/disass.h"
+#endif
+
+#include "vm/jit/jit.h"
+#include "vm/jit/methodtree.h"
 
 #if defined(ENABLE_PROFILING)
 # include "vm/jit/optimizing/profile.h"
 
 #include "vm/jit/optimizing/recompile.h"
 
+#if defined(ENABLE_PYTHON)
+# include "vm/jit/python.h"
+#endif
+
+#include "vm/jit/trap.h"
+
 #include "vmcore/classcache.h"
 #include "vmcore/options.h"
 #include "vmcore/statistics.h"
 #include "vmcore/suck.h"
+#include "vmcore/system.h"
 
 #if defined(ENABLE_JVMTI)
 # include "native/jvmti/cacaodbg.h"
@@ -124,24 +132,12 @@ _Jv_JNIEnv *_Jv_env;                    /* pointer to native method interface */
 s4 vms = 0;                             /* number of VMs created              */
 
 bool vm_initializing = false;
-bool vm_exiting = false;
-
-char      *cacao_prefix = NULL;
-char      *cacao_libjvm = NULL;
-char      *classpath_libdir = NULL;
-
-char      *_Jv_bootclasspath;           /* contains the boot classpath        */
-char      *_Jv_classpath;               /* contains the classpath             */
-char      *_Jv_java_library_path;
+bool vm_created      = false;
+bool vm_exiting      = false;
 
 char      *mainstring = NULL;
 classinfo *mainclass = NULL;
 
-char *specificmethodname = NULL;
-char *specificsignature = NULL;
-
-bool startit = true;
-
 #if defined(ENABLE_INTRP)
 u1 *intrp_main_stack = NULL;
 #endif
@@ -151,7 +147,7 @@ u1 *intrp_main_stack = NULL;
 
 #define HEAP_MAXSIZE      128 * 1024 * 1024 /* default 128MB                  */
 #define HEAP_STARTSIZE      2 * 1024 * 1024 /* default 2MB                    */
-#define STACK_SIZE                64 * 1024 /* default 64kB                   */
+#define STACK_SIZE               128 * 1024 /* default 64kB                   */
 
 
 /* define command line options ************************************************/
@@ -181,6 +177,9 @@ enum {
 
        OPT_EA,
        OPT_DA,
+       OPT_EA_NOARG,
+       OPT_DA_NOARG,
+    
 
        OPT_ESA,
        OPT_DSA,
@@ -247,19 +246,6 @@ enum {
        OPT_LSRA,
 #endif
 
-#if defined(ENABLE_INLINING)
-       OPT_INLINING,
-#if !defined(NDEBUG)
-       OPT_INLINE_LOG,
-#endif
-#if defined(ENABLE_INLINING_DEBUG)
-       OPT_INLINE_DEBUG_ALL,
-       OPT_INLINE_DEBUG_END,
-       OPT_INLINE_DEBUG_MIN,
-       OPT_INLINE_DEBUG_MAX,
-#endif /* defined(ENABLE_INLINING_DEBUG) */
-#endif /* defined(ENABLE_INLINING) */
-
 #if defined(ENABLE_INTRP)
        /* interpreter options */
 
@@ -314,12 +300,16 @@ opt_struct opts[] = {
        { "?",                 false, OPT_HELP },
        { "X",                 false, OPT_X },
        { "XX:",               true,  OPT_XX },
-       { "XX",                false, OPT_XX },
 
        { "ea:",               true,  OPT_EA },
        { "da:",               true,  OPT_DA },
-       { "ea",                false, OPT_EA },
-       { "da",                false, OPT_DA },
+       { "ea",                false, OPT_EA_NOARG },
+       { "da",                false, OPT_DA_NOARG },
+
+       { "enableassertions:",  true,  OPT_EA },
+       { "disableassertions:", true,  OPT_DA },
+       { "enableassertions",   false, OPT_EA_NOARG },
+       { "disableassertions",  false, OPT_DA_NOARG },
 
        { "esa",                     false, OPT_ESA },
        { "enablesystemassertions",  false, OPT_ESA },
@@ -329,6 +319,7 @@ opt_struct opts[] = {
        { "noasyncgc",         false, OPT_IGNORE },
 #if defined(ENABLE_VERIFIER)
        { "noverify",          false, OPT_NOVERIFY },
+       { "Xverify:none",      false, OPT_NOVERIFY },
 #endif
        { "v",                 false, OPT_VERBOSE1 },
        { "verbose:",          true,  OPT_VERBOSE },
@@ -358,9 +349,12 @@ opt_struct opts[] = {
 #if defined(ENABLE_IFCONV)
        { "ifconv",            false, OPT_IFCONV },
 #endif
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
+#if defined(ENABLE_LSRA)
        { "lsra",              false, OPT_LSRA },
 #endif
+#if  defined(ENABLE_SSA)
+       { "lsra",              true, OPT_LSRA },
+#endif
 
 #if defined(ENABLE_INTRP)
        /* interpreter options */
@@ -405,21 +399,6 @@ opt_struct opts[] = {
        { "Xprof",             false, OPT_PROF },
 #endif
 
-       /* inlining options */
-
-#if defined(ENABLE_INLINING)
-#if defined(ENABLE_INLINING_DEBUG)
-       { "ia",                false, OPT_INLINE_DEBUG_ALL },
-       { "ii",                true,  OPT_INLINE_DEBUG_MIN },
-       { "im",                true,  OPT_INLINE_DEBUG_MAX },
-       { "ie",                true,  OPT_INLINE_DEBUG_END },
-#endif /* defined(ENABLE_INLINING_DEBUG) */
-#if !defined(NDEBUG)
-       { "il",                false, OPT_INLINE_LOG },
-#endif
-       { "i",                 false, OPT_INLINING },
-#endif /* defined(ENABLE_INLINING) */
-
        /* keep these at the end of the list */
 
 #if !defined(NDEBUG)
@@ -532,12 +511,12 @@ static void Xusage(void)
 }   
 
 
+#if 0
 static void XXusage(void)
 {
        puts("    -v                       write state-information");
 #if !defined(NDEBUG)
-       puts("    -verbose[:jit|threads]");
-       puts("                             enable specific verbose output");
+       puts("    -verbose:jit             enable specific verbose output");
        puts("    -debug-color             colored output for ANSI terms");
 #endif
 #ifdef TYPECHECK_VERBOSE
@@ -574,24 +553,9 @@ static void XXusage(void)
 #if defined(ENABLE_DISASSEMBLER)
        puts("      (a)ssembler            disassembled listing");
        puts("      n(o)ps                 show NOPs in disassembler output");
-       puts("      (e)xceptionstubs       disassembled exception stubs (only with -sa)");
-       puts("      (n)ative               disassembled native stubs");
 #endif
        puts("      (d)atasegment          data segment listing");
 
-#if defined(ENABLE_INLINING)
-       puts("    -i                       activate inlining");
-#if !defined(NDEBUG)
-       puts("    -il                      log inlining");
-#endif
-#if defined(ENABLE_INLINING_DEBUG)
-       puts("    -ia                      use inlining for all methods");
-       puts("    -ii <size>               set minimum size for inlined result");
-       puts("    -im <size>               set maximum size for inlined result");
-       puts("    -ie <number>             stop inlining after the given number of roots");
-#endif /* defined(ENABLE_INLINING_DEBUG) */
-#endif /* defined(ENABLE_INLINING) */
-
 #if defined(ENABLE_IFCONV)
        puts("    -ifconv                  use if-conversion");
 #endif
@@ -599,7 +563,9 @@ static void XXusage(void)
        puts("    -lsra                    use linear scan register allocation");
 #endif
 #if defined(ENABLE_SSA)
-       puts("    -lsra                    use linear scan register allocation (with SSA)");
+       puts("    -lsra:...                use linear scan register allocation (with SSA)");
+       puts("       (d)ead code elimination");
+       puts("       (c)opy propagation");
 #endif
 #if defined(ENABLE_DEBUG_FILTER)
        puts("    -XXfi <regex>            begin of dynamic scope for verbosecall filter");
@@ -610,6 +576,7 @@ static void XXusage(void)
 
        exit(1);
 }
+#endif
 
 
 /* version *********************************************************************
@@ -621,22 +588,12 @@ static void XXusage(void)
 static void version(bool opt_exit)
 {
        puts("java version \""JAVA_VERSION"\"");
-       puts("CACAO version "VERSION"");
-
-       puts("Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,");
-       puts("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,");
-       puts("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,");
-       puts("J. Wenninger, Institut f. Computersprachen - TU Wien\n");
+       puts("CACAO version "VERSION"\n");
 
-       puts("This program is free software; you can redistribute it and/or");
-       puts("modify it under the terms of the GNU General Public License as");
-       puts("published by the Free Software Foundation; either version 2, or (at");
-       puts("your option) any later version.\n");
-
-       puts("This program is distributed in the hope that it will be useful, but");
-       puts("WITHOUT ANY WARRANTY; without even the implied warranty of");
-       puts("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU");
-       puts("General Public License for more details.");
+       puts("Copyright (C) 1996-2005, 2006, 2007, 2008");
+       puts("CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO");
+       puts("This is free software; see the source for copying conditions.  There is NO");
+       puts("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.");
 
        /* exit normally, if requested */
 
@@ -662,7 +619,7 @@ static void fullversion(void)
 }
 
 
-void vm_printconfig(void)
+static void vm_printconfig(void)
 {
        puts("Configure/Build options:\n");
        puts("  ./configure: "VERSION_CONFIGURE_ARGS"");
@@ -677,21 +634,35 @@ void vm_printconfig(void)
        printf("  maximum heap size              : %d\n", HEAP_MAXSIZE);
        printf("  initial heap size              : %d\n", HEAP_STARTSIZE);
        printf("  stack size                     : %d\n", STACK_SIZE);
-#if defined(WITH_CLASSPATH_GNU)
-       puts("  java.boot.class.path           : "CACAO_VM_ZIP":"CLASSPATH_CLASSES"");
+
+#if defined(ENABLE_JRE_LAYOUT)
+       /* When we're building with JRE-layout, the default paths are the
+          same as the runtime paths. */
 #else
-       puts("  java.boot.class.path           : "CLASSPATH_CLASSES"");
+# if defined(WITH_CLASSPATH_GNU)
+       puts("  gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR);
+       puts("  java.boot.class.path           : "CACAO_VM_ZIP":"CLASSPATH_CLASSES"");
+# elif defined(WITH_CLASSPATH_SUN)
+       puts("  sun.boot.library.path          : "CLASSPATH_LIBDIR);
+       puts("  java.boot.class.path           : "CLASSPATH_CLASSES);
+# endif
 #endif
-       puts("  gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR"/classpath\n");
+
+       puts("");
 
        puts("Runtime variables:\n");
        printf("  maximum heap size              : %d\n", opt_heapmaxsize);
        printf("  initial heap size              : %d\n", opt_heapstartsize);
        printf("  stack size                     : %d\n", opt_stacksize);
-       printf("  libjvm.so                      : %s\n", cacao_libjvm);
-       printf("  java.boot.class.path           : %s\n", _Jv_bootclasspath);
-       printf("  gnu.classpath.boot.library.path: %s\n", classpath_libdir);
-       printf("  java.class.path                : %s\n", _Jv_classpath);
+
+#if defined(WITH_CLASSPATH_GNU)
+       printf("  gnu.classpath.boot.library.path: %s\n", properties_get("gnu.classpath.boot.library.path"));
+#elif defined(WITH_CLASSPATH_SUN)
+       printf("  sun.boot.library.path          : %s\n", properties_get("sun.boot.library.path"));
+#endif
+
+       printf("  java.boot.class.path           : %s\n", properties_get("java.boot.class.path"));
+       printf("  java.class.path                : %s\n", properties_get("java.class.path"));
 }
 
 
@@ -750,13 +721,6 @@ bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args)
        if (!vm_create(_vm_args))
                goto error;
 
-#if defined(ENABLE_JNI)
-       /* setup the local ref table (must be created after vm_create) */
-
-       if (!jni_init_localref_table())
-               goto error;
-#endif
-
        /* now return the values */
 
        *p_vm  = (JavaVM *) vm;
@@ -782,10 +746,12 @@ bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args)
 
 bool vm_create(JavaVMInitArgs *vm_args)
 {
-       char *cp;
-       s4    len;
-       s4    opt;
-       s4    i, j;
+       int   len;
+       char *p;
+       char *boot_class_path;
+       char *class_path;
+       int   opt;
+       int   i, j;
        bool  opt_version;
        bool  opt_exit;
 
@@ -796,220 +762,70 @@ bool vm_create(JavaVMInitArgs *vm_args)
        jdwp = agentbypath = false;
 #endif
 
-#if defined(ENABLE_VMLOG)
-       vmlog_cacao_init(vm_args);
-#endif
-
-       /* check the JNI version requested */
+#if defined(ENABLE_JNI)
+       /* 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:
+       if (!jni_version_check(vm_args->version))
                return false;
-       }
+#endif
 
-       /* we only support 1 JVM instance */
+       /* We only support 1 JVM instance. */
 
        if (vms > 0)
                return false;
 
+       /* Install the exit handler. */
+
        if (atexit(vm_exit_handler))
                vm_abort("atexit failed: %s\n", strerror(errno));
 
-       if (opt_verbose)
-               log_text("CACAO started -------------------------------------------------------");
+       /* Set some options. */
 
-       /* We need to check if the actual size of a java.lang.Class object
-          is smaller or equal than the assumption made in
-          src/vmcore/class.h. */
-
-       if (sizeof(java_lang_Class) > sizeof(dummy_java_lang_Class))
-               vm_abort("vm_create: java_lang_Class structure is bigger than classinfo.object (%d > %d)", sizeof(java_lang_Class), sizeof(dummy_java_lang_Class));
-
-       /* set the VM starttime */
-
-       _Jv_jvm->starttime = builtin_currenttimemillis();
-
-       /* get stuff from the environment *****************************************/
-
-#if defined(WITH_JRE_LAYOUT)
-       /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
-
-       cacao_prefix = MNEW(char, 4096);
-
-       if (readlink("/proc/self/exe", cacao_prefix, 4095) == -1)
-               vm_abort("readlink failed: %s\n", strerror(errno));
-
-       /* get the path of the current executable */
-
-       cacao_prefix = dirname(cacao_prefix);
-
-       if ((strlen(cacao_prefix) + strlen("/..") + strlen("0")) > 4096)
-               vm_abort("libjvm name to long for buffer\n");
-
-       /* concatenate the library name */
-
-       strcat(cacao_prefix, "/..");
-
-       /* now set path to libjvm.so */
+       opt_version       = false;
+       opt_exit          = false;
 
-       len = strlen(cacao_prefix) + strlen("/lib/libjvm") + strlen("0");
+       opt_noieee        = false;
 
-       cacao_libjvm = MNEW(char, len);
-       strcpy(cacao_libjvm, cacao_prefix);
-       strcat(cacao_libjvm, "/lib/libjvm");
+       opt_heapmaxsize   = HEAP_MAXSIZE;
+       opt_heapstartsize = HEAP_STARTSIZE;
+       opt_stacksize     = STACK_SIZE;
 
-       /* and finally set the path to GNU Classpath libraries */
+       /* Initialize the properties list before command-line handling.
+          Otherwise -XX:+PrintConfig crashes. */
 
-       len = strlen(cacao_prefix) + strlen("/lib/classpath") + strlen("0");
+       properties_init();
 
-       classpath_libdir = MNEW(char, len);
-       strcpy(classpath_libdir, cacao_prefix);
-       strcat(classpath_libdir, "/lib/classpath");
-#else
-       cacao_prefix     = CACAO_PREFIX;
-       cacao_libjvm     = CACAO_LIBDIR"/libjvm";
+       /* First of all, parse the -XX options. */
 
-# if defined(WITH_CLASSPATH_GNU)
-       classpath_libdir = CLASSPATH_LIBDIR"/classpath";
-# else
-       classpath_libdir = CLASSPATH_LIBDIR;
-# endif
+#if defined(ENABLE_VMLOG)
+       vmlog_cacao_init_options();
 #endif
 
-       /* set the bootclasspath */
-
-       cp = getenv("BOOTCLASSPATH");
-
-       if (cp != NULL) {
-               _Jv_bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
-               strcpy(_Jv_bootclasspath, cp);
-       }
-       else {
-#if defined(WITH_JRE_LAYOUT)
-               len =
-# if defined(WITH_CLASSPATH_GNU)
-                       strlen(cacao_prefix) +
-                       strlen("/share/cacao/vm.zip") +
-                       strlen(":") +
-# endif
-                       strlen(cacao_prefix) +
-                       strlen("/share/classpath/glibj.zip") +
-                       strlen("0");
-
-               _Jv_bootclasspath = MNEW(char, len);
-# if defined(WITH_CLASSPATH_GNU)
-               strcat(_Jv_bootclasspath, cacao_prefix);
-               strcat(_Jv_bootclasspath, "/share/cacao/vm.zip");
-               strcat(_Jv_bootclasspath, ":");
-# endif
-               strcat(_Jv_bootclasspath, cacao_prefix);
-               strcat(_Jv_bootclasspath, "/share/classpath/glibj.zip");
-#else
-# if defined(WITH_CLASSPATH_GNU)
-               len =
-                       strlen(CACAO_VM_ZIP) +
-                       strlen(":") +
-                       strlen(CLASSPATH_CLASSES) +
-                       strlen("0");
-# elif defined(WITH_CLASSPATH_SUN)
-               /* This is the bootclasspath taken from HotSpot (see
-                  hotspot/src/share/vm/runtime/os.cpp
-                  (os::set_boot_path)). */
-
-               len =
-                       strlen(CLASSPATH_PREFIX"/lib/resources.jar:"
-                                  CLASSPATH_PREFIX"/lib/rt.jar:"
-                                  CLASSPATH_PREFIX"/lib/sunrsasign.jar:"
-                                  CLASSPATH_PREFIX"/lib/jsse.jar:"
-                                  CLASSPATH_PREFIX"/lib/jce.jar:"
-                                  CLASSPATH_PREFIX"/lib/charsets.jar:"
-                                  CLASSPATH_PREFIX"/classes") +
-                       strlen("0");
-# elif defined(WITH_CLASSPATH_CLDC1_1)
-               len =
-                       strlen(CLASSPATH_CLASSES) +
-                       strlen("0");
-# else
-#  error unknown classpath configuration
-# endif
-
-               _Jv_bootclasspath = MNEW(char, len);
+       options_xx(vm_args);
 
-# if defined(WITH_CLASSPATH_GNU)
-               strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
-               strcat(_Jv_bootclasspath, ":");
-               strcat(_Jv_bootclasspath, CLASSPATH_CLASSES);
-# elif defined(WITH_CLASSPATH_SUN)
-               strcpy(_Jv_bootclasspath,
-                          CLASSPATH_PREFIX"/lib/resources.jar:"
-                          CLASSPATH_PREFIX"/lib/rt.jar:"
-                          CLASSPATH_PREFIX"/lib/sunrsasign.jar:"
-                          CLASSPATH_PREFIX"/lib/jsse.jar:"
-                          CLASSPATH_PREFIX"/lib/jce.jar:"
-                          CLASSPATH_PREFIX"/lib/charsets.jar:"
-                          CLASSPATH_PREFIX"/classes");
-# elif defined(WITH_CLASSPATH_CLDC1_1)
-               strcat(_Jv_bootclasspath, CLASSPATH_CLASSES);
-# else
-#  error unknown classpath configuration
-# endif
+#if defined(ENABLE_VMLOG)
+       vmlog_cacao_init();
 #endif
-       }
-
-       /* set the classpath */
-
-       cp = getenv("CLASSPATH");
-
-       if (cp != NULL) {
-               _Jv_classpath = MNEW(char, strlen(cp) + strlen("0"));
-               strcat(_Jv_classpath, cp);
-       }
-       else {
-               _Jv_classpath = MNEW(char, strlen(".") + strlen("0"));
-               strcpy(_Jv_classpath, ".");
-       }
-
-       /* Get and set java.library.path. */
 
-       _Jv_java_library_path = getenv("LD_LIBRARY_PATH");
-
-       if (_Jv_java_library_path == NULL)
-               _Jv_java_library_path = "";
-
-       /* interpret the options **************************************************/
-
-       opt_version       = false;
-       opt_exit          = false;
+       /* We need to check if the actual size of a java.lang.Class object
+          is smaller or equal than the assumption made in
+          src/vmcore/class.h. */
 
-       opt_noieee        = false;
+       if (sizeof(java_lang_Class) > sizeof(dummy_java_lang_Class))
+               vm_abort("vm_create: java_lang_Class structure is bigger than classinfo.object (%d > %d)", sizeof(java_lang_Class), sizeof(dummy_java_lang_Class));
 
-       opt_heapmaxsize   = HEAP_MAXSIZE;
-       opt_heapstartsize = HEAP_STARTSIZE;
-       opt_stacksize     = STACK_SIZE;
+       /* set the VM starttime */
 
+       _Jv_jvm->starttime = builtin_currenttimemillis();
 
 #if defined(ENABLE_JVMTI)
        /* initialize JVMTI related  **********************************************/
        jvmti = false;
 #endif
 
-       /* Initialize and fill properties before command-line handling. */
+       /* Fill the properties before command-line handling. */
 
-       if (!properties_init())
-               vm_abort("vm_create: properties_init failed");
-
-       /* Set the classpath properties. */
-
-#if defined(ENABLE_JAVASE)
-       properties_add("java.boot.class.path", _Jv_bootclasspath);
-       properties_add("sun.boot.class.path", _Jv_bootclasspath);
-       properties_add("java.class.path", _Jv_classpath);
-#endif
+       properties_set();
 
        /* iterate over all passed options */
 
@@ -1041,15 +857,20 @@ bool vm_create(JavaVMInitArgs *vm_args)
                        break;
 
                case OPT_CLASSPATH:
-                       /* forget old classpath and set the argument as new classpath */
-                       MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
+                       /* Forget old classpath and set the argument as new
+                          classpath. */
 
-                       _Jv_classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
-                       strcpy(_Jv_classpath, opt_arg);
+                       class_path = properties_get("java.class.path");
+
+                       p = MNEW(char, strlen(opt_arg) + strlen("0"));
+
+                       strcpy(p, opt_arg);
 
 #if defined(ENABLE_JAVASE)
-                       properties_add("java.class.path", _Jv_classpath);
+                       properties_add("java.class.path", p);
 #endif
+
+                       MFREE(class_path, char, strlen(class_path));
                        break;
 
                case OPT_D:
@@ -1072,78 +893,79 @@ bool vm_create(JavaVMInitArgs *vm_args)
                        /* Forget default bootclasspath and set the argument as
                           new boot classpath. */
 
-                       MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
+                       boot_class_path = properties_get("sun.boot.class.path");
 
-                       _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
-                       strcpy(_Jv_bootclasspath, opt_arg);
+                       p = MNEW(char, strlen(opt_arg) + strlen("0"));
 
-#if defined(ENABLE_JAVASE)
-                       properties_add("java.boot.class.path", _Jv_bootclasspath);
-                       properties_add("sun.boot.class.path", _Jv_bootclasspath);
-#endif
+                       strcpy(p, opt_arg);
+
+                       properties_add("sun.boot.class.path", p);
+                       properties_add("java.boot.class.path", p);
+
+                       MFREE(boot_class_path, char, strlen(boot_class_path));
                        break;
 
                case OPT_BOOTCLASSPATH_A:
-                       /* append to end of bootclasspath */
+                       /* Append to bootclasspath. */
 
-                       len = strlen(_Jv_bootclasspath);
+                       boot_class_path = properties_get("sun.boot.class.path");
 
-                       _Jv_bootclasspath = MREALLOC(_Jv_bootclasspath,
-                                                                                char,
-                                                                                len + strlen("0"),
-                                                                                len + strlen(":") +
-                                                                                strlen(opt_arg) + strlen("0"));
+                       len = strlen(boot_class_path);
 
-                       strcat(_Jv_bootclasspath, ":");
-                       strcat(_Jv_bootclasspath, opt_arg);
+                       p = MREALLOC(boot_class_path,
+                                                char,
+                                                len + strlen("0"),
+                                                len + strlen(":") +
+                                                strlen(opt_arg) + strlen("0"));
 
-#if defined(ENABLE_JAVASE)
-                       properties_add("java.boot.class.path", _Jv_bootclasspath);
-                       properties_add("sun.boot.class.path", _Jv_bootclasspath);
-#endif
+                       strcat(p, ":");
+                       strcat(p, opt_arg);
+
+                       properties_add("sun.boot.class.path", p);
+                       properties_add("java.boot.class.path", p);
                        break;
 
                case OPT_BOOTCLASSPATH_P:
-                       /* prepend in front of bootclasspath */
+                       /* Prepend to bootclasspath. */
 
-                       cp = _Jv_bootclasspath;
-                       len = strlen(cp);
+                       boot_class_path = properties_get("sun.boot.class.path");
 
-                       _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
-                                                                        len + strlen("0"));
+                       len = strlen(boot_class_path);
 
-                       strcpy(_Jv_bootclasspath, opt_arg);
-                       strcat(_Jv_bootclasspath, ":");
-                       strcat(_Jv_bootclasspath, cp);
+                       p = MNEW(char, strlen(opt_arg) + strlen(":") + len + strlen("0"));
 
-                       MFREE(cp, char, len);
+                       strcpy(p, opt_arg);
+                       strcat(p, ":");
+                       strcat(p, boot_class_path);
 
-#if defined(ENABLE_JAVASE)
-                       properties_add("java.boot.class.path", _Jv_bootclasspath);
-                       properties_add("sun.boot.class.path", _Jv_bootclasspath);
-#endif
+                       properties_add("sun.boot.class.path", p);
+                       properties_add("java.boot.class.path", p);
+
+                       MFREE(boot_class_path, char, len);
                        break;
 
                case OPT_BOOTCLASSPATH_C:
-                       /* use as Java core library, but prepend VM interface classes */
+                       /* Use as Java core library, but prepend VM interface
+                          classes. */
 
-                       MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
+                       boot_class_path = properties_get("sun.boot.class.path");
 
-                       len = strlen(CACAO_VM_ZIP) +
+                       len =
+                               strlen(CACAO_VM_ZIP) +
                                strlen(":") +
                                strlen(opt_arg) +
                                strlen("0");
 
-                       _Jv_bootclasspath = MNEW(char, len);
+                       p = MNEW(char, len);
 
-                       strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
-                       strcat(_Jv_bootclasspath, ":");
-                       strcat(_Jv_bootclasspath, opt_arg);
+                       strcpy(p, CACAO_VM_ZIP);
+                       strcat(p, ":");
+                       strcat(p, opt_arg);
 
-#if defined(ENABLE_JAVASE)
-                       properties_add("java.boot.class.path", _Jv_bootclasspath);
-                       properties_add("sun.boot.class.path", _Jv_bootclasspath);
-#endif
+                       properties_add("sun.boot.class.path", p);
+                       properties_add("java.boot.class.path", p);
+
+                       MFREE(boot_class_path, char, strlen(boot_class_path));
                        break;
 
 #if defined(ENABLE_JVMTI)
@@ -1229,9 +1051,6 @@ bool vm_create(JavaVMInitArgs *vm_args)
                                initverbose = true;
                                compileverbose = true;
                        }
-                       else if (strcmp("threads", opt_arg) == 0) {
-                               opt_verbosethreads = true;
-                       }
 #endif
                        else {
                                printf("Unknown -verbose option: %s\n", opt_arg);
@@ -1354,14 +1173,6 @@ bool vm_create(JavaVMInitArgs *vm_args)
                                case 'o':
                                        opt_shownops = true;
                                        break;
-
-                               case 'e':
-                                       opt_showexceptionstubs = true;
-                                       break;
-
-                               case 'n':
-                                       opt_shownativestub = true;
-                                       break;
 #endif
 
                                case 'd':
@@ -1380,41 +1191,37 @@ bool vm_create(JavaVMInitArgs *vm_args)
                        break;
 #endif
 
-#if defined(ENABLE_INLINING)
-#if defined(ENABLE_INLINING_DEBUG)
-               case OPT_INLINE_DEBUG_ALL:
-                       opt_inline_debug_all = true;
-                       break;
-               case OPT_INLINE_DEBUG_END:
-                       opt_inline_debug_end_counter = atoi(opt_arg);
-                       break;
-               case OPT_INLINE_DEBUG_MIN:
-                       opt_inline_debug_min_size = atoi(opt_arg);
-                       break;
-               case OPT_INLINE_DEBUG_MAX:
-                       opt_inline_debug_max_size = atoi(opt_arg);
-                       break;
-#endif /* defined(ENABLE_INLINING_DEBUG) */
-#if !defined(NDEBUG)
-               case OPT_INLINE_LOG:
-                       opt_inline_debug_log = true;
-                       break;
-#endif /* !defined(NDEBUG) */
-
-               case OPT_INLINING:
-                       opt_inlining = true;
-                       break;
-#endif /* defined(ENABLE_INLINING) */
-
 #if defined(ENABLE_IFCONV)
                case OPT_IFCONV:
                        opt_ifconv = true;
                        break;
 #endif
 
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
+#if defined(ENABLE_LSRA)
+               case OPT_LSRA:
+                       opt_lsra = true;
+                       break;
+#endif
+#if  defined(ENABLE_SSA)
                case OPT_LSRA:
                        opt_lsra = true;
+                       for (i = 0; i < strlen(opt_arg); i++) {         
+                               switch (opt_arg[i]) {
+                               case 'c':
+                                       opt_ssa_cp = true;
+                                       break;
+
+                               case 'd':
+                                       opt_ssa_dce = true;
+                                       break;
+
+                               case ':':
+                                       break;
+
+                               default:
+                                       usage();
+                               }
+                       }
                        break;
 #endif
 
@@ -1427,23 +1234,43 @@ bool vm_create(JavaVMInitArgs *vm_args)
                        break;
 
                case OPT_XX:
-                       options_xx(opt_arg);
+                       /* Already parsed. */
                        break;
 
                case OPT_EA:
-                       /* currently ignored */
+#if defined(ENABLE_ASSERTION)
+                       assertion_ea_da(opt_arg, true);
+#endif
                        break;
 
                case OPT_DA:
-                       /* currently ignored */
+#if defined(ENABLE_ASSERTION)
+                       assertion_ea_da(opt_arg, false);
+#endif
+                       break;
+
+               case OPT_EA_NOARG:
+#if defined(ENABLE_ASSERTION)
+                       assertion_user_enabled = true;
+#endif
+                       break;
+
+               case OPT_DA_NOARG:
+#if defined(ENABLE_ASSERTION)
+                       assertion_user_enabled = false;
+#endif
                        break;
 
                case OPT_ESA:
-                       _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = true;
+#if defined(ENABLE_ASSERTION)
+                       assertion_system_enabled = true;
+#endif
                        break;
 
                case OPT_DSA:
-                       _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = false;
+#if defined(ENABLE_ASSERTION)
+                       assertion_system_enabled = false;
+#endif
                        break;
 
 #if defined(ENABLE_PROFILING)
@@ -1546,16 +1373,16 @@ bool vm_create(JavaVMInitArgs *vm_args)
                if (opt_jar == true) {
                        /* free old classpath */
 
-                       MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
+/*                     MFREE(_Jv_classpath, char, strlen(_Jv_classpath)); */
 
                        /* put jarfile into classpath */
 
-                       _Jv_classpath = MNEW(char, strlen(mainstring) + strlen("0"));
+                       p = MNEW(char, strlen(mainstring) + strlen("0"));
 
-                       strcpy(_Jv_classpath, mainstring);
+                       strcpy(p, mainstring);
 
 #if defined(ENABLE_JAVASE)
-                       properties_add("java.class.path", _Jv_classpath);
+                       properties_add("java.class.path", p);
 #endif
                }
                else {
@@ -1588,10 +1415,16 @@ bool vm_create(JavaVMInitArgs *vm_args)
        gc_init(opt_heapmaxsize, opt_heapstartsize);
 
 #if defined(ENABLE_THREADS)
+       /* BEFORE: threads_preinit */
+
+       threadlist_init();
+
        /* AFTER: gc_init (directly after, as this initializes the
           stopworldlock lock */
 
        threads_preinit();
+       lock_init();
+       critical_init();
 #endif
 
        /* install architecture dependent signal handlers */
@@ -1615,8 +1448,7 @@ bool vm_create(JavaVMInitArgs *vm_args)
 
        /* AFTER: threads_preinit */
 
-       if (!utf8_init())
-               vm_abort("vm_create: utf8_init failed");
+       utf8_init();
 
        /* AFTER: thread_preinit */
 
@@ -1635,7 +1467,8 @@ bool vm_create(JavaVMInitArgs *vm_args)
 
        /* AFTER: utf8_init */
 
-       suck_add(_Jv_bootclasspath);
+       boot_class_path = properties_get("sun.boot.class.path");
+       suck_add(boot_class_path);
 
        /* initialize the classcache hashtable stuff: lock, hashtable
           (must be done _after_ threads_preinit) */
@@ -1643,11 +1476,10 @@ bool vm_create(JavaVMInitArgs *vm_args)
        if (!classcache_init())
                vm_abort("vm_create: classcache_init failed");
 
-       /* initialize the memory subsystem (must be done _after_
-          threads_preinit) */
+       /* Initialize the code memory management. */
+       /* AFTER: threads_preinit */
 
-       if (!memory_init())
-               vm_abort("vm_create: memory_init failed");
+       codememory_init();
 
        /* initialize the finalizer stuff (must be done _after_
           threads_preinit) */
@@ -1655,44 +1487,40 @@ bool vm_create(JavaVMInitArgs *vm_args)
        if (!finalizer_init())
                vm_abort("vm_create: finalizer_init failed");
 
-       /* initialize the codegen subsystems */
+       /* Initialize the JIT compiler. */
+
+       jit_init();
+       code_init();
+       methodtree_init();
 
-       codegen_init();
+#if defined(ENABLE_PYTHON)
+       pythonpass_init();
+#endif
 
-       /* initializes jit compiler */
+       /* BEFORE: loader_preinit */
 
-       jit_init();
+       package_init();
 
-       /* machine dependent initialization */
+       /* AFTER: utf8_init, classcache_init */
 
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               intrp_md_init();
-       else
-# endif
-               md_init();
-#else
-       intrp_md_init();
-#endif
+       loader_preinit();
+       linker_preinit();
 
-       /* initialize the loader subsystems (must be done _after_
-       classcache_init) */
+       /* AFTER: loader_preinit, linker_preinit */
 
-       if (!loader_init())
-               vm_abort("vm_create: loader_init failed");
+       primitive_init();
 
-       /* Link some important VM classes. */
-       /* AFTER: utf8_init */
+       loader_init();
+       linker_init();
 
-       if (!linker_init())
-               vm_abort("vm_create: linker_init failed");
+       /* AFTER: loader_init, linker_init */
 
-       if (!primitive_init())
-               vm_abort("vm_create: primitive_init failed");
+       primitive_postinit();
+       method_init();
 
-       if (!exceptions_init())
-               vm_abort("vm_create: exceptions_init failed");
+#if defined(ENABLE_JIT)
+       trap_init();
+#endif
 
        if (!builtin_init())
                vm_abort("vm_create: builtin_init failed");
@@ -1706,8 +1534,7 @@ bool vm_create(JavaVMInitArgs *vm_args)
        /* Register the native methods implemented in the VM. */
        /* BEFORE: threads_init */
 
-       if (!nativevm_preinit())
-               vm_abort("vm_create: nativevm_preinit failed");
+       nativevm_preinit();
 
 #if defined(ENABLE_JNI)
        /* Initialize the JNI subsystem (must be done _before_
@@ -1718,16 +1545,27 @@ bool vm_create(JavaVMInitArgs *vm_args)
                vm_abort("vm_create: jni_init failed");
 #endif
 
+#if defined(ENABLE_JNI) || defined(ENABLE_HANDLES)
+       /* Initialize the local reference table for the main thread. */
+       /* BEFORE: threads_init */
+
+       if (!localref_table_init())
+               vm_abort("vm_create: localref_table_init failed");
+#endif
+
+       /* Iinitialize some important system classes. */
+       /* BEFORE: threads_init */
+
+       initialize_init();
+
 #if defined(ENABLE_THREADS)
-       if (!threads_init())
-               vm_abort("vm_create: threads_init failed");
+       threads_init();
 #endif
 
        /* Initialize the native VM subsystem. */
        /* AFTER: threads_init (at least for SUN's classes) */
 
-       if (!nativevm_init())
-               vm_abort("vm_create: nativevm_init failed");
+       nativevm_init();
 
 #if defined(ENABLE_PROFILING)
        /* initialize profiling */
@@ -1780,20 +1618,31 @@ bool vm_create(JavaVMInitArgs *vm_args)
 #endif
 
 #if defined(ENABLE_JVMTI)
+# if defined(ENABLE_GC_CACAO)
+       /* XXX this will not work with the new indirection cells for classloaders!!! */
+       assert(0);
+# endif
        if (jvmti) {
                /* add agent library to native library hashtable */
                native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
        }
 #endif
 
-       /* increment the number of VMs */
+       /* Increment the number of VMs. */
 
        vms++;
 
-       /* initialization is done */
+       /* Initialization is done, VM is created.. */
 
+       vm_created      = true;
        vm_initializing = false;
 
+       /* Print the VM configuration after all stuff is set and the VM is
+          initialized. */
+
+       if (opt_PrintConfig)
+               vm_printconfig();
+
        /* everything's ok */
 
        return true;
@@ -1808,16 +1657,20 @@ bool vm_create(JavaVMInitArgs *vm_args)
 
 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
 {
-       utf               *mainutf;
-       classinfo         *mainclass;
-       java_objectheader *e;
-       methodinfo        *m;
-       java_objectarray  *oa; 
-       s4                 oalength;
-       utf               *u;
-       java_objectheader *s;
-       s4                 status;
-       s4                 i;
+       utf                       *mainutf;
+       classinfo                 *mainclass;
+       java_handle_t             *e;
+       methodinfo                *m;
+       java_handle_objectarray_t *oa; 
+       s4                         oalength;
+       utf                       *u;
+       java_handle_t             *s;
+       int                        status;
+       int                        i;
+
+#if defined(ENABLE_THREADS)
+       threadobject              *t;
+#endif
 
 #if !defined(NDEBUG)
        if (compileall) {
@@ -1909,7 +1762,7 @@ void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
                u = utf_new_char(vm_args->options[opt_index + i].optionString);
                s = javastring_new(u);
 
-               oa->data[i] = s;
+               array_objectarray_element_set(oa, i, s);
        }
 
 #ifdef TYPEINFO_DEBUG_TEST
@@ -1943,11 +1796,21 @@ void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
                status = 1;
        }
 
-       /* unload the JavaVM */
+#if defined(ENABLE_THREADS)
+    /* Detach the main thread so that it appears to have ended when
+          the application's main method exits. */
+
+       t = thread_get_current();
+
+       if (!threads_detach_thread(t))
+               vm_abort("vm_run: Could not detach main thread.");
+#endif
+
+       /* Destroy the JavaVM. */
 
        (void) vm_destroy(vm);
 
-       /* and exit */
+       /* And exit. */
 
        vm_exit(status);
 }
@@ -1959,13 +1822,30 @@ void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
 
 *******************************************************************************/
 
-s4 vm_destroy(JavaVM *vm)
+int vm_destroy(JavaVM *vm)
 {
 #if defined(ENABLE_THREADS)
+       /* Create a a trivial new Java waiter thread called
+          "DestroyJavaVM". */
+
+       JavaVMAttachArgs args;
+
+       args.name  = "DestroyJavaVM";
+       args.group = NULL;
+
+       if (!threads_attach_current_thread(&args, false))
+               return 1;
+
+       /* Wait until we are the last non-daemon thread. */
+
        threads_join_all_threads();
 #endif
 
-       /* everything's ok */
+       /* VM is gone. */
+
+       vm_created = false;
+
+       /* Everything is ok. */
 
        return 0;
 }
@@ -2047,9 +1927,9 @@ void vm_shutdown(s4 status)
 #if defined(ENABLE_JVMTI)
        /* terminate cacaodbgserver */
        if (dbgcom!=NULL) {
-               pthread_mutex_lock(&dbgcomlock);
+               mutex_lock(&dbgcomlock);
                dbgcom->running=1;
-               pthread_mutex_unlock(&dbgcomlock);
+               mutex_unlock(&dbgcomlock);
                jvmti_cacaodbgserver_quit();
        }       
 #endif
@@ -2123,13 +2003,16 @@ void vm_exit_handler(void)
 
    Prints an error message and aborts the VM.
 
+   IN:
+       text ... error message to print
+
 *******************************************************************************/
 
 void vm_abort(const char *text, ...)
 {
        va_list ap;
 
-       /* print the log message */
+       /* Print the log message. */
 
        log_start();
 
@@ -2139,33 +2022,136 @@ void vm_abort(const char *text, ...)
 
        log_finish();
 
-       /* now abort the VM */
+       /* Now abort the VM. */
 
-       abort();
+       system_abort();
 }
 
 
-/* vm_get_mainclass_from_jar ***************************************************
+/* vm_abort_errnum *************************************************************
 
-   Gets the name of the main class from a JAR's manifest file.
+   Prints an error message, appends ":" plus the strerror-message of
+   errnum and aborts the VM.
+
+   IN:
+       errnum ... error number
+       text ..... error message to print
 
 *******************************************************************************/
 
-static char *vm_get_mainclass_from_jar(char *mainstring)
+void vm_abort_errnum(int errnum, const char *text, ...)
 {
-       classinfo         *c;
-       java_objectheader *o;
-       methodinfo        *m;
-       java_objectheader *s;
+       va_list ap;
 
-       c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
+       /* Print the log message. */
 
-       if (c == NULL) {
-               exceptions_print_stacktrace();
-               return NULL;
-       }
+       log_start();
 
-       /* create JarFile object */
+       va_start(ap, text);
+       log_vprint(text, ap);
+       va_end(ap);
+
+       /* Print the strerror-message of errnum. */
+
+       log_print(": %s", system_strerror(errnum));
+
+       log_finish();
+
+       /* Now abort the VM. */
+
+       system_abort();
+}
+
+
+/* vm_abort_errno **************************************************************
+
+   Equal to vm_abort_errnum, but uses errno to get the error number.
+
+   IN:
+       text ... error message to print
+
+*******************************************************************************/
+
+void vm_abort_errno(const char *text, ...)
+{
+       va_list ap;
+
+       va_start(ap, text);
+       vm_abort_errnum(errno, text, ap);
+       va_end(ap);
+}
+
+
+/* vm_abort_disassemble ********************************************************
+
+   Prints an error message, disassemble the given code range (if
+   enabled) and aborts the VM.
+
+   IN:
+       pc.......PC to disassemble
+          count....number of instructions to disassemble
+
+*******************************************************************************/
+
+void vm_abort_disassemble(void *pc, int count, const char *text, ...)
+{
+       va_list ap;
+#if defined(ENABLE_DISASSEMBLER)
+       int     i;
+#endif
+
+       /* Print debug message. */
+
+       log_start();
+
+       va_start(ap, text);
+       log_vprint(text, ap);
+       va_end(ap);
+
+       log_finish();
+
+       /* Print the PC. */
+
+#if SIZEOF_VOID_P == 8
+       log_println("PC=0x%016lx", pc);
+#else
+       log_println("PC=0x%08x", pc);
+#endif
+
+#if defined(ENABLE_DISASSEMBLER)
+       log_println("machine instructions at PC:");
+
+       /* Disassemble the given number of instructions. */
+
+       for (i = 0; i < count; i++)
+               pc = disassinstr(pc);
+#endif
+
+       vm_abort("Aborting...");
+}
+
+
+/* vm_get_mainclass_from_jar ***************************************************
+
+   Gets the name of the main class from a JAR's manifest file.
+
+*******************************************************************************/
+
+static char *vm_get_mainclass_from_jar(char *mainstring)
+{
+       classinfo     *c;
+       java_handle_t *o;
+       methodinfo    *m;
+       java_handle_t *s;
+
+       c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
+
+       if (c == NULL) {
+               exceptions_print_stacktrace();
+               return NULL;
+       }
+
+       /* create JarFile object */
 
        o = builtin_new(c);
 
@@ -2217,7 +2203,9 @@ static char *vm_get_mainclass_from_jar(char *mainstring)
 
        /* get Main Attributes */
 
-       m = class_resolveclassmethod(o->vftbl->class,
+       LLNI_class_get(o, c);
+
+       m = class_resolveclassmethod(c,
                                                                 utf_new_char("getMainAttributes"), 
                                                                 utf_new_char("()Ljava/util/jar/Attributes;"),
                                                                 class_java_lang_Object,
@@ -2238,7 +2226,9 @@ static char *vm_get_mainclass_from_jar(char *mainstring)
 
        /* get property Main-Class */
 
-       m = class_resolveclassmethod(o->vftbl->class,
+       LLNI_class_get(o, c);
+
+       m = class_resolveclassmethod(c,
                                                                 utf_new_char("getValue"), 
                                                                 utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
                                                                 class_java_lang_Object,
@@ -2254,7 +2244,8 @@ static char *vm_get_mainclass_from_jar(char *mainstring)
        o = vm_call_method(m, o, s);
 
        if (o == NULL) {
-               exceptions_print_stacktrace();
+               fprintf(stderr, "Failed to load Main-Class manifest attribute from\n");
+               fprintf(stderr, "%s\n", mainstring);
                return NULL;
        }
 
@@ -2385,1152 +2376,277 @@ static void vm_compile_method(void)
 #endif /* !defined(NDEBUG) */
 
 
-/* vm_array_store_int **********************************************************
-
-   Helper function to store an integer into the argument array, taking
-   care of architecture specific issues.
-
-*******************************************************************************/
-
-static void vm_array_store_int(uint64_t *array, paramdesc *pd, int32_t value)
-{
-       int32_t index;
-
-       if (!pd->inmemory) {
-               index        = pd->index;
-               array[index] = (int64_t) value;
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-#if SIZEOF_VOID_P == 8
-               array[index] = (int64_t) value;
-#else
-# if WORDS_BIGENDIAN == 1
-               array[index] = ((int64_t) value) << 32;
-# else
-               array[index] = (int64_t) value;
-# endif
-#endif
-       }
-}
-
+/* vm_call_array ***************************************************************
 
-/* vm_array_store_lng **********************************************************
+   Calls a Java method with a variable number of arguments, passed via
+   an argument array.
 
-   Helper function to store a long into the argument array, taking
-   care of architecture specific issues.
+   ATTENTION: This function has to be used outside the nativeworld.
 
 *******************************************************************************/
 
-static void vm_array_store_lng(uint64_t *array, paramdesc *pd, int64_t value)
-{
-       int32_t index;
-
-#if SIZEOF_VOID_P == 8
-       if (!pd->inmemory)
-               index = pd->index;
-       else
-               index = ARG_CNT + pd->index;
-
-       array[index] = value;
-#else
-       if (!pd->inmemory) {
-               /* move low and high 32-bits into it's own argument slot */
-
-               index        = GET_LOW_REG(pd->index);
-               array[index] = value & 0x00000000ffffffff;
-
-               index        = GET_HIGH_REG(pd->index);
-               array[index] = value >> 32;
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-               array[index] = value;
-       }
-#endif
+#define VM_CALL_ARRAY(name, type)                                 \
+static type vm_call##name##_array(methodinfo *m, uint64_t *array) \
+{                                                                 \
+       methoddesc *md;                                               \
+       void       *pv;                                               \
+       type        value;                                            \
+                                                                  \
+       assert(m->code != NULL);                                      \
+                                                                  \
+       md = m->parseddesc;                                           \
+       pv = m->code->entrypoint;                                     \
+                                                                  \
+       STATISTICS(count_calls_native_to_java++);                     \
+                                                                  \
+       value = asm_vm_call_method##name(pv, array, md->memuse);      \
+                                                                  \
+       return value;                                                 \
 }
 
-
-/* vm_array_store_flt **********************************************************
-
-   Helper function to store a float into the argument array, taking
-   care of architecture specific issues.
-
-*******************************************************************************/
-
-static void vm_array_store_flt(uint64_t *array, paramdesc *pd, uint64_t value)
+static java_handle_t *vm_call_array(methodinfo *m, uint64_t *array)
 {
-       int32_t index;
+       methoddesc    *md;
+       void          *pv;
+       java_object_t *o;
 
-       if (!pd->inmemory) {
-#if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
-               index        = pd->index;
-#else
-               index        = INT_ARG_CNT + pd->index;
-#endif
-#if WORDS_BIGENDIAN == 1 && !defined(__POWERPC__) && !defined(__POWERPC64__)
-               array[index] = value >> 32;
-#else
-               array[index] = value;
-#endif
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-#if defined(__SPARC_64__)
-               array[index] = value >> 32;
-#else
-               array[index] = value;
-#endif
-       }
-}
-
-
-/* vm_array_store_dbl **********************************************************
+       assert(m->code != NULL);
 
-   Helper function to store a double into the argument array, taking
-   care of architecture specific issues.
+       md = m->parseddesc;
+       pv = m->code->entrypoint;
 
-*******************************************************************************/
+       STATISTICS(count_calls_native_to_java++);
 
-static void vm_array_store_dbl(uint64_t *array, paramdesc *pd, uint64_t value)
-{
-       int32_t index;
+       o = asm_vm_call_method(pv, array, md->memuse);
 
-       if (!pd->inmemory) {
-#if SIZEOF_VOID_P != 8 && defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
-               index        = GET_LOW_REG(pd->index);
-               array[index] = value & 0x00000000ffffffff;
+       if (md->returntype.type == TYPE_VOID)
+               o = NULL;
 
-               index        = GET_HIGH_REG(pd->index);
-               array[index] = value >> 32;
-#else
-               index        = INT_ARG_CNT + pd->index;
-               array[index] = value;
-#endif
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-               array[index] = value;
-       }
+       return LLNI_WRAP(o);
 }
 
-
-/* vm_array_store_adr **********************************************************
-
-   Helper function to store an address into the argument array, taking
-   care of architecture specific issues.
-
-*******************************************************************************/
-
-static void vm_array_store_adr(uint64_t *array, paramdesc *pd, void *value)
-{
-       int32_t index;
-
-       if (!pd->inmemory) {
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-               /* When the architecture has address registers, place them
-                  after integer and float registers. */
-
-               index        = INT_ARG_CNT + FLT_ARG_CNT + pd->index;
-#else
-               index        = pd->index;
-#endif
-               array[index] = (uint64_t) (intptr_t) value;
-       }
-       else {
-               index        = ARG_CNT + pd->index;
-#if SIZEOF_VOID_P == 8
-               array[index] = (uint64_t) (intptr_t) value;
-#else
-# if WORDS_BIGENDIAN == 1
-               array[index] = ((uint64_t) (intptr_t) value) << 32;
-# else
-               array[index] = (uint64_t) (intptr_t) value;
-# endif
-#endif
-       }
-}
+VM_CALL_ARRAY(_int,    int32_t)
+VM_CALL_ARRAY(_long,   int64_t)
+VM_CALL_ARRAY(_float,  float)
+VM_CALL_ARRAY(_double, double)
 
 
-/* vm_array_from_valist ********************************************************
+/* vm_call_method **************************************************************
 
-   XXX
+   Calls a Java method with a variable number of arguments.
 
 *******************************************************************************/
 
-uint64_t *vm_array_from_valist(methodinfo *m, java_objectheader *o, va_list ap)
-{
-       methoddesc *md;
-       paramdesc  *pd;
-       typedesc   *td;
-       uint64_t   *array;
-       int32_t     i;
-       imm_union   value;
-
-       /* get the descriptors */
-
-       md = m->parseddesc;
-       pd = md->params;
-       td = md->paramtypes;
-
-       /* allocate argument array */
-
-       array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + md->memuse);
-
-       /* if method is non-static fill first block and skip `this' pointer */
-
-       i = 0;
-
-       if (o != NULL) {
-               /* the `this' pointer */
-               vm_array_store_adr(array, pd, o);
-
-               pd++;
-               td++;
-               i++;
-       } 
-
-       for (; i < md->paramcount; i++, pd++, td++) {
-               switch (td->type) {
-               case TYPE_INT:
-                       value.i = va_arg(ap, int32_t);
-                       vm_array_store_int(array, pd, value.i);
-                       break;
-
-               case TYPE_LNG:
-                       value.l = va_arg(ap, int64_t);
-                       vm_array_store_lng(array, pd, value.l);
-                       break;
-
-               case TYPE_FLT:
-#if defined(__ALPHA__) || defined(__POWERPC__) || defined(__POWERPC64__)
-                       /* This is required to load the correct float value in
-                          assembler code. */
-
-                       value.d = (double) va_arg(ap, double);
-#else
-                       value.f = (float) va_arg(ap, double);
-#endif
-                       vm_array_store_flt(array, pd, value.l);
-                       break;
-
-               case TYPE_DBL:
-                       value.d = va_arg(ap, double);
-                       vm_array_store_dbl(array, pd, value.l);
-                       break;
-
-               case TYPE_ADR: 
-                       value.a = va_arg(ap, void*);
-                       vm_array_store_adr(array, pd, value.a);
-                       break;
-               }
-       }
-
-       return array;
+#define VM_CALL_METHOD(name, type)                                  \
+type vm_call_method##name(methodinfo *m, java_handle_t *o, ...)     \
+{                                                                   \
+       va_list ap;                                                     \
+       type    value;                                                  \
+                                                                    \
+       va_start(ap, o);                                                \
+       value = vm_call_method##name##_valist(m, o, ap);                \
+       va_end(ap);                                                     \
+                                                                    \
+       return value;                                                   \
 }
 
+VM_CALL_METHOD(,        java_handle_t *)
+VM_CALL_METHOD(_int,    int32_t)
+VM_CALL_METHOD(_long,   int64_t)
+VM_CALL_METHOD(_float,  float)
+VM_CALL_METHOD(_double, double)
 
-/* vm_array_from_jvalue ********************************************************
-
-   XXX
-
-*******************************************************************************/
-
-static uint64_t *vm_array_from_jvalue(methodinfo *m, java_objectheader *o,
-                                                                         const jvalue *args)
-{
-       methoddesc *md;
-       paramdesc  *pd;
-       typedesc   *td;
-       uint64_t   *array;
-       int32_t     i;
-       int32_t     j;
-
-       /* get the descriptors */
-
-       md = m->parseddesc;
-       pd = md->params;
-       td = md->paramtypes;
-
-       /* allocate argument array */
-
-#if defined(HAS_ADDRESS_REGISTER_FILE)
-       array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + ADR_ARG_CNT + md->memuse);
-#else
-       array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + md->memuse);
-#endif
 
-       /* if method is non-static fill first block and skip `this' pointer */
+/* vm_call_method_valist *******************************************************
 
-       i = 0;
+   Calls a Java method with a variable number of arguments, passed via
+   a va_list.
 
-       if (o != NULL) {
-               /* the `this' pointer */
-               vm_array_store_adr(array, pd, o);
+*******************************************************************************/
 
-               pd++;
-               td++;
-               i++;
-       } 
+#define VM_CALL_METHOD_VALIST(name, type)                               \
+type vm_call_method##name##_valist(methodinfo *m, java_handle_t *o,     \
+                                                                  va_list ap)                          \
+{                                                                       \
+       uint64_t *array;                                                    \
+       type      value;                                                    \
+       int32_t   dumpmarker;                                               \
+                                                                        \
+       if (m->code == NULL)                                                \
+               if (!jit_compile(m))                                            \
+                       return 0;                                                   \
+                                                                        \
+       THREAD_NATIVEWORLD_EXIT;                                            \
+       DMARKER;                                                            \
+                                                                        \
+       array = argument_vmarray_from_valist(m, o, ap);                     \
+       value = vm_call##name##_array(m, array);                            \
+                                                                        \
+       DRELEASE;                                                           \
+       THREAD_NATIVEWORLD_ENTER;                                           \
+                                                                        \
+       return value;                                                       \
+}
 
-       for (j = 0; i < md->paramcount; i++, j++, pd++, td++) {
-               switch (td->decltype) {
-               case TYPE_INT:
-                       vm_array_store_int(array, pd, args[j].i);
-                       break;
+VM_CALL_METHOD_VALIST(,        java_handle_t *)
+VM_CALL_METHOD_VALIST(_int,    int32_t)
+VM_CALL_METHOD_VALIST(_long,   int64_t)
+VM_CALL_METHOD_VALIST(_float,  float)
+VM_CALL_METHOD_VALIST(_double, double)
 
-               case TYPE_LNG:
-                       vm_array_store_lng(array, pd, args[j].j);
-                       break;
 
-               case TYPE_FLT:
-                       vm_array_store_flt(array, pd, args[j].j);
-                       break;
+/* vm_call_method_jvalue *******************************************************
 
-               case TYPE_DBL:
-                       vm_array_store_dbl(array, pd, args[j].j);
-                       break;
+   Calls a Java method with a variable number of arguments, passed via
+   a jvalue array.
 
-               case TYPE_ADR: 
-                       vm_array_store_adr(array, pd, args[j].l);
-                       break;
-               }
-       }
+*******************************************************************************/
 
-       return array;
+#define VM_CALL_METHOD_JVALUE(name, type)                               \
+type vm_call_method##name##_jvalue(methodinfo *m, java_handle_t *o,     \
+                                                          const jvalue *args)                  \
+{                                                                       \
+       uint64_t *array;                                                    \
+       type      value;                                                    \
+       int32_t   dumpmarker;                                               \
+                                                                        \
+       if (m->code == NULL)                                                \
+               if (!jit_compile(m))                                            \
+                       return 0;                                                   \
+                                                                        \
+       THREAD_NATIVEWORLD_EXIT;                                            \
+       DMARKER;                                                            \
+                                                                        \
+       array = argument_vmarray_from_jvalue(m, o, args);                   \
+       value = vm_call##name##_array(m, array);                            \
+                                                                        \
+       DRELEASE;                                                           \
+       THREAD_NATIVEWORLD_ENTER;                                           \
+                                                                        \
+       return value;                                                       \
 }
 
+VM_CALL_METHOD_JVALUE(,        java_handle_t *)
+VM_CALL_METHOD_JVALUE(_int,    int32_t)
+VM_CALL_METHOD_JVALUE(_long,   int64_t)
+VM_CALL_METHOD_JVALUE(_float,  float)
+VM_CALL_METHOD_JVALUE(_double, double)
 
-/* vm_array_from_objectarray ***************************************************
 
-   XXX
+/* vm_call_method_objectarray **************************************************
+
+   Calls a Java method with a variable number if arguments, passed via
+   an objectarray of boxed values. Returns a boxed value.
 
 *******************************************************************************/
 
-uint64_t *vm_array_from_objectarray(methodinfo *m, java_objectheader *o,
-                                                                       java_objectarray *params)
+java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o,
+                                                                                 java_handle_objectarray_t *params)
 {
-       methoddesc        *md;
-       paramdesc         *pd;
-       typedesc          *td;
-       uint64_t          *array;
-       java_objectheader *param;
-       classinfo         *c;
-       int32_t            i;
-       int32_t            j;
-       imm_union          value;
-
-       /* get the descriptors */
-
-       md = m->parseddesc;
-       pd = md->params;
-       td = md->paramtypes;
-
-       /* allocate argument array */
+       uint64_t      *array;
+       java_handle_t *xptr;
+       java_handle_t *ro;
+       imm_union      value;
+       int32_t        dumpmarker;
 
-       array = DMNEW(uint64_t, INT_ARG_CNT + FLT_ARG_CNT + md->memuse);
+       /* Prevent compiler warnings. */
 
-       /* if method is non-static fill first block and skip `this' pointer */
+       ro = NULL;
 
-       i = 0;
+       /* compile methods which are not yet compiled */
 
-       if (o != NULL) {
-               /* this pointer */
-               vm_array_store_adr(array, pd, o);
+       if (m->code == NULL)
+               if (!jit_compile(m))
+                       return NULL;
 
-               pd++;
-               td++;
-               i++;
-       }
+       /* leave the nativeworld */
 
-       for (j = 0; i < md->paramcount; i++, j++, pd++, td++) {
-               param = params->data[j];
+       THREAD_NATIVEWORLD_EXIT;
 
-               switch (td->type) {
-               case TYPE_INT:
-                       if (param == NULL)
-                               goto illegal_arg;
+       /* mark start of dump memory area */
 
-                       /* convert the value according to its declared type */
+       DMARKER;
 
-                       c = param->vftbl->class;
+       /* Fill the argument array from a object-array. */
 
-                       switch (td->decltype) {
-                       case PRIMITIVETYPE_BOOLEAN:
-                               if (c == class_java_lang_Boolean)
-                                       LLNI_field_get_val((java_lang_Boolean *) param, value, value.i);
-                               else
-                                       goto illegal_arg;
-                               break;
+       array = argument_vmarray_from_objectarray(m, o, params);
 
-                       case PRIMITIVETYPE_BYTE:
-                               if (c == class_java_lang_Byte)
-                                       LLNI_field_get_val((java_lang_Byte *) param, value, value.i);
-                               else
-                                       goto illegal_arg;
-                               break;
+       if (array == NULL) {
+               /* release dump area */
 
-                       case PRIMITIVETYPE_CHAR:
-                               if (c == class_java_lang_Character)
-                                       LLNI_field_get_val((java_lang_Character *) param, value, value.i);
-                               else
-                                       goto illegal_arg;
-                               break;
-
-                       case PRIMITIVETYPE_SHORT:
-                               if (c == class_java_lang_Short)
-                                       LLNI_field_get_val((java_lang_Short *) param, value, value.i);
-                               else if (c == class_java_lang_Byte)
-                                       LLNI_field_get_val((java_lang_Byte *) param, value, value.i);
-                               else
-                                       goto illegal_arg;
-                               break;
-
-                       case PRIMITIVETYPE_INT:
-                               if (c == class_java_lang_Integer)
-                                       LLNI_field_get_val((java_lang_Integer *) param, value, value.i);
-                               else if (c == class_java_lang_Short)
-                                       LLNI_field_get_val((java_lang_Short *) param, value, value.i);
-                               else if (c == class_java_lang_Byte)
-                                       LLNI_field_get_val((java_lang_Byte *) param, value, value.i);
-                               else
-                                       goto illegal_arg;
-                               break;
+               DRELEASE;
 
-                       default:
-                               goto illegal_arg;
-                       }
+               /* enter the nativeworld again */
 
-                       vm_array_store_int(array, pd, value.i);
-                       break;
+               THREAD_NATIVEWORLD_ENTER;
 
-               case TYPE_LNG:
-                       if (param == NULL)
-                               goto illegal_arg;
+               exceptions_throw_illegalargumentexception();
 
-                       /* convert the value according to its declared type */
+               return NULL;
+       }
 
-                       c = param->vftbl->class;
+       switch (m->parseddesc->returntype.decltype) {
+       case PRIMITIVETYPE_VOID:
+               value.a = vm_call_array(m, array);
+               break;
 
-                       switch (td->decltype) {
-                       case PRIMITIVETYPE_LONG:
-                               if (c == class_java_lang_Long)
-                                       LLNI_field_get_val((java_lang_Long *) param, value, value.l);
-                               else if (c == class_java_lang_Integer)
-                                       value.l = (int64_t) LLNI_field_direct(((java_lang_Integer *) param), value);
-                               else if (c == class_java_lang_Short)
-                                       value.l = (int64_t) LLNI_field_direct(((java_lang_Short *) param), value);
-                               else if (c == class_java_lang_Byte)
-                                       value.l = (int64_t) LLNI_field_direct(((java_lang_Byte *) param), value);
-                               else
-                                       goto illegal_arg;
-                               break;
+       case PRIMITIVETYPE_BOOLEAN:
+       case PRIMITIVETYPE_BYTE:
+       case PRIMITIVETYPE_CHAR:
+       case PRIMITIVETYPE_SHORT:
+       case PRIMITIVETYPE_INT:
+               value.i = vm_call_int_array(m, array);
+               break;
 
-                       default:
-                               goto illegal_arg;
-                       }
+       case PRIMITIVETYPE_LONG:
+               value.l = vm_call_long_array(m, array);
+               break;
 
-                       vm_array_store_lng(array, pd, value.l);
-                       break;
+       case PRIMITIVETYPE_FLOAT:
+               value.f = vm_call_float_array(m, array);
+               break;
 
-               case TYPE_FLT:
-                       if (param == NULL)
-                               goto illegal_arg;
+       case PRIMITIVETYPE_DOUBLE:
+               value.d = vm_call_double_array(m, array);
+               break;
 
-                       /* convert the value according to its declared type */
+       case TYPE_ADR:
+               ro = vm_call_array(m, array);
+               break;
 
-                       c = param->vftbl->class;
+       default:
+               vm_abort("vm_call_method_objectarray: invalid return type %d", m->parseddesc->returntype.decltype);
+       }
 
-                       switch (td->decltype) {
-                       case PRIMITIVETYPE_FLOAT:
-                               if (c == class_java_lang_Float)
-                                       LLNI_field_get_val((java_lang_Float *) param, value, value.f);
-                               else
-                                       goto illegal_arg;
-                               break;
+       /* release dump area */
 
-                       default:
-                               goto illegal_arg;
-                       }
+       DRELEASE;
 
-                       vm_array_store_flt(array, pd, value.l);
-                       break;
+       /* enter the nativeworld again */
 
-               case TYPE_DBL:
-                       if (param == NULL)
-                               goto illegal_arg;
+       THREAD_NATIVEWORLD_ENTER;
 
-                       /* convert the value according to its declared type */
+       /* box the return value if necesarry */
 
-                       c = param->vftbl->class;
+       if (m->parseddesc->returntype.decltype != TYPE_ADR)
+               ro = primitive_box(m->parseddesc->returntype.decltype, value);
 
-                       switch (td->decltype) {
-                       case PRIMITIVETYPE_DOUBLE:
-                               if (c == class_java_lang_Double)
-                                       LLNI_field_get_val((java_lang_Double *) param, value, value.d);
-                               else if (c == class_java_lang_Float)
-                                       LLNI_field_get_val((java_lang_Float *) param, value, value.f);
-                               else
-                                       goto illegal_arg;
-                               break;
+       /* check for an exception */
 
-                       default:
-                               goto illegal_arg;
-                       }
+       xptr = exceptions_get_exception();
 
-                       vm_array_store_dbl(array, pd, value.l);
-                       break;
-               
-               case TYPE_ADR:
-                       if (!resolve_class_from_typedesc(td, true, true, &c))
-                               return false;
-
-                       if (param != NULL) {
-                               if (td->arraydim > 0) {
-                                       if (!builtin_arrayinstanceof(param, c))
-                                               goto illegal_arg;
-                               }
-                               else {
-                                       if (!builtin_instanceof(param, c))
-                                               goto illegal_arg;
-                               }
-                       }
+       if (xptr != NULL) {
+               /* clear exception pointer, we are calling JIT code again */
 
-                       vm_array_store_adr(array, pd, param);
-                       break;
+               exceptions_clear_exception();
 
-               default:
-                       goto illegal_arg;
-               }
+               exceptions_throw_invocationtargetexception(xptr);
        }
 
-       return array;
-
-illegal_arg:
-       exceptions_throw_illegalargumentexception();
-       return NULL;
-}
-
-
-/* vm_call_method **************************************************************
-
-   Calls a Java method with a variable number of arguments and returns
-   an address.
-
-*******************************************************************************/
-
-java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
-{
-       va_list            ap;
-       java_objectheader *ro;
-
-       va_start(ap, o);
-       ro = vm_call_method_valist(m, o, ap);
-       va_end(ap);
-
        return ro;
 }
 
 
-/* vm_call_method_valist *******************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a va_list, and returns an address.
-
-*******************************************************************************/
-
-java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
-                                                                                va_list ap)
-{
-       java_objectheader *ro;
-       int32_t            dumpsize;
-       uint64_t          *array;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_valist(m, o, ap);
-
-       /* call the Java method */
-
-       ro = vm_call_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return ro;
-}
-
-
-/* vm_call_method_jvalue *******************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a jvalue array, and returns an address.
-
-*******************************************************************************/
-
-java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
-                                                                                const jvalue *args)
-{
-       java_objectheader *ro;
-       int32_t            dumpsize;
-       uint64_t          *array;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_jvalue(m, o, args);
-
-       /* call the Java method */
-
-       ro = vm_call_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return ro;
-}
-
-
-/* vm_call_array ***************************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   an argument array, and returns an address.
-
-*******************************************************************************/
-
-java_objectheader *vm_call_array(methodinfo *m, uint64_t *array)
-{
-       methoddesc        *md;
-       java_objectheader *o;
-
-       md = m->parseddesc;
-
-       /* compile the method if not already done */
-
-       if (m->code == NULL)
-               if (!jit_compile(m))
-                       return NULL;
-
-       STATISTICS(count_calls_native_to_java++);
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
-       else
-# endif
-               o = asm_vm_call_method(m->code->entrypoint, array, md->memuse);
-#else
-       o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
-#endif
-
-       return o;
-}
-
-
-/* vm_call_int_array ***********************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   an argument array, and returns an integer (int32_t).
-
-*******************************************************************************/
-
-int32_t vm_call_int_array(methodinfo *m, uint64_t *array)
-{
-       methoddesc *md;
-       int32_t     i;
-
-       md = m->parseddesc;
-
-       /* compile the method if not already done */
-
-       if (m->code == NULL)
-               if (!jit_compile(m))
-                       return 0;
-
-       STATISTICS(count_calls_native_to_java++);
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
-       else
-# endif
-               i = asm_vm_call_method_int(m->code->entrypoint, array, md->memuse);
-#else
-       i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
-#endif
-
-       return i;
-}
-
-
-/* vm_call_method_int **********************************************************
-
-   Calls a Java method with a variable number of arguments and returns
-   an integer (s4).
-
-*******************************************************************************/
-
-s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
-{
-       va_list ap;
-       s4      i;
-
-       va_start(ap, o);
-       i = vm_call_method_int_valist(m, o, ap);
-       va_end(ap);
-
-       return i;
-}
-
-
-/* vm_call_method_int_valist ***************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a va_list, and returns an integer (int32_t).
-
-*******************************************************************************/
-
-int32_t vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
-{
-       int32_t   dumpsize;
-       uint64_t *array;
-       int32_t   i;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_valist(m, o, ap);
-
-       /* call the Java method */
-
-       i = vm_call_int_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return i;
-}
-
-
-/* vm_call_method_int_jvalue ***************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a jvalue array, and returns an integer (s4).
-
-*******************************************************************************/
-
-int32_t vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o,
-                                                                 const jvalue *args)
-{
-       int32_t   dumpsize;
-       uint64_t *array;
-       int32_t   i;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_jvalue(m, o, args);
-
-       /* call the Java method */
-
-       i = vm_call_int_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return i;
-}
-
-
-/* vm_call_long_array **********************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   an argument array, and returns a long (int64_t).
-
-*******************************************************************************/
-
-int64_t vm_call_long_array(methodinfo *m, uint64_t *array)
-{
-       methoddesc *md;
-       int64_t     l;
-
-       md = m->parseddesc;
-
-       /* compile the method if not already done */
-
-       if (m->code == NULL)
-               if (!jit_compile(m))
-                       return 0;
-
-       STATISTICS(count_calls_native_to_java++);
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
-       else
-# endif
-               l = asm_vm_call_method_long(m->code->entrypoint, array, md->memuse);
-#else
-       l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
-#endif
-
-       return l;
-}
-
-
-/* vm_call_method_long *********************************************************
-
-   Calls a Java method with a variable number of arguments and returns
-   a long (s8).
-
-*******************************************************************************/
-
-s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
-{
-       va_list ap;
-       s8      l;
-
-       va_start(ap, o);
-       l = vm_call_method_long_valist(m, o, ap);
-       va_end(ap);
-
-       return l;
-}
-
-
-/* vm_call_method_long_valist **************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a va_list, and returns a long (s8).
-
-*******************************************************************************/
-
-int64_t vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
-{
-       int32_t   dumpsize;
-       uint64_t *array;
-       int64_t   l;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_valist(m, o, ap);
-
-       /* call the Java method */
-
-       l = vm_call_long_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return l;
-}
-
-
-/* vm_call_method_long_jvalue **************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a jvalue array, and returns a long (s8).
-
-*******************************************************************************/
-
-int64_t vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o,
-                                                                  const jvalue *args)
-{
-       int32_t   dumpsize;
-       uint64_t *array;
-       int64_t   l;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_jvalue(m, o, args);
-
-       /* call the Java method */
-
-       l = vm_call_long_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return l;
-}
-
-
-/* vm_call_float_array *********************************************************
-
-   Calls a Java method with a variable number of arguments and returns
-   an float.
-
-*******************************************************************************/
-
-float vm_call_float_array(methodinfo *m, uint64_t *array)
-{
-       methoddesc *md;
-       float       f;
-
-       md = m->parseddesc;
-
-       /* compile the method if not already done */
-
-       if (m->code == NULL)
-               if (!jit_compile(m))
-                       return 0;
-
-       STATISTICS(count_calls_native_to_java++);
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
-       else
-# endif
-               f = asm_vm_call_method_float(m->code->entrypoint, array, md->memuse);
-#else
-       f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
-#endif
-
-       return f;
-}
-
-
-/* vm_call_method_float ********************************************************
-
-   Calls a Java method with a variable number of arguments and returns
-   an float.
-
-*******************************************************************************/
-
-float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
-{
-       va_list ap;
-       float   f;
-
-       va_start(ap, o);
-       f = vm_call_method_float_valist(m, o, ap);
-       va_end(ap);
-
-       return f;
-}
-
-
-/* vm_call_method_float_valist *************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a va_list, and returns a float.
-
-*******************************************************************************/
-
-float vm_call_method_float_valist(methodinfo *m, java_objectheader *o, va_list ap)
-{
-       int32_t   dumpsize;
-       uint64_t *array;
-       float     f;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_valist(m, o, ap);
-
-       /* call the Java method */
-
-       f = vm_call_float_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return f;
-}
-
-
-/* vm_call_method_float_jvalue *************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a jvalue array, and returns a float.
-
-*******************************************************************************/
-
-float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o, const jvalue *args)
-{
-       int32_t   dumpsize;
-       uint64_t *array;
-       float     f;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_jvalue(m, o, args);
-
-       /* call the Java method */
-
-       f = vm_call_float_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return f;
-}
-
-
-/* vm_call_double_array ********************************************************
-
-   Calls a Java method with a variable number of arguments and returns
-   a double.
-
-*******************************************************************************/
-
-double vm_call_double_array(methodinfo *m, uint64_t *array)
-{
-       methoddesc *md;
-       double      d;
-
-       md = m->parseddesc;
-
-       /* compile the method if not already done */
-
-       if (m->code == NULL)
-               if (!jit_compile(m))
-                       return 0;
-
-       STATISTICS(count_calls_native_to_java++);
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
-       if (opt_intrp)
-               d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
-       else
-# endif
-               d = asm_vm_call_method_double(m->code->entrypoint, array, md->memuse);
-#else
-       d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
-#endif
-
-       return d;
-}
-
-
-/* vm_call_method_double *******************************************************
-
-   Calls a Java method with a variable number of arguments and returns
-   a double.
-
-*******************************************************************************/
-
-double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
-{
-       va_list ap;
-       double  d;
-
-       va_start(ap, o);
-       d = vm_call_method_double_valist(m, o, ap);
-       va_end(ap);
-
-       return d;
-}
-
-
-/* vm_call_method_double_valist ************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a va_list, and returns a double.
-
-*******************************************************************************/
-
-double vm_call_method_double_valist(methodinfo *m, java_objectheader *o, va_list ap)
-{
-       int32_t   dumpsize;
-       uint64_t *array;
-       double    d;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_valist(m, o, ap);
-
-       /* call the Java method */
-
-       d = vm_call_double_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return d;
-}
-
-
-/* vm_call_method_double_jvalue ************************************************
-
-   Calls a Java method with a variable number of arguments, passed via
-   a jvalue array, and returns a double.
-
-*******************************************************************************/
-
-double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o, const jvalue *args)
-{
-       int32_t   dumpsize;
-       uint64_t *array;
-       double    d;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
-
-       /* fill the argument array from a va_list */
-
-       array = vm_array_from_jvalue(m, o, args);
-
-       /* call the Java method */
-
-       d = vm_call_double_array(m, array);
-
-       /* release dump area */
-
-       dump_release(dumpsize);
-
-       return d;
-}
-
-
 /*
  * 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
@@ -3542,4 +2658,5 @@ double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o, const j
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */