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)
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/signallocal.h"
66 #include "vm/stringlocal.h"
69 #include "vm/jit/jit.h"
70 #include "vm/jit/asmpart.h"
72 #include "vm/jit/recompile.h"
74 #include "vm/jit/profile/profile.h"
75 #include "vm/rt-timing.h"
77 #if defined(ENABLE_JVMTI)
78 #include "native/jvmti/cacaodbg.h"
82 /* Invocation API variables ***************************************************/
84 _Jv_JavaVM *_Jv_jvm; /* denotes a Java VM */
85 _Jv_JNIEnv *_Jv_env; /* pointer to native method interface */
88 /* global variables ***********************************************************/
90 s4 vms = 0; /* number of VMs created */
92 bool vm_initializing = false;
93 bool vm_exiting = false;
95 char *cacao_prefix = NULL;
96 char *cacao_libjvm = NULL;
97 char *classpath_libdir = NULL;
99 char *_Jv_bootclasspath; /* contains the boot classpath */
100 char *_Jv_classpath; /* contains the classpath */
101 char *_Jv_java_library_path;
103 char *mainstring = NULL;
104 classinfo *mainclass = NULL;
106 char *specificmethodname = NULL;
107 char *specificsignature = NULL;
111 #if defined(ENABLE_INTRP)
112 u1 *intrp_main_stack = NULL;
116 /* define heap sizes **********************************************************/
118 #define HEAP_MAXSIZE 128 * 1024 * 1024 /* default 128MB */
119 #define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
120 #define STACK_SIZE 64 * 1024 /* default 64kB */
123 /* define command line options ************************************************/
150 /* Java non-standard options */
161 #if defined(ENABLE_PROFILING)
175 #if defined(ENABLE_STATISTICS)
192 #if defined(ENABLE_VERIFIER)
194 #if defined(TYPECHECK_VERBOSE)
197 #endif /* defined(ENABLE_VERIFIER) */
200 /* optimization options */
202 #if defined(ENABLE_LOOP)
206 #if defined(ENABLE_IFCONV)
210 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
214 #if defined(ENABLE_INLINING)
218 #if defined(ENABLE_INTRP)
219 /* interpreter options */
242 opt_struct opts[] = {
243 { "foo", false, OPT_FOO },
247 { "jar", false, OPT_JAR },
249 { "d32", false, OPT_D32 },
250 { "d64", false, OPT_D64 },
251 { "client", false, OPT_IGNORE },
252 { "server", false, OPT_IGNORE },
253 { "jvm", false, OPT_IGNORE },
254 { "hotspot", false, OPT_IGNORE },
256 { "classpath", true, OPT_CLASSPATH },
257 { "cp", true, OPT_CLASSPATH },
258 { "D", true, OPT_D },
259 { "version", false, OPT_VERSION },
260 { "showversion", false, OPT_SHOWVERSION },
261 { "fullversion", false, OPT_FULLVERSION },
262 { "help", false, OPT_HELP },
263 { "?", false, OPT_HELP },
264 { "X", false, OPT_X },
266 { "esa", false, OPT_ESA },
267 { "enablesystemassertions", false, OPT_ESA },
268 { "dsa", false, OPT_DSA },
269 { "disablesystemassertions", false, OPT_DSA },
271 { "noasyncgc", false, OPT_IGNORE },
272 #if defined(ENABLE_VERIFIER)
273 { "noverify", false, OPT_NOVERIFY },
275 { "v", false, OPT_VERBOSE1 },
276 { "verbose:", true, OPT_VERBOSE },
278 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
279 { "verbosetc", false, OPT_VERBOSETC },
281 #if defined(__ALPHA__)
282 { "noieee", false, OPT_NOIEEE },
284 { "softnull", false, OPT_SOFTNULL },
285 #if defined(ENABLE_STATISTICS)
286 { "time", false, OPT_TIME },
287 { "stat", false, OPT_STAT },
289 { "log", true, OPT_LOG },
290 { "c", true, OPT_CHECK },
291 { "l", false, OPT_LOAD },
292 { "eager", false, OPT_EAGER },
295 { "all", false, OPT_ALL },
296 { "sig", true, OPT_SIGNATURE },
299 #if defined(ENABLE_LOOP)
300 { "oloop", false, OPT_OLOOP },
302 #if defined(ENABLE_IFCONV)
303 { "ifconv", false, OPT_IFCONV },
305 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
306 { "lsra", false, OPT_LSRA },
309 #if defined(ENABLE_INTRP)
310 /* interpreter options */
312 { "trace", false, OPT_TRACE },
313 { "static-supers", true, OPT_STATIC_SUPERS },
314 { "no-dynamic", false, OPT_NO_DYNAMIC },
315 { "no-replication", false, OPT_NO_REPLICATION },
316 { "no-quicksuper", false, OPT_NO_QUICKSUPER },
319 /* JVMTI Agent Command Line Options */
321 { "agentlib:", true, OPT_AGENTLIB },
322 { "agentpath:", true, OPT_AGENTPATH },
325 /* Java non-standard options */
327 { "Xjit", false, OPT_JIT },
328 { "Xint", false, OPT_INTRP },
329 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
330 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
331 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
332 { "Xbootclasspath/c:", true, OPT_BOOTCLASSPATH_C },
335 { "Xdebug", false, OPT_DEBUG },
336 { "Xnoagent", false, OPT_NOAGENT },
337 { "Xrunjdwp", true, OPT_XRUNJDWP },
340 { "Xms", true, OPT_MS },
341 { "ms", true, OPT_MS },
342 { "Xmx", true, OPT_MX },
343 { "mx", true, OPT_MX },
344 { "Xss", true, OPT_SS },
345 { "ss", true, OPT_SS },
347 #if defined(ENABLE_PROFILING)
348 { "Xprof:", true, OPT_PROF_OPTION },
349 { "Xprof", false, OPT_PROF },
352 /* keep these at the end of the list */
354 #if defined(ENABLE_INLINING)
355 { "i", true, OPT_INLINING },
359 { "m", true, OPT_METHOD },
362 { "s", true, OPT_SHOW },
363 { "debug-color", false, OPT_DEBUGCOLOR },
369 /* usage ***********************************************************************
371 Prints the correct usage syntax to stdout.
373 *******************************************************************************/
377 puts("Usage: cacao [-options] classname [arguments]");
378 puts(" (to run a class file)");
379 puts(" or cacao [-options] -jar jarfile [arguments]");
380 puts(" (to run a standalone jar file)\n");
382 puts("Java options:");
383 puts(" -d32 use 32-bit data model if available");
384 puts(" -d64 use 64-bit data model if available");
385 puts(" -client compatibility (currently ignored)");
386 puts(" -server compatibility (currently ignored)");
387 puts(" -jvm compatibility (currently ignored)");
388 puts(" -hotspot compatibility (currently ignored)\n");
390 puts(" -cp <path> specify a path to look for classes");
391 puts(" -classpath <path> specify a path to look for classes");
392 puts(" -D<name>=<value> add an entry to the property list");
393 puts(" -verbose[:class|gc|jni] enable specific verbose output");
394 puts(" -version print product version and exit");
395 puts(" -fullversion print jpackage-compatible product version and exit");
396 puts(" -showversion print product version and continue");
397 puts(" -help, -? print this help message");
398 puts(" -X print help on non-standard Java options");
399 puts(" -esa | -enablesystemassertions");
400 puts(" enable system assertions");
401 puts(" -dsa | -disablesystemassertions");
402 puts(" disable system assertions");
406 puts(" -agentlib:<agent-lib-name>=<options> library to load containg JVMTI agent");
407 puts (" for jdwp help use: -agentlib:jdwp=help");
408 puts(" -agentpath:<path-to-agent>=<options> path to library containg JVMTI agent");
411 puts("CACAO options:");
412 puts(" -v write state-information");
413 puts(" -verbose[:call|exception|jit]");
414 puts(" enable specific verbose output");
415 puts(" -debug-color colored output for ANSI terms");
416 #ifdef TYPECHECK_VERBOSE
417 puts(" -verbosetc write debug messages while typechecking");
419 #if defined(__ALPHA__)
420 puts(" -noieee don't use ieee compliant arithmetic");
422 #if defined(ENABLE_VERIFIER)
423 puts(" -noverify don't verify classfiles");
425 puts(" -softnull use software nullpointer check");
426 #if defined(ENABLE_STATISTICS)
427 puts(" -time measure the runtime");
428 puts(" -stat detailed compiler statistics");
430 puts(" -log logfile specify a name for the logfile");
431 puts(" -c(heck)b(ounds) don't check array bounds");
432 puts(" s(ync) don't check for synchronization");
433 #if defined(ENABLE_LOOP)
434 puts(" -oloop optimize array accesses in loops");
436 puts(" -l don't start the class after loading");
437 puts(" -eager perform eager class loading and linking");
439 puts(" -all compile all methods, no execution");
440 puts(" -m compile only a specific method");
441 puts(" -sig specify signature for a specific method");
444 puts(" -s(how)... show...");
445 puts(" c(onstants) the constant pool");
446 puts(" m(ethods) class fields and methods");
447 puts(" u(tf) the utf - hash");
448 puts(" i(ntermediate) intermediate representation");
449 #if defined(ENABLE_DISASSEMBLER)
450 puts(" a(ssembler) disassembled listing");
451 puts(" e(xceptionstubs) disassembled exception stubs (only with -sa)");
452 puts(" n(ative) disassembled native stubs");
454 puts(" d(atasegment) data segment listing");
455 #if defined(ENABLE_INLINING)
456 puts(" -i n(line) activate inlining");
457 puts(" v(irtual) inline virtual methods (uses/turns rt option on)");
458 puts(" e(exception) inline methods with exceptions");
459 puts(" p(aramopt) optimize argument renaming");
460 puts(" o(utsiders) inline methods of foreign classes");
461 #endif /* defined(ENABLE_INLINING) */
462 #if defined(ENABLE_IFCONV)
463 puts(" -ifconv use if-conversion");
465 #if defined(ENABLE_LSRA)
466 puts(" -lsra use linear scan register allocation");
468 #if defined(ENABLE_SSA)
469 puts(" -lsra use linear scan register allocation (with SSA)");
472 /* exit with error code */
478 static void Xusage(void)
480 #if defined(ENABLE_JIT)
481 puts(" -Xjit JIT mode execution (default)");
483 #if defined(ENABLE_INTRP)
484 puts(" -Xint interpreter mode execution");
486 puts(" -Xbootclasspath:<zip/jar files and directories separated by :>");
487 puts(" value is set as bootstrap class path");
488 puts(" -Xbootclasspath/a:<zip/jar files and directories separated by :>");
489 puts(" value is appended to the bootstrap class path");
490 puts(" -Xbootclasspath/p:<zip/jar files and directories separated by :>");
491 puts(" value is prepended to the bootstrap class path");
492 puts(" -Xbootclasspath/c:<zip/jar files and directories separated by :>");
493 puts(" value is used as Java core library, but the");
494 puts(" hardcoded VM interface classes are prepended");
495 printf(" -Xms<size> set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024);
496 printf(" -Xmx<size> set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024);
497 printf(" -Xss<size> set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024);
499 #if defined(ENABLE_PROFILING)
500 puts(" -Xprof[:bb] collect and print profiling data");
503 #if defined(ENABLE_JVMTI)
504 /* -Xdebug option depend on gnu classpath JDWP options. options:
505 transport=dt_socket,address=<hostname:port>,server=(y|n),suspend(y|n) */
506 puts(" -Xdebug enable remote debugging\n");
507 puts(" -Xrunjdwp transport=[dt_socket|...],address=<hostname:port>,server=[y|n],suspend=[y|n]\n");
508 puts(" enable remote debugging\n");
511 /* exit with error code */
517 /* version *********************************************************************
519 Only prints cacao version information.
521 *******************************************************************************/
523 static void version(bool opt_exit)
525 puts("java version \""JAVA_VERSION"\"");
526 puts("CACAO version "VERSION"");
528 puts("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,");
529 puts("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,");
530 puts("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,");
531 puts("J. Wenninger, Institut f. Computersprachen - TU Wien\n");
533 puts("This program is free software; you can redistribute it and/or");
534 puts("modify it under the terms of the GNU General Public License as");
535 puts("published by the Free Software Foundation; either version 2, or (at");
536 puts("your option) any later version.\n");
538 puts("This program is distributed in the hope that it will be useful, but");
539 puts("WITHOUT ANY WARRANTY; without even the implied warranty of");
540 puts("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU");
541 puts("General Public License for more details.\n");
543 puts("Configure/Build options:\n");
544 puts(" ./configure: "VERSION_CONFIGURE_ARGS"");
545 #if defined(__VERSION__)
546 puts(" CC : "VERSION_CC" ("__VERSION__")");
548 puts(" CC : "VERSION_CC"");
550 puts(" CFLAGS : "VERSION_CFLAGS"\n");
552 puts("Default variables:\n");
553 printf(" maximum heap size : %d\n", HEAP_MAXSIZE);
554 printf(" initial heap size : %d\n", HEAP_STARTSIZE);
555 printf(" stack size : %d\n", STACK_SIZE);
556 puts(" java.boot.class.path : "CACAO_VM_ZIP":"CLASSPATH_GLIBJ_ZIP"");
557 puts(" gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR"/classpath\n");
559 puts("Runtime variables:\n");
560 printf(" maximum heap size : %d\n", opt_heapmaxsize);
561 printf(" initial heap size : %d\n", opt_heapstartsize);
562 printf(" stack size : %d\n", opt_stacksize);
563 printf(" java.boot.class.path : %s\n", _Jv_bootclasspath);
564 printf(" gnu.classpath.boot.library.path: %s\n", classpath_libdir);
566 /* exit normally, if requested */
573 /* fullversion *****************************************************************
575 Prints a Sun compatible version information (required e.g. by
576 jpackage, www.jpackage.org).
578 *******************************************************************************/
580 static void fullversion(void)
582 puts("java full version \"cacao-"JAVA_VERSION"\"");
590 /* forward declarations *******************************************************/
592 static char *vm_get_mainclass_from_jar(char *mainstring);
594 static void vm_compile_all(void);
595 static void vm_compile_method(void);
599 /* vm_create *******************************************************************
601 Creates a JVM. Called by JNI_CreateJavaVM.
603 *******************************************************************************/
605 bool vm_create(JavaVMInitArgs *vm_args)
614 #if defined(ENABLE_JVMTI)
616 char *libname, *agentarg;
617 bool jdwp,agentbypath;
618 jdwp = agentbypath = false;
621 /* check the JNI version requested */
623 switch (vm_args->version) {
624 case JNI_VERSION_1_1:
626 case JNI_VERSION_1_2:
627 case JNI_VERSION_1_4:
633 /* we only support 1 JVM instance */
638 if (atexit(vm_exit_handler))
639 vm_abort("atexit failed: %s\n", strerror(errno));
642 log_text("CACAO started -------------------------------------------------------");
644 /* set the VM starttime */
646 _Jv_jvm->starttime = builtin_currenttimemillis();
648 /* get stuff from the environment *****************************************/
650 #if defined(DISABLE_GC)
651 nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
654 #if defined(WITH_JRE_LAYOUT)
655 /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
657 cacao_prefix = MNEW(char, 4096);
659 if (readlink("/proc/self/exe", cacao_prefix, 4095) == -1)
660 vm_abort("readlink failed: %s\n", strerror(errno));
662 /* get the path of the current executable */
664 cacao_prefix = dirname(cacao_prefix);
666 if ((strlen(cacao_prefix) + strlen("/..") + strlen("0")) > 4096)
667 vm_abort("libjvm name to long for buffer\n");
669 /* concatenate the library name */
671 strcat(cacao_prefix, "/..");
673 /* now set path to libjvm.so */
675 len = strlen(cacao_prefix) + strlen("/lib/libjvm") + strlen("0");
677 cacao_libjvm = MNEW(char, len);
678 strcpy(cacao_libjvm, cacao_prefix);
679 strcat(cacao_libjvm, "/lib/libjvm");
681 /* and finally set the path to GNU Classpath libraries */
683 len = strlen(cacao_prefix) + strlen("/lib/classpath") + strlen("0");
685 classpath_libdir = MNEW(char, len);
686 strcpy(classpath_libdir, cacao_prefix);
687 strcat(classpath_libdir, "/lib/classpath");
689 cacao_prefix = CACAO_PREFIX;
690 cacao_libjvm = CACAO_LIBDIR"/libjvm";
691 classpath_libdir = CLASSPATH_LIBDIR"/classpath";
694 /* set the bootclasspath */
696 cp = getenv("BOOTCLASSPATH");
699 _Jv_bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
700 strcpy(_Jv_bootclasspath, cp);
703 #if defined(WITH_JRE_LAYOUT)
705 strlen(cacao_prefix) +
706 strlen("/share/cacao/vm.zip") +
708 strlen(cacao_prefix) +
709 strlen("/share/classpath/glibj.zip") +
712 _Jv_bootclasspath = MNEW(char, len);
713 strcat(_Jv_bootclasspath, cacao_prefix);
714 strcat(_Jv_bootclasspath, "/share/cacao/vm.zip");
715 strcat(_Jv_bootclasspath, ":");
716 strcat(_Jv_bootclasspath, cacao_prefix);
717 strcat(_Jv_bootclasspath, "/share/classpath/glibj.zip");
720 strlen(CACAO_VM_ZIP) +
722 strlen(CLASSPATH_GLIBJ_ZIP) +
725 _Jv_bootclasspath = MNEW(char, len);
726 strcat(_Jv_bootclasspath, CACAO_VM_ZIP);
727 strcat(_Jv_bootclasspath, ":");
728 strcat(_Jv_bootclasspath, CLASSPATH_GLIBJ_ZIP);
732 /* set the classpath */
734 cp = getenv("CLASSPATH");
737 _Jv_classpath = MNEW(char, strlen(cp) + strlen("0"));
738 strcat(_Jv_classpath, cp);
741 _Jv_classpath = MNEW(char, strlen(".") + strlen("0"));
742 strcpy(_Jv_classpath, ".");
745 /* get and set java.library.path */
747 _Jv_java_library_path = getenv("LD_LIBRARY_PATH");
749 if (_Jv_java_library_path == NULL)
750 _Jv_java_library_path = "";
752 /* interpret the options **************************************************/
760 opt_heapmaxsize = HEAP_MAXSIZE;
761 opt_heapstartsize = HEAP_STARTSIZE;
762 opt_stacksize = STACK_SIZE;
765 #if defined(ENABLE_JVMTI)
766 /* initialize JVMTI related **********************************************/
770 /* initialize properties before commandline handling */
772 if (!properties_init())
773 throw_cacao_exception_exit(string_java_lang_InternalError,
774 "Unable to init properties");
776 /* add some default properties */
778 properties_add("java.endorsed.dirs", ""CACAO_PREFIX"/jre/lib/endorsed");
780 /* iterate over all passed options */
782 while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
796 #if SIZEOF_VOID_P == 8
797 puts("Running a 32-bit JVM is not supported on this platform.");
803 #if SIZEOF_VOID_P == 4
804 puts("Running a 64-bit JVM is not supported on this platform.");
810 /* forget old classpath and set the argument as new classpath */
811 MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
813 _Jv_classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
814 strcpy(_Jv_classpath, opt_arg);
818 for (i = 0; i < strlen(opt_arg); i++) {
819 if (opt_arg[i] == '=') {
821 properties_add(opt_arg, opt_arg + i + 1);
826 /* if no '=' is given, just create an empty property */
828 properties_add(opt_arg, "");
833 case OPT_BOOTCLASSPATH:
834 /* Forget default bootclasspath and set the argument as
835 new boot classpath. */
837 MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
839 _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
840 strcpy(_Jv_bootclasspath, opt_arg);
843 case OPT_BOOTCLASSPATH_A:
844 /* append to end of bootclasspath */
846 len = strlen(_Jv_bootclasspath);
848 _Jv_bootclasspath = MREALLOC(_Jv_bootclasspath,
852 strlen(opt_arg) + strlen("0"));
854 strcat(_Jv_bootclasspath, ":");
855 strcat(_Jv_bootclasspath, opt_arg);
858 case OPT_BOOTCLASSPATH_P:
859 /* prepend in front of bootclasspath */
861 cp = _Jv_bootclasspath;
864 _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
867 strcpy(_Jv_bootclasspath, opt_arg);
868 strcat(_Jv_bootclasspath, ":");
869 strcat(_Jv_bootclasspath, cp);
871 MFREE(cp, char, len);
874 case OPT_BOOTCLASSPATH_C:
875 /* use as Java core library, but prepend VM interface classes */
877 MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
879 len = strlen(CACAO_VM_ZIP) +
884 _Jv_bootclasspath = MNEW(char, len);
886 strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
887 strcat(_Jv_bootclasspath, ":");
888 strcat(_Jv_bootclasspath, opt_arg);
891 #if defined(ENABLE_JVMTI)
893 /* this option exists only for compatibility reasons */
897 /* I don't know yet what Xnoagent should do. This is only for
898 compatiblity with eclipse - motse */
907 strlen(CACAO_LIBDIR) +
908 strlen("/libjdwp.so=") +
912 agentarg = MNEW(char, len);
914 strcpy(agentarg, CACAO_LIBDIR);
915 strcat(agentarg, "/libjdwp.so=");
916 strcat(agentarg, &opt_arg[1]);
933 c = opt_arg[strlen(opt_arg) - 1];
935 if ((c == 'k') || (c == 'K')) {
936 j = atoi(opt_arg) * 1024;
938 } else if ((c == 'm') || (c == 'M')) {
939 j = atoi(opt_arg) * 1024 * 1024;
946 else if (opt == OPT_MS)
947 opt_heapstartsize = j;
958 if (strcmp("class", opt_arg) == 0)
959 opt_verboseclass = true;
961 else if (strcmp("gc", opt_arg) == 0)
962 opt_verbosegc = true;
964 else if (strcmp("jni", opt_arg) == 0)
965 opt_verbosejni = true;
967 else if (strcmp("call", opt_arg) == 0)
968 opt_verbosecall = true;
970 else if (strcmp("jit", opt_arg) == 0) {
975 compileverbose = true;
977 else if (strcmp("exception", opt_arg) == 0)
978 opt_verboseexception = true;
981 opt_debugcolor = true;
984 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
986 opt_typecheckverbose = true;
995 case OPT_FULLVERSION:
999 case OPT_SHOWVERSION:
1007 #if defined(ENABLE_VERIFIER)
1017 #if defined(ENABLE_STATISTICS)
1019 opt_getcompilingtime = true;
1020 opt_getloadingtime = true;
1033 for (i = 0; i < strlen(opt_arg); i++) {
1034 switch (opt_arg[i]) {
1036 checkbounds = false;
1049 makeinitializations = false;
1056 #if !defined(NDEBUG)
1060 makeinitializations = false;
1065 opt_method = opt_arg;
1066 makeinitializations = false;
1070 opt_signature = opt_arg;
1074 case OPT_SHOW: /* Display options */
1075 for (i = 0; i < strlen(opt_arg); i++) {
1076 switch (opt_arg[i]) {
1078 showconstantpool = true;
1090 opt_showintermediate = true;
1091 compileverbose = true;
1094 #if defined(ENABLE_DISASSEMBLER)
1096 opt_showdisassemble = true;
1097 compileverbose = true;
1101 opt_showexceptionstubs = true;
1105 opt_shownativestub = true;
1110 opt_showddatasegment = true;
1119 #if defined(ENABLE_LOOP)
1125 #if defined(ENABLE_INLINING)
1127 for (i = 0; i < strlen(opt_arg); i++) {
1128 switch (opt_arg[i]) {
1130 /* define in options.h; Used in main.c, jit.c
1131 & inline.c inlining is currently
1135 inlinevirtuals = true;
1138 inlineexceptions = true;
1141 inlineparamopt = true;
1144 inlineoutsiders = true;
1151 #endif /* defined(ENABLE_INLINING) */
1153 #if defined(ENABLE_IFCONV)
1159 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1174 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = true;
1178 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = false;
1181 #if defined(ENABLE_PROFILING)
1182 case OPT_PROF_OPTION:
1183 /* use <= to get the last \0 too */
1185 for (i = 0, j = 0; i <= strlen(opt_arg); i++) {
1186 if (opt_arg[i] == ',')
1189 if (opt_arg[i] == '\0') {
1190 if (strcmp("bb", opt_arg + j) == 0)
1194 printf("Unknown option: -Xprof:%s\n", opt_arg + j);
1198 /* set k to next char */
1211 #if defined(ENABLE_JIT)
1214 printf("-Xjit option not enabled.\n");
1220 #if defined(ENABLE_INTRP)
1223 printf("-Xint option not enabled.\n");
1228 #if defined(ENABLE_INTRP)
1229 case OPT_STATIC_SUPERS:
1230 opt_static_supers = atoi(opt_arg);
1233 case OPT_NO_DYNAMIC:
1234 opt_no_dynamic = true;
1237 case OPT_NO_REPLICATION:
1238 opt_no_replication = true;
1241 case OPT_NO_QUICKSUPER:
1242 opt_no_quicksuper = true;
1251 printf("Unknown option: %s\n",
1252 vm_args->options[opt_index].optionString);
1258 /* Now we have all options handled and we can print the version
1265 /* get the main class *****************************************************/
1267 if (opt_index < vm_args->nOptions) {
1268 mainstring = vm_args->options[opt_index++].optionString;
1270 /* Put the jar file into the classpath (if any). */
1272 if (opt_jar == true) {
1273 /* free old classpath */
1275 MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
1277 /* put jarfile into classpath */
1279 _Jv_classpath = MNEW(char, strlen(mainstring) + strlen("0"));
1281 strcpy(_Jv_classpath, mainstring);
1284 /* replace .'s with /'s in classname */
1286 for (i = strlen(mainstring) - 1; i >= 0; i--)
1287 if (mainstring[i] == '.')
1288 mainstring[i] = '/';
1292 #if defined(ENABLE_JVMTI)
1294 jvmti_set_phase(JVMTI_PHASE_ONLOAD);
1295 jvmti_agentload(agentarg, agentbypath, &handle, &libname);
1298 MFREE(agentarg, char, strlen(agentarg));
1300 jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
1306 /* initialize this JVM ****************************************************/
1308 vm_initializing = true;
1310 #if defined(ENABLE_THREADS)
1311 /* pre-initialize some core thread stuff, like the stopworldlock,
1312 thus this has to happen _before_ gc_init()!!! */
1317 /* initialize the garbage collector */
1319 gc_init(opt_heapmaxsize, opt_heapstartsize);
1321 #if defined(ENABLE_INTRP)
1322 /* Allocate main thread stack on the Java heap. */
1325 intrp_main_stack = GCMNEW(u1, opt_stacksize);
1326 MSET(intrp_main_stack, 0, u1, opt_stacksize);
1330 /* initialize the string hashtable stuff: lock (must be done
1331 _after_ threads_preinit) */
1334 throw_main_exception_exit();
1336 /* initialize the utf8 hashtable stuff: lock, often used utf8
1337 strings (must be done _after_ threads_preinit) */
1340 throw_main_exception_exit();
1342 /* initialize the classcache hashtable stuff: lock, hashtable
1343 (must be done _after_ threads_preinit) */
1345 if (!classcache_init())
1346 throw_main_exception_exit();
1348 /* initialize the loader with bootclasspath (must be done _after_
1352 throw_main_exception_exit();
1354 suck_add_from_property("java.endorsed.dirs");
1355 suck_add(_Jv_bootclasspath);
1357 /* initialize the memory subsystem (must be done _after_
1361 throw_main_exception_exit();
1363 /* initialize the finalizer stuff (must be done _after_
1366 if (!finalizer_init())
1367 throw_main_exception_exit();
1369 /* install architecture dependent signal handler used for exceptions */
1373 /* initialize the codegen subsystems */
1377 /* initializes jit compiler */
1381 /* machine dependent initialization */
1383 #if defined(ENABLE_JIT)
1384 # if defined(ENABLE_INTRP)
1394 /* initialize the loader subsystems (must be done _after_
1398 throw_main_exception_exit();
1401 throw_main_exception_exit();
1404 throw_main_exception_exit();
1406 if (!exceptions_init())
1407 throw_main_exception_exit();
1409 if (!builtin_init())
1410 throw_main_exception_exit();
1412 /* Initialize the JNI subsystem (must be done _before_
1413 threads_init, as threads_init can call JNI methods
1414 (e.g. NewGlobalRef). */
1417 throw_main_exception_exit();
1419 #if defined(ENABLE_THREADS)
1420 if (!threads_init())
1421 throw_main_exception_exit();
1424 /* That's important, otherwise we get into trouble, if the Runtime
1425 static initializer is called before (circular dependency. This
1426 is with classpath 0.09. Another important thing is, that this
1427 has to happen after initThreads!!! */
1429 if (!initialize_class(class_java_lang_System))
1430 throw_main_exception_exit();
1432 #if defined(ENABLE_PROFILING)
1433 /* initialize profiling */
1435 if (!profile_init())
1436 throw_main_exception_exit();
1439 #if defined(ENABLE_THREADS)
1440 /* initialize recompilation */
1442 if (!recompile_init())
1443 throw_main_exception_exit();
1445 /* finally, start the finalizer thread */
1447 if (!finalizer_start_thread())
1448 throw_main_exception_exit();
1450 /* start the recompilation thread (must be done before the
1451 profiling thread) */
1453 if (!recompile_start_thread())
1454 throw_main_exception_exit();
1456 # if defined(ENABLE_PROFILING)
1457 /* start the profile sampling thread */
1460 /* if (!profile_start_thread()) */
1461 /* throw_main_exception_exit(); */
1465 #if defined(ENABLE_JVMTI)
1467 /* add agent library to native library hashtable */
1468 native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
1472 /* increment the number of VMs */
1476 /* initialization is done */
1478 vm_initializing = false;
1480 /* everything's ok */
1486 /* vm_run **********************************************************************
1488 Runs the main-method of the passed class.
1490 *******************************************************************************/
1492 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
1495 classinfo *mainclass;
1497 java_objectarray *oa;
1500 java_lang_String *s;
1504 #if !defined(NDEBUG)
1510 if (opt_method != NULL) {
1511 vm_compile_method();
1514 #endif /* !defined(NDEBUG) */
1516 /* should we run the main-method? */
1518 if (mainstring == NULL)
1521 /* set return value to OK */
1525 if (opt_jar == true)
1526 /* open jar file with java.util.jar.JarFile */
1527 mainstring = vm_get_mainclass_from_jar(mainstring);
1529 /* load the main class */
1531 mainutf = utf_new_char(mainstring);
1533 if (!(mainclass = load_class_from_sysloader(mainutf)))
1534 throw_main_exception_exit();
1536 /* error loading class */
1538 if ((*exceptionptr != NULL) || (mainclass == NULL))
1539 throw_main_exception_exit();
1541 if (!link_class(mainclass))
1542 throw_main_exception_exit();
1544 /* find the `main' method of the main class */
1546 m = class_resolveclassmethod(mainclass,
1547 utf_new_char("main"),
1548 utf_new_char("([Ljava/lang/String;)V"),
1549 class_java_lang_Object,
1552 if (*exceptionptr) {
1553 throw_main_exception_exit();
1556 /* there is no main method or it isn't static */
1558 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
1559 *exceptionptr = NULL;
1562 new_exception_message(string_java_lang_NoSuchMethodError, "main");
1563 throw_main_exception_exit();
1566 /* build argument array */
1568 oalength = vm_args->nOptions - opt_index;
1570 oa = builtin_anewarray(oalength, class_java_lang_String);
1572 for (i = 0; i < oalength; i++) {
1573 u = utf_new_char(vm_args->options[opt_index + i].optionString);
1574 s = javastring_new(u);
1576 oa->data[i] = (java_objectheader *) s;
1579 #ifdef TYPEINFO_DEBUG_TEST
1580 /* test the typeinfo system */
1583 /*class_showmethods(currentThread->group->header.vftbl->class); */
1585 #if defined(ENABLE_JVMTI)
1586 jvmti_set_phase(JVMTI_PHASE_LIVE);
1589 /* increase total started thread count */
1591 _Jv_jvm->total_started_thread_count++;
1593 /* start the main thread */
1595 (void) vm_call_method(m, NULL, oa);
1597 /* exception occurred? */
1599 if (*exceptionptr) {
1600 throw_main_exception();
1604 /* unload the JavaVM */
1614 /* vm_destroy ******************************************************************
1616 Unloads a Java VM and reclaims its resources.
1618 *******************************************************************************/
1620 s4 vm_destroy(JavaVM *vm)
1622 #if defined(ENABLE_THREADS)
1623 threads_join_all_threads();
1626 /* everything's ok */
1632 /* vm_exit *********************************************************************
1634 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1636 *******************************************************************************/
1638 void vm_exit(s4 status)
1642 /* signal that we are exiting */
1646 assert(class_java_lang_System);
1647 assert(class_java_lang_System->state & CLASS_LOADED);
1649 #if defined(ENABLE_JVMTI)
1650 if (jvmti || (dbgcom!=NULL)) {
1651 jvmti_set_phase(JVMTI_PHASE_DEAD);
1652 if (jvmti) jvmti_agentunload();
1656 if (!link_class(class_java_lang_System))
1657 throw_main_exception_exit();
1659 /* call java.lang.System.exit(I)V */
1661 m = class_resolveclassmethod(class_java_lang_System,
1662 utf_new_char("exit"),
1664 class_java_lang_Object,
1668 throw_main_exception_exit();
1670 /* call the exit function with passed exit status */
1672 (void) vm_call_method(m, NULL, status);
1674 /* If we had an exception, just ignore the exception and exit with
1677 vm_shutdown(status);
1681 /* vm_shutdown *****************************************************************
1683 Terminates the system immediately without freeing memory explicitly
1684 (to be used only for abnormal termination).
1686 *******************************************************************************/
1688 void vm_shutdown(s4 status)
1691 #if defined(ENABLE_STATISTICS)
1692 || opt_getcompilingtime || opt_stat
1696 log_text("CACAO terminated by shutdown");
1697 dolog("Exit status: %d\n", (s4) status);
1701 #if defined(ENABLE_JVMTI)
1702 /* terminate cacaodbgserver */
1704 pthread_mutex_lock(&dbgcomlock);
1706 pthread_mutex_unlock(&dbgcomlock);
1707 jvmti_cacaodbgserver_quit();
1715 /* vm_exit_handler *************************************************************
1717 The exit_handler function is called upon program termination.
1719 ATTENTION: Don't free system resources here! Some threads may still
1720 be running as this is called from VMRuntime.exit(). The OS does the
1723 *******************************************************************************/
1725 void vm_exit_handler(void)
1727 #if !defined(NDEBUG)
1729 class_showmethods(mainclass);
1731 if (showconstantpool)
1732 class_showconstantpool(mainclass);
1737 # if defined(ENABLE_PROFILING)
1739 profile_printstats();
1741 #endif /* !defined(NDEBUG) */
1743 #if defined(ENABLE_RT_TIMING)
1744 rt_timing_print_time_stats(stderr);
1747 #if defined(ENABLE_CYCLES_STATS)
1748 builtin_print_cycles_stats(stderr);
1749 stacktrace_print_cycles_stats(stderr);
1753 #if defined(ENABLE_STATISTICS)
1754 || opt_getcompilingtime || opt_stat
1758 log_text("CACAO terminated");
1760 #if defined(ENABLE_STATISTICS)
1763 #ifdef TYPECHECK_STATISTICS
1764 typecheck_print_statistics(get_logfile());
1770 if (opt_getcompilingtime)
1772 #endif /* defined(ENABLE_STATISTICS) */
1774 /* vm_print_profile(stderr);*/
1778 /* vm_abort ********************************************************************
1780 Prints an error message and aborts the VM.
1782 *******************************************************************************/
1784 void vm_abort(const char *text, ...)
1788 /* print the log message */
1793 log_vprint(text, ap);
1798 /* now abort the VM */
1804 /* vm_get_mainclass_from_jar ***************************************************
1806 Gets the name of the main class from a JAR's manifest file.
1808 *******************************************************************************/
1810 static char *vm_get_mainclass_from_jar(char *mainstring)
1813 java_objectheader *o;
1815 java_lang_String *s;
1817 c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
1820 throw_main_exception_exit();
1822 /* create JarFile object */
1827 throw_main_exception_exit();
1830 m = class_resolveclassmethod(c,
1832 utf_java_lang_String__void,
1833 class_java_lang_Object,
1837 throw_main_exception_exit();
1839 s = javastring_new_from_ascii(mainstring);
1841 (void) vm_call_method(m, o, s);
1844 throw_main_exception_exit();
1846 /* get manifest object */
1848 m = class_resolveclassmethod(c,
1849 utf_new_char("getManifest"),
1850 utf_new_char("()Ljava/util/jar/Manifest;"),
1851 class_java_lang_Object,
1855 throw_main_exception_exit();
1857 o = vm_call_method(m, o);
1860 fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
1865 /* get Main Attributes */
1867 m = class_resolveclassmethod(o->vftbl->class,
1868 utf_new_char("getMainAttributes"),
1869 utf_new_char("()Ljava/util/jar/Attributes;"),
1870 class_java_lang_Object,
1874 throw_main_exception_exit();
1876 o = vm_call_method(m, o);
1879 fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
1884 /* get property Main-Class */
1886 m = class_resolveclassmethod(o->vftbl->class,
1887 utf_new_char("getValue"),
1888 utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
1889 class_java_lang_Object,
1893 throw_main_exception_exit();
1895 s = javastring_new_from_ascii("Main-Class");
1897 o = vm_call_method(m, o, s);
1900 throw_main_exception_exit();
1902 return javastring_tochar(o);
1906 /* vm_compile_all **************************************************************
1908 Compile all methods found in the bootclasspath.
1910 *******************************************************************************/
1912 #if !defined(NDEBUG)
1913 static void vm_compile_all(void)
1918 classcache_name_entry *nmen;
1919 classcache_class_entry *clsen;
1922 /* create all classes found in the bootclasspath */
1923 /* XXX currently only works with zip/jar's */
1925 loader_load_all_classes();
1927 /* link all classes */
1929 for (slot = 0; slot < hashtable_classcache.size; slot++) {
1930 nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
1932 for (; nmen; nmen = nmen->hashlink) {
1933 /* iterate over all class entries */
1935 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1936 c = clsen->classobj;
1941 if (!(c->state & CLASS_LINKED)) {
1942 if (!link_class(c)) {
1943 fprintf(stderr, "Error linking: ");
1944 utf_fprint_printable_ascii_classname(stderr, c->name);
1945 fprintf(stderr, "\n");
1947 /* print out exception and cause */
1949 exceptions_print_exception(*exceptionptr);
1951 /* goto next class */
1957 /* compile all class methods */
1959 for (i = 0; i < c->methodscount; i++) {
1960 m = &(c->methods[i]);
1962 if (m->jcode != NULL) {
1963 if (!jit_compile(m)) {
1964 fprintf(stderr, "Error compiling: ");
1965 utf_fprint_printable_ascii_classname(stderr, c->name);
1966 fprintf(stderr, ".");
1967 utf_fprint_printable_ascii(stderr, m->name);
1968 utf_fprint_printable_ascii(stderr, m->descriptor);
1969 fprintf(stderr, "\n");
1971 /* print out exception and cause */
1973 exceptions_print_exception(*exceptionptr);
1981 #endif /* !defined(NDEBUG) */
1984 /* vm_compile_method ***********************************************************
1986 Compile a specific method.
1988 *******************************************************************************/
1990 #if !defined(NDEBUG)
1991 static void vm_compile_method(void)
1995 /* create, load and link the main class */
1997 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
1998 throw_main_exception_exit();
2000 if (!link_class(mainclass))
2001 throw_main_exception_exit();
2003 if (opt_signature != NULL) {
2004 m = class_resolveclassmethod(mainclass,
2005 utf_new_char(opt_method),
2006 utf_new_char(opt_signature),
2011 m = class_resolveclassmethod(mainclass,
2012 utf_new_char(opt_method),
2019 char message[MAXLOGTEXT];
2020 sprintf(message, "%s%s", opt_method,
2021 opt_signature ? opt_signature : "");
2024 new_exception_message(string_java_lang_NoSuchMethodException,
2027 throw_main_exception_exit();
2032 #endif /* !defined(NDEBUG) */
2035 /* vm_vmargs_from_valist *******************************************************
2039 *******************************************************************************/
2041 static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
2042 vm_arg *vmargs, va_list ap)
2044 typedesc *paramtypes;
2047 paramtypes = m->parseddesc->paramtypes;
2049 /* if method is non-static fill first block and skip `this' pointer */
2054 /* the `this' pointer */
2055 vmargs[0].type = TYPE_ADR;
2056 vmargs[0].data.l = (u8) (ptrint) o;
2062 for (; i < m->parseddesc->paramcount; i++, paramtypes++) {
2063 switch (paramtypes->decltype) {
2064 /* primitive types */
2065 case PRIMITIVETYPE_BOOLEAN:
2066 case PRIMITIVETYPE_BYTE:
2067 case PRIMITIVETYPE_CHAR:
2068 case PRIMITIVETYPE_SHORT:
2069 case PRIMITIVETYPE_INT:
2070 vmargs[i].type = TYPE_INT;
2071 vmargs[i].data.l = (s8) va_arg(ap, s4);
2074 case PRIMITIVETYPE_LONG:
2075 vmargs[i].type = TYPE_LNG;
2076 vmargs[i].data.l = (s8) va_arg(ap, s8);
2079 case PRIMITIVETYPE_FLOAT:
2080 vmargs[i].type = TYPE_FLT;
2081 #if defined(__ALPHA__)
2082 /* this keeps the assembler function much simpler */
2084 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2086 vmargs[i].data.f = (jfloat) va_arg(ap, jdouble);
2090 case PRIMITIVETYPE_DOUBLE:
2091 vmargs[i].type = TYPE_DBL;
2092 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2096 vmargs[i].type = TYPE_ADR;
2097 vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*);
2104 /* vm_vmargs_from_jvalue *******************************************************
2108 *******************************************************************************/
2110 static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
2111 vm_arg *vmargs, jvalue *args)
2113 typedesc *paramtypes;
2117 paramtypes = m->parseddesc->paramtypes;
2119 /* if method is non-static fill first block and skip `this' pointer */
2124 /* the `this' pointer */
2125 vmargs[0].type = TYPE_ADR;
2126 vmargs[0].data.l = (u8) (ptrint) o;
2132 for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) {
2133 switch (paramtypes->decltype) {
2134 /* primitive types */
2135 case PRIMITIVETYPE_BOOLEAN:
2136 case PRIMITIVETYPE_BYTE:
2137 case PRIMITIVETYPE_CHAR:
2138 case PRIMITIVETYPE_SHORT:
2139 case PRIMITIVETYPE_INT:
2140 vmargs[i].type = TYPE_INT;
2141 vmargs[i].data.l = (s8) args[j].i;
2144 case PRIMITIVETYPE_LONG:
2145 vmargs[i].type = TYPE_LNG;
2146 vmargs[i].data.l = (s8) args[j].j;
2149 case PRIMITIVETYPE_FLOAT:
2150 vmargs[i].type = TYPE_FLT;
2151 #if defined(__ALPHA__)
2152 /* this keeps the assembler function much simpler */
2154 vmargs[i].data.d = (jdouble) args[j].f;
2156 vmargs[i].data.f = args[j].f;
2160 case PRIMITIVETYPE_DOUBLE:
2161 vmargs[i].type = TYPE_DBL;
2162 vmargs[i].data.d = args[j].d;
2166 vmargs[i].type = TYPE_ADR;
2167 vmargs[i].data.l = (u8) (ptrint) args[j].l;
2174 /* vm_call_method **************************************************************
2176 Calls a Java method with a variable number of arguments and returns
2179 *******************************************************************************/
2181 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
2184 java_objectheader *ro;
2187 ro = vm_call_method_valist(m, o, ap);
2194 /* vm_call_method_valist *******************************************************
2196 Calls a Java method with a variable number of arguments, passed via
2197 a va_list, and returns an address.
2199 *******************************************************************************/
2201 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
2206 java_objectheader *ro;
2209 /* mark start of dump memory area */
2211 dumpsize = dump_size();
2213 /* get number of Java method arguments */
2215 vmargscount = m->parseddesc->paramcount;
2217 /* allocate vm_arg array */
2219 vmargs = DMNEW(vm_arg, vmargscount);
2221 /* fill the vm_arg array from a va_list */
2223 vm_vmargs_from_valist(m, o, vmargs, ap);
2225 /* call the Java method */
2227 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2229 /* release dump area */
2231 dump_release(dumpsize);
2237 /* vm_call_method_jvalue *******************************************************
2239 Calls a Java method with a variable number of arguments, passed via
2240 a jvalue array, and returns an address.
2242 *******************************************************************************/
2244 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
2249 java_objectheader *ro;
2252 /* mark start of dump memory area */
2254 dumpsize = dump_size();
2256 /* get number of Java method arguments */
2258 vmargscount = m->parseddesc->paramcount;
2260 /* allocate vm_arg array */
2262 vmargs = DMNEW(vm_arg, vmargscount);
2264 /* fill the vm_arg array from a va_list */
2266 vm_vmargs_from_jvalue(m, o, vmargs, args);
2268 /* call the Java method */
2270 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2272 /* release dump area */
2274 dump_release(dumpsize);
2280 /* vm_call_method_vmarg ********************************************************
2282 Calls a Java method with a variable number of arguments, passed via
2283 a vm_arg array, and returns an address.
2285 *******************************************************************************/
2287 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
2290 java_objectheader *o;
2292 #if defined(ENABLE_JIT)
2293 # if defined(ENABLE_INTRP)
2295 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2298 o = asm_vm_call_method(m, vmargscount, vmargs);
2300 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2307 /* vm_call_method_int **********************************************************
2309 Calls a Java method with a variable number of arguments and returns
2312 *******************************************************************************/
2314 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
2320 i = vm_call_method_int_valist(m, o, ap);
2327 /* vm_call_method_int_valist ***************************************************
2329 Calls a Java method with a variable number of arguments, passed via
2330 a va_list, and returns an integer (s4).
2332 *******************************************************************************/
2334 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
2341 /* mark start of dump memory area */
2343 dumpsize = dump_size();
2345 /* get number of Java method arguments */
2347 vmargscount = m->parseddesc->paramcount;
2349 /* allocate vm_arg array */
2351 vmargs = DMNEW(vm_arg, vmargscount);
2353 /* fill the vm_arg array from a va_list */
2355 vm_vmargs_from_valist(m, o, vmargs, ap);
2357 /* call the Java method */
2359 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2361 /* release dump area */
2363 dump_release(dumpsize);
2369 /* vm_call_method_int_jvalue ***************************************************
2371 Calls a Java method with a variable number of arguments, passed via
2372 a jvalue array, and returns an integer (s4).
2374 *******************************************************************************/
2376 s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2383 /* mark start of dump memory area */
2385 dumpsize = dump_size();
2387 /* get number of Java method arguments */
2389 vmargscount = m->parseddesc->paramcount;
2391 /* allocate vm_arg array */
2393 vmargs = DMNEW(vm_arg, vmargscount);
2395 /* fill the vm_arg array from a va_list */
2397 vm_vmargs_from_jvalue(m, o, vmargs, args);
2399 /* call the Java method */
2401 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2403 /* release dump area */
2405 dump_release(dumpsize);
2411 /* vm_call_method_int_vmarg ****************************************************
2413 Calls a Java method with a variable number of arguments, passed via
2414 a vm_arg array, and returns an integer (s4).
2416 *******************************************************************************/
2418 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2422 #if defined(ENABLE_JIT)
2423 # if defined(ENABLE_INTRP)
2425 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2428 i = asm_vm_call_method_int(m, vmargscount, vmargs);
2430 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2437 /* vm_call_method_long *********************************************************
2439 Calls a Java method with a variable number of arguments and returns
2442 *******************************************************************************/
2444 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
2450 l = vm_call_method_long_valist(m, o, ap);
2457 /* vm_call_method_long_valist **************************************************
2459 Calls a Java method with a variable number of arguments, passed via
2460 a va_list, and returns a long (s8).
2462 *******************************************************************************/
2464 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
2471 /* mark start of dump memory area */
2473 dumpsize = dump_size();
2475 /* get number of Java method arguments */
2477 vmargscount = m->parseddesc->paramcount;
2479 /* allocate vm_arg array */
2481 vmargs = DMNEW(vm_arg, vmargscount);
2483 /* fill the vm_arg array from a va_list */
2485 vm_vmargs_from_valist(m, o, vmargs, ap);
2487 /* call the Java method */
2489 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2491 /* release dump area */
2493 dump_release(dumpsize);
2499 /* vm_call_method_long_jvalue **************************************************
2501 Calls a Java method with a variable number of arguments, passed via
2502 a jvalue array, and returns a long (s8).
2504 *******************************************************************************/
2506 s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2513 /* mark start of dump memory area */
2515 dumpsize = dump_size();
2517 /* get number of Java method arguments */
2519 vmargscount = m->parseddesc->paramcount;
2521 /* allocate vm_arg array */
2523 vmargs = DMNEW(vm_arg, vmargscount);
2525 /* fill the vm_arg array from a va_list */
2527 vm_vmargs_from_jvalue(m, o, vmargs, args);
2529 /* call the Java method */
2531 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2533 /* release dump area */
2535 dump_release(dumpsize);
2541 /* vm_call_method_long_vmarg ***************************************************
2543 Calls a Java method with a variable number of arguments, passed via
2544 a vm_arg array, and returns a long (s8).
2546 *******************************************************************************/
2548 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2552 #if defined(ENABLE_JIT)
2553 # if defined(ENABLE_INTRP)
2555 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2558 l = asm_vm_call_method_long(m, vmargscount, vmargs);
2560 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2567 /* vm_call_method_float ********************************************************
2569 Calls a Java method with a variable number of arguments and returns
2572 *******************************************************************************/
2574 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
2580 f = vm_call_method_float_valist(m, o, ap);
2587 /* vm_call_method_float_valist *************************************************
2589 Calls a Java method with a variable number of arguments, passed via
2590 a va_list, and returns a float.
2592 *******************************************************************************/
2594 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
2602 /* mark start of dump memory area */
2604 dumpsize = dump_size();
2606 /* get number of Java method arguments */
2608 vmargscount = m->parseddesc->paramcount;
2610 /* allocate vm_arg array */
2612 vmargs = DMNEW(vm_arg, vmargscount);
2614 /* fill the vm_arg array from a va_list */
2616 vm_vmargs_from_valist(m, o, vmargs, ap);
2618 /* call the Java method */
2620 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2622 /* release dump area */
2624 dump_release(dumpsize);
2630 /* vm_call_method_float_jvalue *************************************************
2632 Calls a Java method with a variable number of arguments, passed via
2633 a jvalue array, and returns a float.
2635 *******************************************************************************/
2637 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
2645 /* mark start of dump memory area */
2647 dumpsize = dump_size();
2649 /* get number of Java method arguments */
2651 vmargscount = m->parseddesc->paramcount;
2653 /* allocate vm_arg array */
2655 vmargs = DMNEW(vm_arg, vmargscount);
2657 /* fill the vm_arg array from a va_list */
2659 vm_vmargs_from_jvalue(m, o, vmargs, args);
2661 /* call the Java method */
2663 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2665 /* release dump area */
2667 dump_release(dumpsize);
2673 /* vm_call_method_float_vmarg **************************************************
2675 Calls a Java method with a variable number of arguments and returns
2678 *******************************************************************************/
2680 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2684 #if defined(ENABLE_JIT)
2685 # if defined(ENABLE_INTRP)
2687 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2690 f = asm_vm_call_method_float(m, vmargscount, vmargs);
2692 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2699 /* vm_call_method_double *******************************************************
2701 Calls a Java method with a variable number of arguments and returns
2704 *******************************************************************************/
2706 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
2712 d = vm_call_method_double_valist(m, o, ap);
2719 /* vm_call_method_double_valist ************************************************
2721 Calls a Java method with a variable number of arguments, passed via
2722 a va_list, and returns a double.
2724 *******************************************************************************/
2726 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
2734 /* mark start of dump memory area */
2736 dumpsize = dump_size();
2738 /* get number of Java method arguments */
2740 vmargscount = m->parseddesc->paramcount;
2742 /* allocate vm_arg array */
2744 vmargs = DMNEW(vm_arg, vmargscount);
2746 /* fill the vm_arg array from a va_list */
2748 vm_vmargs_from_valist(m, o, vmargs, ap);
2750 /* call the Java method */
2752 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2754 /* release dump area */
2756 dump_release(dumpsize);
2762 /* vm_call_method_double_jvalue ************************************************
2764 Calls a Java method with a variable number of arguments, passed via
2765 a jvalue array, and returns a double.
2767 *******************************************************************************/
2769 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
2777 /* mark start of dump memory area */
2779 dumpsize = dump_size();
2781 /* get number of Java method arguments */
2783 vmargscount = m->parseddesc->paramcount;
2785 /* allocate vm_arg array */
2787 vmargs = DMNEW(vm_arg, vmargscount);
2789 /* fill the vm_arg array from a va_list */
2791 vm_vmargs_from_jvalue(m, o, vmargs, args);
2793 /* call the Java method */
2795 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2797 /* release dump area */
2799 dump_release(dumpsize);
2805 /* vm_call_method_double_vmarg *************************************************
2807 Calls a Java method with a variable number of arguments and returns
2810 *******************************************************************************/
2812 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
2817 #if defined(ENABLE_JIT)
2818 # if defined(ENABLE_INTRP)
2820 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2823 d = asm_vm_call_method_double(m, vmargscount, vmargs);
2825 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2833 * These are local overrides for various environment variables in Emacs.
2834 * Please do not remove this and leave it at the end of the file, where
2835 * Emacs will automagically detect them.
2836 * ---------------------------------------------------------------------
2839 * indent-tabs-mode: t