1 /* src/vm/vm.c - VM startup and shutdown functions
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
29 Changes: Martin Platter
31 $Id: vm.c 4357 2006-01-22 23:33:38Z twisti $
45 #include "mm/memory.h"
46 #include "native/jni.h"
47 #include "native/native.h"
49 #if defined(ENABLE_THREADS)
50 # include "threads/native/threads.h"
53 #include "vm/classcache.h"
54 #include "vm/exceptions.h"
55 #include "vm/finalizer.h"
56 #include "vm/global.h"
57 #include "vm/initialize.h"
58 #include "vm/options.h"
59 #include "vm/properties.h"
60 #include "vm/signallocal.h"
61 #include "vm/stringlocal.h"
64 #include "vm/jit/jit.h"
65 #include "vm/jit/asmpart.h"
67 #include "vm/jit/recompile.h"
69 #include "vm/jit/profile/profile.h"
70 #include "vm/rt-timing.h"
72 #if defined(ENABLE_JVMTI)
73 #include "native/jvmti/cacaodbg.h"
77 /* Invocation API variables ***************************************************/
79 _Jv_JavaVM *_Jv_jvm; /* denotes a Java VM */
80 _Jv_JNIEnv *_Jv_env; /* pointer to native method interface */
83 /* global variables ***********************************************************/
85 s4 vms = 0; /* number of VMs created */
87 bool vm_initializing = false;
88 bool vm_exiting = false;
90 #if defined(ENABLE_INTRP)
91 u1 *intrp_main_stack = NULL;
94 char *mainstring = NULL;
95 classinfo *mainclass = NULL;
97 char *specificmethodname = NULL;
98 char *specificsignature = NULL;
103 /* define heap sizes **********************************************************/
105 #define HEAP_MAXSIZE 128 * 1024 * 1024 /* default 128MB */
106 #define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
107 #define STACK_SIZE 64 * 1024 /* default 64kB */
110 /* define command line options ************************************************/
137 /* Java non-standard options */
160 #if defined(ENABLE_STATISTICS)
177 #if defined(ENABLE_VERIFIER)
179 #if defined(TYPECHECK_VERBOSE)
182 #endif /* defined(ENABLE_VERIFIER) */
185 /* optimization options */
187 #if defined(ENABLE_LOOP)
191 #if defined(ENABLE_IFCONV)
195 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
199 #if defined(ENABLE_INLINING)
203 #if defined(ENABLE_INTRP)
204 /* interpreter options */
227 opt_struct opts[] = {
228 { "foo", false, OPT_FOO },
232 { "jar", false, OPT_JAR },
234 { "d32", false, OPT_D32 },
235 { "d64", false, OPT_D64 },
236 { "client", false, OPT_IGNORE },
237 { "server", false, OPT_IGNORE },
238 { "jvm", false, OPT_IGNORE },
239 { "hotspot", false, OPT_IGNORE },
241 { "classpath", true, OPT_CLASSPATH },
242 { "cp", true, OPT_CLASSPATH },
243 { "D", true, OPT_D },
244 { "version", false, OPT_VERSION },
245 { "showversion", false, OPT_SHOWVERSION },
246 { "fullversion", false, OPT_FULLVERSION },
247 { "help", false, OPT_HELP },
248 { "?", false, OPT_HELP },
249 { "X", false, OPT_X },
251 { "esa", false, OPT_ESA },
252 { "enablesystemassertions", false, OPT_ESA },
253 { "dsa", false, OPT_DSA },
254 { "disablesystemassertions", false, OPT_DSA },
256 { "noasyncgc", false, OPT_IGNORE },
257 #if defined(ENABLE_VERIFIER)
258 { "noverify", false, OPT_NOVERIFY },
260 { "v", false, OPT_VERBOSE1 },
261 { "verbose:", true, OPT_VERBOSE },
263 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
264 { "verbosetc", false, OPT_VERBOSETC },
266 #if defined(__ALPHA__)
267 { "noieee", false, OPT_NOIEEE },
269 { "softnull", false, OPT_SOFTNULL },
270 #if defined(ENABLE_STATISTICS)
271 { "time", false, OPT_TIME },
272 { "stat", false, OPT_STAT },
274 { "log", true, OPT_LOG },
275 { "c", true, OPT_CHECK },
276 { "l", false, OPT_LOAD },
277 { "eager", false, OPT_EAGER },
280 { "all", false, OPT_ALL },
281 { "sig", true, OPT_SIGNATURE },
284 #if defined(ENABLE_LOOP)
285 { "oloop", false, OPT_OLOOP },
287 #if defined(ENABLE_IFCONV)
288 { "ifconv", false, OPT_IFCONV },
290 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
291 { "lsra", false, OPT_LSRA },
294 #if defined(ENABLE_INTRP)
295 /* interpreter options */
297 { "trace", false, OPT_TRACE },
298 { "static-supers", true, OPT_STATIC_SUPERS },
299 { "no-dynamic", false, OPT_NO_DYNAMIC },
300 { "no-replication", false, OPT_NO_REPLICATION },
301 { "no-quicksuper", false, OPT_NO_QUICKSUPER },
304 /* JVMTI Agent Command Line Options */
306 { "agentlib:", true, OPT_AGENTLIB },
307 { "agentpath:", true, OPT_AGENTPATH },
310 /* Java non-standard options */
312 { "Xjit", false, OPT_JIT },
313 { "Xint", false, OPT_INTRP },
314 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
315 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
316 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
317 { "Xglibj:", true, OPT_GLIBJ },
320 { "Xdebug", false, OPT_DEBUG },
321 { "Xnoagent", false, OPT_NOAGENT },
322 { "Xrunjdwp", true, OPT_XRUNJDWP },
325 { "Xms", true, OPT_MS },
326 { "ms", true, OPT_MS },
327 { "Xmx", true, OPT_MX },
328 { "mx", true, OPT_MX },
329 { "Xss", true, OPT_SS },
330 { "ss", true, OPT_SS },
331 { "Xprof:", true, OPT_PROF_OPTION },
332 { "Xprof", false, OPT_PROF },
334 /* keep these at the end of the list */
336 #if defined(ENABLE_INLINING)
337 { "i", true, OPT_INLINING },
341 { "m", true, OPT_METHOD },
344 { "s", true, OPT_SHOW },
345 { "debug-color", false, OPT_DEBUGCOLOR },
351 /* usage ***********************************************************************
353 Prints the correct usage syntax to stdout.
355 *******************************************************************************/
359 puts("Usage: cacao [-options] classname [arguments]");
360 puts(" (to run a class file)");
361 puts(" or cacao [-options] -jar jarfile [arguments]");
362 puts(" (to run a standalone jar file)\n");
364 puts("Java options:");
365 puts(" -d32 use 32-bit data model if available");
366 puts(" -d64 use 64-bit data model if available");
367 puts(" -client compatibility (currently ignored)");
368 puts(" -server compatibility (currently ignored)");
369 puts(" -jvm compatibility (currently ignored)");
370 puts(" -hotspot compatibility (currently ignored)\n");
372 puts(" -cp <path> specify a path to look for classes");
373 puts(" -classpath <path> specify a path to look for classes");
374 puts(" -D<name>=<value> add an entry to the property list");
375 puts(" -verbose[:class|gc|jni] enable specific verbose output");
376 puts(" -version print product version and exit");
377 puts(" -fullversion print jpackage-compatible product version and exit");
378 puts(" -showversion print product version and continue");
379 puts(" -help, -? print this help message");
380 puts(" -X print help on non-standard Java options");
381 puts(" -esa | -enablesystemassertions");
382 puts(" enable system assertions");
383 puts(" -dsa | -disablesystemassertions");
384 puts(" disable system assertions");
388 puts(" -agentlib:<agent-lib-name>=<options> library to load containg JVMTI agent");
389 puts (" for jdwp help use: -agentlib:jdwp=help");
390 puts(" -agentpath:<path-to-agent>=<options> path to library containg JVMTI agent");
393 puts("CACAO options:");
394 puts(" -v write state-information");
395 puts(" -verbose[:call|exception|jit]");
396 puts(" enable specific verbose output");
397 puts(" -debug-color colored output for ANSI terms");
398 #ifdef TYPECHECK_VERBOSE
399 puts(" -verbosetc write debug messages while typechecking");
401 #if defined(__ALPHA__)
402 puts(" -noieee don't use ieee compliant arithmetic");
404 #if defined(ENABLE_VERIFIER)
405 puts(" -noverify don't verify classfiles");
407 puts(" -softnull use software nullpointer check");
408 #if defined(ENABLE_STATISTICS)
409 puts(" -time measure the runtime");
410 puts(" -stat detailed compiler statistics");
412 puts(" -log logfile specify a name for the logfile");
413 puts(" -c(heck)b(ounds) don't check array bounds");
414 puts(" s(ync) don't check for synchronization");
415 #if defined(ENABLE_LOOP)
416 puts(" -oloop optimize array accesses in loops");
418 puts(" -l don't start the class after loading");
419 puts(" -eager perform eager class loading and linking");
421 puts(" -all compile all methods, no execution");
422 puts(" -m compile only a specific method");
423 puts(" -sig specify signature for a specific method");
426 puts(" -s(how)... show...");
427 puts(" c(onstants) the constant pool");
428 puts(" m(ethods) class fields and methods");
429 puts(" u(tf) the utf - hash");
430 puts(" i(ntermediate) intermediate representation");
431 #if defined(ENABLE_DISASSEMBLER)
432 puts(" a(ssembler) disassembled listing");
433 puts(" e(xceptionstubs) disassembled exception stubs (only with -sa)");
434 puts(" n(ative) disassembled native stubs");
436 puts(" d(atasegment) data segment listing");
437 #if defined(ENABLE_INLINING)
438 puts(" -i n(line) activate inlining");
439 puts(" v(irtual) inline virtual methods (uses/turns rt option on)");
440 puts(" e(exception) inline methods with exceptions");
441 puts(" p(aramopt) optimize argument renaming");
442 puts(" o(utsiders) inline methods of foreign classes");
443 #endif /* defined(ENABLE_INLINING) */
444 #if defined(ENABLE_IFCONV)
445 puts(" -ifconv use if-conversion");
447 #if defined(ENABLE_LSRA)
448 puts(" -lsra use linear scan register allocation");
450 #if defined(ENABLE_SSA)
451 puts(" -lsra use linear scan register allocation (with SSA)");
454 /* exit with error code */
460 static void Xusage(void)
462 #if defined(ENABLE_JIT)
463 puts(" -Xjit JIT mode execution (default)");
465 #if defined(ENABLE_INTRP)
466 puts(" -Xint interpreter mode execution");
468 puts(" -Xbootclasspath:<zip/jar files and directories separated by :>");
469 puts(" value is set as bootstrap class path");
470 puts(" -Xbootclasspath/a:<zip/jar files and directories separated by :>");
471 puts(" value is appended to the bootstrap class path");
472 puts(" -Xbootclasspath/p:<zip/jar files and directories separated by :>");
473 puts(" value is prepended to the bootstrap class path");
474 puts(" -Xglibj:<zip/jar files and directories separated by :>");
475 puts(" value is used as Java core library, but the");
476 puts(" hardcoded VM interface classes are prepended");
477 printf(" -Xms<size> set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024);
478 printf(" -Xmx<size> set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024);
479 printf(" -Xss<size> set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024);
480 puts(" -Xprof[:bb] collect and print profiling data");
481 #if defined(ENABLE_JVMTI)
482 /* -Xdebug option depend on gnu classpath JDWP options. options:
483 transport=dt_socket,address=<hostname:port>,server=(y|n),suspend(y|n) */
484 puts(" -Xdebug enable remote debugging\n");
485 puts(" -Xrunjdwp transport=[dt_socket|...],address=<hostname:port>,server=[y|n],suspend=[y|n]\n");
486 puts(" enable remote debugging\n");
489 /* exit with error code */
495 /* version *********************************************************************
497 Only prints cacao version information.
499 *******************************************************************************/
501 static void version(bool opt_exit)
503 puts("java version \""JAVA_VERSION"\"");
504 puts("CACAO version "VERSION"");
506 puts("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,");
507 puts("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,");
508 puts("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,");
509 puts("J. Wenninger, Institut f. Computersprachen - TU Wien\n");
511 puts("This program is free software; you can redistribute it and/or");
512 puts("modify it under the terms of the GNU General Public License as");
513 puts("published by the Free Software Foundation; either version 2, or (at");
514 puts("your option) any later version.\n");
516 puts("This program is distributed in the hope that it will be useful, but");
517 puts("WITHOUT ANY WARRANTY; without even the implied warranty of");
518 puts("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU");
519 puts("General Public License for more details.\n");
521 puts("Configure/Build options:\n");
522 puts(" ./configure: "VERSION_CONFIGURE_ARGS"");
523 #if defined(__VERSION__)
524 puts(" CC : "VERSION_CC" ("__VERSION__")");
526 puts(" CC : "VERSION_CC"");
528 puts(" CFLAGS : "VERSION_CFLAGS"\n");
530 puts("Default variables:\n");
531 printf(" maximum heap size : %d\n", HEAP_MAXSIZE);
532 printf(" initial heap size : %d\n", HEAP_STARTSIZE);
533 printf(" stack size : %d\n", STACK_SIZE);
534 puts(" java.boot.class.path: "CACAO_VM_ZIP":"CLASSPATH_GLIBJ_ZIP"");
535 puts(" java.library.path : "CLASSPATH_LIBRARY_PATH"\n");
537 puts("Runtime variables:\n");
538 printf(" maximum heap size : %d\n", opt_heapmaxsize);
539 printf(" initial heap size : %d\n", opt_heapstartsize);
540 printf(" stack size : %d\n", opt_stacksize);
541 printf(" java.boot.class.path: %s\n", bootclasspath);
543 /* exit normally, if requested */
550 /* fullversion *****************************************************************
552 Prints a Sun compatible version information (required e.g. by
553 jpackage, www.jpackage.org).
555 *******************************************************************************/
557 static void fullversion(void)
559 puts("java full version \"cacao-"JAVA_VERSION"\"");
567 /* forward declarations *******************************************************/
569 static char *vm_get_mainclass_from_jar(char *mainstring);
571 static void vm_compile_all(void);
572 static void vm_compile_method(void);
576 /* vm_create *******************************************************************
578 Creates a JVM. Called by JNI_CreateJavaVM.
580 *******************************************************************************/
582 bool vm_create(JavaVMInitArgs *vm_args)
591 #if defined(ENABLE_JVMTI)
593 char *libname, *agentarg;
594 bool jdwp,agentbypath;
595 jdwp = agentbypath = false;
598 /* check the JNI version requested */
600 switch (vm_args->version) {
601 case JNI_VERSION_1_1:
603 case JNI_VERSION_1_2:
604 case JNI_VERSION_1_4:
610 /* we only support 1 JVM instance */
615 if (atexit(vm_exit_handler))
616 vm_abort("atexit failed: %s\n", strerror(errno));
619 log_text("CACAO started -------------------------------------------------------");
621 /* set the VM starttime */
623 _Jv_jvm->starttime = builtin_currenttimemillis();
625 /* get stuff from the environment *****************************************/
627 #if defined(DISABLE_GC)
628 nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
631 /* set the bootclasspath */
633 cp = getenv("BOOTCLASSPATH");
636 bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
637 strcpy(bootclasspath, cp);
640 len = strlen(CACAO_VM_ZIP) +
642 strlen(CLASSPATH_GLIBJ_ZIP) +
645 bootclasspath = MNEW(char, len);
646 strcat(bootclasspath, CACAO_VM_ZIP);
647 strcat(bootclasspath, ":");
648 strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP);
651 /* set the classpath */
653 cp = getenv("CLASSPATH");
656 classpath = MNEW(char, strlen(cp) + strlen("0"));
657 strcat(classpath, cp);
660 classpath = MNEW(char, strlen(".") + strlen("0"));
661 strcpy(classpath, ".");
665 /* interpret the options **************************************************/
673 opt_heapmaxsize = HEAP_MAXSIZE;
674 opt_heapstartsize = HEAP_STARTSIZE;
675 opt_stacksize = STACK_SIZE;
678 #if defined(ENABLE_JVMTI)
679 /* initialize JVMTI related **********************************************/
683 /* initialize properties before commandline handling */
685 if (!properties_init())
686 throw_cacao_exception_exit(string_java_lang_InternalError,
687 "Unable to init properties");
689 /* add some default properties */
691 properties_add("java.endorsed.dirs", ""CACAO_PREFIX"/jre/lib/endorsed");
693 /* iterate over all passed options */
695 while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
709 #if SIZEOF_VOID_P == 8
710 puts("Running a 32-bit JVM is not supported on this platform.");
716 #if SIZEOF_VOID_P == 4
717 puts("Running a 64-bit JVM is not supported on this platform.");
723 /* forget old classpath and set the argument as new classpath */
724 MFREE(classpath, char, strlen(classpath));
726 classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
727 strcpy(classpath, opt_arg);
731 for (j = 0; j < strlen(opt_arg); j++) {
732 if (opt_arg[j] == '=') {
734 properties_add(opt_arg, opt_arg + j + 1);
739 /* if no '=' is given, just create an empty property */
741 properties_add(opt_arg, "");
746 case OPT_BOOTCLASSPATH:
747 /* Forget default bootclasspath and set the argument as
748 new boot classpath. */
750 MFREE(bootclasspath, char, strlen(bootclasspath));
752 bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
753 strcpy(bootclasspath, opt_arg);
756 case OPT_BOOTCLASSPATH_A:
757 /* append to end of bootclasspath */
759 len = strlen(bootclasspath);
761 bootclasspath = MREALLOC(bootclasspath,
765 strlen(opt_arg) + strlen("0"));
767 strcat(bootclasspath, ":");
768 strcat(bootclasspath, opt_arg);
771 case OPT_BOOTCLASSPATH_P:
772 /* prepend in front of bootclasspath */
777 bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
780 strcpy(bootclasspath, opt_arg);
781 strcat(bootclasspath, ":");
782 strcat(bootclasspath, cp);
784 MFREE(cp, char, len);
788 /* use as Java core library, but prepend VM interface classes */
790 MFREE(bootclasspath, char, strlen(bootclasspath));
792 len = strlen(CACAO_VM_ZIP) +
797 bootclasspath = MNEW(char, len);
799 strcpy(bootclasspath, CACAO_VM_ZIP);
800 strcat(bootclasspath, ":");
801 strcat(bootclasspath, opt_arg);
804 #if defined(ENABLE_JVMTI)
806 /* this option exists only for compatibility reasons */
810 /* I don't know yet what Xnoagent should do. This is only for
811 compatiblity with eclipse - motse */
820 strlen(CACAO_LIBDIR) +
821 strlen("/libjdwp.so=") +
825 agentarg = MNEW(char, len);
827 strcpy(agentarg, CACAO_LIBDIR);
828 strcat(agentarg, "/libjdwp.so=");
829 strcat(agentarg, &opt_arg[1]);
846 c = opt_arg[strlen(opt_arg) - 1];
848 if ((c == 'k') || (c == 'K')) {
849 j = atoi(opt_arg) * 1024;
851 } else if ((c == 'm') || (c == 'M')) {
852 j = atoi(opt_arg) * 1024 * 1024;
859 else if (opt == OPT_MS)
860 opt_heapstartsize = j;
871 if (strcmp("class", opt_arg) == 0)
872 opt_verboseclass = true;
874 else if (strcmp("gc", opt_arg) == 0)
875 opt_verbosegc = true;
877 else if (strcmp("jni", opt_arg) == 0)
878 opt_verbosejni = true;
880 else if (strcmp("call", opt_arg) == 0)
881 opt_verbosecall = true;
883 else if (strcmp("jit", opt_arg) == 0) {
888 compileverbose = true;
890 else if (strcmp("exception", opt_arg) == 0)
891 opt_verboseexception = true;
894 opt_debugcolor = true;
897 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
899 opt_typecheckverbose = true;
908 case OPT_FULLVERSION:
912 case OPT_SHOWVERSION:
920 #if defined(ENABLE_VERIFIER)
930 #if defined(ENABLE_STATISTICS)
932 opt_getcompilingtime = true;
933 opt_getloadingtime = true;
946 for (j = 0; j < strlen(opt_arg); j++) {
947 switch (opt_arg[j]) {
962 makeinitializations = false;
973 makeinitializations = false;
978 opt_method = opt_arg;
979 makeinitializations = false;
983 opt_signature = opt_arg;
987 case OPT_SHOW: /* Display options */
988 for (j = 0; j < strlen(opt_arg); j++) {
989 switch (opt_arg[j]) {
991 showconstantpool = true;
1003 opt_showintermediate = true;
1004 compileverbose = true;
1007 #if defined(ENABLE_DISASSEMBLER)
1009 opt_showdisassemble = true;
1010 compileverbose = true;
1014 opt_showexceptionstubs = true;
1018 opt_shownativestub = true;
1023 opt_showddatasegment = true;
1032 #if defined(ENABLE_LOOP)
1038 #if defined(ENABLE_INLINING)
1040 for (j = 0; j < strlen(opt_arg); j++) {
1041 switch (opt_arg[j]) {
1043 /* define in options.h; Used in main.c, jit.c
1044 & inline.c inlining is currently
1048 inlinevirtuals = true;
1051 inlineexceptions = true;
1054 inlineparamopt = true;
1057 inlineoutsiders = true;
1064 #endif /* defined(ENABLE_INLINING) */
1066 #if defined(ENABLE_IFCONV)
1072 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1087 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = true;
1091 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = false;
1094 case OPT_PROF_OPTION:
1095 /* use <= to get the last \0 too */
1097 for (j = 0, k = 0; j <= strlen(opt_arg); j++) {
1098 if (opt_arg[j] == ',')
1101 if (opt_arg[j] == '\0') {
1102 if (strcmp("bb", opt_arg + k) == 0)
1106 printf("Unknown option: -Xprof:%s\n", opt_arg + k);
1110 /* set k to next char */
1122 #if defined(ENABLE_JIT)
1125 printf("-Xjit option not enabled.\n");
1131 #if defined(ENABLE_INTRP)
1134 printf("-Xint option not enabled.\n");
1139 #if defined(ENABLE_INTRP)
1140 case OPT_STATIC_SUPERS:
1141 opt_static_supers = atoi(opt_arg);
1144 case OPT_NO_DYNAMIC:
1145 opt_no_dynamic = true;
1148 case OPT_NO_REPLICATION:
1149 opt_no_replication = true;
1152 case OPT_NO_QUICKSUPER:
1153 opt_no_quicksuper = true;
1162 printf("Unknown option: %s\n",
1163 vm_args->options[opt_index].optionString);
1169 /* Now we have all options handled and we can print the version
1176 /* get the main class *****************************************************/
1178 if (opt_index < vm_args->nOptions) {
1179 mainstring = vm_args->options[opt_index++].optionString;
1181 /* Put the jar file into the classpath (if any). */
1183 if (opt_jar == true) {
1184 /* free old classpath */
1186 MFREE(classpath, char, strlen(classpath));
1188 /* put jarfile into classpath */
1190 classpath = MNEW(char, strlen(mainstring) + strlen("0"));
1192 strcpy(classpath, mainstring);
1195 /* replace .'s with /'s in classname */
1197 for (i = strlen(mainstring) - 1; i >= 0; i--)
1198 if (mainstring[i] == '.')
1199 mainstring[i] = '/';
1203 #if defined(ENABLE_JVMTI)
1205 jvmti_set_phase(JVMTI_PHASE_ONLOAD);
1206 jvmti_agentload(agentarg, agentbypath, &handle, &libname);
1209 MFREE(agentarg, char, strlen(agentarg));
1211 jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
1217 /* initialize this JVM ****************************************************/
1219 vm_initializing = true;
1221 /* initialize the garbage collector */
1223 gc_init(opt_heapmaxsize, opt_heapstartsize);
1225 #if defined(ENABLE_INTRP)
1226 /* Allocate main thread stack on the Java heap. */
1229 intrp_main_stack = GCMNEW(u1, opt_stacksize);
1230 MSET(intrp_main_stack, 0, u1, opt_stacksize);
1234 #if defined(ENABLE_THREADS)
1238 /* initialize the string hashtable stuff: lock (must be done
1239 _after_ threads_preinit) */
1242 throw_main_exception_exit();
1244 /* initialize the utf8 hashtable stuff: lock, often used utf8
1245 strings (must be done _after_ threads_preinit) */
1248 throw_main_exception_exit();
1250 /* initialize the classcache hashtable stuff: lock, hashtable
1251 (must be done _after_ threads_preinit) */
1253 if (!classcache_init())
1254 throw_main_exception_exit();
1256 /* initialize the loader with bootclasspath (must be done _after_
1260 throw_main_exception_exit();
1262 suck_add_from_property("java.endorsed.dirs");
1263 suck_add(bootclasspath);
1265 /* initialize the memory subsystem (must be done _after_
1269 throw_main_exception_exit();
1271 /* initialize the finalizer stuff (must be done _after_
1274 if (!finalizer_init())
1275 throw_main_exception_exit();
1277 /* install architecture dependent signal handler used for exceptions */
1281 /* initialize the codegen subsystems */
1285 /* initializes jit compiler */
1289 /* machine dependent initialization */
1291 #if defined(ENABLE_JIT)
1292 # if defined(ENABLE_INTRP)
1302 /* initialize the loader subsystems (must be done _after_
1306 throw_main_exception_exit();
1309 throw_main_exception_exit();
1312 throw_main_exception_exit();
1314 if (!exceptions_init())
1315 throw_main_exception_exit();
1317 if (!builtin_init())
1318 throw_main_exception_exit();
1320 /* Initialize the JNI subsystem (must be done _before_
1321 threads_init, as threads_init can call JNI methods
1322 (e.g. NewGlobalRef). */
1325 throw_main_exception_exit();
1327 #if defined(ENABLE_THREADS)
1328 if (!threads_init())
1329 throw_main_exception_exit();
1332 /* That's important, otherwise we get into trouble, if the Runtime
1333 static initializer is called before (circular dependency. This
1334 is with classpath 0.09. Another important thing is, that this
1335 has to happen after initThreads!!! */
1337 if (!initialize_class(class_java_lang_System))
1338 throw_main_exception_exit();
1340 #if defined(ENABLE_PROFILING)
1341 /* initialize profiling */
1343 if (!profile_init())
1344 throw_main_exception_exit();
1347 #if defined(ENABLE_THREADS)
1348 /* initialize recompilation */
1350 if (!recompile_init())
1351 throw_main_exception_exit();
1353 /* finally, start the finalizer thread */
1355 if (!finalizer_start_thread())
1356 throw_main_exception_exit();
1358 /* start the recompilation thread (must be done before the
1359 profiling thread) */
1361 if (!recompile_start_thread())
1362 throw_main_exception_exit();
1364 # if defined(ENABLE_PROFILING)
1365 /* start the profile sampling thread */
1368 if (!profile_start_thread())
1369 throw_main_exception_exit();
1373 #if defined(ENABLE_JVMTI)
1375 /* add agent library to native library hashtable */
1376 native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
1380 /* increment the number of VMs */
1384 /* initialization is done */
1386 vm_initializing = false;
1388 /* everything's ok */
1394 /* vm_run **********************************************************************
1396 Runs the main-method of the passed class.
1398 *******************************************************************************/
1400 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
1403 classinfo *mainclass;
1405 java_objectarray *oa;
1408 java_lang_String *s;
1412 #if !defined(NDEBUG)
1418 if (opt_method != NULL) {
1419 vm_compile_method();
1422 #endif /* !defined(NDEBUG) */
1424 /* should we run the main-method? */
1426 if (mainstring == NULL)
1429 /* set return value to OK */
1433 if (opt_jar == true)
1434 /* open jar file with java.util.jar.JarFile */
1435 mainstring = vm_get_mainclass_from_jar(mainstring);
1437 /* load the main class */
1439 mainutf = utf_new_char(mainstring);
1441 if (!(mainclass = load_class_from_sysloader(mainutf)))
1442 throw_main_exception_exit();
1444 /* error loading class, clear exceptionptr for new exception */
1446 if (*exceptionptr || !mainclass) {
1447 /* *exceptionptr = NULL; */
1449 /* *exceptionptr = */
1450 /* new_exception_message(string_java_lang_NoClassDefFoundError, */
1452 throw_main_exception_exit();
1455 if (!link_class(mainclass))
1456 throw_main_exception_exit();
1458 /* find the `main' method of the main class */
1460 m = class_resolveclassmethod(mainclass,
1461 utf_new_char("main"),
1462 utf_new_char("([Ljava/lang/String;)V"),
1463 class_java_lang_Object,
1466 if (*exceptionptr) {
1467 throw_main_exception_exit();
1470 /* there is no main method or it isn't static */
1472 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
1473 *exceptionptr = NULL;
1476 new_exception_message(string_java_lang_NoSuchMethodError, "main");
1477 throw_main_exception_exit();
1480 /* build argument array */
1482 oalength = vm_args->nOptions - opt_index;
1484 oa = builtin_anewarray(oalength, class_java_lang_String);
1486 for (i = 0; i < oalength; i++) {
1487 u = utf_new_char(vm_args->options[opt_index + i].optionString);
1488 s = javastring_new(u);
1490 oa->data[i] = (java_objectheader *) s;
1493 #ifdef TYPEINFO_DEBUG_TEST
1494 /* test the typeinfo system */
1497 /*class_showmethods(currentThread->group->header.vftbl->class); */
1499 #if defined(ENABLE_JVMTI)
1500 jvmti_set_phase(JVMTI_PHASE_LIVE);
1503 /* increase total started thread count */
1505 _Jv_jvm->total_started_thread_count++;
1507 /* start the main thread */
1509 (void) vm_call_method(m, NULL, oa);
1511 /* exception occurred? */
1513 if (*exceptionptr) {
1514 throw_main_exception();
1518 /* unload the JavaVM */
1528 /* vm_destroy ******************************************************************
1530 Unloads a Java VM and reclaims its resources.
1532 *******************************************************************************/
1534 s4 vm_destroy(JavaVM *vm)
1536 #if defined(ENABLE_THREADS)
1537 threads_join_all_threads();
1540 /* everything's ok */
1546 /* vm_exit *********************************************************************
1548 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1550 *******************************************************************************/
1552 void vm_exit(s4 status)
1556 /* signal that we are exiting */
1560 assert(class_java_lang_System);
1561 assert(class_java_lang_System->state & CLASS_LOADED);
1563 #if defined(ENABLE_JVMTI)
1564 if (jvmti || (dbgcom!=NULL)) {
1565 jvmti_set_phase(JVMTI_PHASE_DEAD);
1566 if (jvmti) jvmti_agentunload();
1570 if (!link_class(class_java_lang_System))
1571 throw_main_exception_exit();
1573 /* call java.lang.System.exit(I)V */
1575 m = class_resolveclassmethod(class_java_lang_System,
1576 utf_new_char("exit"),
1578 class_java_lang_Object,
1582 throw_main_exception_exit();
1584 /* call the exit function with passed exit status */
1586 (void) vm_call_method(m, NULL, status);
1588 /* If we had an exception, just ignore the exception and exit with
1591 vm_shutdown(status);
1595 /* vm_shutdown *****************************************************************
1597 Terminates the system immediately without freeing memory explicitly
1598 (to be used only for abnormal termination).
1600 *******************************************************************************/
1602 void vm_shutdown(s4 status)
1605 #if defined(ENABLE_STATISTICS)
1606 || opt_getcompilingtime || opt_stat
1610 log_text("CACAO terminated by shutdown");
1611 dolog("Exit status: %d\n", (s4) status);
1615 #if defined(ENABLE_JVMTI)
1616 /* terminate cacaodbgserver */
1618 pthread_mutex_lock(&dbgcomlock);
1620 pthread_mutex_unlock(&dbgcomlock);
1621 jvmti_cacaodbgserver_quit();
1629 /* vm_exit_handler *************************************************************
1631 The exit_handler function is called upon program termination.
1633 ATTENTION: Don't free system resources here! Some threads may still
1634 be running as this is called from VMRuntime.exit(). The OS does the
1637 *******************************************************************************/
1639 void vm_exit_handler(void)
1641 #if !defined(NDEBUG)
1643 class_showmethods(mainclass);
1645 if (showconstantpool)
1646 class_showconstantpool(mainclass);
1651 # if defined(ENABLE_PROFILING)
1653 profile_printstats();
1655 #endif /* !defined(NDEBUG) */
1657 #if defined(ENABLE_RT_TIMING)
1658 rt_timing_print_time_stats(stderr);
1661 #if defined(ENABLE_CYCLES_STATS)
1662 builtin_print_cycles_stats(stderr);
1663 stacktrace_print_cycles_stats(stderr);
1667 #if defined(ENABLE_STATISTICS)
1668 || opt_getcompilingtime || opt_stat
1672 log_text("CACAO terminated");
1674 #if defined(ENABLE_STATISTICS)
1677 #ifdef TYPECHECK_STATISTICS
1678 typecheck_print_statistics(get_logfile());
1684 if (opt_getcompilingtime)
1686 #endif /* defined(ENABLE_STATISTICS) */
1688 /* vm_print_profile(stderr);*/
1692 /* vm_abort ********************************************************************
1694 Prints an error message and aborts the VM.
1696 *******************************************************************************/
1698 void vm_abort(const char *text, ...)
1702 /* print the log message */
1707 log_vprint(text, ap);
1712 /* now abort the VM */
1718 /* vm_get_mainclass_from_jar ***************************************************
1720 Gets the name of the main class from a JAR's manifest file.
1722 *******************************************************************************/
1724 static char *vm_get_mainclass_from_jar(char *mainstring)
1727 java_objectheader *o;
1729 java_lang_String *s;
1731 c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
1734 throw_main_exception_exit();
1736 /* create JarFile object */
1741 throw_main_exception_exit();
1744 m = class_resolveclassmethod(c,
1746 utf_java_lang_String__void,
1747 class_java_lang_Object,
1751 throw_main_exception_exit();
1753 s = javastring_new_from_ascii(mainstring);
1755 (void) vm_call_method(m, o, s);
1758 throw_main_exception_exit();
1760 /* get manifest object */
1762 m = class_resolveclassmethod(c,
1763 utf_new_char("getManifest"),
1764 utf_new_char("()Ljava/util/jar/Manifest;"),
1765 class_java_lang_Object,
1769 throw_main_exception_exit();
1771 o = vm_call_method(m, o);
1774 fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
1779 /* get Main Attributes */
1781 m = class_resolveclassmethod(o->vftbl->class,
1782 utf_new_char("getMainAttributes"),
1783 utf_new_char("()Ljava/util/jar/Attributes;"),
1784 class_java_lang_Object,
1788 throw_main_exception_exit();
1790 o = vm_call_method(m, o);
1793 fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
1798 /* get property Main-Class */
1800 m = class_resolveclassmethod(o->vftbl->class,
1801 utf_new_char("getValue"),
1802 utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
1803 class_java_lang_Object,
1807 throw_main_exception_exit();
1809 s = javastring_new_from_ascii("Main-Class");
1811 o = vm_call_method(m, o, s);
1814 throw_main_exception_exit();
1816 return javastring_tochar(o);
1820 /* vm_compile_all **************************************************************
1822 Compile all methods found in the bootclasspath.
1824 *******************************************************************************/
1826 #if !defined(NDEBUG)
1827 static void vm_compile_all(void)
1832 classcache_name_entry *nmen;
1833 classcache_class_entry *clsen;
1836 /* create all classes found in the bootclasspath */
1837 /* XXX currently only works with zip/jar's */
1839 loader_load_all_classes();
1841 /* link all classes */
1843 for (slot = 0; slot < hashtable_classcache.size; slot++) {
1844 nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
1846 for (; nmen; nmen = nmen->hashlink) {
1847 /* iterate over all class entries */
1849 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1850 c = clsen->classobj;
1855 if (!(c->state & CLASS_LINKED)) {
1856 if (!link_class(c)) {
1857 fprintf(stderr, "Error linking: ");
1858 utf_fprint_printable_ascii_classname(stderr, c->name);
1859 fprintf(stderr, "\n");
1861 /* print out exception and cause */
1863 exceptions_print_exception(*exceptionptr);
1865 /* goto next class */
1871 /* compile all class methods */
1873 for (i = 0; i < c->methodscount; i++) {
1874 m = &(c->methods[i]);
1876 if (m->jcode != NULL) {
1877 if (!jit_compile(m)) {
1878 fprintf(stderr, "Error compiling: ");
1879 utf_fprint_printable_ascii_classname(stderr, c->name);
1880 fprintf(stderr, ".");
1881 utf_fprint_printable_ascii(stderr, m->name);
1882 utf_fprint_printable_ascii(stderr, m->descriptor);
1883 fprintf(stderr, "\n");
1885 /* print out exception and cause */
1887 exceptions_print_exception(*exceptionptr);
1895 #endif /* !defined(NDEBUG) */
1898 /* vm_compile_method ***********************************************************
1900 Compile a specific method.
1902 *******************************************************************************/
1904 #if !defined(NDEBUG)
1905 static void vm_compile_method(void)
1909 /* create, load and link the main class */
1911 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
1912 throw_main_exception_exit();
1914 if (!link_class(mainclass))
1915 throw_main_exception_exit();
1917 if (opt_signature != NULL) {
1918 m = class_resolveclassmethod(mainclass,
1919 utf_new_char(opt_method),
1920 utf_new_char(opt_signature),
1925 m = class_resolveclassmethod(mainclass,
1926 utf_new_char(opt_method),
1933 char message[MAXLOGTEXT];
1934 sprintf(message, "%s%s", opt_method,
1935 opt_signature ? opt_signature : "");
1938 new_exception_message(string_java_lang_NoSuchMethodException,
1941 throw_main_exception_exit();
1946 #endif /* !defined(NDEBUG) */
1949 /* vm_vmargs_from_valist *******************************************************
1953 *******************************************************************************/
1955 static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
1956 vm_arg *vmargs, va_list ap)
1958 typedesc *paramtypes;
1961 paramtypes = m->parseddesc->paramtypes;
1963 /* if method is non-static fill first block and skip `this' pointer */
1968 /* the `this' pointer */
1969 vmargs[0].type = TYPE_ADR;
1970 vmargs[0].data.l = (u8) (ptrint) o;
1976 for (; i < m->parseddesc->paramcount; i++, paramtypes++) {
1977 switch (paramtypes->decltype) {
1978 /* primitive types */
1979 case PRIMITIVETYPE_BOOLEAN:
1980 case PRIMITIVETYPE_BYTE:
1981 case PRIMITIVETYPE_CHAR:
1982 case PRIMITIVETYPE_SHORT:
1983 case PRIMITIVETYPE_INT:
1984 vmargs[i].type = TYPE_INT;
1985 vmargs[i].data.l = (s8) va_arg(ap, s4);
1988 case PRIMITIVETYPE_LONG:
1989 vmargs[i].type = TYPE_LNG;
1990 vmargs[i].data.l = (s8) va_arg(ap, s8);
1993 case PRIMITIVETYPE_FLOAT:
1994 vmargs[i].type = TYPE_FLT;
1995 #if defined(__ALPHA__)
1996 /* this keeps the assembler function much simpler */
1998 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2000 vmargs[i].data.f = (jfloat) va_arg(ap, jdouble);
2004 case PRIMITIVETYPE_DOUBLE:
2005 vmargs[i].type = TYPE_DBL;
2006 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2010 vmargs[i].type = TYPE_ADR;
2011 vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*);
2018 /* vm_vmargs_from_jvalue *******************************************************
2022 *******************************************************************************/
2024 static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
2025 vm_arg *vmargs, jvalue *args)
2027 typedesc *paramtypes;
2031 paramtypes = m->parseddesc->paramtypes;
2033 /* if method is non-static fill first block and skip `this' pointer */
2038 /* the `this' pointer */
2039 vmargs[0].type = TYPE_ADR;
2040 vmargs[0].data.l = (u8) (ptrint) o;
2046 for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) {
2047 switch (paramtypes->decltype) {
2048 /* primitive types */
2049 case PRIMITIVETYPE_BOOLEAN:
2050 case PRIMITIVETYPE_BYTE:
2051 case PRIMITIVETYPE_CHAR:
2052 case PRIMITIVETYPE_SHORT:
2053 case PRIMITIVETYPE_INT:
2054 vmargs[i].type = TYPE_INT;
2055 vmargs[i].data.l = (s8) args[j].i;
2058 case PRIMITIVETYPE_LONG:
2059 vmargs[i].type = TYPE_LNG;
2060 vmargs[i].data.l = (s8) args[j].j;
2063 case PRIMITIVETYPE_FLOAT:
2064 vmargs[i].type = TYPE_FLT;
2065 #if defined(__ALPHA__)
2066 /* this keeps the assembler function much simpler */
2068 vmargs[i].data.d = (jdouble) args[j].f;
2070 vmargs[i].data.f = args[j].f;
2074 case PRIMITIVETYPE_DOUBLE:
2075 vmargs[i].type = TYPE_DBL;
2076 vmargs[i].data.d = args[j].d;
2080 vmargs[i].type = TYPE_ADR;
2081 vmargs[i].data.l = (u8) (ptrint) args[j].l;
2088 /* vm_call_method **************************************************************
2090 Calls a Java method with a variable number of arguments and returns
2093 *******************************************************************************/
2095 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
2098 java_objectheader *ro;
2101 ro = vm_call_method_valist(m, o, ap);
2108 /* vm_call_method_valist *******************************************************
2110 Calls a Java method with a variable number of arguments, passed via
2111 a va_list, and returns an address.
2113 *******************************************************************************/
2115 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
2120 java_objectheader *ro;
2123 /* mark start of dump memory area */
2125 dumpsize = dump_size();
2127 /* get number of Java method arguments */
2129 vmargscount = m->parseddesc->paramcount;
2131 /* allocate vm_arg array */
2133 vmargs = DMNEW(vm_arg, vmargscount);
2135 /* fill the vm_arg array from a va_list */
2137 vm_vmargs_from_valist(m, o, vmargs, ap);
2139 /* call the Java method */
2141 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2143 /* release dump area */
2145 dump_release(dumpsize);
2151 /* vm_call_method_jvalue *******************************************************
2153 Calls a Java method with a variable number of arguments, passed via
2154 a jvalue array, and returns an address.
2156 *******************************************************************************/
2158 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
2163 java_objectheader *ro;
2166 /* mark start of dump memory area */
2168 dumpsize = dump_size();
2170 /* get number of Java method arguments */
2172 vmargscount = m->parseddesc->paramcount;
2174 /* allocate vm_arg array */
2176 vmargs = DMNEW(vm_arg, vmargscount);
2178 /* fill the vm_arg array from a va_list */
2180 vm_vmargs_from_jvalue(m, o, vmargs, args);
2182 /* call the Java method */
2184 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2186 /* release dump area */
2188 dump_release(dumpsize);
2194 /* vm_call_method_vmarg ********************************************************
2196 Calls a Java method with a variable number of arguments, passed via
2197 a vm_arg array, and returns an address.
2199 *******************************************************************************/
2201 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
2204 java_objectheader *o;
2206 #if defined(ENABLE_JIT)
2207 # if defined(ENABLE_INTRP)
2209 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2212 o = asm_vm_call_method(m, vmargscount, vmargs);
2214 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2221 /* vm_call_method_int **********************************************************
2223 Calls a Java method with a variable number of arguments and returns
2226 *******************************************************************************/
2228 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
2234 i = vm_call_method_int_valist(m, o, ap);
2241 /* vm_call_method_int_valist ***************************************************
2243 Calls a Java method with a variable number of arguments, passed via
2244 a va_list, and returns an integer (s4).
2246 *******************************************************************************/
2248 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
2255 /* mark start of dump memory area */
2257 dumpsize = dump_size();
2259 /* get number of Java method arguments */
2261 vmargscount = m->parseddesc->paramcount;
2263 /* allocate vm_arg array */
2265 vmargs = DMNEW(vm_arg, vmargscount);
2267 /* fill the vm_arg array from a va_list */
2269 vm_vmargs_from_valist(m, o, vmargs, ap);
2271 /* call the Java method */
2273 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2275 /* release dump area */
2277 dump_release(dumpsize);
2283 /* vm_call_method_int_jvalue ***************************************************
2285 Calls a Java method with a variable number of arguments, passed via
2286 a jvalue array, and returns an integer (s4).
2288 *******************************************************************************/
2290 s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2297 /* mark start of dump memory area */
2299 dumpsize = dump_size();
2301 /* get number of Java method arguments */
2303 vmargscount = m->parseddesc->paramcount;
2305 /* allocate vm_arg array */
2307 vmargs = DMNEW(vm_arg, vmargscount);
2309 /* fill the vm_arg array from a va_list */
2311 vm_vmargs_from_jvalue(m, o, vmargs, args);
2313 /* call the Java method */
2315 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2317 /* release dump area */
2319 dump_release(dumpsize);
2325 /* vm_call_method_int_vmarg ****************************************************
2327 Calls a Java method with a variable number of arguments, passed via
2328 a vm_arg array, and returns an integer (s4).
2330 *******************************************************************************/
2332 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2336 #if defined(ENABLE_JIT)
2337 # if defined(ENABLE_INTRP)
2339 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2342 i = asm_vm_call_method_int(m, vmargscount, vmargs);
2344 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2351 /* vm_call_method_long *********************************************************
2353 Calls a Java method with a variable number of arguments and returns
2356 *******************************************************************************/
2358 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
2364 l = vm_call_method_long_valist(m, o, ap);
2371 /* vm_call_method_long_valist **************************************************
2373 Calls a Java method with a variable number of arguments, passed via
2374 a va_list, and returns a long (s8).
2376 *******************************************************************************/
2378 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
2385 /* mark start of dump memory area */
2387 dumpsize = dump_size();
2389 /* get number of Java method arguments */
2391 vmargscount = m->parseddesc->paramcount;
2393 /* allocate vm_arg array */
2395 vmargs = DMNEW(vm_arg, vmargscount);
2397 /* fill the vm_arg array from a va_list */
2399 vm_vmargs_from_valist(m, o, vmargs, ap);
2401 /* call the Java method */
2403 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2405 /* release dump area */
2407 dump_release(dumpsize);
2413 /* vm_call_method_long_jvalue **************************************************
2415 Calls a Java method with a variable number of arguments, passed via
2416 a jvalue array, and returns a long (s8).
2418 *******************************************************************************/
2420 s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2427 /* mark start of dump memory area */
2429 dumpsize = dump_size();
2431 /* get number of Java method arguments */
2433 vmargscount = m->parseddesc->paramcount;
2435 /* allocate vm_arg array */
2437 vmargs = DMNEW(vm_arg, vmargscount);
2439 /* fill the vm_arg array from a va_list */
2441 vm_vmargs_from_jvalue(m, o, vmargs, args);
2443 /* call the Java method */
2445 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2447 /* release dump area */
2449 dump_release(dumpsize);
2455 /* vm_call_method_long_vmarg ***************************************************
2457 Calls a Java method with a variable number of arguments, passed via
2458 a vm_arg array, and returns a long (s8).
2460 *******************************************************************************/
2462 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2466 #if defined(ENABLE_JIT)
2467 # if defined(ENABLE_INTRP)
2469 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2472 l = asm_vm_call_method_long(m, vmargscount, vmargs);
2474 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2481 /* vm_call_method_float ********************************************************
2483 Calls a Java method with a variable number of arguments and returns
2486 *******************************************************************************/
2488 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
2494 f = vm_call_method_float_valist(m, o, ap);
2501 /* vm_call_method_float_valist *************************************************
2503 Calls a Java method with a variable number of arguments, passed via
2504 a va_list, and returns a float.
2506 *******************************************************************************/
2508 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
2516 /* mark start of dump memory area */
2518 dumpsize = dump_size();
2520 /* get number of Java method arguments */
2522 vmargscount = m->parseddesc->paramcount;
2524 /* allocate vm_arg array */
2526 vmargs = DMNEW(vm_arg, vmargscount);
2528 /* fill the vm_arg array from a va_list */
2530 vm_vmargs_from_valist(m, o, vmargs, ap);
2532 /* call the Java method */
2534 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2536 /* release dump area */
2538 dump_release(dumpsize);
2544 /* vm_call_method_float_jvalue *************************************************
2546 Calls a Java method with a variable number of arguments, passed via
2547 a jvalue array, and returns a float.
2549 *******************************************************************************/
2551 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
2559 /* mark start of dump memory area */
2561 dumpsize = dump_size();
2563 /* get number of Java method arguments */
2565 vmargscount = m->parseddesc->paramcount;
2567 /* allocate vm_arg array */
2569 vmargs = DMNEW(vm_arg, vmargscount);
2571 /* fill the vm_arg array from a va_list */
2573 vm_vmargs_from_jvalue(m, o, vmargs, args);
2575 /* call the Java method */
2577 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2579 /* release dump area */
2581 dump_release(dumpsize);
2587 /* vm_call_method_float_vmarg **************************************************
2589 Calls a Java method with a variable number of arguments and returns
2592 *******************************************************************************/
2594 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2598 #if defined(ENABLE_JIT)
2599 # if defined(ENABLE_INTRP)
2601 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2604 f = asm_vm_call_method_float(m, vmargscount, vmargs);
2606 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2613 /* vm_call_method_double *******************************************************
2615 Calls a Java method with a variable number of arguments and returns
2618 *******************************************************************************/
2620 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
2626 d = vm_call_method_double_valist(m, o, ap);
2633 /* vm_call_method_double_valist ************************************************
2635 Calls a Java method with a variable number of arguments, passed via
2636 a va_list, and returns a double.
2638 *******************************************************************************/
2640 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
2648 /* mark start of dump memory area */
2650 dumpsize = dump_size();
2652 /* get number of Java method arguments */
2654 vmargscount = m->parseddesc->paramcount;
2656 /* allocate vm_arg array */
2658 vmargs = DMNEW(vm_arg, vmargscount);
2660 /* fill the vm_arg array from a va_list */
2662 vm_vmargs_from_valist(m, o, vmargs, ap);
2664 /* call the Java method */
2666 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2668 /* release dump area */
2670 dump_release(dumpsize);
2676 /* vm_call_method_double_jvalue ************************************************
2678 Calls a Java method with a variable number of arguments, passed via
2679 a jvalue array, and returns a double.
2681 *******************************************************************************/
2683 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
2691 /* mark start of dump memory area */
2693 dumpsize = dump_size();
2695 /* get number of Java method arguments */
2697 vmargscount = m->parseddesc->paramcount;
2699 /* allocate vm_arg array */
2701 vmargs = DMNEW(vm_arg, vmargscount);
2703 /* fill the vm_arg array from a va_list */
2705 vm_vmargs_from_jvalue(m, o, vmargs, args);
2707 /* call the Java method */
2709 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2711 /* release dump area */
2713 dump_release(dumpsize);
2719 /* vm_call_method_double_vmarg *************************************************
2721 Calls a Java method with a variable number of arguments and returns
2724 *******************************************************************************/
2726 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
2731 #if defined(ENABLE_JIT)
2732 # if defined(ENABLE_INTRP)
2734 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2737 d = asm_vm_call_method_double(m, vmargscount, vmargs);
2739 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2747 * These are local overrides for various environment variables in Emacs.
2748 * Please do not remove this and leave it at the end of the file, where
2749 * Emacs will automagically detect them.
2750 * ---------------------------------------------------------------------
2753 * indent-tabs-mode: t