/* 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.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: vm.c 4357 2006-01-22 23:33:38Z twisti $
-
*/
#include <assert.h>
#include <errno.h>
+#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 "md-abi.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_Class.h"
-#include "native/include/java_lang_String.h"
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
+#include "native/include/java_lang_Object.h" /* required by j.l.C */
+#include "native/include/java_lang_String.h" /* required by j.l.C */
+
+#if defined(WITH_CLASSPATH_SUN)
+# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
+# include "native/include/java_lang_ClassLoader.h" /* required by j.l.C */
#endif
+#include "native/include/java_lang_Class.h"
+
+#include "native/vm/nativevm.h"
+
+#include "threads/threads-common.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"
+#if defined(ENABLE_DISASSEMBLER)
+# include "vm/jit/disass.h"
+#endif
+
+#include "vm/jit/jit.h"
+
#if defined(ENABLE_PROFILING)
# include "vm/jit/optimizing/profile.h"
#endif
#include "vm/jit/optimizing/recompile.h"
+#if defined(ENABLE_PYTHON)
+# include "vm/jit/python.h"
+#endif
+
#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"
#endif
+#if defined(ENABLE_VMLOG)
+#include <vmlog_cacao.h>
+#endif
+
/* Invocation API variables ***************************************************/
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;
-
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
#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 ************************************************/
OPT_X,
OPT_XX,
+ OPT_EA,
+ OPT_DA,
+ OPT_EA_NOARG,
+ OPT_DA_NOARG,
+
+
OPT_ESA,
OPT_DSA,
OPT_VERBOSE1,
OPT_NOIEEE,
- OPT_SOFTNULL,
#if defined(ENABLE_STATISTICS)
OPT_TIME,
OPT_VERBOSETC,
#endif
#endif /* defined(ENABLE_VERIFIER) */
- OPT_EAGER,
/* optimization options */
OPT_INLINE_DEBUG_END,
OPT_INLINE_DEBUG_MIN,
OPT_INLINE_DEBUG_MAX,
- OPT_INLINE_REPLACE_VERBOSE,
- OPT_INLINE_REPLACE_VERBOSE2,
#endif /* defined(ENABLE_INLINING_DEBUG) */
#endif /* defined(ENABLE_INLINING) */
OPT_AGENTPATH,
#endif
+#if defined(ENABLE_DEBUG_FILTER)
+ OPT_FILTER_VERBOSECALL_INCLUDE,
+ OPT_FILTER_VERBOSECALL_EXCLUDE,
+ OPT_FILTER_SHOW_METHOD,
+#endif
+
DUMMY
};
{ "help", false, OPT_HELP },
{ "?", false, OPT_HELP },
{ "X", false, OPT_X },
- { "XX", false, OPT_XX },
+ { "XX:", true, OPT_XX },
+
+ { "ea:", true, OPT_EA },
+ { "da:", true, 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 },
{ "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 },
#if defined(__ALPHA__)
{ "noieee", false, OPT_NOIEEE },
#endif
- { "softnull", false, OPT_SOFTNULL },
#if defined(ENABLE_STATISTICS)
{ "time", false, OPT_TIME },
{ "stat", false, OPT_STAT },
{ "log", true, OPT_LOG },
{ "c", true, OPT_CHECK },
{ "l", false, OPT_LOAD },
- { "eager", false, OPT_EAGER },
#if !defined(NDEBUG)
{ "all", false, OPT_ALL },
#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 */
{ "ii", true, OPT_INLINE_DEBUG_MIN },
{ "im", true, OPT_INLINE_DEBUG_MAX },
{ "ie", true, OPT_INLINE_DEBUG_END },
- { "ir", false, OPT_INLINE_REPLACE_VERBOSE },
- { "iR", false, OPT_INLINE_REPLACE_VERBOSE2 },
#endif /* defined(ENABLE_INLINING_DEBUG) */
#if !defined(NDEBUG)
{ "il", false, OPT_INLINE_LOG },
{ "s", true, OPT_SHOW },
{ "debug-color", false, OPT_DEBUGCOLOR },
+#if defined(ENABLE_DEBUG_FILTER)
+ { "XXfi", true, OPT_FILTER_VERBOSECALL_INCLUDE },
+ { "XXfx", true, OPT_FILTER_VERBOSECALL_EXCLUDE },
+ { "XXfm", true, OPT_FILTER_SHOW_METHOD },
+#endif
+
{ NULL, false, 0 }
};
puts(" -showversion print product version and continue");
puts(" -help, -? print this help message");
puts(" -X print help on non-standard Java options");
- puts(" -XX print help on CACAO options");
+ puts(" -XX print help on debugging options");
+ puts(" -ea[:<packagename>...|:<classname>]");
+ puts(" -enableassertions[:<packagename>...|:<classname>]");
+ puts(" enable assertions with specified granularity");
+ puts(" -da[:<packagename>...|:<classname>]");
+ puts(" -disableassertions[:<packagename>...|:<classname>]");
+ puts(" disable assertions with specified granularity");
puts(" -esa | -enablesystemassertions");
puts(" enable system assertions");
puts(" -dsa | -disablesystemassertions");
}
+#if 0
static void XXusage(void)
{
puts(" -v write state-information");
#if !defined(NDEBUG)
- puts(" -verbose[:call|exception|jit|memory]");
- puts(" enable specific verbose output");
+ puts(" -verbose:jit enable specific verbose output");
puts(" -debug-color colored output for ANSI terms");
#endif
#ifdef TYPECHECK_VERBOSE
#if defined(ENABLE_VERIFIER)
puts(" -noverify don't verify classfiles");
#endif
- puts(" -softnull use software nullpointer check");
#if defined(ENABLE_STATISTICS)
puts(" -time measure the runtime");
puts(" -stat detailed compiler statistics");
puts(" -oloop optimize array accesses in loops");
#endif
puts(" -l don't start the class after loading");
- puts(" -eager perform eager class loading and linking");
#if !defined(NDEBUG)
puts(" -all compile all methods, no execution");
puts(" -m compile only a specific method");
#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");
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");
- puts(" -ir log on-stack replacement");
- puts(" -iR log on-stack replacement, more verbose");
#endif /* defined(ENABLE_INLINING_DEBUG) */
#endif /* defined(ENABLE_INLINING) */
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");
+ puts(" -XXfx <regex> end of dynamic scope for verbosecall filter");
+ puts(" -XXfm <regex> filter for show options");
#endif
-
/* exit with error code */
exit(1);
}
+#endif
/* version *********************************************************************
static void version(bool opt_exit)
{
puts("java version \""JAVA_VERSION"\"");
- puts("CACAO version "VERSION"");
+ puts("CACAO version "VERSION"\n");
+
+ 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 */
+
+ if (opt_exit)
+ exit(0);
+}
+
+
+/* fullversion *****************************************************************
+
+ Prints a Sun compatible version information (required e.g. by
+ jpackage, www.jpackage.org).
- 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");
+*******************************************************************************/
+
+static void fullversion(void)
+{
+ puts("java full version \"cacao-"JAVA_VERSION"\"");
+
+ /* exit normally */
- 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");
+ exit(0);
+}
- 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.\n");
+static void vm_printconfig(void)
+{
puts("Configure/Build options:\n");
puts(" ./configure: "VERSION_CONFIGURE_ARGS"");
#if defined(__VERSION__)
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(WITH_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(" 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);
-
- /* exit normally, if requested */
-
- if (opt_exit)
- exit(0);
-}
+#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
-/* fullversion *****************************************************************
-
- Prints a Sun compatible version information (required e.g. by
- jpackage, www.jpackage.org).
-
-*******************************************************************************/
-
-static void fullversion(void)
-{
- puts("java full version \"cacao-"JAVA_VERSION"\"");
-
- /* exit normally */
-
- exit(0);
+ printf(" java.boot.class.path : %s\n", properties_get("java.boot.class.path"));
+ printf(" java.class.path : %s\n", properties_get("java.class.path"));
}
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;
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;
jdwp = agentbypath = false;
#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 -------------------------------------------------------");
-
- /* 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 */
+ /* Set some options. */
- strcat(cacao_prefix, "/..");
+ opt_version = false;
+ opt_exit = false;
- /* now set path to libjvm.so */
+ opt_noieee = false;
- len = strlen(cacao_prefix) + strlen("/lib/libjvm") + strlen("0");
+ opt_heapmaxsize = HEAP_MAXSIZE;
+ opt_heapstartsize = HEAP_STARTSIZE;
+ opt_stacksize = STACK_SIZE;
- cacao_libjvm = MNEW(char, len);
- strcpy(cacao_libjvm, cacao_prefix);
- strcat(cacao_libjvm, "/lib/libjvm");
+ /* Initialize the properties list before command-line handling.
+ Otherwise -XX:+PrintConfig crashes. */
- /* and finally set the path to GNU Classpath libraries */
+ properties_init();
- len = strlen(cacao_prefix) + strlen("/lib/classpath") + strlen("0");
+ /* First of all, parse the -XX options. */
- 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";
- classpath_libdir = CLASSPATH_LIBDIR"/classpath";
+#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
- len =
-# if defined(WITH_CLASSPATH_GNU)
- strlen(CACAO_VM_ZIP) +
- strlen(":") +
-# endif
- strlen(CLASSPATH_CLASSES) +
- strlen("0");
+ options_xx(vm_args);
- _Jv_bootclasspath = MNEW(char, len);
-# if defined(WITH_CLASSPATH_GNU)
- strcat(_Jv_bootclasspath, CACAO_VM_ZIP);
- strcat(_Jv_bootclasspath, ":");
-# endif
- strcat(_Jv_bootclasspath, CLASSPATH_CLASSES);
+#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. */
- checknull = false;
- 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("properties_init failed");
+ properties_set();
/* iterate over all passed options */
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. */
+
+ class_path = properties_get("java.class.path");
+
+ p = MNEW(char, strlen(opt_arg) + strlen("0"));
- _Jv_classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
- strcpy(_Jv_classpath, opt_arg);
+ strcpy(p, opt_arg);
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.class.path", p);
+#endif
+
+ MFREE(class_path, char, strlen(class_path));
break;
case OPT_D:
/* 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");
+
+ p = MNEW(char, strlen(opt_arg) + strlen("0"));
- _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
- strcpy(_Jv_bootclasspath, opt_arg);
+ 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. */
+
+ boot_class_path = properties_get("sun.boot.class.path");
+
+ len = strlen(boot_class_path);
- len = strlen(_Jv_bootclasspath);
+ p = MREALLOC(boot_class_path,
+ char,
+ len + strlen("0"),
+ len + strlen(":") +
+ strlen(opt_arg) + strlen("0"));
- _Jv_bootclasspath = MREALLOC(_Jv_bootclasspath,
- char,
- len + strlen("0"),
- len + strlen(":") +
- strlen(opt_arg) + strlen("0"));
+ strcat(p, ":");
+ strcat(p, opt_arg);
- strcat(_Jv_bootclasspath, ":");
- strcat(_Jv_bootclasspath, 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);
+
+ 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(p, CACAO_VM_ZIP);
+ strcat(p, ":");
+ strcat(p, opt_arg);
- strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
- strcat(_Jv_bootclasspath, ":");
- strcat(_Jv_bootclasspath, 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;
#if defined(ENABLE_JVMTI)
opt_verbosejni = true;
}
#if !defined(NDEBUG)
- else if (strcmp("call", opt_arg) == 0) {
- opt_verbosecall = true;
- }
- else if (strcmp("exception", opt_arg) == 0) {
- opt_verboseexception = true;
- }
else if (strcmp("jit", opt_arg) == 0) {
opt_verbose = true;
loadverbose = true;
- linkverbose = true;
initverbose = true;
compileverbose = true;
}
- else if (strcmp("memory", opt_arg) == 0) {
- opt_verbosememory = true;
-
-# if defined(ENABLE_STATISTICS)
- /* we also need statistics */
-
- opt_stat = true;
-# endif
- }
#endif
+ else {
+ printf("Unknown -verbose option: %s\n", opt_arg);
+ usage();
+ }
break;
+
case OPT_DEBUGCOLOR:
opt_debugcolor = true;
break;
break;
#endif
- case OPT_SOFTNULL:
- checknull = true;
- break;
-
#if defined(ENABLE_STATISTICS)
case OPT_TIME:
opt_getcompilingtime = true;
makeinitializations = false;
break;
- case OPT_EAGER:
- opt_eager = true;
- break;
-
#if !defined(NDEBUG)
case OPT_ALL:
compileall = true;
case 'o':
opt_shownops = true;
break;
-
- case 'e':
- opt_showexceptionstubs = true;
- break;
-
- case 'n':
- opt_shownativestub = true;
- break;
#endif
case 'd':
case OPT_INLINE_DEBUG_MAX:
opt_inline_debug_max_size = atoi(opt_arg);
break;
- case OPT_INLINE_REPLACE_VERBOSE:
- opt_replace_verbose = 1;
- break;
- case OPT_INLINE_REPLACE_VERBOSE2:
- opt_replace_verbose = 2;
- break;
#endif /* defined(ENABLE_INLINING_DEBUG) */
#if !defined(NDEBUG)
case OPT_INLINE_LOG:
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
break;
case OPT_XX:
- XXusage();
+ /* Already parsed. */
+ break;
+
+ case OPT_EA:
+#if defined(ENABLE_ASSERTION)
+ assertion_ea_da(opt_arg, true);
+#endif
+ break;
+
+ case OPT_DA:
+#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)
break;
#endif
+#if defined(ENABLE_DEBUG_FILTER)
+ case OPT_FILTER_VERBOSECALL_INCLUDE:
+ opt_filter_verbosecall_include = opt_arg;
+ break;
+
+ case OPT_FILTER_VERBOSECALL_EXCLUDE:
+ opt_filter_verbosecall_exclude = opt_arg;
+ break;
+
+ case OPT_FILTER_SHOW_METHOD:
+ opt_filter_show_method = opt_arg;
+ break;
+
+#endif
default:
printf("Unknown option: %s\n",
vm_args->options[opt_index].optionString);
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", p);
+#endif
}
else {
/* replace .'s with /'s in classname */
vm_initializing = true;
+ /* initialize the garbage collector */
+
+ gc_init(opt_heapmaxsize, opt_heapstartsize);
+
#if defined(ENABLE_THREADS)
- /* pre-initialize some core thread stuff, like the stopworldlock,
- thus this has to happen _before_ gc_init()!!! */
+ /* AFTER: gc_init (directly after, as this initializes the
+ stopworldlock lock */
threads_preinit();
#endif
- /* initialize the garbage collector */
+ /* install architecture dependent signal handlers */
- gc_init(opt_heapmaxsize, opt_heapstartsize);
+ if (!signal_init())
+ vm_abort("vm_create: signal_init failed");
#if defined(ENABLE_INTRP)
/* Allocate main thread stack on the Java heap. */
/* AFTER: threads_preinit */
if (!string_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: string_init failed");
/* AFTER: threads_preinit */
if (!utf8_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: utf8_init failed");
/* AFTER: thread_preinit */
if (!suck_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: suck_init failed");
suck_add_from_property("java.endorsed.dirs");
/* AFTER: utf8_init */
- suck_add(_Jv_bootclasspath);
-
- /* Now re-set some of the properties that may have changed. This
- must be done after _all_ environment variables have been
- processes (e.g. -jar handling).
-
- AFTER: suck_add_from_property, since it may change the
- _Jv_bootclasspath pointer. */
-
- if (!properties_postinit())
- vm_abort("properties_postinit failed");
+ 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) */
if (!classcache_init())
- throw_main_exception_exit();
+ 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())
- throw_main_exception_exit();
+ codememory_init();
/* initialize the finalizer stuff (must be done _after_
threads_preinit) */
if (!finalizer_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: finalizer_init failed");
- /* install architecture dependent signal handlers */
+ /* initializes jit compiler */
- signal_init();
+ jit_init();
- /* initialize the codegen subsystems */
+#if defined(ENABLE_PYTHON)
+ pythonpass_init();
+#endif
- codegen_init();
+ /* BEFORE: loader_preinit */
- /* initializes jit compiler */
+ package_init();
- jit_init();
+ /* AFTER: utf8_init, classcache_init */
- /* machine dependent initialization */
+ loader_preinit();
+ linker_preinit();
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
- if (opt_intrp)
- intrp_md_init();
- else
-# endif
- md_init();
-#else
- intrp_md_init();
-#endif
+ /* AFTER: loader_preinit, linker_preinit */
- /* initialize the loader subsystems (must be done _after_
- classcache_init) */
+ primitive_init();
- if (!loader_init())
- vm_abort("loader_init failed");
+ loader_init();
+ linker_init();
- if (!linker_init())
- vm_abort("linker_init failed");
+ /* AFTER: loader_init, linker_init */
- if (!native_init())
- throw_main_exception_exit();
+ primitive_postinit();
- if (!exceptions_init())
- throw_main_exception_exit();
+ exceptions_init();
if (!builtin_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: builtin_init failed");
+
+ /* Initialize the native subsystem. */
+ /* BEFORE: threads_init */
+
+ if (!native_init())
+ vm_abort("vm_create: native_init failed");
+
+ /* Register the native methods implemented in the VM. */
+ /* BEFORE: threads_init */
+
+ if (!nativevm_preinit())
+ vm_abort("vm_create: nativevm_preinit failed");
#if defined(ENABLE_JNI)
/* Initialize the JNI subsystem (must be done _before_
(e.g. NewGlobalRef). */
if (!jni_init())
- throw_main_exception_exit();
+ 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
#if defined(ENABLE_THREADS)
if (!threads_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: threads_init failed");
#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");
+
#if defined(ENABLE_PROFILING)
/* initialize profiling */
if (!profile_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: profile_init failed");
#endif
#if defined(ENABLE_THREADS)
/* initialize recompilation */
if (!recompile_init())
- throw_main_exception_exit();
+ vm_abort("vm_create: recompile_init failed");
/* start the signal handler thread */
- if (!signal_start_thread())
- throw_main_exception_exit();
+#if defined(__LINUX__)
+ /* XXX Remove for exact-GC. */
+ if (threads_pthreads_implementation_nptl)
+#endif
+ if (!signal_start_thread())
+ vm_abort("vm_create: signal_start_thread failed");
/* finally, start the finalizer thread */
if (!finalizer_start_thread())
- throw_main_exception_exit();
+ vm_abort("vm_create: finalizer_start_thread failed");
# if !defined(NDEBUG)
/* start the memory profiling thread */
- if (opt_verbosememory)
+ if (opt_ProfileMemoryUsage || opt_ProfileGCMemoryUsage)
if (!memory_start_thread())
- throw_main_exception_exit();
+ vm_abort("vm_create: memory_start_thread failed");
# endif
/* start the recompilation thread (must be done before the
profiling thread) */
if (!recompile_start_thread())
- throw_main_exception_exit();
+ vm_abort("vm_create: recompile_start_thread failed");
# if defined(ENABLE_PROFILING)
/* start the profile sampling thread */
/* if (opt_prof) */
/* if (!profile_start_thread()) */
-/* throw_main_exception_exit(); */
+/* vm_abort("vm_create: profile_start_thread failed"); */
# endif
#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);
vm_initializing = false;
+#if !defined(NDEBUG)
+ /* Print the VM configuration after all stuff is set and the VM is
+ initialized. */
+
+ if (opt_PrintConfig)
+ vm_printconfig();
+#endif
+
/* everything's ok */
return true;
void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
{
- utf *mainutf;
- classinfo *mainclass;
- 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;
+ s4 status;
+ s4 i;
#if !defined(NDEBUG)
if (compileall) {
status = 0;
- if (opt_jar == true)
+ if (opt_jar == true) {
/* open jar file with java.util.jar.JarFile */
+
mainstring = vm_get_mainclass_from_jar(mainstring);
+ if (mainstring == NULL)
+ vm_exit(1);
+ }
+
/* load the main class */
mainutf = utf_new_char(mainstring);
/* error loading class */
- if ((exceptions_get_exception() != NULL) || (mainclass == NULL))
- throw_main_exception_exit();
+ e = exceptions_get_and_clear_exception();
- if (!link_class(mainclass))
- throw_main_exception_exit();
+ if ((e != NULL) || (mainclass == NULL)) {
+ exceptions_throw_noclassdeffounderror_cause(e);
+ exceptions_print_stacktrace();
+ vm_exit(1);
+ }
+
+ if (!link_class(mainclass)) {
+ exceptions_print_stacktrace();
+ vm_exit(1);
+ }
/* find the `main' method of the main class */
class_java_lang_Object,
false);
- if (*exceptionptr) {
- throw_main_exception_exit();
+ if (exceptions_get_exception()) {
+ exceptions_print_stacktrace();
+ vm_exit(1);
}
/* there is no main method or it isn't static */
utf_new_char("main"),
utf_new_char("([Ljava/lang/String;)V"));
- throw_main_exception_exit();
+ exceptions_print_stacktrace();
+ vm_exit(1);
}
/* build argument array */
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
/* exception occurred? */
- if (*exceptionptr) {
- throw_main_exception();
+ if (exceptions_get_exception()) {
+ exceptions_print_stacktrace();
status = 1;
}
/* unload the JavaVM */
- vm_destroy(vm);
+ (void) vm_destroy(vm);
/* and exit */
}
#endif
- if (!link_class(class_java_lang_System))
- throw_main_exception_exit();
+ if (!link_class(class_java_lang_System)) {
+ exceptions_print_stacktrace();
+ exit(1);
+ }
/* call java.lang.System.exit(I)V */
class_java_lang_Object,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ exit(1);
+ }
/* call the exit function with passed exit status */
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();
+
+ va_start(ap, text);
+ log_vprint(text, ap);
+ va_end(ap);
+
+ log_finish();
+
+ /* Now abort the VM. */
+
+ system_abort();
+}
+
+
+/* vm_abort_errnum *************************************************************
+
+ Prints an error message, appends ":" plus the strerror-message of
+ errnum and aborts the VM.
+
+ IN:
+ errnum ... error number
+ text ..... error message to print
+
+*******************************************************************************/
+
+void vm_abort_errnum(int errnum, const char *text, ...)
+{
+ va_list ap;
+
+ /* Print the log message. */
log_start();
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 */
+ /* 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;
- abort();
+ 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...");
}
static char *vm_get_mainclass_from_jar(char *mainstring)
{
- classinfo *c;
- java_objectheader *o;
- methodinfo *m;
- java_objectheader *s;
+ 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)
- throw_main_exception_exit();
-
+ if (c == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
+
/* create JarFile object */
o = builtin_new(c);
- if (o == NULL)
- throw_main_exception_exit();
-
+ if (o == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
m = class_resolveclassmethod(c,
utf_init,
class_java_lang_Object,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
s = javastring_new_from_ascii(mainstring);
(void) vm_call_method(m, o, s);
- if (*exceptionptr)
- throw_main_exception_exit();
+ if (exceptions_get_exception()) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
/* get manifest object */
class_java_lang_Object,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
o = vm_call_method(m, o);
if (o == NULL) {
fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
- vm_exit(1);
+ return NULL;
}
/* 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,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
o = vm_call_method(m, o);
if (o == NULL) {
fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
- vm_exit(1);
+ return NULL;
}
/* 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,
true);
- if (m == NULL)
- throw_main_exception_exit();
+ if (m == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
s = javastring_new_from_ascii("Main-Class");
o = vm_call_method(m, o, s);
- if (o == NULL)
- throw_main_exception_exit();
+ if (o == NULL) {
+ exceptions_print_stacktrace();
+ return NULL;
+ }
return javastring_tochar(o);
}
/* create, load and link the main class */
- if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
- throw_main_exception_exit();
+ mainclass = load_class_bootstrap(utf_new_char(mainstring));
+
+ if (mainclass == NULL)
+ exceptions_print_stacktrace();
if (!link_class(mainclass))
- throw_main_exception_exit();
+ exceptions_print_stacktrace();
if (opt_signature != NULL) {
m = class_resolveclassmethod(mainclass,
#endif /* !defined(NDEBUG) */
-/* vm_vmargs_from_valist *******************************************************
-
- XXX
-
-*******************************************************************************/
-
-static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
- vm_arg *vmargs, va_list ap)
-{
- typedesc *paramtypes;
- s4 i;
-
- paramtypes = m->parseddesc->paramtypes;
-
- /* if method is non-static fill first block and skip `this' pointer */
-
- i = 0;
-
- if (o != NULL) {
- /* the `this' pointer */
- vmargs[0].type = TYPE_ADR;
- vmargs[0].data.l = (u8) (ptrint) o;
-
- paramtypes++;
- i++;
- }
-
- for (; i < m->parseddesc->paramcount; i++, paramtypes++) {
- switch (paramtypes->decltype) {
- /* primitive types */
- case PRIMITIVETYPE_BOOLEAN:
- case PRIMITIVETYPE_BYTE:
- case PRIMITIVETYPE_CHAR:
- case PRIMITIVETYPE_SHORT:
- case PRIMITIVETYPE_INT:
- vmargs[i].type = TYPE_INT;
- vmargs[i].data.l = (s8) va_arg(ap, s4);
- break;
-
- case PRIMITIVETYPE_LONG:
- vmargs[i].type = TYPE_LNG;
- vmargs[i].data.l = (s8) va_arg(ap, s8);
- break;
-
- case PRIMITIVETYPE_FLOAT:
- vmargs[i].type = TYPE_FLT;
-#if defined(__ALPHA__)
- /* this keeps the assembler function much simpler */
-
- vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
-#else
- vmargs[i].data.f = (jfloat) va_arg(ap, jdouble);
-#endif
- break;
-
- case PRIMITIVETYPE_DOUBLE:
- vmargs[i].type = TYPE_DBL;
- vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
- break;
-
- case TYPE_ADR:
- vmargs[i].type = TYPE_ADR;
- vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*);
- break;
- }
- }
-}
-
-
-/* vm_vmargs_from_jvalue *******************************************************
-
- XXX
-
-*******************************************************************************/
-
-static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
- vm_arg *vmargs, jvalue *args)
-{
- typedesc *paramtypes;
- s4 i;
- s4 j;
-
- paramtypes = m->parseddesc->paramtypes;
-
- /* if method is non-static fill first block and skip `this' pointer */
-
- i = 0;
-
- if (o != NULL) {
- /* the `this' pointer */
- vmargs[0].type = TYPE_ADR;
- vmargs[0].data.l = (u8) (ptrint) o;
-
- paramtypes++;
- i++;
- }
-
- for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) {
- switch (paramtypes->decltype) {
- /* primitive types */
- case PRIMITIVETYPE_BOOLEAN:
- case PRIMITIVETYPE_BYTE:
- case PRIMITIVETYPE_CHAR:
- case PRIMITIVETYPE_SHORT:
- case PRIMITIVETYPE_INT:
- vmargs[i].type = TYPE_INT;
- vmargs[i].data.l = (s8) args[j].i;
- break;
-
- case PRIMITIVETYPE_LONG:
- vmargs[i].type = TYPE_LNG;
- vmargs[i].data.l = (s8) args[j].j;
- break;
-
- case PRIMITIVETYPE_FLOAT:
- vmargs[i].type = TYPE_FLT;
-#if defined(__ALPHA__)
- /* this keeps the assembler function much simpler */
-
- vmargs[i].data.d = (jdouble) args[j].f;
-#else
- vmargs[i].data.f = args[j].f;
-#endif
- break;
-
- case PRIMITIVETYPE_DOUBLE:
- vmargs[i].type = TYPE_DBL;
- vmargs[i].data.d = args[j].d;
- break;
-
- case TYPE_ADR:
- vmargs[i].type = TYPE_ADR;
- vmargs[i].data.l = (u8) (ptrint) args[j].l;
- break;
- }
- }
-}
-
-
-/* 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 *******************************************************
+/* vm_call_array ***************************************************************
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)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- java_objectheader *ro;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
+ an argument array.
- vmargscount = m->parseddesc->paramcount;
-
- /* allocate vm_arg array */
-
- vmargs = DMNEW(vm_arg, vmargscount);
-
- /* fill the vm_arg array from a va_list */
-
- vm_vmargs_from_valist(m, o, vmargs, ap);
-
- /* call the Java method */
-
- ro = vm_call_method_vmarg(m, vmargscount, vmargs);
-
- /* 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.
+ ATTENTION: This function has to be used outside the nativeworld.
*******************************************************************************/
-java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
- jvalue *args)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- java_objectheader *ro;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
-
- vmargscount = m->parseddesc->paramcount;
-
- /* allocate vm_arg array */
-
- vmargs = DMNEW(vm_arg, vmargscount);
-
- /* fill the vm_arg array from a va_list */
-
- vm_vmargs_from_jvalue(m, o, vmargs, args);
-
- /* call the Java method */
-
- ro = vm_call_method_vmarg(m, vmargscount, vmargs);
-
- /* release dump area */
-
- dump_release(dumpsize);
-
- return ro;
+#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_call_method_vmarg ********************************************************
-
- Calls a Java method with a variable number of arguments, passed via
- a vm_arg array, and returns an address.
-
-*******************************************************************************/
-
-java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
- vm_arg *vmargs)
+static java_handle_t *vm_call_array(methodinfo *m, uint64_t *array)
{
- java_objectheader *o;
-
-#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, vmargscount, vmargs);
-#else
- o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
-#endif
-
- return o;
-}
+ methoddesc *md;
+ void *pv;
+ java_object_t *o;
+ assert(m->code != NULL);
-/* vm_call_method_int **********************************************************
+ md = m->parseddesc;
+ pv = m->code->entrypoint;
- Calls a Java method with a variable number of arguments and returns
- an integer (s4).
+ STATISTICS(count_calls_native_to_java++);
-*******************************************************************************/
-
-s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
-{
- va_list ap;
- s4 i;
+ o = asm_vm_call_method(pv, array, md->memuse);
- va_start(ap, o);
- i = vm_call_method_int_valist(m, o, ap);
- va_end(ap);
+ if (md->returntype.type == TYPE_VOID)
+ o = NULL;
- return i;
+ return LLNI_WRAP(o);
}
+VM_CALL_ARRAY(_int, int32_t)
+VM_CALL_ARRAY(_long, int64_t)
+VM_CALL_ARRAY(_float, float)
+VM_CALL_ARRAY(_double, double)
-/* vm_call_method_int_valist ***************************************************
-
- Calls a Java method with a variable number of arguments, passed via
- a va_list, and returns an integer (s4).
-
-*******************************************************************************/
-
-s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- s4 i;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
-
- vmargscount = m->parseddesc->paramcount;
- /* allocate vm_arg array */
-
- vmargs = DMNEW(vm_arg, vmargscount);
-
- /* fill the vm_arg array from a va_list */
-
- vm_vmargs_from_valist(m, o, vmargs, ap);
-
- /* call the Java method */
-
- i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
-
- /* 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).
-
-*******************************************************************************/
-
-s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- s4 i;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
-
- vmargscount = m->parseddesc->paramcount;
-
- /* allocate vm_arg array */
-
- vmargs = DMNEW(vm_arg, vmargscount);
-
- /* fill the vm_arg array from a va_list */
-
- vm_vmargs_from_jvalue(m, o, vmargs, args);
-
- /* call the Java method */
-
- i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
-
- /* release dump area */
-
- dump_release(dumpsize);
-
- return i;
-}
-
-
-/* vm_call_method_int_vmarg ****************************************************
+/* vm_call_method **************************************************************
- Calls a Java method with a variable number of arguments, passed via
- a vm_arg array, and returns an integer (s4).
+ Calls a Java method with a variable number of arguments.
*******************************************************************************/
-s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
-{
- s4 i;
-
-#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, vmargscount, vmargs);
-#else
- i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
-#endif
-
- return i;
+#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_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 **************************************************
+/* vm_call_method_valist *******************************************************
Calls a Java method with a variable number of arguments, passed via
- a va_list, and returns a long (s8).
+ a va_list.
*******************************************************************************/
-s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- s8 l;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
-
- vmargscount = m->parseddesc->paramcount;
-
- /* allocate vm_arg array */
-
- vmargs = DMNEW(vm_arg, vmargscount);
-
- /* fill the vm_arg array from a va_list */
-
- vm_vmargs_from_valist(m, o, vmargs, ap);
-
- /* call the Java method */
-
- l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
-
- /* release dump area */
-
- dump_release(dumpsize);
-
- return l;
+#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; \
}
-
-/* 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).
-
-*******************************************************************************/
-
-s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- s8 l;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
-
- vmargscount = m->parseddesc->paramcount;
-
- /* allocate vm_arg array */
-
- vmargs = DMNEW(vm_arg, vmargscount);
-
- /* fill the vm_arg array from a va_list */
-
- vm_vmargs_from_jvalue(m, o, vmargs, args);
-
- /* call the Java method */
-
- l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
-
- /* release dump area */
-
- dump_release(dumpsize);
-
- return l;
-}
+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)
-/* vm_call_method_long_vmarg ***************************************************
+/* vm_call_method_jvalue *******************************************************
Calls a Java method with a variable number of arguments, passed via
- a vm_arg array, and returns a long (s8).
+ a jvalue array.
*******************************************************************************/
-s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
-{
- s8 l;
-
-#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, vmargscount, vmargs);
-#else
- l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
-#endif
-
- return l;
+#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_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_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_call_method_float_valist *************************************************
+/* vm_call_method_objectarray **************************************************
- Calls a Java method with a variable number of arguments, passed via
- a va_list, and returns a float.
+ Calls a Java method with a variable number if arguments, passed via
+ an objectarray of boxed values. Returns a boxed value.
*******************************************************************************/
-float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
- va_list ap)
+java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o,
+ java_handle_objectarray_t *params)
{
- s4 vmargscount;
- vm_arg *vmargs;
- float f;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
-
- vmargscount = m->parseddesc->paramcount;
+ uint64_t *array;
+ java_handle_t *xptr;
+ java_handle_t *ro;
+ imm_union value;
+ int32_t dumpmarker;
- /* allocate vm_arg array */
+ /* Prevent compiler warnings. */
- vmargs = DMNEW(vm_arg, vmargscount);
+ ro = NULL;
- /* fill the vm_arg array from a va_list */
+ /* compile methods which are not yet compiled */
- vm_vmargs_from_valist(m, o, vmargs, ap);
+ if (m->code == NULL)
+ if (!jit_compile(m))
+ return NULL;
- /* call the Java method */
+ /* leave the nativeworld */
- f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
-
- /* 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,
- jvalue *args)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- float f;
- s4 dumpsize;
+ THREAD_NATIVEWORLD_EXIT;
/* mark start of dump memory area */
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
-
- vmargscount = m->parseddesc->paramcount;
-
- /* allocate vm_arg array */
+ DMARKER;
- vmargs = DMNEW(vm_arg, vmargscount);
+ /* Fill the argument array from a object-array. */
- /* fill the vm_arg array from a va_list */
+ array = argument_vmarray_from_objectarray(m, o, params);
- vm_vmargs_from_jvalue(m, o, vmargs, args);
-
- /* call the Java method */
-
- f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
-
- /* release dump area */
+ if (array == NULL) {
+ /* release dump area */
- dump_release(dumpsize);
+ DRELEASE;
- return f;
-}
-
-
-/* vm_call_method_float_vmarg **************************************************
-
- Calls a Java method with a variable number of arguments and returns
- an float.
-
-*******************************************************************************/
-
-float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
-{
- float f;
-
-#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, vmargscount, vmargs);
-#else
- f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
-#endif
-
- return f;
-}
+ /* enter the nativeworld again */
+ THREAD_NATIVEWORLD_ENTER;
-/* vm_call_method_double *******************************************************
+ exceptions_throw_illegalargumentexception();
- 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)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- double d;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
-
- /* get number of Java method arguments */
+ return NULL;
+ }
- vmargscount = m->parseddesc->paramcount;
+ switch (m->parseddesc->returntype.decltype) {
+ case PRIMITIVETYPE_VOID:
+ value.a = vm_call_array(m, array);
+ break;
- /* allocate vm_arg array */
+ case PRIMITIVETYPE_BOOLEAN:
+ case PRIMITIVETYPE_BYTE:
+ case PRIMITIVETYPE_CHAR:
+ case PRIMITIVETYPE_SHORT:
+ case PRIMITIVETYPE_INT:
+ value.i = vm_call_int_array(m, array);
+ break;
- vmargs = DMNEW(vm_arg, vmargscount);
+ case PRIMITIVETYPE_LONG:
+ value.l = vm_call_long_array(m, array);
+ break;
- /* fill the vm_arg array from a va_list */
+ case PRIMITIVETYPE_FLOAT:
+ value.f = vm_call_float_array(m, array);
+ break;
- vm_vmargs_from_valist(m, o, vmargs, ap);
+ case PRIMITIVETYPE_DOUBLE:
+ value.d = vm_call_double_array(m, array);
+ break;
- /* call the Java method */
+ case TYPE_ADR:
+ ro = vm_call_array(m, array);
+ break;
- d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
+ default:
+ vm_abort("vm_call_method_objectarray: invalid return type %d", m->parseddesc->returntype.decltype);
+ }
/* 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,
- jvalue *args)
-{
- s4 vmargscount;
- vm_arg *vmargs;
- double d;
- s4 dumpsize;
-
- /* mark start of dump memory area */
-
- dumpsize = dump_size();
+ DRELEASE;
- /* get number of Java method arguments */
+ /* enter the nativeworld again */
- vmargscount = m->parseddesc->paramcount;
+ THREAD_NATIVEWORLD_ENTER;
- /* allocate vm_arg array */
+ /* box the return value if necesarry */
- vmargs = DMNEW(vm_arg, vmargscount);
+ if (m->parseddesc->returntype.decltype != TYPE_ADR)
+ ro = primitive_box(m->parseddesc->returntype.decltype, value);
- /* fill the vm_arg array from a va_list */
+ /* check for an exception */
- vm_vmargs_from_jvalue(m, o, vmargs, args);
-
- /* call the Java method */
-
- d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
-
- /* release dump area */
+ xptr = exceptions_get_exception();
- dump_release(dumpsize);
+ if (xptr != NULL) {
+ /* clear exception pointer, we are calling JIT code again */
- return d;
-}
-
-
-/* vm_call_method_double_vmarg *************************************************
-
- Calls a Java method with a variable number of arguments and returns
- a double.
-
-*******************************************************************************/
-
-double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
- vm_arg *vmargs)
-{
- double d;
+ exceptions_clear_exception();
-#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, vmargscount, vmargs);
-#else
- d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
-#endif
+ exceptions_throw_invocationtargetexception(xptr);
+ }
- return d;
+ return ro;
}
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/