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 *mainstring = NULL;
100 classinfo *mainclass = NULL;
102 char *specificmethodname = NULL;
103 char *specificsignature = NULL;
107 #if defined(ENABLE_INTRP)
108 u1 *intrp_main_stack = NULL;
112 /* define heap sizes **********************************************************/
114 #define HEAP_MAXSIZE 128 * 1024 * 1024 /* default 128MB */
115 #define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
116 #define STACK_SIZE 64 * 1024 /* default 64kB */
119 /* define command line options ************************************************/
146 /* Java non-standard options */
169 #if defined(ENABLE_STATISTICS)
186 #if defined(ENABLE_VERIFIER)
188 #if defined(TYPECHECK_VERBOSE)
191 #endif /* defined(ENABLE_VERIFIER) */
194 /* optimization options */
196 #if defined(ENABLE_LOOP)
200 #if defined(ENABLE_IFCONV)
204 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
208 #if defined(ENABLE_INLINING)
212 #if defined(ENABLE_INTRP)
213 /* interpreter options */
236 opt_struct opts[] = {
237 { "foo", false, OPT_FOO },
241 { "jar", false, OPT_JAR },
243 { "d32", false, OPT_D32 },
244 { "d64", false, OPT_D64 },
245 { "client", false, OPT_IGNORE },
246 { "server", false, OPT_IGNORE },
247 { "jvm", false, OPT_IGNORE },
248 { "hotspot", false, OPT_IGNORE },
250 { "classpath", true, OPT_CLASSPATH },
251 { "cp", true, OPT_CLASSPATH },
252 { "D", true, OPT_D },
253 { "version", false, OPT_VERSION },
254 { "showversion", false, OPT_SHOWVERSION },
255 { "fullversion", false, OPT_FULLVERSION },
256 { "help", false, OPT_HELP },
257 { "?", false, OPT_HELP },
258 { "X", false, OPT_X },
260 { "esa", false, OPT_ESA },
261 { "enablesystemassertions", false, OPT_ESA },
262 { "dsa", false, OPT_DSA },
263 { "disablesystemassertions", false, OPT_DSA },
265 { "noasyncgc", false, OPT_IGNORE },
266 #if defined(ENABLE_VERIFIER)
267 { "noverify", false, OPT_NOVERIFY },
269 { "v", false, OPT_VERBOSE1 },
270 { "verbose:", true, OPT_VERBOSE },
272 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
273 { "verbosetc", false, OPT_VERBOSETC },
275 #if defined(__ALPHA__)
276 { "noieee", false, OPT_NOIEEE },
278 { "softnull", false, OPT_SOFTNULL },
279 #if defined(ENABLE_STATISTICS)
280 { "time", false, OPT_TIME },
281 { "stat", false, OPT_STAT },
283 { "log", true, OPT_LOG },
284 { "c", true, OPT_CHECK },
285 { "l", false, OPT_LOAD },
286 { "eager", false, OPT_EAGER },
289 { "all", false, OPT_ALL },
290 { "sig", true, OPT_SIGNATURE },
293 #if defined(ENABLE_LOOP)
294 { "oloop", false, OPT_OLOOP },
296 #if defined(ENABLE_IFCONV)
297 { "ifconv", false, OPT_IFCONV },
299 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
300 { "lsra", false, OPT_LSRA },
303 #if defined(ENABLE_INTRP)
304 /* interpreter options */
306 { "trace", false, OPT_TRACE },
307 { "static-supers", true, OPT_STATIC_SUPERS },
308 { "no-dynamic", false, OPT_NO_DYNAMIC },
309 { "no-replication", false, OPT_NO_REPLICATION },
310 { "no-quicksuper", false, OPT_NO_QUICKSUPER },
313 /* JVMTI Agent Command Line Options */
315 { "agentlib:", true, OPT_AGENTLIB },
316 { "agentpath:", true, OPT_AGENTPATH },
319 /* Java non-standard options */
321 { "Xjit", false, OPT_JIT },
322 { "Xint", false, OPT_INTRP },
323 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
324 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
325 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
326 { "Xglibj:", true, OPT_GLIBJ },
329 { "Xdebug", false, OPT_DEBUG },
330 { "Xnoagent", false, OPT_NOAGENT },
331 { "Xrunjdwp", true, OPT_XRUNJDWP },
334 { "Xms", true, OPT_MS },
335 { "ms", true, OPT_MS },
336 { "Xmx", true, OPT_MX },
337 { "mx", true, OPT_MX },
338 { "Xss", true, OPT_SS },
339 { "ss", true, OPT_SS },
340 { "Xprof:", true, OPT_PROF_OPTION },
341 { "Xprof", false, OPT_PROF },
343 /* keep these at the end of the list */
345 #if defined(ENABLE_INLINING)
346 { "i", true, OPT_INLINING },
350 { "m", true, OPT_METHOD },
353 { "s", true, OPT_SHOW },
354 { "debug-color", false, OPT_DEBUGCOLOR },
360 /* usage ***********************************************************************
362 Prints the correct usage syntax to stdout.
364 *******************************************************************************/
368 puts("Usage: cacao [-options] classname [arguments]");
369 puts(" (to run a class file)");
370 puts(" or cacao [-options] -jar jarfile [arguments]");
371 puts(" (to run a standalone jar file)\n");
373 puts("Java options:");
374 puts(" -d32 use 32-bit data model if available");
375 puts(" -d64 use 64-bit data model if available");
376 puts(" -client compatibility (currently ignored)");
377 puts(" -server compatibility (currently ignored)");
378 puts(" -jvm compatibility (currently ignored)");
379 puts(" -hotspot compatibility (currently ignored)\n");
381 puts(" -cp <path> specify a path to look for classes");
382 puts(" -classpath <path> specify a path to look for classes");
383 puts(" -D<name>=<value> add an entry to the property list");
384 puts(" -verbose[:class|gc|jni] enable specific verbose output");
385 puts(" -version print product version and exit");
386 puts(" -fullversion print jpackage-compatible product version and exit");
387 puts(" -showversion print product version and continue");
388 puts(" -help, -? print this help message");
389 puts(" -X print help on non-standard Java options");
390 puts(" -esa | -enablesystemassertions");
391 puts(" enable system assertions");
392 puts(" -dsa | -disablesystemassertions");
393 puts(" disable system assertions");
397 puts(" -agentlib:<agent-lib-name>=<options> library to load containg JVMTI agent");
398 puts (" for jdwp help use: -agentlib:jdwp=help");
399 puts(" -agentpath:<path-to-agent>=<options> path to library containg JVMTI agent");
402 puts("CACAO options:");
403 puts(" -v write state-information");
404 puts(" -verbose[:call|exception|jit]");
405 puts(" enable specific verbose output");
406 puts(" -debug-color colored output for ANSI terms");
407 #ifdef TYPECHECK_VERBOSE
408 puts(" -verbosetc write debug messages while typechecking");
410 #if defined(__ALPHA__)
411 puts(" -noieee don't use ieee compliant arithmetic");
413 #if defined(ENABLE_VERIFIER)
414 puts(" -noverify don't verify classfiles");
416 puts(" -softnull use software nullpointer check");
417 #if defined(ENABLE_STATISTICS)
418 puts(" -time measure the runtime");
419 puts(" -stat detailed compiler statistics");
421 puts(" -log logfile specify a name for the logfile");
422 puts(" -c(heck)b(ounds) don't check array bounds");
423 puts(" s(ync) don't check for synchronization");
424 #if defined(ENABLE_LOOP)
425 puts(" -oloop optimize array accesses in loops");
427 puts(" -l don't start the class after loading");
428 puts(" -eager perform eager class loading and linking");
430 puts(" -all compile all methods, no execution");
431 puts(" -m compile only a specific method");
432 puts(" -sig specify signature for a specific method");
435 puts(" -s(how)... show...");
436 puts(" c(onstants) the constant pool");
437 puts(" m(ethods) class fields and methods");
438 puts(" u(tf) the utf - hash");
439 puts(" i(ntermediate) intermediate representation");
440 #if defined(ENABLE_DISASSEMBLER)
441 puts(" a(ssembler) disassembled listing");
442 puts(" e(xceptionstubs) disassembled exception stubs (only with -sa)");
443 puts(" n(ative) disassembled native stubs");
445 puts(" d(atasegment) data segment listing");
446 #if defined(ENABLE_INLINING)
447 puts(" -i n(line) activate inlining");
448 puts(" v(irtual) inline virtual methods (uses/turns rt option on)");
449 puts(" e(exception) inline methods with exceptions");
450 puts(" p(aramopt) optimize argument renaming");
451 puts(" o(utsiders) inline methods of foreign classes");
452 #endif /* defined(ENABLE_INLINING) */
453 #if defined(ENABLE_IFCONV)
454 puts(" -ifconv use if-conversion");
456 #if defined(ENABLE_LSRA)
457 puts(" -lsra use linear scan register allocation");
459 #if defined(ENABLE_SSA)
460 puts(" -lsra use linear scan register allocation (with SSA)");
463 /* exit with error code */
469 static void Xusage(void)
471 #if defined(ENABLE_JIT)
472 puts(" -Xjit JIT mode execution (default)");
474 #if defined(ENABLE_INTRP)
475 puts(" -Xint interpreter mode execution");
477 puts(" -Xbootclasspath:<zip/jar files and directories separated by :>");
478 puts(" value is set as bootstrap class path");
479 puts(" -Xbootclasspath/a:<zip/jar files and directories separated by :>");
480 puts(" value is appended to the bootstrap class path");
481 puts(" -Xbootclasspath/p:<zip/jar files and directories separated by :>");
482 puts(" value is prepended to the bootstrap class path");
483 puts(" -Xglibj:<zip/jar files and directories separated by :>");
484 puts(" value is used as Java core library, but the");
485 puts(" hardcoded VM interface classes are prepended");
486 printf(" -Xms<size> set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024);
487 printf(" -Xmx<size> set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024);
488 printf(" -Xss<size> set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024);
489 puts(" -Xprof[:bb] collect and print profiling data");
490 #if defined(ENABLE_JVMTI)
491 /* -Xdebug option depend on gnu classpath JDWP options. options:
492 transport=dt_socket,address=<hostname:port>,server=(y|n),suspend(y|n) */
493 puts(" -Xdebug enable remote debugging\n");
494 puts(" -Xrunjdwp transport=[dt_socket|...],address=<hostname:port>,server=[y|n],suspend=[y|n]\n");
495 puts(" enable remote debugging\n");
498 /* exit with error code */
504 /* version *********************************************************************
506 Only prints cacao version information.
508 *******************************************************************************/
510 static void version(bool opt_exit)
512 puts("java version \""JAVA_VERSION"\"");
513 puts("CACAO version "VERSION"");
515 puts("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,");
516 puts("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,");
517 puts("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,");
518 puts("J. Wenninger, Institut f. Computersprachen - TU Wien\n");
520 puts("This program is free software; you can redistribute it and/or");
521 puts("modify it under the terms of the GNU General Public License as");
522 puts("published by the Free Software Foundation; either version 2, or (at");
523 puts("your option) any later version.\n");
525 puts("This program is distributed in the hope that it will be useful, but");
526 puts("WITHOUT ANY WARRANTY; without even the implied warranty of");
527 puts("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU");
528 puts("General Public License for more details.\n");
530 puts("Configure/Build options:\n");
531 puts(" ./configure: "VERSION_CONFIGURE_ARGS"");
532 #if defined(__VERSION__)
533 puts(" CC : "VERSION_CC" ("__VERSION__")");
535 puts(" CC : "VERSION_CC"");
537 puts(" CFLAGS : "VERSION_CFLAGS"\n");
539 puts("Default variables:\n");
540 printf(" maximum heap size : %d\n", HEAP_MAXSIZE);
541 printf(" initial heap size : %d\n", HEAP_STARTSIZE);
542 printf(" stack size : %d\n", STACK_SIZE);
543 puts(" java.boot.class.path : "CACAO_VM_ZIP":"CLASSPATH_GLIBJ_ZIP"");
544 puts(" gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR"/classpath\n");
546 puts("Runtime variables:\n");
547 printf(" maximum heap size : %d\n", opt_heapmaxsize);
548 printf(" initial heap size : %d\n", opt_heapstartsize);
549 printf(" stack size : %d\n", opt_stacksize);
550 printf(" java.boot.class.path : %s\n", bootclasspath);
551 printf(" gnu.classpath.boot.library.path: %s\n", classpath_libdir);
553 /* exit normally, if requested */
560 /* fullversion *****************************************************************
562 Prints a Sun compatible version information (required e.g. by
563 jpackage, www.jpackage.org).
565 *******************************************************************************/
567 static void fullversion(void)
569 puts("java full version \"cacao-"JAVA_VERSION"\"");
577 /* forward declarations *******************************************************/
579 static char *vm_get_mainclass_from_jar(char *mainstring);
581 static void vm_compile_all(void);
582 static void vm_compile_method(void);
586 /* vm_create *******************************************************************
588 Creates a JVM. Called by JNI_CreateJavaVM.
590 *******************************************************************************/
592 bool vm_create(JavaVMInitArgs *vm_args)
601 #if defined(ENABLE_JVMTI)
603 char *libname, *agentarg;
604 bool jdwp,agentbypath;
605 jdwp = agentbypath = false;
608 /* check the JNI version requested */
610 switch (vm_args->version) {
611 case JNI_VERSION_1_1:
613 case JNI_VERSION_1_2:
614 case JNI_VERSION_1_4:
620 /* we only support 1 JVM instance */
625 if (atexit(vm_exit_handler))
626 vm_abort("atexit failed: %s\n", strerror(errno));
629 log_text("CACAO started -------------------------------------------------------");
631 /* set the VM starttime */
633 _Jv_jvm->starttime = builtin_currenttimemillis();
635 /* get stuff from the environment *****************************************/
637 #if defined(DISABLE_GC)
638 nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
641 #if defined(WITH_JRE_LAYOUT)
642 /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
644 cacao_prefix = MNEW(char, 4096);
646 if (readlink("/proc/self/exe", cacao_prefix, 4095) == -1)
647 vm_abort("readlink failed: %s\n", strerror(errno));
649 /* get the path of the current executable */
651 cacao_prefix = dirname(cacao_prefix);
653 if ((strlen(cacao_prefix) + strlen("/..") + strlen("0")) > 4096)
654 vm_abort("libjvm name to long for buffer\n");
656 /* concatenate the library name */
658 strcat(cacao_prefix, "/..");
660 /* now set path to libjvm.so */
662 len = strlen(cacao_prefix) + strlen("/lib/libjvm") + strlen("0");
664 cacao_libjvm = MNEW(char, len);
665 strcpy(cacao_libjvm, cacao_prefix);
666 strcat(cacao_libjvm, "/lib/libjvm");
668 /* and finally set the path to GNU Classpath libraries */
670 len = strlen(cacao_prefix) + strlen("/lib/classpath") + strlen("0");
672 classpath_libdir = MNEW(char, len);
673 strcpy(classpath_libdir, cacao_prefix);
674 strcat(classpath_libdir, "/lib/classpath");
676 cacao_prefix = CACAO_PREFIX;
677 cacao_libjvm = CACAO_LIBDIR"/libjvm";
678 classpath_libdir = CLASSPATH_LIBDIR"/classpath";
681 /* set the bootclasspath */
683 cp = getenv("BOOTCLASSPATH");
686 bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
687 strcpy(bootclasspath, cp);
690 #if defined(WITH_JRE_LAYOUT)
692 strlen(cacao_prefix) +
693 strlen("/share/cacao/vm.zip") +
695 strlen(cacao_prefix) +
696 strlen("/share/classpath/glibj.zip") +
699 bootclasspath = MNEW(char, len);
700 strcat(bootclasspath, cacao_prefix);
701 strcat(bootclasspath, "/share/cacao/vm.zip");
702 strcat(bootclasspath, ":");
703 strcat(bootclasspath, cacao_prefix);
704 strcat(bootclasspath, "/share/classpath/glibj.zip");
706 len = strlen(CACAO_VM_ZIP) +
708 strlen(CLASSPATH_GLIBJ_ZIP) +
711 bootclasspath = MNEW(char, len);
712 strcat(bootclasspath, CACAO_VM_ZIP);
713 strcat(bootclasspath, ":");
714 strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP);
718 /* set the classpath */
720 cp = getenv("CLASSPATH");
723 classpath = MNEW(char, strlen(cp) + strlen("0"));
724 strcat(classpath, cp);
727 classpath = MNEW(char, strlen(".") + strlen("0"));
728 strcpy(classpath, ".");
732 /* interpret the options **************************************************/
740 opt_heapmaxsize = HEAP_MAXSIZE;
741 opt_heapstartsize = HEAP_STARTSIZE;
742 opt_stacksize = STACK_SIZE;
745 #if defined(ENABLE_JVMTI)
746 /* initialize JVMTI related **********************************************/
750 /* initialize properties before commandline handling */
752 if (!properties_init())
753 throw_cacao_exception_exit(string_java_lang_InternalError,
754 "Unable to init properties");
756 /* add some default properties */
758 properties_add("java.endorsed.dirs", ""CACAO_PREFIX"/jre/lib/endorsed");
760 /* iterate over all passed options */
762 while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
776 #if SIZEOF_VOID_P == 8
777 puts("Running a 32-bit JVM is not supported on this platform.");
783 #if SIZEOF_VOID_P == 4
784 puts("Running a 64-bit JVM is not supported on this platform.");
790 /* forget old classpath and set the argument as new classpath */
791 MFREE(classpath, char, strlen(classpath));
793 classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
794 strcpy(classpath, opt_arg);
798 for (j = 0; j < strlen(opt_arg); j++) {
799 if (opt_arg[j] == '=') {
801 properties_add(opt_arg, opt_arg + j + 1);
806 /* if no '=' is given, just create an empty property */
808 properties_add(opt_arg, "");
813 case OPT_BOOTCLASSPATH:
814 /* Forget default bootclasspath and set the argument as
815 new boot classpath. */
817 MFREE(bootclasspath, char, strlen(bootclasspath));
819 bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
820 strcpy(bootclasspath, opt_arg);
823 case OPT_BOOTCLASSPATH_A:
824 /* append to end of bootclasspath */
826 len = strlen(bootclasspath);
828 bootclasspath = MREALLOC(bootclasspath,
832 strlen(opt_arg) + strlen("0"));
834 strcat(bootclasspath, ":");
835 strcat(bootclasspath, opt_arg);
838 case OPT_BOOTCLASSPATH_P:
839 /* prepend in front of bootclasspath */
844 bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
847 strcpy(bootclasspath, opt_arg);
848 strcat(bootclasspath, ":");
849 strcat(bootclasspath, cp);
851 MFREE(cp, char, len);
855 /* use as Java core library, but prepend VM interface classes */
857 MFREE(bootclasspath, char, strlen(bootclasspath));
859 len = strlen(CACAO_VM_ZIP) +
864 bootclasspath = MNEW(char, len);
866 strcpy(bootclasspath, CACAO_VM_ZIP);
867 strcat(bootclasspath, ":");
868 strcat(bootclasspath, opt_arg);
871 #if defined(ENABLE_JVMTI)
873 /* this option exists only for compatibility reasons */
877 /* I don't know yet what Xnoagent should do. This is only for
878 compatiblity with eclipse - motse */
887 strlen(CACAO_LIBDIR) +
888 strlen("/libjdwp.so=") +
892 agentarg = MNEW(char, len);
894 strcpy(agentarg, CACAO_LIBDIR);
895 strcat(agentarg, "/libjdwp.so=");
896 strcat(agentarg, &opt_arg[1]);
913 c = opt_arg[strlen(opt_arg) - 1];
915 if ((c == 'k') || (c == 'K')) {
916 j = atoi(opt_arg) * 1024;
918 } else if ((c == 'm') || (c == 'M')) {
919 j = atoi(opt_arg) * 1024 * 1024;
926 else if (opt == OPT_MS)
927 opt_heapstartsize = j;
938 if (strcmp("class", opt_arg) == 0)
939 opt_verboseclass = true;
941 else if (strcmp("gc", opt_arg) == 0)
942 opt_verbosegc = true;
944 else if (strcmp("jni", opt_arg) == 0)
945 opt_verbosejni = true;
947 else if (strcmp("call", opt_arg) == 0)
948 opt_verbosecall = true;
950 else if (strcmp("jit", opt_arg) == 0) {
955 compileverbose = true;
957 else if (strcmp("exception", opt_arg) == 0)
958 opt_verboseexception = true;
961 opt_debugcolor = true;
964 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
966 opt_typecheckverbose = true;
975 case OPT_FULLVERSION:
979 case OPT_SHOWVERSION:
987 #if defined(ENABLE_VERIFIER)
997 #if defined(ENABLE_STATISTICS)
999 opt_getcompilingtime = true;
1000 opt_getloadingtime = true;
1013 for (j = 0; j < strlen(opt_arg); j++) {
1014 switch (opt_arg[j]) {
1016 checkbounds = false;
1029 makeinitializations = false;
1036 #if !defined(NDEBUG)
1040 makeinitializations = false;
1045 opt_method = opt_arg;
1046 makeinitializations = false;
1050 opt_signature = opt_arg;
1054 case OPT_SHOW: /* Display options */
1055 for (j = 0; j < strlen(opt_arg); j++) {
1056 switch (opt_arg[j]) {
1058 showconstantpool = true;
1070 opt_showintermediate = true;
1071 compileverbose = true;
1074 #if defined(ENABLE_DISASSEMBLER)
1076 opt_showdisassemble = true;
1077 compileverbose = true;
1081 opt_showexceptionstubs = true;
1085 opt_shownativestub = true;
1090 opt_showddatasegment = true;
1099 #if defined(ENABLE_LOOP)
1105 #if defined(ENABLE_INLINING)
1107 for (j = 0; j < strlen(opt_arg); j++) {
1108 switch (opt_arg[j]) {
1110 /* define in options.h; Used in main.c, jit.c
1111 & inline.c inlining is currently
1115 inlinevirtuals = true;
1118 inlineexceptions = true;
1121 inlineparamopt = true;
1124 inlineoutsiders = true;
1131 #endif /* defined(ENABLE_INLINING) */
1133 #if defined(ENABLE_IFCONV)
1139 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1154 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = true;
1158 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = false;
1161 case OPT_PROF_OPTION:
1162 /* use <= to get the last \0 too */
1164 for (j = 0, k = 0; j <= strlen(opt_arg); j++) {
1165 if (opt_arg[j] == ',')
1168 if (opt_arg[j] == '\0') {
1169 if (strcmp("bb", opt_arg + k) == 0)
1173 printf("Unknown option: -Xprof:%s\n", opt_arg + k);
1177 /* set k to next char */
1189 #if defined(ENABLE_JIT)
1192 printf("-Xjit option not enabled.\n");
1198 #if defined(ENABLE_INTRP)
1201 printf("-Xint option not enabled.\n");
1206 #if defined(ENABLE_INTRP)
1207 case OPT_STATIC_SUPERS:
1208 opt_static_supers = atoi(opt_arg);
1211 case OPT_NO_DYNAMIC:
1212 opt_no_dynamic = true;
1215 case OPT_NO_REPLICATION:
1216 opt_no_replication = true;
1219 case OPT_NO_QUICKSUPER:
1220 opt_no_quicksuper = true;
1229 printf("Unknown option: %s\n",
1230 vm_args->options[opt_index].optionString);
1236 /* Now we have all options handled and we can print the version
1243 /* get the main class *****************************************************/
1245 if (opt_index < vm_args->nOptions) {
1246 mainstring = vm_args->options[opt_index++].optionString;
1248 /* Put the jar file into the classpath (if any). */
1250 if (opt_jar == true) {
1251 /* free old classpath */
1253 MFREE(classpath, char, strlen(classpath));
1255 /* put jarfile into classpath */
1257 classpath = MNEW(char, strlen(mainstring) + strlen("0"));
1259 strcpy(classpath, mainstring);
1262 /* replace .'s with /'s in classname */
1264 for (i = strlen(mainstring) - 1; i >= 0; i--)
1265 if (mainstring[i] == '.')
1266 mainstring[i] = '/';
1270 #if defined(ENABLE_JVMTI)
1272 jvmti_set_phase(JVMTI_PHASE_ONLOAD);
1273 jvmti_agentload(agentarg, agentbypath, &handle, &libname);
1276 MFREE(agentarg, char, strlen(agentarg));
1278 jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
1284 /* initialize this JVM ****************************************************/
1286 vm_initializing = true;
1288 /* initialize the garbage collector */
1290 gc_init(opt_heapmaxsize, opt_heapstartsize);
1292 #if defined(ENABLE_INTRP)
1293 /* Allocate main thread stack on the Java heap. */
1296 intrp_main_stack = GCMNEW(u1, opt_stacksize);
1297 MSET(intrp_main_stack, 0, u1, opt_stacksize);
1301 #if defined(ENABLE_THREADS)
1305 /* initialize the string hashtable stuff: lock (must be done
1306 _after_ threads_preinit) */
1309 throw_main_exception_exit();
1311 /* initialize the utf8 hashtable stuff: lock, often used utf8
1312 strings (must be done _after_ threads_preinit) */
1315 throw_main_exception_exit();
1317 /* initialize the classcache hashtable stuff: lock, hashtable
1318 (must be done _after_ threads_preinit) */
1320 if (!classcache_init())
1321 throw_main_exception_exit();
1323 /* initialize the loader with bootclasspath (must be done _after_
1327 throw_main_exception_exit();
1329 suck_add_from_property("java.endorsed.dirs");
1330 suck_add(bootclasspath);
1332 /* initialize the memory subsystem (must be done _after_
1336 throw_main_exception_exit();
1338 /* initialize the finalizer stuff (must be done _after_
1341 if (!finalizer_init())
1342 throw_main_exception_exit();
1344 /* install architecture dependent signal handler used for exceptions */
1348 /* initialize the codegen subsystems */
1352 /* initializes jit compiler */
1356 /* machine dependent initialization */
1358 #if defined(ENABLE_JIT)
1359 # if defined(ENABLE_INTRP)
1369 /* initialize the loader subsystems (must be done _after_
1373 throw_main_exception_exit();
1376 throw_main_exception_exit();
1379 throw_main_exception_exit();
1381 if (!exceptions_init())
1382 throw_main_exception_exit();
1384 if (!builtin_init())
1385 throw_main_exception_exit();
1387 /* Initialize the JNI subsystem (must be done _before_
1388 threads_init, as threads_init can call JNI methods
1389 (e.g. NewGlobalRef). */
1392 throw_main_exception_exit();
1394 #if defined(ENABLE_THREADS)
1395 if (!threads_init())
1396 throw_main_exception_exit();
1399 /* That's important, otherwise we get into trouble, if the Runtime
1400 static initializer is called before (circular dependency. This
1401 is with classpath 0.09. Another important thing is, that this
1402 has to happen after initThreads!!! */
1404 if (!initialize_class(class_java_lang_System))
1405 throw_main_exception_exit();
1407 #if defined(ENABLE_PROFILING)
1408 /* initialize profiling */
1410 if (!profile_init())
1411 throw_main_exception_exit();
1414 #if defined(ENABLE_THREADS)
1415 /* initialize recompilation */
1417 if (!recompile_init())
1418 throw_main_exception_exit();
1420 /* finally, start the finalizer thread */
1422 if (!finalizer_start_thread())
1423 throw_main_exception_exit();
1425 /* start the recompilation thread (must be done before the
1426 profiling thread) */
1428 if (!recompile_start_thread())
1429 throw_main_exception_exit();
1431 # if defined(ENABLE_PROFILING)
1432 /* start the profile sampling thread */
1435 if (!profile_start_thread())
1436 throw_main_exception_exit();
1440 #if defined(ENABLE_JVMTI)
1442 /* add agent library to native library hashtable */
1443 native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
1447 /* increment the number of VMs */
1451 /* initialization is done */
1453 vm_initializing = false;
1455 /* everything's ok */
1461 /* vm_run **********************************************************************
1463 Runs the main-method of the passed class.
1465 *******************************************************************************/
1467 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
1470 classinfo *mainclass;
1472 java_objectarray *oa;
1475 java_lang_String *s;
1479 #if !defined(NDEBUG)
1485 if (opt_method != NULL) {
1486 vm_compile_method();
1489 #endif /* !defined(NDEBUG) */
1491 /* should we run the main-method? */
1493 if (mainstring == NULL)
1496 /* set return value to OK */
1500 if (opt_jar == true)
1501 /* open jar file with java.util.jar.JarFile */
1502 mainstring = vm_get_mainclass_from_jar(mainstring);
1504 /* load the main class */
1506 mainutf = utf_new_char(mainstring);
1508 if (!(mainclass = load_class_from_sysloader(mainutf)))
1509 throw_main_exception_exit();
1511 /* error loading class, clear exceptionptr for new exception */
1513 if (*exceptionptr || !mainclass) {
1514 /* *exceptionptr = NULL; */
1516 /* *exceptionptr = */
1517 /* new_exception_message(string_java_lang_NoClassDefFoundError, */
1519 throw_main_exception_exit();
1522 if (!link_class(mainclass))
1523 throw_main_exception_exit();
1525 /* find the `main' method of the main class */
1527 m = class_resolveclassmethod(mainclass,
1528 utf_new_char("main"),
1529 utf_new_char("([Ljava/lang/String;)V"),
1530 class_java_lang_Object,
1533 if (*exceptionptr) {
1534 throw_main_exception_exit();
1537 /* there is no main method or it isn't static */
1539 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
1540 *exceptionptr = NULL;
1543 new_exception_message(string_java_lang_NoSuchMethodError, "main");
1544 throw_main_exception_exit();
1547 /* build argument array */
1549 oalength = vm_args->nOptions - opt_index;
1551 oa = builtin_anewarray(oalength, class_java_lang_String);
1553 for (i = 0; i < oalength; i++) {
1554 u = utf_new_char(vm_args->options[opt_index + i].optionString);
1555 s = javastring_new(u);
1557 oa->data[i] = (java_objectheader *) s;
1560 #ifdef TYPEINFO_DEBUG_TEST
1561 /* test the typeinfo system */
1564 /*class_showmethods(currentThread->group->header.vftbl->class); */
1566 #if defined(ENABLE_JVMTI)
1567 jvmti_set_phase(JVMTI_PHASE_LIVE);
1570 /* increase total started thread count */
1572 _Jv_jvm->total_started_thread_count++;
1574 /* start the main thread */
1576 (void) vm_call_method(m, NULL, oa);
1578 /* exception occurred? */
1580 if (*exceptionptr) {
1581 throw_main_exception();
1585 /* unload the JavaVM */
1595 /* vm_destroy ******************************************************************
1597 Unloads a Java VM and reclaims its resources.
1599 *******************************************************************************/
1601 s4 vm_destroy(JavaVM *vm)
1603 #if defined(ENABLE_THREADS)
1604 threads_join_all_threads();
1607 /* everything's ok */
1613 /* vm_exit *********************************************************************
1615 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1617 *******************************************************************************/
1619 void vm_exit(s4 status)
1623 /* signal that we are exiting */
1627 assert(class_java_lang_System);
1628 assert(class_java_lang_System->state & CLASS_LOADED);
1630 #if defined(ENABLE_JVMTI)
1631 if (jvmti || (dbgcom!=NULL)) {
1632 jvmti_set_phase(JVMTI_PHASE_DEAD);
1633 if (jvmti) jvmti_agentunload();
1637 if (!link_class(class_java_lang_System))
1638 throw_main_exception_exit();
1640 /* call java.lang.System.exit(I)V */
1642 m = class_resolveclassmethod(class_java_lang_System,
1643 utf_new_char("exit"),
1645 class_java_lang_Object,
1649 throw_main_exception_exit();
1651 /* call the exit function with passed exit status */
1653 (void) vm_call_method(m, NULL, status);
1655 /* If we had an exception, just ignore the exception and exit with
1658 vm_shutdown(status);
1662 /* vm_shutdown *****************************************************************
1664 Terminates the system immediately without freeing memory explicitly
1665 (to be used only for abnormal termination).
1667 *******************************************************************************/
1669 void vm_shutdown(s4 status)
1672 #if defined(ENABLE_STATISTICS)
1673 || opt_getcompilingtime || opt_stat
1677 log_text("CACAO terminated by shutdown");
1678 dolog("Exit status: %d\n", (s4) status);
1682 #if defined(ENABLE_JVMTI)
1683 /* terminate cacaodbgserver */
1685 pthread_mutex_lock(&dbgcomlock);
1687 pthread_mutex_unlock(&dbgcomlock);
1688 jvmti_cacaodbgserver_quit();
1696 /* vm_exit_handler *************************************************************
1698 The exit_handler function is called upon program termination.
1700 ATTENTION: Don't free system resources here! Some threads may still
1701 be running as this is called from VMRuntime.exit(). The OS does the
1704 *******************************************************************************/
1706 void vm_exit_handler(void)
1708 #if !defined(NDEBUG)
1710 class_showmethods(mainclass);
1712 if (showconstantpool)
1713 class_showconstantpool(mainclass);
1718 # if defined(ENABLE_PROFILING)
1720 profile_printstats();
1722 #endif /* !defined(NDEBUG) */
1724 #if defined(ENABLE_RT_TIMING)
1725 rt_timing_print_time_stats(stderr);
1728 #if defined(ENABLE_CYCLES_STATS)
1729 builtin_print_cycles_stats(stderr);
1730 stacktrace_print_cycles_stats(stderr);
1734 #if defined(ENABLE_STATISTICS)
1735 || opt_getcompilingtime || opt_stat
1739 log_text("CACAO terminated");
1741 #if defined(ENABLE_STATISTICS)
1744 #ifdef TYPECHECK_STATISTICS
1745 typecheck_print_statistics(get_logfile());
1751 if (opt_getcompilingtime)
1753 #endif /* defined(ENABLE_STATISTICS) */
1755 /* vm_print_profile(stderr);*/
1759 /* vm_abort ********************************************************************
1761 Prints an error message and aborts the VM.
1763 *******************************************************************************/
1765 void vm_abort(const char *text, ...)
1769 /* print the log message */
1774 log_vprint(text, ap);
1779 /* now abort the VM */
1785 /* vm_get_mainclass_from_jar ***************************************************
1787 Gets the name of the main class from a JAR's manifest file.
1789 *******************************************************************************/
1791 static char *vm_get_mainclass_from_jar(char *mainstring)
1794 java_objectheader *o;
1796 java_lang_String *s;
1798 c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
1801 throw_main_exception_exit();
1803 /* create JarFile object */
1808 throw_main_exception_exit();
1811 m = class_resolveclassmethod(c,
1813 utf_java_lang_String__void,
1814 class_java_lang_Object,
1818 throw_main_exception_exit();
1820 s = javastring_new_from_ascii(mainstring);
1822 (void) vm_call_method(m, o, s);
1825 throw_main_exception_exit();
1827 /* get manifest object */
1829 m = class_resolveclassmethod(c,
1830 utf_new_char("getManifest"),
1831 utf_new_char("()Ljava/util/jar/Manifest;"),
1832 class_java_lang_Object,
1836 throw_main_exception_exit();
1838 o = vm_call_method(m, o);
1841 fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
1846 /* get Main Attributes */
1848 m = class_resolveclassmethod(o->vftbl->class,
1849 utf_new_char("getMainAttributes"),
1850 utf_new_char("()Ljava/util/jar/Attributes;"),
1851 class_java_lang_Object,
1855 throw_main_exception_exit();
1857 o = vm_call_method(m, o);
1860 fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
1865 /* get property Main-Class */
1867 m = class_resolveclassmethod(o->vftbl->class,
1868 utf_new_char("getValue"),
1869 utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
1870 class_java_lang_Object,
1874 throw_main_exception_exit();
1876 s = javastring_new_from_ascii("Main-Class");
1878 o = vm_call_method(m, o, s);
1881 throw_main_exception_exit();
1883 return javastring_tochar(o);
1887 /* vm_compile_all **************************************************************
1889 Compile all methods found in the bootclasspath.
1891 *******************************************************************************/
1893 #if !defined(NDEBUG)
1894 static void vm_compile_all(void)
1899 classcache_name_entry *nmen;
1900 classcache_class_entry *clsen;
1903 /* create all classes found in the bootclasspath */
1904 /* XXX currently only works with zip/jar's */
1906 loader_load_all_classes();
1908 /* link all classes */
1910 for (slot = 0; slot < hashtable_classcache.size; slot++) {
1911 nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
1913 for (; nmen; nmen = nmen->hashlink) {
1914 /* iterate over all class entries */
1916 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1917 c = clsen->classobj;
1922 if (!(c->state & CLASS_LINKED)) {
1923 if (!link_class(c)) {
1924 fprintf(stderr, "Error linking: ");
1925 utf_fprint_printable_ascii_classname(stderr, c->name);
1926 fprintf(stderr, "\n");
1928 /* print out exception and cause */
1930 exceptions_print_exception(*exceptionptr);
1932 /* goto next class */
1938 /* compile all class methods */
1940 for (i = 0; i < c->methodscount; i++) {
1941 m = &(c->methods[i]);
1943 if (m->jcode != NULL) {
1944 if (!jit_compile(m)) {
1945 fprintf(stderr, "Error compiling: ");
1946 utf_fprint_printable_ascii_classname(stderr, c->name);
1947 fprintf(stderr, ".");
1948 utf_fprint_printable_ascii(stderr, m->name);
1949 utf_fprint_printable_ascii(stderr, m->descriptor);
1950 fprintf(stderr, "\n");
1952 /* print out exception and cause */
1954 exceptions_print_exception(*exceptionptr);
1962 #endif /* !defined(NDEBUG) */
1965 /* vm_compile_method ***********************************************************
1967 Compile a specific method.
1969 *******************************************************************************/
1971 #if !defined(NDEBUG)
1972 static void vm_compile_method(void)
1976 /* create, load and link the main class */
1978 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
1979 throw_main_exception_exit();
1981 if (!link_class(mainclass))
1982 throw_main_exception_exit();
1984 if (opt_signature != NULL) {
1985 m = class_resolveclassmethod(mainclass,
1986 utf_new_char(opt_method),
1987 utf_new_char(opt_signature),
1992 m = class_resolveclassmethod(mainclass,
1993 utf_new_char(opt_method),
2000 char message[MAXLOGTEXT];
2001 sprintf(message, "%s%s", opt_method,
2002 opt_signature ? opt_signature : "");
2005 new_exception_message(string_java_lang_NoSuchMethodException,
2008 throw_main_exception_exit();
2013 #endif /* !defined(NDEBUG) */
2016 /* vm_vmargs_from_valist *******************************************************
2020 *******************************************************************************/
2022 static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
2023 vm_arg *vmargs, va_list ap)
2025 typedesc *paramtypes;
2028 paramtypes = m->parseddesc->paramtypes;
2030 /* if method is non-static fill first block and skip `this' pointer */
2035 /* the `this' pointer */
2036 vmargs[0].type = TYPE_ADR;
2037 vmargs[0].data.l = (u8) (ptrint) o;
2043 for (; i < m->parseddesc->paramcount; i++, paramtypes++) {
2044 switch (paramtypes->decltype) {
2045 /* primitive types */
2046 case PRIMITIVETYPE_BOOLEAN:
2047 case PRIMITIVETYPE_BYTE:
2048 case PRIMITIVETYPE_CHAR:
2049 case PRIMITIVETYPE_SHORT:
2050 case PRIMITIVETYPE_INT:
2051 vmargs[i].type = TYPE_INT;
2052 vmargs[i].data.l = (s8) va_arg(ap, s4);
2055 case PRIMITIVETYPE_LONG:
2056 vmargs[i].type = TYPE_LNG;
2057 vmargs[i].data.l = (s8) va_arg(ap, s8);
2060 case PRIMITIVETYPE_FLOAT:
2061 vmargs[i].type = TYPE_FLT;
2062 #if defined(__ALPHA__)
2063 /* this keeps the assembler function much simpler */
2065 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2067 vmargs[i].data.f = (jfloat) va_arg(ap, jdouble);
2071 case PRIMITIVETYPE_DOUBLE:
2072 vmargs[i].type = TYPE_DBL;
2073 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2077 vmargs[i].type = TYPE_ADR;
2078 vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*);
2085 /* vm_vmargs_from_jvalue *******************************************************
2089 *******************************************************************************/
2091 static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
2092 vm_arg *vmargs, jvalue *args)
2094 typedesc *paramtypes;
2098 paramtypes = m->parseddesc->paramtypes;
2100 /* if method is non-static fill first block and skip `this' pointer */
2105 /* the `this' pointer */
2106 vmargs[0].type = TYPE_ADR;
2107 vmargs[0].data.l = (u8) (ptrint) o;
2113 for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) {
2114 switch (paramtypes->decltype) {
2115 /* primitive types */
2116 case PRIMITIVETYPE_BOOLEAN:
2117 case PRIMITIVETYPE_BYTE:
2118 case PRIMITIVETYPE_CHAR:
2119 case PRIMITIVETYPE_SHORT:
2120 case PRIMITIVETYPE_INT:
2121 vmargs[i].type = TYPE_INT;
2122 vmargs[i].data.l = (s8) args[j].i;
2125 case PRIMITIVETYPE_LONG:
2126 vmargs[i].type = TYPE_LNG;
2127 vmargs[i].data.l = (s8) args[j].j;
2130 case PRIMITIVETYPE_FLOAT:
2131 vmargs[i].type = TYPE_FLT;
2132 #if defined(__ALPHA__)
2133 /* this keeps the assembler function much simpler */
2135 vmargs[i].data.d = (jdouble) args[j].f;
2137 vmargs[i].data.f = args[j].f;
2141 case PRIMITIVETYPE_DOUBLE:
2142 vmargs[i].type = TYPE_DBL;
2143 vmargs[i].data.d = args[j].d;
2147 vmargs[i].type = TYPE_ADR;
2148 vmargs[i].data.l = (u8) (ptrint) args[j].l;
2155 /* vm_call_method **************************************************************
2157 Calls a Java method with a variable number of arguments and returns
2160 *******************************************************************************/
2162 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
2165 java_objectheader *ro;
2168 ro = vm_call_method_valist(m, o, ap);
2175 /* vm_call_method_valist *******************************************************
2177 Calls a Java method with a variable number of arguments, passed via
2178 a va_list, and returns an address.
2180 *******************************************************************************/
2182 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
2187 java_objectheader *ro;
2190 /* mark start of dump memory area */
2192 dumpsize = dump_size();
2194 /* get number of Java method arguments */
2196 vmargscount = m->parseddesc->paramcount;
2198 /* allocate vm_arg array */
2200 vmargs = DMNEW(vm_arg, vmargscount);
2202 /* fill the vm_arg array from a va_list */
2204 vm_vmargs_from_valist(m, o, vmargs, ap);
2206 /* call the Java method */
2208 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2210 /* release dump area */
2212 dump_release(dumpsize);
2218 /* vm_call_method_jvalue *******************************************************
2220 Calls a Java method with a variable number of arguments, passed via
2221 a jvalue array, and returns an address.
2223 *******************************************************************************/
2225 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
2230 java_objectheader *ro;
2233 /* mark start of dump memory area */
2235 dumpsize = dump_size();
2237 /* get number of Java method arguments */
2239 vmargscount = m->parseddesc->paramcount;
2241 /* allocate vm_arg array */
2243 vmargs = DMNEW(vm_arg, vmargscount);
2245 /* fill the vm_arg array from a va_list */
2247 vm_vmargs_from_jvalue(m, o, vmargs, args);
2249 /* call the Java method */
2251 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2253 /* release dump area */
2255 dump_release(dumpsize);
2261 /* vm_call_method_vmarg ********************************************************
2263 Calls a Java method with a variable number of arguments, passed via
2264 a vm_arg array, and returns an address.
2266 *******************************************************************************/
2268 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
2271 java_objectheader *o;
2273 #if defined(ENABLE_JIT)
2274 # if defined(ENABLE_INTRP)
2276 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2279 o = asm_vm_call_method(m, vmargscount, vmargs);
2281 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2288 /* vm_call_method_int **********************************************************
2290 Calls a Java method with a variable number of arguments and returns
2293 *******************************************************************************/
2295 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
2301 i = vm_call_method_int_valist(m, o, ap);
2308 /* vm_call_method_int_valist ***************************************************
2310 Calls a Java method with a variable number of arguments, passed via
2311 a va_list, and returns an integer (s4).
2313 *******************************************************************************/
2315 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
2322 /* mark start of dump memory area */
2324 dumpsize = dump_size();
2326 /* get number of Java method arguments */
2328 vmargscount = m->parseddesc->paramcount;
2330 /* allocate vm_arg array */
2332 vmargs = DMNEW(vm_arg, vmargscount);
2334 /* fill the vm_arg array from a va_list */
2336 vm_vmargs_from_valist(m, o, vmargs, ap);
2338 /* call the Java method */
2340 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2342 /* release dump area */
2344 dump_release(dumpsize);
2350 /* vm_call_method_int_jvalue ***************************************************
2352 Calls a Java method with a variable number of arguments, passed via
2353 a jvalue array, and returns an integer (s4).
2355 *******************************************************************************/
2357 s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2364 /* mark start of dump memory area */
2366 dumpsize = dump_size();
2368 /* get number of Java method arguments */
2370 vmargscount = m->parseddesc->paramcount;
2372 /* allocate vm_arg array */
2374 vmargs = DMNEW(vm_arg, vmargscount);
2376 /* fill the vm_arg array from a va_list */
2378 vm_vmargs_from_jvalue(m, o, vmargs, args);
2380 /* call the Java method */
2382 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2384 /* release dump area */
2386 dump_release(dumpsize);
2392 /* vm_call_method_int_vmarg ****************************************************
2394 Calls a Java method with a variable number of arguments, passed via
2395 a vm_arg array, and returns an integer (s4).
2397 *******************************************************************************/
2399 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2403 #if defined(ENABLE_JIT)
2404 # if defined(ENABLE_INTRP)
2406 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2409 i = asm_vm_call_method_int(m, vmargscount, vmargs);
2411 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2418 /* vm_call_method_long *********************************************************
2420 Calls a Java method with a variable number of arguments and returns
2423 *******************************************************************************/
2425 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
2431 l = vm_call_method_long_valist(m, o, ap);
2438 /* vm_call_method_long_valist **************************************************
2440 Calls a Java method with a variable number of arguments, passed via
2441 a va_list, and returns a long (s8).
2443 *******************************************************************************/
2445 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
2452 /* mark start of dump memory area */
2454 dumpsize = dump_size();
2456 /* get number of Java method arguments */
2458 vmargscount = m->parseddesc->paramcount;
2460 /* allocate vm_arg array */
2462 vmargs = DMNEW(vm_arg, vmargscount);
2464 /* fill the vm_arg array from a va_list */
2466 vm_vmargs_from_valist(m, o, vmargs, ap);
2468 /* call the Java method */
2470 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2472 /* release dump area */
2474 dump_release(dumpsize);
2480 /* vm_call_method_long_jvalue **************************************************
2482 Calls a Java method with a variable number of arguments, passed via
2483 a jvalue array, and returns a long (s8).
2485 *******************************************************************************/
2487 s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2494 /* mark start of dump memory area */
2496 dumpsize = dump_size();
2498 /* get number of Java method arguments */
2500 vmargscount = m->parseddesc->paramcount;
2502 /* allocate vm_arg array */
2504 vmargs = DMNEW(vm_arg, vmargscount);
2506 /* fill the vm_arg array from a va_list */
2508 vm_vmargs_from_jvalue(m, o, vmargs, args);
2510 /* call the Java method */
2512 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2514 /* release dump area */
2516 dump_release(dumpsize);
2522 /* vm_call_method_long_vmarg ***************************************************
2524 Calls a Java method with a variable number of arguments, passed via
2525 a vm_arg array, and returns a long (s8).
2527 *******************************************************************************/
2529 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2533 #if defined(ENABLE_JIT)
2534 # if defined(ENABLE_INTRP)
2536 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2539 l = asm_vm_call_method_long(m, vmargscount, vmargs);
2541 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2548 /* vm_call_method_float ********************************************************
2550 Calls a Java method with a variable number of arguments and returns
2553 *******************************************************************************/
2555 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
2561 f = vm_call_method_float_valist(m, o, ap);
2568 /* vm_call_method_float_valist *************************************************
2570 Calls a Java method with a variable number of arguments, passed via
2571 a va_list, and returns a float.
2573 *******************************************************************************/
2575 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
2583 /* mark start of dump memory area */
2585 dumpsize = dump_size();
2587 /* get number of Java method arguments */
2589 vmargscount = m->parseddesc->paramcount;
2591 /* allocate vm_arg array */
2593 vmargs = DMNEW(vm_arg, vmargscount);
2595 /* fill the vm_arg array from a va_list */
2597 vm_vmargs_from_valist(m, o, vmargs, ap);
2599 /* call the Java method */
2601 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2603 /* release dump area */
2605 dump_release(dumpsize);
2611 /* vm_call_method_float_jvalue *************************************************
2613 Calls a Java method with a variable number of arguments, passed via
2614 a jvalue array, and returns a float.
2616 *******************************************************************************/
2618 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
2626 /* mark start of dump memory area */
2628 dumpsize = dump_size();
2630 /* get number of Java method arguments */
2632 vmargscount = m->parseddesc->paramcount;
2634 /* allocate vm_arg array */
2636 vmargs = DMNEW(vm_arg, vmargscount);
2638 /* fill the vm_arg array from a va_list */
2640 vm_vmargs_from_jvalue(m, o, vmargs, args);
2642 /* call the Java method */
2644 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2646 /* release dump area */
2648 dump_release(dumpsize);
2654 /* vm_call_method_float_vmarg **************************************************
2656 Calls a Java method with a variable number of arguments and returns
2659 *******************************************************************************/
2661 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2665 #if defined(ENABLE_JIT)
2666 # if defined(ENABLE_INTRP)
2668 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2671 f = asm_vm_call_method_float(m, vmargscount, vmargs);
2673 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2680 /* vm_call_method_double *******************************************************
2682 Calls a Java method with a variable number of arguments and returns
2685 *******************************************************************************/
2687 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
2693 d = vm_call_method_double_valist(m, o, ap);
2700 /* vm_call_method_double_valist ************************************************
2702 Calls a Java method with a variable number of arguments, passed via
2703 a va_list, and returns a double.
2705 *******************************************************************************/
2707 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
2715 /* mark start of dump memory area */
2717 dumpsize = dump_size();
2719 /* get number of Java method arguments */
2721 vmargscount = m->parseddesc->paramcount;
2723 /* allocate vm_arg array */
2725 vmargs = DMNEW(vm_arg, vmargscount);
2727 /* fill the vm_arg array from a va_list */
2729 vm_vmargs_from_valist(m, o, vmargs, ap);
2731 /* call the Java method */
2733 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2735 /* release dump area */
2737 dump_release(dumpsize);
2743 /* vm_call_method_double_jvalue ************************************************
2745 Calls a Java method with a variable number of arguments, passed via
2746 a jvalue array, and returns a double.
2748 *******************************************************************************/
2750 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
2758 /* mark start of dump memory area */
2760 dumpsize = dump_size();
2762 /* get number of Java method arguments */
2764 vmargscount = m->parseddesc->paramcount;
2766 /* allocate vm_arg array */
2768 vmargs = DMNEW(vm_arg, vmargscount);
2770 /* fill the vm_arg array from a va_list */
2772 vm_vmargs_from_jvalue(m, o, vmargs, args);
2774 /* call the Java method */
2776 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2778 /* release dump area */
2780 dump_release(dumpsize);
2786 /* vm_call_method_double_vmarg *************************************************
2788 Calls a Java method with a variable number of arguments and returns
2791 *******************************************************************************/
2793 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
2798 #if defined(ENABLE_JIT)
2799 # if defined(ENABLE_INTRP)
2801 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2804 d = asm_vm_call_method_double(m, vmargscount, vmargs);
2806 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2814 * These are local overrides for various environment variables in Emacs.
2815 * Please do not remove this and leave it at the end of the file, where
2816 * Emacs will automagically detect them.
2817 * ---------------------------------------------------------------------
2820 * indent-tabs-mode: t