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 $
42 #if defined(WITH_JRE_LAYOUT)
49 #include "mm/gc-common.h"
50 #include "mm/memory.h"
51 #include "native/jni.h"
52 #include "native/native.h"
54 #if defined(ENABLE_THREADS)
55 # include "threads/native/threads.h"
58 #include "vm/classcache.h"
59 #include "vm/exceptions.h"
60 #include "vm/finalizer.h"
61 #include "vm/global.h"
62 #include "vm/initialize.h"
63 #include "vm/options.h"
64 #include "vm/properties.h"
65 #include "vm/rt-timing.h"
66 #include "vm/signallocal.h"
67 #include "vm/stringlocal.h"
70 #include "vm/jit/jit.h"
71 #include "vm/jit/asmpart.h"
73 #if defined(ENABLE_PROFILING)
74 # include "vm/jit/optimizing/profile.h"
77 #include "vm/jit/optimizing/recompile.h"
79 #if defined(ENABLE_JVMTI)
80 #include "native/jvmti/cacaodbg.h"
84 /* Invocation API variables ***************************************************/
86 _Jv_JavaVM *_Jv_jvm; /* denotes a Java VM */
87 _Jv_JNIEnv *_Jv_env; /* pointer to native method interface */
90 /* global variables ***********************************************************/
92 s4 vms = 0; /* number of VMs created */
94 bool vm_initializing = false;
95 bool vm_exiting = false;
97 char *cacao_prefix = NULL;
98 char *cacao_libjvm = NULL;
99 char *classpath_libdir = NULL;
101 char *_Jv_bootclasspath; /* contains the boot classpath */
102 char *_Jv_classpath; /* contains the classpath */
103 char *_Jv_java_library_path;
105 char *mainstring = NULL;
106 classinfo *mainclass = NULL;
108 char *specificmethodname = NULL;
109 char *specificsignature = NULL;
113 #if defined(ENABLE_INTRP)
114 u1 *intrp_main_stack = NULL;
118 /* define heap sizes **********************************************************/
120 #define HEAP_MAXSIZE 128 * 1024 * 1024 /* default 128MB */
121 #define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
122 #define STACK_SIZE 64 * 1024 /* default 64kB */
125 /* define command line options ************************************************/
152 /* Java non-standard options */
163 #if defined(ENABLE_PROFILING)
177 #if defined(ENABLE_STATISTICS)
194 #if defined(ENABLE_VERIFIER)
196 #if defined(TYPECHECK_VERBOSE)
199 #endif /* defined(ENABLE_VERIFIER) */
202 /* optimization options */
204 #if defined(ENABLE_LOOP)
208 #if defined(ENABLE_IFCONV)
212 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
216 #if defined(ENABLE_INLINING)
220 #if defined(ENABLE_INTRP)
221 /* interpreter options */
244 opt_struct opts[] = {
245 { "foo", false, OPT_FOO },
249 { "jar", false, OPT_JAR },
251 { "d32", false, OPT_D32 },
252 { "d64", false, OPT_D64 },
253 { "client", false, OPT_IGNORE },
254 { "server", false, OPT_IGNORE },
255 { "jvm", false, OPT_IGNORE },
256 { "hotspot", false, OPT_IGNORE },
258 { "classpath", true, OPT_CLASSPATH },
259 { "cp", true, OPT_CLASSPATH },
260 { "D", true, OPT_D },
261 { "version", false, OPT_VERSION },
262 { "showversion", false, OPT_SHOWVERSION },
263 { "fullversion", false, OPT_FULLVERSION },
264 { "help", false, OPT_HELP },
265 { "?", false, OPT_HELP },
266 { "X", false, OPT_X },
268 { "esa", false, OPT_ESA },
269 { "enablesystemassertions", false, OPT_ESA },
270 { "dsa", false, OPT_DSA },
271 { "disablesystemassertions", false, OPT_DSA },
273 { "noasyncgc", false, OPT_IGNORE },
274 #if defined(ENABLE_VERIFIER)
275 { "noverify", false, OPT_NOVERIFY },
277 { "v", false, OPT_VERBOSE1 },
278 { "verbose:", true, OPT_VERBOSE },
280 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
281 { "verbosetc", false, OPT_VERBOSETC },
283 #if defined(__ALPHA__)
284 { "noieee", false, OPT_NOIEEE },
286 { "softnull", false, OPT_SOFTNULL },
287 #if defined(ENABLE_STATISTICS)
288 { "time", false, OPT_TIME },
289 { "stat", false, OPT_STAT },
291 { "log", true, OPT_LOG },
292 { "c", true, OPT_CHECK },
293 { "l", false, OPT_LOAD },
294 { "eager", false, OPT_EAGER },
297 { "all", false, OPT_ALL },
298 { "sig", true, OPT_SIGNATURE },
301 #if defined(ENABLE_LOOP)
302 { "oloop", false, OPT_OLOOP },
304 #if defined(ENABLE_IFCONV)
305 { "ifconv", false, OPT_IFCONV },
307 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
308 { "lsra", false, OPT_LSRA },
311 #if defined(ENABLE_INTRP)
312 /* interpreter options */
314 { "trace", false, OPT_TRACE },
315 { "static-supers", true, OPT_STATIC_SUPERS },
316 { "no-dynamic", false, OPT_NO_DYNAMIC },
317 { "no-replication", false, OPT_NO_REPLICATION },
318 { "no-quicksuper", false, OPT_NO_QUICKSUPER },
321 /* JVMTI Agent Command Line Options */
323 { "agentlib:", true, OPT_AGENTLIB },
324 { "agentpath:", true, OPT_AGENTPATH },
327 /* Java non-standard options */
329 { "Xjit", false, OPT_JIT },
330 { "Xint", false, OPT_INTRP },
331 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
332 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
333 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
334 { "Xbootclasspath/c:", true, OPT_BOOTCLASSPATH_C },
337 { "Xdebug", false, OPT_DEBUG },
338 { "Xnoagent", false, OPT_NOAGENT },
339 { "Xrunjdwp", true, OPT_XRUNJDWP },
342 { "Xms", true, OPT_MS },
343 { "ms", true, OPT_MS },
344 { "Xmx", true, OPT_MX },
345 { "mx", true, OPT_MX },
346 { "Xss", true, OPT_SS },
347 { "ss", true, OPT_SS },
349 #if defined(ENABLE_PROFILING)
350 { "Xprof:", true, OPT_PROF_OPTION },
351 { "Xprof", false, OPT_PROF },
354 /* keep these at the end of the list */
356 #if defined(ENABLE_INLINING)
357 { "i", true, OPT_INLINING },
361 { "m", true, OPT_METHOD },
364 { "s", true, OPT_SHOW },
365 { "debug-color", false, OPT_DEBUGCOLOR },
371 /* usage ***********************************************************************
373 Prints the correct usage syntax to stdout.
375 *******************************************************************************/
379 puts("Usage: cacao [-options] classname [arguments]");
380 puts(" (to run a class file)");
381 puts(" or cacao [-options] -jar jarfile [arguments]");
382 puts(" (to run a standalone jar file)\n");
384 puts("Java options:");
385 puts(" -d32 use 32-bit data model if available");
386 puts(" -d64 use 64-bit data model if available");
387 puts(" -client compatibility (currently ignored)");
388 puts(" -server compatibility (currently ignored)");
389 puts(" -jvm compatibility (currently ignored)");
390 puts(" -hotspot compatibility (currently ignored)\n");
392 puts(" -cp <path> specify a path to look for classes");
393 puts(" -classpath <path> specify a path to look for classes");
394 puts(" -D<name>=<value> add an entry to the property list");
395 puts(" -verbose[:class|gc|jni] enable specific verbose output");
396 puts(" -version print product version and exit");
397 puts(" -fullversion print jpackage-compatible product version and exit");
398 puts(" -showversion print product version and continue");
399 puts(" -help, -? print this help message");
400 puts(" -X print help on non-standard Java options");
401 puts(" -esa | -enablesystemassertions");
402 puts(" enable system assertions");
403 puts(" -dsa | -disablesystemassertions");
404 puts(" disable system assertions");
408 puts(" -agentlib:<agent-lib-name>=<options> library to load containg JVMTI agent");
409 puts (" for jdwp help use: -agentlib:jdwp=help");
410 puts(" -agentpath:<path-to-agent>=<options> path to library containg JVMTI agent");
413 puts("CACAO options:");
414 puts(" -v write state-information");
415 puts(" -verbose[:call|exception|jit]");
416 puts(" enable specific verbose output");
417 puts(" -debug-color colored output for ANSI terms");
418 #ifdef TYPECHECK_VERBOSE
419 puts(" -verbosetc write debug messages while typechecking");
421 #if defined(__ALPHA__)
422 puts(" -noieee don't use ieee compliant arithmetic");
424 #if defined(ENABLE_VERIFIER)
425 puts(" -noverify don't verify classfiles");
427 puts(" -softnull use software nullpointer check");
428 #if defined(ENABLE_STATISTICS)
429 puts(" -time measure the runtime");
430 puts(" -stat detailed compiler statistics");
432 puts(" -log logfile specify a name for the logfile");
433 puts(" -c(heck)b(ounds) don't check array bounds");
434 puts(" s(ync) don't check for synchronization");
435 #if defined(ENABLE_LOOP)
436 puts(" -oloop optimize array accesses in loops");
438 puts(" -l don't start the class after loading");
439 puts(" -eager perform eager class loading and linking");
441 puts(" -all compile all methods, no execution");
442 puts(" -m compile only a specific method");
443 puts(" -sig specify signature for a specific method");
446 puts(" -s(how)... show...");
447 puts(" c(onstants) the constant pool");
448 puts(" m(ethods) class fields and methods");
449 puts(" u(tf) the utf - hash");
450 puts(" i(ntermediate) intermediate representation");
451 #if defined(ENABLE_DISASSEMBLER)
452 puts(" a(ssembler) disassembled listing");
453 puts(" e(xceptionstubs) disassembled exception stubs (only with -sa)");
454 puts(" n(ative) disassembled native stubs");
456 puts(" d(atasegment) data segment listing");
457 #if defined(ENABLE_INLINING)
458 puts(" -i n(line) activate inlining");
459 puts(" v(irtual) inline virtual methods (uses/turns rt option on)");
460 puts(" e(exception) inline methods with exceptions");
461 puts(" p(aramopt) optimize argument renaming");
462 puts(" o(utsiders) inline methods of foreign classes");
463 #endif /* defined(ENABLE_INLINING) */
464 #if defined(ENABLE_IFCONV)
465 puts(" -ifconv use if-conversion");
467 #if defined(ENABLE_LSRA)
468 puts(" -lsra use linear scan register allocation");
470 #if defined(ENABLE_SSA)
471 puts(" -lsra use linear scan register allocation (with SSA)");
474 /* exit with error code */
480 static void Xusage(void)
482 #if defined(ENABLE_JIT)
483 puts(" -Xjit JIT mode execution (default)");
485 #if defined(ENABLE_INTRP)
486 puts(" -Xint interpreter mode execution");
488 puts(" -Xbootclasspath:<zip/jar files and directories separated by :>");
489 puts(" value is set as bootstrap class path");
490 puts(" -Xbootclasspath/a:<zip/jar files and directories separated by :>");
491 puts(" value is appended to the bootstrap class path");
492 puts(" -Xbootclasspath/p:<zip/jar files and directories separated by :>");
493 puts(" value is prepended to the bootstrap class path");
494 puts(" -Xbootclasspath/c:<zip/jar files and directories separated by :>");
495 puts(" value is used as Java core library, but the");
496 puts(" hardcoded VM interface classes are prepended");
497 printf(" -Xms<size> set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024);
498 printf(" -Xmx<size> set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024);
499 printf(" -Xss<size> set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024);
501 #if defined(ENABLE_PROFILING)
502 puts(" -Xprof[:bb] collect and print profiling data");
505 #if defined(ENABLE_JVMTI)
506 /* -Xdebug option depend on gnu classpath JDWP options. options:
507 transport=dt_socket,address=<hostname:port>,server=(y|n),suspend(y|n) */
508 puts(" -Xdebug enable remote debugging\n");
509 puts(" -Xrunjdwp transport=[dt_socket|...],address=<hostname:port>,server=[y|n],suspend=[y|n]\n");
510 puts(" enable remote debugging\n");
513 /* exit with error code */
519 /* version *********************************************************************
521 Only prints cacao version information.
523 *******************************************************************************/
525 static void version(bool opt_exit)
527 puts("java version \""JAVA_VERSION"\"");
528 puts("CACAO version "VERSION"");
530 puts("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,");
531 puts("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,");
532 puts("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,");
533 puts("J. Wenninger, Institut f. Computersprachen - TU Wien\n");
535 puts("This program is free software; you can redistribute it and/or");
536 puts("modify it under the terms of the GNU General Public License as");
537 puts("published by the Free Software Foundation; either version 2, or (at");
538 puts("your option) any later version.\n");
540 puts("This program is distributed in the hope that it will be useful, but");
541 puts("WITHOUT ANY WARRANTY; without even the implied warranty of");
542 puts("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU");
543 puts("General Public License for more details.\n");
545 puts("Configure/Build options:\n");
546 puts(" ./configure: "VERSION_CONFIGURE_ARGS"");
547 #if defined(__VERSION__)
548 puts(" CC : "VERSION_CC" ("__VERSION__")");
550 puts(" CC : "VERSION_CC"");
552 puts(" CFLAGS : "VERSION_CFLAGS"\n");
554 puts("Default variables:\n");
555 printf(" maximum heap size : %d\n", HEAP_MAXSIZE);
556 printf(" initial heap size : %d\n", HEAP_STARTSIZE);
557 printf(" stack size : %d\n", STACK_SIZE);
558 puts(" java.boot.class.path : "CACAO_VM_ZIP":"CLASSPATH_GLIBJ_ZIP"");
559 puts(" gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR"/classpath\n");
561 puts("Runtime variables:\n");
562 printf(" maximum heap size : %d\n", opt_heapmaxsize);
563 printf(" initial heap size : %d\n", opt_heapstartsize);
564 printf(" stack size : %d\n", opt_stacksize);
565 printf(" java.boot.class.path : %s\n", _Jv_bootclasspath);
566 printf(" gnu.classpath.boot.library.path: %s\n", classpath_libdir);
568 /* exit normally, if requested */
575 /* fullversion *****************************************************************
577 Prints a Sun compatible version information (required e.g. by
578 jpackage, www.jpackage.org).
580 *******************************************************************************/
582 static void fullversion(void)
584 puts("java full version \"cacao-"JAVA_VERSION"\"");
592 /* forward declarations *******************************************************/
594 static char *vm_get_mainclass_from_jar(char *mainstring);
596 static void vm_compile_all(void);
597 static void vm_compile_method(void);
601 /* vm_create *******************************************************************
603 Creates a JVM. Called by JNI_CreateJavaVM.
605 *******************************************************************************/
607 bool vm_create(JavaVMInitArgs *vm_args)
616 #if defined(ENABLE_JVMTI)
618 char *libname, *agentarg;
619 bool jdwp,agentbypath;
620 jdwp = agentbypath = false;
623 /* check the JNI version requested */
625 switch (vm_args->version) {
626 case JNI_VERSION_1_1:
628 case JNI_VERSION_1_2:
629 case JNI_VERSION_1_4:
635 /* we only support 1 JVM instance */
640 if (atexit(vm_exit_handler))
641 vm_abort("atexit failed: %s\n", strerror(errno));
644 log_text("CACAO started -------------------------------------------------------");
646 /* set the VM starttime */
648 _Jv_jvm->starttime = builtin_currenttimemillis();
650 /* get stuff from the environment *****************************************/
652 #if defined(DISABLE_GC)
653 nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
656 #if defined(WITH_JRE_LAYOUT)
657 /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
659 cacao_prefix = MNEW(char, 4096);
661 if (readlink("/proc/self/exe", cacao_prefix, 4095) == -1)
662 vm_abort("readlink failed: %s\n", strerror(errno));
664 /* get the path of the current executable */
666 cacao_prefix = dirname(cacao_prefix);
668 if ((strlen(cacao_prefix) + strlen("/..") + strlen("0")) > 4096)
669 vm_abort("libjvm name to long for buffer\n");
671 /* concatenate the library name */
673 strcat(cacao_prefix, "/..");
675 /* now set path to libjvm.so */
677 len = strlen(cacao_prefix) + strlen("/lib/libjvm") + strlen("0");
679 cacao_libjvm = MNEW(char, len);
680 strcpy(cacao_libjvm, cacao_prefix);
681 strcat(cacao_libjvm, "/lib/libjvm");
683 /* and finally set the path to GNU Classpath libraries */
685 len = strlen(cacao_prefix) + strlen("/lib/classpath") + strlen("0");
687 classpath_libdir = MNEW(char, len);
688 strcpy(classpath_libdir, cacao_prefix);
689 strcat(classpath_libdir, "/lib/classpath");
691 cacao_prefix = CACAO_PREFIX;
692 cacao_libjvm = CACAO_LIBDIR"/libjvm";
693 classpath_libdir = CLASSPATH_LIBDIR"/classpath";
696 /* set the bootclasspath */
698 cp = getenv("BOOTCLASSPATH");
701 _Jv_bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
702 strcpy(_Jv_bootclasspath, cp);
705 #if defined(WITH_JRE_LAYOUT)
707 strlen(cacao_prefix) +
708 strlen("/share/cacao/vm.zip") +
710 strlen(cacao_prefix) +
711 strlen("/share/classpath/glibj.zip") +
714 _Jv_bootclasspath = MNEW(char, len);
715 strcat(_Jv_bootclasspath, cacao_prefix);
716 strcat(_Jv_bootclasspath, "/share/cacao/vm.zip");
717 strcat(_Jv_bootclasspath, ":");
718 strcat(_Jv_bootclasspath, cacao_prefix);
719 strcat(_Jv_bootclasspath, "/share/classpath/glibj.zip");
722 strlen(CACAO_VM_ZIP) +
724 strlen(CLASSPATH_GLIBJ_ZIP) +
727 _Jv_bootclasspath = MNEW(char, len);
728 strcat(_Jv_bootclasspath, CACAO_VM_ZIP);
729 strcat(_Jv_bootclasspath, ":");
730 strcat(_Jv_bootclasspath, CLASSPATH_GLIBJ_ZIP);
734 /* set the classpath */
736 cp = getenv("CLASSPATH");
739 _Jv_classpath = MNEW(char, strlen(cp) + strlen("0"));
740 strcat(_Jv_classpath, cp);
743 _Jv_classpath = MNEW(char, strlen(".") + strlen("0"));
744 strcpy(_Jv_classpath, ".");
747 /* get and set java.library.path */
749 _Jv_java_library_path = getenv("LD_LIBRARY_PATH");
751 if (_Jv_java_library_path == NULL)
752 _Jv_java_library_path = "";
754 /* interpret the options **************************************************/
762 opt_heapmaxsize = HEAP_MAXSIZE;
763 opt_heapstartsize = HEAP_STARTSIZE;
764 opt_stacksize = STACK_SIZE;
767 #if defined(ENABLE_JVMTI)
768 /* initialize JVMTI related **********************************************/
772 /* initialize properties before commandline handling */
774 if (!properties_init())
775 throw_cacao_exception_exit(string_java_lang_InternalError,
776 "Unable to init properties");
778 /* add some default properties */
780 properties_add("java.endorsed.dirs", ""CACAO_PREFIX"/jre/lib/endorsed");
782 /* iterate over all passed options */
784 while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
798 #if SIZEOF_VOID_P == 8
799 puts("Running a 32-bit JVM is not supported on this platform.");
805 #if SIZEOF_VOID_P == 4
806 puts("Running a 64-bit JVM is not supported on this platform.");
812 /* forget old classpath and set the argument as new classpath */
813 MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
815 _Jv_classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
816 strcpy(_Jv_classpath, opt_arg);
820 for (i = 0; i < strlen(opt_arg); i++) {
821 if (opt_arg[i] == '=') {
823 properties_add(opt_arg, opt_arg + i + 1);
828 /* if no '=' is given, just create an empty property */
830 properties_add(opt_arg, "");
835 case OPT_BOOTCLASSPATH:
836 /* Forget default bootclasspath and set the argument as
837 new boot classpath. */
839 MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
841 _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
842 strcpy(_Jv_bootclasspath, opt_arg);
845 case OPT_BOOTCLASSPATH_A:
846 /* append to end of bootclasspath */
848 len = strlen(_Jv_bootclasspath);
850 _Jv_bootclasspath = MREALLOC(_Jv_bootclasspath,
854 strlen(opt_arg) + strlen("0"));
856 strcat(_Jv_bootclasspath, ":");
857 strcat(_Jv_bootclasspath, opt_arg);
860 case OPT_BOOTCLASSPATH_P:
861 /* prepend in front of bootclasspath */
863 cp = _Jv_bootclasspath;
866 _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
869 strcpy(_Jv_bootclasspath, opt_arg);
870 strcat(_Jv_bootclasspath, ":");
871 strcat(_Jv_bootclasspath, cp);
873 MFREE(cp, char, len);
876 case OPT_BOOTCLASSPATH_C:
877 /* use as Java core library, but prepend VM interface classes */
879 MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
881 len = strlen(CACAO_VM_ZIP) +
886 _Jv_bootclasspath = MNEW(char, len);
888 strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
889 strcat(_Jv_bootclasspath, ":");
890 strcat(_Jv_bootclasspath, opt_arg);
893 #if defined(ENABLE_JVMTI)
895 /* this option exists only for compatibility reasons */
899 /* I don't know yet what Xnoagent should do. This is only for
900 compatiblity with eclipse - motse */
909 strlen(CACAO_LIBDIR) +
910 strlen("/libjdwp.so=") +
914 agentarg = MNEW(char, len);
916 strcpy(agentarg, CACAO_LIBDIR);
917 strcat(agentarg, "/libjdwp.so=");
918 strcat(agentarg, &opt_arg[1]);
935 c = opt_arg[strlen(opt_arg) - 1];
937 if ((c == 'k') || (c == 'K')) {
938 j = atoi(opt_arg) * 1024;
940 } else if ((c == 'm') || (c == 'M')) {
941 j = atoi(opt_arg) * 1024 * 1024;
948 else if (opt == OPT_MS)
949 opt_heapstartsize = j;
960 if (strcmp("class", opt_arg) == 0)
961 opt_verboseclass = true;
963 else if (strcmp("gc", opt_arg) == 0)
964 opt_verbosegc = true;
966 else if (strcmp("jni", opt_arg) == 0)
967 opt_verbosejni = true;
969 else if (strcmp("call", opt_arg) == 0)
970 opt_verbosecall = true;
972 else if (strcmp("jit", opt_arg) == 0) {
977 compileverbose = true;
979 else if (strcmp("exception", opt_arg) == 0)
980 opt_verboseexception = true;
983 opt_debugcolor = true;
986 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
988 opt_typecheckverbose = true;
997 case OPT_FULLVERSION:
1001 case OPT_SHOWVERSION:
1009 #if defined(ENABLE_VERIFIER)
1019 #if defined(ENABLE_STATISTICS)
1021 opt_getcompilingtime = true;
1022 opt_getloadingtime = true;
1035 for (i = 0; i < strlen(opt_arg); i++) {
1036 switch (opt_arg[i]) {
1038 checkbounds = false;
1051 makeinitializations = false;
1058 #if !defined(NDEBUG)
1062 makeinitializations = false;
1067 opt_method = opt_arg;
1068 makeinitializations = false;
1072 opt_signature = opt_arg;
1076 case OPT_SHOW: /* Display options */
1077 for (i = 0; i < strlen(opt_arg); i++) {
1078 switch (opt_arg[i]) {
1080 showconstantpool = true;
1092 opt_showintermediate = true;
1093 compileverbose = true;
1096 #if defined(ENABLE_DISASSEMBLER)
1098 opt_showdisassemble = true;
1099 compileverbose = true;
1103 opt_showexceptionstubs = true;
1107 opt_shownativestub = true;
1112 opt_showddatasegment = true;
1121 #if defined(ENABLE_LOOP)
1127 #if defined(ENABLE_INLINING)
1129 for (i = 0; i < strlen(opt_arg); i++) {
1130 switch (opt_arg[i]) {
1132 /* define in options.h; Used in main.c, jit.c
1133 & inline.c inlining is currently
1137 inlinevirtuals = true;
1140 inlineexceptions = true;
1143 inlineparamopt = true;
1146 inlineoutsiders = true;
1153 #endif /* defined(ENABLE_INLINING) */
1155 #if defined(ENABLE_IFCONV)
1161 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1176 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = true;
1180 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = false;
1183 #if defined(ENABLE_PROFILING)
1184 case OPT_PROF_OPTION:
1185 /* use <= to get the last \0 too */
1187 for (i = 0, j = 0; i <= strlen(opt_arg); i++) {
1188 if (opt_arg[i] == ',')
1191 if (opt_arg[i] == '\0') {
1192 if (strcmp("bb", opt_arg + j) == 0)
1196 printf("Unknown option: -Xprof:%s\n", opt_arg + j);
1200 /* set k to next char */
1213 #if defined(ENABLE_JIT)
1216 printf("-Xjit option not enabled.\n");
1222 #if defined(ENABLE_INTRP)
1225 printf("-Xint option not enabled.\n");
1230 #if defined(ENABLE_INTRP)
1231 case OPT_STATIC_SUPERS:
1232 opt_static_supers = atoi(opt_arg);
1235 case OPT_NO_DYNAMIC:
1236 opt_no_dynamic = true;
1239 case OPT_NO_REPLICATION:
1240 opt_no_replication = true;
1243 case OPT_NO_QUICKSUPER:
1244 opt_no_quicksuper = true;
1253 printf("Unknown option: %s\n",
1254 vm_args->options[opt_index].optionString);
1260 /* Now we have all options handled and we can print the version
1267 /* get the main class *****************************************************/
1269 if (opt_index < vm_args->nOptions) {
1270 mainstring = vm_args->options[opt_index++].optionString;
1272 /* Put the jar file into the classpath (if any). */
1274 if (opt_jar == true) {
1275 /* free old classpath */
1277 MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
1279 /* put jarfile into classpath */
1281 _Jv_classpath = MNEW(char, strlen(mainstring) + strlen("0"));
1283 strcpy(_Jv_classpath, mainstring);
1286 /* replace .'s with /'s in classname */
1288 for (i = strlen(mainstring) - 1; i >= 0; i--)
1289 if (mainstring[i] == '.')
1290 mainstring[i] = '/';
1294 #if defined(ENABLE_JVMTI)
1296 jvmti_set_phase(JVMTI_PHASE_ONLOAD);
1297 jvmti_agentload(agentarg, agentbypath, &handle, &libname);
1300 MFREE(agentarg, char, strlen(agentarg));
1302 jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
1308 /* initialize this JVM ****************************************************/
1310 vm_initializing = true;
1312 #if defined(ENABLE_THREADS)
1313 /* pre-initialize some core thread stuff, like the stopworldlock,
1314 thus this has to happen _before_ gc_init()!!! */
1319 /* initialize the garbage collector */
1321 gc_init(opt_heapmaxsize, opt_heapstartsize);
1323 #if defined(ENABLE_INTRP)
1324 /* Allocate main thread stack on the Java heap. */
1327 intrp_main_stack = GCMNEW(u1, opt_stacksize);
1328 MSET(intrp_main_stack, 0, u1, opt_stacksize);
1332 /* initialize the string hashtable stuff: lock (must be done
1333 _after_ threads_preinit) */
1336 throw_main_exception_exit();
1338 /* initialize the utf8 hashtable stuff: lock, often used utf8
1339 strings (must be done _after_ threads_preinit) */
1342 throw_main_exception_exit();
1344 /* initialize the classcache hashtable stuff: lock, hashtable
1345 (must be done _after_ threads_preinit) */
1347 if (!classcache_init())
1348 throw_main_exception_exit();
1350 /* initialize the loader with bootclasspath (must be done _after_
1354 throw_main_exception_exit();
1356 suck_add_from_property("java.endorsed.dirs");
1357 suck_add(_Jv_bootclasspath);
1359 /* initialize the memory subsystem (must be done _after_
1363 throw_main_exception_exit();
1365 /* initialize the finalizer stuff (must be done _after_
1368 if (!finalizer_init())
1369 throw_main_exception_exit();
1371 /* install architecture dependent signal handler used for exceptions */
1375 /* initialize the codegen subsystems */
1379 /* initializes jit compiler */
1383 /* machine dependent initialization */
1385 #if defined(ENABLE_JIT)
1386 # if defined(ENABLE_INTRP)
1396 /* initialize the loader subsystems (must be done _after_
1400 throw_main_exception_exit();
1403 throw_main_exception_exit();
1406 throw_main_exception_exit();
1408 if (!exceptions_init())
1409 throw_main_exception_exit();
1411 if (!builtin_init())
1412 throw_main_exception_exit();
1414 /* Initialize the JNI subsystem (must be done _before_
1415 threads_init, as threads_init can call JNI methods
1416 (e.g. NewGlobalRef). */
1419 throw_main_exception_exit();
1421 #if defined(ENABLE_THREADS)
1422 if (!threads_init())
1423 throw_main_exception_exit();
1426 /* That's important, otherwise we get into trouble, if the Runtime
1427 static initializer is called before (circular dependency. This
1428 is with classpath 0.09. Another important thing is, that this
1429 has to happen after initThreads!!! */
1431 if (!initialize_class(class_java_lang_System))
1432 throw_main_exception_exit();
1434 #if defined(ENABLE_PROFILING)
1435 /* initialize profiling */
1437 if (!profile_init())
1438 throw_main_exception_exit();
1441 #if defined(ENABLE_THREADS)
1442 /* initialize recompilation */
1444 if (!recompile_init())
1445 throw_main_exception_exit();
1447 /* finally, start the finalizer thread */
1449 if (!finalizer_start_thread())
1450 throw_main_exception_exit();
1452 /* start the recompilation thread (must be done before the
1453 profiling thread) */
1455 if (!recompile_start_thread())
1456 throw_main_exception_exit();
1458 # if defined(ENABLE_PROFILING)
1459 /* start the profile sampling thread */
1462 /* if (!profile_start_thread()) */
1463 /* throw_main_exception_exit(); */
1467 #if defined(ENABLE_JVMTI)
1469 /* add agent library to native library hashtable */
1470 native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
1474 /* increment the number of VMs */
1478 /* initialization is done */
1480 vm_initializing = false;
1482 /* everything's ok */
1488 /* vm_run **********************************************************************
1490 Runs the main-method of the passed class.
1492 *******************************************************************************/
1494 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
1497 classinfo *mainclass;
1499 java_objectarray *oa;
1502 java_lang_String *s;
1506 #if !defined(NDEBUG)
1512 if (opt_method != NULL) {
1513 vm_compile_method();
1516 #endif /* !defined(NDEBUG) */
1518 /* should we run the main-method? */
1520 if (mainstring == NULL)
1523 /* set return value to OK */
1527 if (opt_jar == true)
1528 /* open jar file with java.util.jar.JarFile */
1529 mainstring = vm_get_mainclass_from_jar(mainstring);
1531 /* load the main class */
1533 mainutf = utf_new_char(mainstring);
1535 if (!(mainclass = load_class_from_sysloader(mainutf)))
1536 throw_main_exception_exit();
1538 /* error loading class */
1540 if ((*exceptionptr != NULL) || (mainclass == NULL))
1541 throw_main_exception_exit();
1543 if (!link_class(mainclass))
1544 throw_main_exception_exit();
1546 /* find the `main' method of the main class */
1548 m = class_resolveclassmethod(mainclass,
1549 utf_new_char("main"),
1550 utf_new_char("([Ljava/lang/String;)V"),
1551 class_java_lang_Object,
1554 if (*exceptionptr) {
1555 throw_main_exception_exit();
1558 /* there is no main method or it isn't static */
1560 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
1561 *exceptionptr = NULL;
1564 new_exception_message(string_java_lang_NoSuchMethodError, "main");
1565 throw_main_exception_exit();
1568 /* build argument array */
1570 oalength = vm_args->nOptions - opt_index;
1572 oa = builtin_anewarray(oalength, class_java_lang_String);
1574 for (i = 0; i < oalength; i++) {
1575 u = utf_new_char(vm_args->options[opt_index + i].optionString);
1576 s = javastring_new(u);
1578 oa->data[i] = (java_objectheader *) s;
1581 #ifdef TYPEINFO_DEBUG_TEST
1582 /* test the typeinfo system */
1585 /*class_showmethods(currentThread->group->header.vftbl->class); */
1587 #if defined(ENABLE_JVMTI)
1588 jvmti_set_phase(JVMTI_PHASE_LIVE);
1591 /* increase total started thread count */
1593 _Jv_jvm->total_started_thread_count++;
1595 /* start the main thread */
1597 (void) vm_call_method(m, NULL, oa);
1599 /* exception occurred? */
1601 if (*exceptionptr) {
1602 throw_main_exception();
1606 /* unload the JavaVM */
1616 /* vm_destroy ******************************************************************
1618 Unloads a Java VM and reclaims its resources.
1620 *******************************************************************************/
1622 s4 vm_destroy(JavaVM *vm)
1624 #if defined(ENABLE_THREADS)
1625 threads_join_all_threads();
1628 /* everything's ok */
1634 /* vm_exit *********************************************************************
1636 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1638 *******************************************************************************/
1640 void vm_exit(s4 status)
1644 /* signal that we are exiting */
1648 assert(class_java_lang_System);
1649 assert(class_java_lang_System->state & CLASS_LOADED);
1651 #if defined(ENABLE_JVMTI)
1652 if (jvmti || (dbgcom!=NULL)) {
1653 jvmti_set_phase(JVMTI_PHASE_DEAD);
1654 if (jvmti) jvmti_agentunload();
1658 if (!link_class(class_java_lang_System))
1659 throw_main_exception_exit();
1661 /* call java.lang.System.exit(I)V */
1663 m = class_resolveclassmethod(class_java_lang_System,
1664 utf_new_char("exit"),
1666 class_java_lang_Object,
1670 throw_main_exception_exit();
1672 /* call the exit function with passed exit status */
1674 (void) vm_call_method(m, NULL, status);
1676 /* If we had an exception, just ignore the exception and exit with
1679 vm_shutdown(status);
1683 /* vm_shutdown *****************************************************************
1685 Terminates the system immediately without freeing memory explicitly
1686 (to be used only for abnormal termination).
1688 *******************************************************************************/
1690 void vm_shutdown(s4 status)
1693 #if defined(ENABLE_STATISTICS)
1694 || opt_getcompilingtime || opt_stat
1698 log_text("CACAO terminated by shutdown");
1699 dolog("Exit status: %d\n", (s4) status);
1703 #if defined(ENABLE_JVMTI)
1704 /* terminate cacaodbgserver */
1706 pthread_mutex_lock(&dbgcomlock);
1708 pthread_mutex_unlock(&dbgcomlock);
1709 jvmti_cacaodbgserver_quit();
1717 /* vm_exit_handler *************************************************************
1719 The exit_handler function is called upon program termination.
1721 ATTENTION: Don't free system resources here! Some threads may still
1722 be running as this is called from VMRuntime.exit(). The OS does the
1725 *******************************************************************************/
1727 void vm_exit_handler(void)
1729 #if !defined(NDEBUG)
1731 class_showmethods(mainclass);
1733 if (showconstantpool)
1734 class_showconstantpool(mainclass);
1739 # if defined(ENABLE_PROFILING)
1741 profile_printstats();
1743 #endif /* !defined(NDEBUG) */
1745 #if defined(ENABLE_RT_TIMING)
1746 rt_timing_print_time_stats(stderr);
1749 #if defined(ENABLE_CYCLES_STATS)
1750 builtin_print_cycles_stats(stderr);
1751 stacktrace_print_cycles_stats(stderr);
1755 #if defined(ENABLE_STATISTICS)
1756 || opt_getcompilingtime || opt_stat
1760 log_text("CACAO terminated");
1762 #if defined(ENABLE_STATISTICS)
1765 #ifdef TYPECHECK_STATISTICS
1766 typecheck_print_statistics(get_logfile());
1772 if (opt_getcompilingtime)
1774 #endif /* defined(ENABLE_STATISTICS) */
1776 /* vm_print_profile(stderr);*/
1780 /* vm_abort ********************************************************************
1782 Prints an error message and aborts the VM.
1784 *******************************************************************************/
1786 void vm_abort(const char *text, ...)
1790 /* print the log message */
1795 log_vprint(text, ap);
1800 /* now abort the VM */
1806 /* vm_get_mainclass_from_jar ***************************************************
1808 Gets the name of the main class from a JAR's manifest file.
1810 *******************************************************************************/
1812 static char *vm_get_mainclass_from_jar(char *mainstring)
1815 java_objectheader *o;
1817 java_lang_String *s;
1819 c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
1822 throw_main_exception_exit();
1824 /* create JarFile object */
1829 throw_main_exception_exit();
1832 m = class_resolveclassmethod(c,
1834 utf_java_lang_String__void,
1835 class_java_lang_Object,
1839 throw_main_exception_exit();
1841 s = javastring_new_from_ascii(mainstring);
1843 (void) vm_call_method(m, o, s);
1846 throw_main_exception_exit();
1848 /* get manifest object */
1850 m = class_resolveclassmethod(c,
1851 utf_new_char("getManifest"),
1852 utf_new_char("()Ljava/util/jar/Manifest;"),
1853 class_java_lang_Object,
1857 throw_main_exception_exit();
1859 o = vm_call_method(m, o);
1862 fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
1867 /* get Main Attributes */
1869 m = class_resolveclassmethod(o->vftbl->class,
1870 utf_new_char("getMainAttributes"),
1871 utf_new_char("()Ljava/util/jar/Attributes;"),
1872 class_java_lang_Object,
1876 throw_main_exception_exit();
1878 o = vm_call_method(m, o);
1881 fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
1886 /* get property Main-Class */
1888 m = class_resolveclassmethod(o->vftbl->class,
1889 utf_new_char("getValue"),
1890 utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
1891 class_java_lang_Object,
1895 throw_main_exception_exit();
1897 s = javastring_new_from_ascii("Main-Class");
1899 o = vm_call_method(m, o, s);
1902 throw_main_exception_exit();
1904 return javastring_tochar(o);
1908 /* vm_compile_all **************************************************************
1910 Compile all methods found in the bootclasspath.
1912 *******************************************************************************/
1914 #if !defined(NDEBUG)
1915 static void vm_compile_all(void)
1920 classcache_name_entry *nmen;
1921 classcache_class_entry *clsen;
1924 /* create all classes found in the bootclasspath */
1925 /* XXX currently only works with zip/jar's */
1927 loader_load_all_classes();
1929 /* link all classes */
1931 for (slot = 0; slot < hashtable_classcache.size; slot++) {
1932 nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
1934 for (; nmen; nmen = nmen->hashlink) {
1935 /* iterate over all class entries */
1937 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1938 c = clsen->classobj;
1943 if (!(c->state & CLASS_LINKED)) {
1944 if (!link_class(c)) {
1945 fprintf(stderr, "Error linking: ");
1946 utf_fprint_printable_ascii_classname(stderr, c->name);
1947 fprintf(stderr, "\n");
1949 /* print out exception and cause */
1951 exceptions_print_exception(*exceptionptr);
1953 /* goto next class */
1959 /* compile all class methods */
1961 for (i = 0; i < c->methodscount; i++) {
1962 m = &(c->methods[i]);
1964 if (m->jcode != NULL) {
1965 if (!jit_compile(m)) {
1966 fprintf(stderr, "Error compiling: ");
1967 utf_fprint_printable_ascii_classname(stderr, c->name);
1968 fprintf(stderr, ".");
1969 utf_fprint_printable_ascii(stderr, m->name);
1970 utf_fprint_printable_ascii(stderr, m->descriptor);
1971 fprintf(stderr, "\n");
1973 /* print out exception and cause */
1975 exceptions_print_exception(*exceptionptr);
1983 #endif /* !defined(NDEBUG) */
1986 /* vm_compile_method ***********************************************************
1988 Compile a specific method.
1990 *******************************************************************************/
1992 #if !defined(NDEBUG)
1993 static void vm_compile_method(void)
1997 /* create, load and link the main class */
1999 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
2000 throw_main_exception_exit();
2002 if (!link_class(mainclass))
2003 throw_main_exception_exit();
2005 if (opt_signature != NULL) {
2006 m = class_resolveclassmethod(mainclass,
2007 utf_new_char(opt_method),
2008 utf_new_char(opt_signature),
2013 m = class_resolveclassmethod(mainclass,
2014 utf_new_char(opt_method),
2021 char message[MAXLOGTEXT];
2022 sprintf(message, "%s%s", opt_method,
2023 opt_signature ? opt_signature : "");
2026 new_exception_message(string_java_lang_NoSuchMethodException,
2029 throw_main_exception_exit();
2034 #endif /* !defined(NDEBUG) */
2037 /* vm_vmargs_from_valist *******************************************************
2041 *******************************************************************************/
2043 static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
2044 vm_arg *vmargs, va_list ap)
2046 typedesc *paramtypes;
2049 paramtypes = m->parseddesc->paramtypes;
2051 /* if method is non-static fill first block and skip `this' pointer */
2056 /* the `this' pointer */
2057 vmargs[0].type = TYPE_ADR;
2058 vmargs[0].data.l = (u8) (ptrint) o;
2064 for (; i < m->parseddesc->paramcount; i++, paramtypes++) {
2065 switch (paramtypes->decltype) {
2066 /* primitive types */
2067 case PRIMITIVETYPE_BOOLEAN:
2068 case PRIMITIVETYPE_BYTE:
2069 case PRIMITIVETYPE_CHAR:
2070 case PRIMITIVETYPE_SHORT:
2071 case PRIMITIVETYPE_INT:
2072 vmargs[i].type = TYPE_INT;
2073 vmargs[i].data.l = (s8) va_arg(ap, s4);
2076 case PRIMITIVETYPE_LONG:
2077 vmargs[i].type = TYPE_LNG;
2078 vmargs[i].data.l = (s8) va_arg(ap, s8);
2081 case PRIMITIVETYPE_FLOAT:
2082 vmargs[i].type = TYPE_FLT;
2083 #if defined(__ALPHA__)
2084 /* this keeps the assembler function much simpler */
2086 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2088 vmargs[i].data.f = (jfloat) va_arg(ap, jdouble);
2092 case PRIMITIVETYPE_DOUBLE:
2093 vmargs[i].type = TYPE_DBL;
2094 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2098 vmargs[i].type = TYPE_ADR;
2099 vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*);
2106 /* vm_vmargs_from_jvalue *******************************************************
2110 *******************************************************************************/
2112 static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
2113 vm_arg *vmargs, jvalue *args)
2115 typedesc *paramtypes;
2119 paramtypes = m->parseddesc->paramtypes;
2121 /* if method is non-static fill first block and skip `this' pointer */
2126 /* the `this' pointer */
2127 vmargs[0].type = TYPE_ADR;
2128 vmargs[0].data.l = (u8) (ptrint) o;
2134 for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) {
2135 switch (paramtypes->decltype) {
2136 /* primitive types */
2137 case PRIMITIVETYPE_BOOLEAN:
2138 case PRIMITIVETYPE_BYTE:
2139 case PRIMITIVETYPE_CHAR:
2140 case PRIMITIVETYPE_SHORT:
2141 case PRIMITIVETYPE_INT:
2142 vmargs[i].type = TYPE_INT;
2143 vmargs[i].data.l = (s8) args[j].i;
2146 case PRIMITIVETYPE_LONG:
2147 vmargs[i].type = TYPE_LNG;
2148 vmargs[i].data.l = (s8) args[j].j;
2151 case PRIMITIVETYPE_FLOAT:
2152 vmargs[i].type = TYPE_FLT;
2153 #if defined(__ALPHA__)
2154 /* this keeps the assembler function much simpler */
2156 vmargs[i].data.d = (jdouble) args[j].f;
2158 vmargs[i].data.f = args[j].f;
2162 case PRIMITIVETYPE_DOUBLE:
2163 vmargs[i].type = TYPE_DBL;
2164 vmargs[i].data.d = args[j].d;
2168 vmargs[i].type = TYPE_ADR;
2169 vmargs[i].data.l = (u8) (ptrint) args[j].l;
2176 /* vm_call_method **************************************************************
2178 Calls a Java method with a variable number of arguments and returns
2181 *******************************************************************************/
2183 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
2186 java_objectheader *ro;
2189 ro = vm_call_method_valist(m, o, ap);
2196 /* vm_call_method_valist *******************************************************
2198 Calls a Java method with a variable number of arguments, passed via
2199 a va_list, and returns an address.
2201 *******************************************************************************/
2203 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
2208 java_objectheader *ro;
2211 /* mark start of dump memory area */
2213 dumpsize = dump_size();
2215 /* get number of Java method arguments */
2217 vmargscount = m->parseddesc->paramcount;
2219 /* allocate vm_arg array */
2221 vmargs = DMNEW(vm_arg, vmargscount);
2223 /* fill the vm_arg array from a va_list */
2225 vm_vmargs_from_valist(m, o, vmargs, ap);
2227 /* call the Java method */
2229 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2231 /* release dump area */
2233 dump_release(dumpsize);
2239 /* vm_call_method_jvalue *******************************************************
2241 Calls a Java method with a variable number of arguments, passed via
2242 a jvalue array, and returns an address.
2244 *******************************************************************************/
2246 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
2251 java_objectheader *ro;
2254 /* mark start of dump memory area */
2256 dumpsize = dump_size();
2258 /* get number of Java method arguments */
2260 vmargscount = m->parseddesc->paramcount;
2262 /* allocate vm_arg array */
2264 vmargs = DMNEW(vm_arg, vmargscount);
2266 /* fill the vm_arg array from a va_list */
2268 vm_vmargs_from_jvalue(m, o, vmargs, args);
2270 /* call the Java method */
2272 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2274 /* release dump area */
2276 dump_release(dumpsize);
2282 /* vm_call_method_vmarg ********************************************************
2284 Calls a Java method with a variable number of arguments, passed via
2285 a vm_arg array, and returns an address.
2287 *******************************************************************************/
2289 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
2292 java_objectheader *o;
2294 #if defined(ENABLE_JIT)
2295 # if defined(ENABLE_INTRP)
2297 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2300 o = asm_vm_call_method(m, vmargscount, vmargs);
2302 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2309 /* vm_call_method_int **********************************************************
2311 Calls a Java method with a variable number of arguments and returns
2314 *******************************************************************************/
2316 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
2322 i = vm_call_method_int_valist(m, o, ap);
2329 /* vm_call_method_int_valist ***************************************************
2331 Calls a Java method with a variable number of arguments, passed via
2332 a va_list, and returns an integer (s4).
2334 *******************************************************************************/
2336 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
2343 /* mark start of dump memory area */
2345 dumpsize = dump_size();
2347 /* get number of Java method arguments */
2349 vmargscount = m->parseddesc->paramcount;
2351 /* allocate vm_arg array */
2353 vmargs = DMNEW(vm_arg, vmargscount);
2355 /* fill the vm_arg array from a va_list */
2357 vm_vmargs_from_valist(m, o, vmargs, ap);
2359 /* call the Java method */
2361 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2363 /* release dump area */
2365 dump_release(dumpsize);
2371 /* vm_call_method_int_jvalue ***************************************************
2373 Calls a Java method with a variable number of arguments, passed via
2374 a jvalue array, and returns an integer (s4).
2376 *******************************************************************************/
2378 s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
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_jvalue(m, o, vmargs, args);
2401 /* call the Java method */
2403 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2405 /* release dump area */
2407 dump_release(dumpsize);
2413 /* vm_call_method_int_vmarg ****************************************************
2415 Calls a Java method with a variable number of arguments, passed via
2416 a vm_arg array, and returns an integer (s4).
2418 *******************************************************************************/
2420 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2424 #if defined(ENABLE_JIT)
2425 # if defined(ENABLE_INTRP)
2427 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2430 i = asm_vm_call_method_int(m, vmargscount, vmargs);
2432 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2439 /* vm_call_method_long *********************************************************
2441 Calls a Java method with a variable number of arguments and returns
2444 *******************************************************************************/
2446 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
2452 l = vm_call_method_long_valist(m, o, ap);
2459 /* vm_call_method_long_valist **************************************************
2461 Calls a Java method with a variable number of arguments, passed via
2462 a va_list, and returns a long (s8).
2464 *******************************************************************************/
2466 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
2473 /* mark start of dump memory area */
2475 dumpsize = dump_size();
2477 /* get number of Java method arguments */
2479 vmargscount = m->parseddesc->paramcount;
2481 /* allocate vm_arg array */
2483 vmargs = DMNEW(vm_arg, vmargscount);
2485 /* fill the vm_arg array from a va_list */
2487 vm_vmargs_from_valist(m, o, vmargs, ap);
2489 /* call the Java method */
2491 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2493 /* release dump area */
2495 dump_release(dumpsize);
2501 /* vm_call_method_long_jvalue **************************************************
2503 Calls a Java method with a variable number of arguments, passed via
2504 a jvalue array, and returns a long (s8).
2506 *******************************************************************************/
2508 s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2515 /* mark start of dump memory area */
2517 dumpsize = dump_size();
2519 /* get number of Java method arguments */
2521 vmargscount = m->parseddesc->paramcount;
2523 /* allocate vm_arg array */
2525 vmargs = DMNEW(vm_arg, vmargscount);
2527 /* fill the vm_arg array from a va_list */
2529 vm_vmargs_from_jvalue(m, o, vmargs, args);
2531 /* call the Java method */
2533 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2535 /* release dump area */
2537 dump_release(dumpsize);
2543 /* vm_call_method_long_vmarg ***************************************************
2545 Calls a Java method with a variable number of arguments, passed via
2546 a vm_arg array, and returns a long (s8).
2548 *******************************************************************************/
2550 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2554 #if defined(ENABLE_JIT)
2555 # if defined(ENABLE_INTRP)
2557 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2560 l = asm_vm_call_method_long(m, vmargscount, vmargs);
2562 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2569 /* vm_call_method_float ********************************************************
2571 Calls a Java method with a variable number of arguments and returns
2574 *******************************************************************************/
2576 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
2582 f = vm_call_method_float_valist(m, o, ap);
2589 /* vm_call_method_float_valist *************************************************
2591 Calls a Java method with a variable number of arguments, passed via
2592 a va_list, and returns a float.
2594 *******************************************************************************/
2596 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
2604 /* mark start of dump memory area */
2606 dumpsize = dump_size();
2608 /* get number of Java method arguments */
2610 vmargscount = m->parseddesc->paramcount;
2612 /* allocate vm_arg array */
2614 vmargs = DMNEW(vm_arg, vmargscount);
2616 /* fill the vm_arg array from a va_list */
2618 vm_vmargs_from_valist(m, o, vmargs, ap);
2620 /* call the Java method */
2622 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2624 /* release dump area */
2626 dump_release(dumpsize);
2632 /* vm_call_method_float_jvalue *************************************************
2634 Calls a Java method with a variable number of arguments, passed via
2635 a jvalue array, and returns a float.
2637 *******************************************************************************/
2639 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
2647 /* mark start of dump memory area */
2649 dumpsize = dump_size();
2651 /* get number of Java method arguments */
2653 vmargscount = m->parseddesc->paramcount;
2655 /* allocate vm_arg array */
2657 vmargs = DMNEW(vm_arg, vmargscount);
2659 /* fill the vm_arg array from a va_list */
2661 vm_vmargs_from_jvalue(m, o, vmargs, args);
2663 /* call the Java method */
2665 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2667 /* release dump area */
2669 dump_release(dumpsize);
2675 /* vm_call_method_float_vmarg **************************************************
2677 Calls a Java method with a variable number of arguments and returns
2680 *******************************************************************************/
2682 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2686 #if defined(ENABLE_JIT)
2687 # if defined(ENABLE_INTRP)
2689 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2692 f = asm_vm_call_method_float(m, vmargscount, vmargs);
2694 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2701 /* vm_call_method_double *******************************************************
2703 Calls a Java method with a variable number of arguments and returns
2706 *******************************************************************************/
2708 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
2714 d = vm_call_method_double_valist(m, o, ap);
2721 /* vm_call_method_double_valist ************************************************
2723 Calls a Java method with a variable number of arguments, passed via
2724 a va_list, and returns a double.
2726 *******************************************************************************/
2728 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
2736 /* mark start of dump memory area */
2738 dumpsize = dump_size();
2740 /* get number of Java method arguments */
2742 vmargscount = m->parseddesc->paramcount;
2744 /* allocate vm_arg array */
2746 vmargs = DMNEW(vm_arg, vmargscount);
2748 /* fill the vm_arg array from a va_list */
2750 vm_vmargs_from_valist(m, o, vmargs, ap);
2752 /* call the Java method */
2754 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2756 /* release dump area */
2758 dump_release(dumpsize);
2764 /* vm_call_method_double_jvalue ************************************************
2766 Calls a Java method with a variable number of arguments, passed via
2767 a jvalue array, and returns a double.
2769 *******************************************************************************/
2771 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
2779 /* mark start of dump memory area */
2781 dumpsize = dump_size();
2783 /* get number of Java method arguments */
2785 vmargscount = m->parseddesc->paramcount;
2787 /* allocate vm_arg array */
2789 vmargs = DMNEW(vm_arg, vmargscount);
2791 /* fill the vm_arg array from a va_list */
2793 vm_vmargs_from_jvalue(m, o, vmargs, args);
2795 /* call the Java method */
2797 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2799 /* release dump area */
2801 dump_release(dumpsize);
2807 /* vm_call_method_double_vmarg *************************************************
2809 Calls a Java method with a variable number of arguments and returns
2812 *******************************************************************************/
2814 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
2819 #if defined(ENABLE_JIT)
2820 # if defined(ENABLE_INTRP)
2822 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2825 d = asm_vm_call_method_double(m, vmargscount, vmargs);
2827 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2835 * These are local overrides for various environment variables in Emacs.
2836 * Please do not remove this and leave it at the end of the file, where
2837 * Emacs will automagically detect them.
2838 * ---------------------------------------------------------------------
2841 * indent-tabs-mode: t