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)
1200 #if defined(ENABLE_VERIFIER)
1201 /* XXX currently the verifier does not work with the interpreter */
1205 printf("-Xint option not enabled.\n");
1210 #if defined(ENABLE_INTRP)
1211 case OPT_STATIC_SUPERS:
1212 opt_static_supers = atoi(opt_arg);
1215 case OPT_NO_DYNAMIC:
1216 opt_no_dynamic = true;
1219 case OPT_NO_REPLICATION:
1220 opt_no_replication = true;
1223 case OPT_NO_QUICKSUPER:
1224 opt_no_quicksuper = true;
1233 printf("Unknown option: %s\n",
1234 vm_args->options[opt_index].optionString);
1240 /* Now we have all options handled and we can print the version
1247 /* get the main class *****************************************************/
1249 if (opt_index < vm_args->nOptions) {
1250 mainstring = vm_args->options[opt_index++].optionString;
1252 /* Put the jar file into the classpath (if any). */
1254 if (opt_jar == true) {
1255 /* free old classpath */
1257 MFREE(classpath, char, strlen(classpath));
1259 /* put jarfile into classpath */
1261 classpath = MNEW(char, strlen(mainstring) + strlen("0"));
1263 strcpy(classpath, mainstring);
1266 /* replace .'s with /'s in classname */
1268 for (i = strlen(mainstring) - 1; i >= 0; i--)
1269 if (mainstring[i] == '.')
1270 mainstring[i] = '/';
1274 #if defined(ENABLE_JVMTI)
1276 jvmti_set_phase(JVMTI_PHASE_ONLOAD);
1277 jvmti_agentload(agentarg, agentbypath, &handle, &libname);
1280 MFREE(agentarg, char, strlen(agentarg));
1282 jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
1288 /* initialize this JVM ****************************************************/
1290 vm_initializing = true;
1292 /* initialize the garbage collector */
1294 gc_init(opt_heapmaxsize, opt_heapstartsize);
1296 #if defined(ENABLE_INTRP)
1297 /* Allocate main thread stack on the Java heap. */
1300 intrp_main_stack = GCMNEW(u1, opt_stacksize);
1301 MSET(intrp_main_stack, 0, u1, opt_stacksize);
1305 #if defined(ENABLE_THREADS)
1309 /* initialize the string hashtable stuff: lock (must be done
1310 _after_ threads_preinit) */
1313 throw_main_exception_exit();
1315 /* initialize the utf8 hashtable stuff: lock, often used utf8
1316 strings (must be done _after_ threads_preinit) */
1319 throw_main_exception_exit();
1321 /* initialize the classcache hashtable stuff: lock, hashtable
1322 (must be done _after_ threads_preinit) */
1324 if (!classcache_init())
1325 throw_main_exception_exit();
1327 /* initialize the loader with bootclasspath (must be done _after_
1331 throw_main_exception_exit();
1333 suck_add_from_property("java.endorsed.dirs");
1334 suck_add(bootclasspath);
1336 /* initialize the memory subsystem (must be done _after_
1340 throw_main_exception_exit();
1342 /* initialize the finalizer stuff (must be done _after_
1345 if (!finalizer_init())
1346 throw_main_exception_exit();
1348 /* install architecture dependent signal handler used for exceptions */
1352 /* initialize the codegen subsystems */
1356 /* initializes jit compiler */
1360 /* machine dependent initialization */
1362 #if defined(ENABLE_JIT)
1363 # if defined(ENABLE_INTRP)
1373 /* initialize the loader subsystems (must be done _after_
1377 throw_main_exception_exit();
1380 throw_main_exception_exit();
1383 throw_main_exception_exit();
1385 if (!exceptions_init())
1386 throw_main_exception_exit();
1388 if (!builtin_init())
1389 throw_main_exception_exit();
1391 /* Initialize the JNI subsystem (must be done _before_
1392 threads_init, as threads_init can call JNI methods
1393 (e.g. NewGlobalRef). */
1396 throw_main_exception_exit();
1398 #if defined(ENABLE_THREADS)
1399 if (!threads_init())
1400 throw_main_exception_exit();
1403 /* That's important, otherwise we get into trouble, if the Runtime
1404 static initializer is called before (circular dependency. This
1405 is with classpath 0.09. Another important thing is, that this
1406 has to happen after initThreads!!! */
1408 if (!initialize_class(class_java_lang_System))
1409 throw_main_exception_exit();
1411 #if defined(ENABLE_PROFILING)
1412 /* initialize profiling */
1414 if (!profile_init())
1415 throw_main_exception_exit();
1418 #if defined(ENABLE_THREADS)
1419 /* initialize recompilation */
1421 if (!recompile_init())
1422 throw_main_exception_exit();
1424 /* finally, start the finalizer thread */
1426 if (!finalizer_start_thread())
1427 throw_main_exception_exit();
1429 /* start the recompilation thread (must be done before the
1430 profiling thread) */
1432 if (!recompile_start_thread())
1433 throw_main_exception_exit();
1435 # if defined(ENABLE_PROFILING)
1436 /* start the profile sampling thread */
1439 if (!profile_start_thread())
1440 throw_main_exception_exit();
1444 #if defined(ENABLE_JVMTI)
1446 /* add agent library to native library hashtable */
1447 native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
1451 /* increment the number of VMs */
1455 /* initialization is done */
1457 vm_initializing = false;
1459 /* everything's ok */
1465 /* vm_run **********************************************************************
1467 Runs the main-method of the passed class.
1469 *******************************************************************************/
1471 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
1474 classinfo *mainclass;
1476 java_objectarray *oa;
1479 java_lang_String *s;
1483 #if !defined(NDEBUG)
1489 if (opt_method != NULL) {
1490 vm_compile_method();
1493 #endif /* !defined(NDEBUG) */
1495 /* should we run the main-method? */
1497 if (mainstring == NULL)
1500 /* set return value to OK */
1504 if (opt_jar == true)
1505 /* open jar file with java.util.jar.JarFile */
1506 mainstring = vm_get_mainclass_from_jar(mainstring);
1508 /* load the main class */
1510 mainutf = utf_new_char(mainstring);
1512 if (!(mainclass = load_class_from_sysloader(mainutf)))
1513 throw_main_exception_exit();
1515 /* error loading class, clear exceptionptr for new exception */
1517 if (*exceptionptr || !mainclass) {
1518 /* *exceptionptr = NULL; */
1520 /* *exceptionptr = */
1521 /* new_exception_message(string_java_lang_NoClassDefFoundError, */
1523 throw_main_exception_exit();
1526 if (!link_class(mainclass))
1527 throw_main_exception_exit();
1529 /* find the `main' method of the main class */
1531 m = class_resolveclassmethod(mainclass,
1532 utf_new_char("main"),
1533 utf_new_char("([Ljava/lang/String;)V"),
1534 class_java_lang_Object,
1537 if (*exceptionptr) {
1538 throw_main_exception_exit();
1541 /* there is no main method or it isn't static */
1543 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
1544 *exceptionptr = NULL;
1547 new_exception_message(string_java_lang_NoSuchMethodError, "main");
1548 throw_main_exception_exit();
1551 /* build argument array */
1553 oalength = vm_args->nOptions - opt_index;
1555 oa = builtin_anewarray(oalength, class_java_lang_String);
1557 for (i = 0; i < oalength; i++) {
1558 u = utf_new_char(vm_args->options[opt_index + i].optionString);
1559 s = javastring_new(u);
1561 oa->data[i] = (java_objectheader *) s;
1564 #ifdef TYPEINFO_DEBUG_TEST
1565 /* test the typeinfo system */
1568 /*class_showmethods(currentThread->group->header.vftbl->class); */
1570 #if defined(ENABLE_JVMTI)
1571 jvmti_set_phase(JVMTI_PHASE_LIVE);
1574 /* increase total started thread count */
1576 _Jv_jvm->total_started_thread_count++;
1578 /* start the main thread */
1580 (void) vm_call_method(m, NULL, oa);
1582 /* exception occurred? */
1584 if (*exceptionptr) {
1585 throw_main_exception();
1589 /* unload the JavaVM */
1599 /* vm_destroy ******************************************************************
1601 Unloads a Java VM and reclaims its resources.
1603 *******************************************************************************/
1605 s4 vm_destroy(JavaVM *vm)
1607 #if defined(ENABLE_THREADS)
1608 threads_join_all_threads();
1611 /* everything's ok */
1617 /* vm_exit *********************************************************************
1619 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1621 *******************************************************************************/
1623 void vm_exit(s4 status)
1627 /* signal that we are exiting */
1631 assert(class_java_lang_System);
1632 assert(class_java_lang_System->state & CLASS_LOADED);
1634 #if defined(ENABLE_JVMTI)
1635 if (jvmti || (dbgcom!=NULL)) {
1636 jvmti_set_phase(JVMTI_PHASE_DEAD);
1637 if (jvmti) jvmti_agentunload();
1641 if (!link_class(class_java_lang_System))
1642 throw_main_exception_exit();
1644 /* call java.lang.System.exit(I)V */
1646 m = class_resolveclassmethod(class_java_lang_System,
1647 utf_new_char("exit"),
1649 class_java_lang_Object,
1653 throw_main_exception_exit();
1655 /* call the exit function with passed exit status */
1657 (void) vm_call_method(m, NULL, status);
1659 /* If we had an exception, just ignore the exception and exit with
1662 vm_shutdown(status);
1666 /* vm_shutdown *****************************************************************
1668 Terminates the system immediately without freeing memory explicitly
1669 (to be used only for abnormal termination).
1671 *******************************************************************************/
1673 void vm_shutdown(s4 status)
1676 #if defined(ENABLE_STATISTICS)
1677 || opt_getcompilingtime || opt_stat
1681 log_text("CACAO terminated by shutdown");
1682 dolog("Exit status: %d\n", (s4) status);
1686 #if defined(ENABLE_JVMTI)
1687 /* terminate cacaodbgserver */
1689 pthread_mutex_lock(&dbgcomlock);
1691 pthread_mutex_unlock(&dbgcomlock);
1692 jvmti_cacaodbgserver_quit();
1700 /* vm_exit_handler *************************************************************
1702 The exit_handler function is called upon program termination.
1704 ATTENTION: Don't free system resources here! Some threads may still
1705 be running as this is called from VMRuntime.exit(). The OS does the
1708 *******************************************************************************/
1710 void vm_exit_handler(void)
1712 #if !defined(NDEBUG)
1714 class_showmethods(mainclass);
1716 if (showconstantpool)
1717 class_showconstantpool(mainclass);
1722 # if defined(ENABLE_PROFILING)
1724 profile_printstats();
1726 #endif /* !defined(NDEBUG) */
1728 #if defined(ENABLE_RT_TIMING)
1729 rt_timing_print_time_stats(stderr);
1732 #if defined(ENABLE_CYCLES_STATS)
1733 builtin_print_cycles_stats(stderr);
1734 stacktrace_print_cycles_stats(stderr);
1738 #if defined(ENABLE_STATISTICS)
1739 || opt_getcompilingtime || opt_stat
1743 log_text("CACAO terminated");
1745 #if defined(ENABLE_STATISTICS)
1748 #ifdef TYPECHECK_STATISTICS
1749 typecheck_print_statistics(get_logfile());
1755 if (opt_getcompilingtime)
1757 #endif /* defined(ENABLE_STATISTICS) */
1759 /* vm_print_profile(stderr);*/
1763 /* vm_abort ********************************************************************
1765 Prints an error message and aborts the VM.
1767 *******************************************************************************/
1769 void vm_abort(const char *text, ...)
1773 /* print the log message */
1778 log_vprint(text, ap);
1783 /* now abort the VM */
1789 /* vm_get_mainclass_from_jar ***************************************************
1791 Gets the name of the main class from a JAR's manifest file.
1793 *******************************************************************************/
1795 static char *vm_get_mainclass_from_jar(char *mainstring)
1798 java_objectheader *o;
1800 java_lang_String *s;
1802 c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
1805 throw_main_exception_exit();
1807 /* create JarFile object */
1812 throw_main_exception_exit();
1815 m = class_resolveclassmethod(c,
1817 utf_java_lang_String__void,
1818 class_java_lang_Object,
1822 throw_main_exception_exit();
1824 s = javastring_new_from_ascii(mainstring);
1826 (void) vm_call_method(m, o, s);
1829 throw_main_exception_exit();
1831 /* get manifest object */
1833 m = class_resolveclassmethod(c,
1834 utf_new_char("getManifest"),
1835 utf_new_char("()Ljava/util/jar/Manifest;"),
1836 class_java_lang_Object,
1840 throw_main_exception_exit();
1842 o = vm_call_method(m, o);
1845 fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
1850 /* get Main Attributes */
1852 m = class_resolveclassmethod(o->vftbl->class,
1853 utf_new_char("getMainAttributes"),
1854 utf_new_char("()Ljava/util/jar/Attributes;"),
1855 class_java_lang_Object,
1859 throw_main_exception_exit();
1861 o = vm_call_method(m, o);
1864 fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
1869 /* get property Main-Class */
1871 m = class_resolveclassmethod(o->vftbl->class,
1872 utf_new_char("getValue"),
1873 utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
1874 class_java_lang_Object,
1878 throw_main_exception_exit();
1880 s = javastring_new_from_ascii("Main-Class");
1882 o = vm_call_method(m, o, s);
1885 throw_main_exception_exit();
1887 return javastring_tochar(o);
1891 /* vm_compile_all **************************************************************
1893 Compile all methods found in the bootclasspath.
1895 *******************************************************************************/
1897 #if !defined(NDEBUG)
1898 static void vm_compile_all(void)
1903 classcache_name_entry *nmen;
1904 classcache_class_entry *clsen;
1907 /* create all classes found in the bootclasspath */
1908 /* XXX currently only works with zip/jar's */
1910 loader_load_all_classes();
1912 /* link all classes */
1914 for (slot = 0; slot < hashtable_classcache.size; slot++) {
1915 nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
1917 for (; nmen; nmen = nmen->hashlink) {
1918 /* iterate over all class entries */
1920 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1921 c = clsen->classobj;
1926 if (!(c->state & CLASS_LINKED)) {
1927 if (!link_class(c)) {
1928 fprintf(stderr, "Error linking: ");
1929 utf_fprint_printable_ascii_classname(stderr, c->name);
1930 fprintf(stderr, "\n");
1932 /* print out exception and cause */
1934 exceptions_print_exception(*exceptionptr);
1936 /* goto next class */
1942 /* compile all class methods */
1944 for (i = 0; i < c->methodscount; i++) {
1945 m = &(c->methods[i]);
1947 if (m->jcode != NULL) {
1948 if (!jit_compile(m)) {
1949 fprintf(stderr, "Error compiling: ");
1950 utf_fprint_printable_ascii_classname(stderr, c->name);
1951 fprintf(stderr, ".");
1952 utf_fprint_printable_ascii(stderr, m->name);
1953 utf_fprint_printable_ascii(stderr, m->descriptor);
1954 fprintf(stderr, "\n");
1956 /* print out exception and cause */
1958 exceptions_print_exception(*exceptionptr);
1966 #endif /* !defined(NDEBUG) */
1969 /* vm_compile_method ***********************************************************
1971 Compile a specific method.
1973 *******************************************************************************/
1975 #if !defined(NDEBUG)
1976 static void vm_compile_method(void)
1980 /* create, load and link the main class */
1982 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
1983 throw_main_exception_exit();
1985 if (!link_class(mainclass))
1986 throw_main_exception_exit();
1988 if (opt_signature != NULL) {
1989 m = class_resolveclassmethod(mainclass,
1990 utf_new_char(opt_method),
1991 utf_new_char(opt_signature),
1996 m = class_resolveclassmethod(mainclass,
1997 utf_new_char(opt_method),
2004 char message[MAXLOGTEXT];
2005 sprintf(message, "%s%s", opt_method,
2006 opt_signature ? opt_signature : "");
2009 new_exception_message(string_java_lang_NoSuchMethodException,
2012 throw_main_exception_exit();
2017 #endif /* !defined(NDEBUG) */
2020 /* vm_vmargs_from_valist *******************************************************
2024 *******************************************************************************/
2026 static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
2027 vm_arg *vmargs, va_list ap)
2029 typedesc *paramtypes;
2032 paramtypes = m->parseddesc->paramtypes;
2034 /* if method is non-static fill first block and skip `this' pointer */
2039 /* the `this' pointer */
2040 vmargs[0].type = TYPE_ADR;
2041 vmargs[0].data.l = (u8) (ptrint) o;
2047 for (; i < m->parseddesc->paramcount; i++, paramtypes++) {
2048 switch (paramtypes->decltype) {
2049 /* primitive types */
2050 case PRIMITIVETYPE_BOOLEAN:
2051 case PRIMITIVETYPE_BYTE:
2052 case PRIMITIVETYPE_CHAR:
2053 case PRIMITIVETYPE_SHORT:
2054 case PRIMITIVETYPE_INT:
2055 vmargs[i].type = TYPE_INT;
2056 vmargs[i].data.l = (s8) va_arg(ap, s4);
2059 case PRIMITIVETYPE_LONG:
2060 vmargs[i].type = TYPE_LNG;
2061 vmargs[i].data.l = (s8) va_arg(ap, s8);
2064 case PRIMITIVETYPE_FLOAT:
2065 vmargs[i].type = TYPE_FLT;
2066 #if defined(__ALPHA__)
2067 /* this keeps the assembler function much simpler */
2069 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2071 vmargs[i].data.f = (jfloat) va_arg(ap, jdouble);
2075 case PRIMITIVETYPE_DOUBLE:
2076 vmargs[i].type = TYPE_DBL;
2077 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2081 vmargs[i].type = TYPE_ADR;
2082 vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*);
2089 /* vm_vmargs_from_jvalue *******************************************************
2093 *******************************************************************************/
2095 static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
2096 vm_arg *vmargs, jvalue *args)
2098 typedesc *paramtypes;
2102 paramtypes = m->parseddesc->paramtypes;
2104 /* if method is non-static fill first block and skip `this' pointer */
2109 /* the `this' pointer */
2110 vmargs[0].type = TYPE_ADR;
2111 vmargs[0].data.l = (u8) (ptrint) o;
2117 for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) {
2118 switch (paramtypes->decltype) {
2119 /* primitive types */
2120 case PRIMITIVETYPE_BOOLEAN:
2121 case PRIMITIVETYPE_BYTE:
2122 case PRIMITIVETYPE_CHAR:
2123 case PRIMITIVETYPE_SHORT:
2124 case PRIMITIVETYPE_INT:
2125 vmargs[i].type = TYPE_INT;
2126 vmargs[i].data.l = (s8) args[j].i;
2129 case PRIMITIVETYPE_LONG:
2130 vmargs[i].type = TYPE_LNG;
2131 vmargs[i].data.l = (s8) args[j].j;
2134 case PRIMITIVETYPE_FLOAT:
2135 vmargs[i].type = TYPE_FLT;
2136 #if defined(__ALPHA__)
2137 /* this keeps the assembler function much simpler */
2139 vmargs[i].data.d = (jdouble) args[j].f;
2141 vmargs[i].data.f = args[j].f;
2145 case PRIMITIVETYPE_DOUBLE:
2146 vmargs[i].type = TYPE_DBL;
2147 vmargs[i].data.d = args[j].d;
2151 vmargs[i].type = TYPE_ADR;
2152 vmargs[i].data.l = (u8) (ptrint) args[j].l;
2159 /* vm_call_method **************************************************************
2161 Calls a Java method with a variable number of arguments and returns
2164 *******************************************************************************/
2166 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
2169 java_objectheader *ro;
2172 ro = vm_call_method_valist(m, o, ap);
2179 /* vm_call_method_valist *******************************************************
2181 Calls a Java method with a variable number of arguments, passed via
2182 a va_list, and returns an address.
2184 *******************************************************************************/
2186 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
2191 java_objectheader *ro;
2194 /* mark start of dump memory area */
2196 dumpsize = dump_size();
2198 /* get number of Java method arguments */
2200 vmargscount = m->parseddesc->paramcount;
2202 /* allocate vm_arg array */
2204 vmargs = DMNEW(vm_arg, vmargscount);
2206 /* fill the vm_arg array from a va_list */
2208 vm_vmargs_from_valist(m, o, vmargs, ap);
2210 /* call the Java method */
2212 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2214 /* release dump area */
2216 dump_release(dumpsize);
2222 /* vm_call_method_jvalue *******************************************************
2224 Calls a Java method with a variable number of arguments, passed via
2225 a jvalue array, and returns an address.
2227 *******************************************************************************/
2229 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
2234 java_objectheader *ro;
2237 /* mark start of dump memory area */
2239 dumpsize = dump_size();
2241 /* get number of Java method arguments */
2243 vmargscount = m->parseddesc->paramcount;
2245 /* allocate vm_arg array */
2247 vmargs = DMNEW(vm_arg, vmargscount);
2249 /* fill the vm_arg array from a va_list */
2251 vm_vmargs_from_jvalue(m, o, vmargs, args);
2253 /* call the Java method */
2255 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2257 /* release dump area */
2259 dump_release(dumpsize);
2265 /* vm_call_method_vmarg ********************************************************
2267 Calls a Java method with a variable number of arguments, passed via
2268 a vm_arg array, and returns an address.
2270 *******************************************************************************/
2272 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
2275 java_objectheader *o;
2277 #if defined(ENABLE_JIT)
2278 # if defined(ENABLE_INTRP)
2280 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2283 o = asm_vm_call_method(m, vmargscount, vmargs);
2285 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2292 /* vm_call_method_int **********************************************************
2294 Calls a Java method with a variable number of arguments and returns
2297 *******************************************************************************/
2299 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
2305 i = vm_call_method_int_valist(m, o, ap);
2312 /* vm_call_method_int_valist ***************************************************
2314 Calls a Java method with a variable number of arguments, passed via
2315 a va_list, and returns an integer (s4).
2317 *******************************************************************************/
2319 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
2326 /* mark start of dump memory area */
2328 dumpsize = dump_size();
2330 /* get number of Java method arguments */
2332 vmargscount = m->parseddesc->paramcount;
2334 /* allocate vm_arg array */
2336 vmargs = DMNEW(vm_arg, vmargscount);
2338 /* fill the vm_arg array from a va_list */
2340 vm_vmargs_from_valist(m, o, vmargs, ap);
2342 /* call the Java method */
2344 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2346 /* release dump area */
2348 dump_release(dumpsize);
2354 /* vm_call_method_int_jvalue ***************************************************
2356 Calls a Java method with a variable number of arguments, passed via
2357 a jvalue array, and returns an integer (s4).
2359 *******************************************************************************/
2361 s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2368 /* mark start of dump memory area */
2370 dumpsize = dump_size();
2372 /* get number of Java method arguments */
2374 vmargscount = m->parseddesc->paramcount;
2376 /* allocate vm_arg array */
2378 vmargs = DMNEW(vm_arg, vmargscount);
2380 /* fill the vm_arg array from a va_list */
2382 vm_vmargs_from_jvalue(m, o, vmargs, args);
2384 /* call the Java method */
2386 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2388 /* release dump area */
2390 dump_release(dumpsize);
2396 /* vm_call_method_int_vmarg ****************************************************
2398 Calls a Java method with a variable number of arguments, passed via
2399 a vm_arg array, and returns an integer (s4).
2401 *******************************************************************************/
2403 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2407 #if defined(ENABLE_JIT)
2408 # if defined(ENABLE_INTRP)
2410 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2413 i = asm_vm_call_method_int(m, vmargscount, vmargs);
2415 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2422 /* vm_call_method_long *********************************************************
2424 Calls a Java method with a variable number of arguments and returns
2427 *******************************************************************************/
2429 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
2435 l = vm_call_method_long_valist(m, o, ap);
2442 /* vm_call_method_long_valist **************************************************
2444 Calls a Java method with a variable number of arguments, passed via
2445 a va_list, and returns a long (s8).
2447 *******************************************************************************/
2449 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
2456 /* mark start of dump memory area */
2458 dumpsize = dump_size();
2460 /* get number of Java method arguments */
2462 vmargscount = m->parseddesc->paramcount;
2464 /* allocate vm_arg array */
2466 vmargs = DMNEW(vm_arg, vmargscount);
2468 /* fill the vm_arg array from a va_list */
2470 vm_vmargs_from_valist(m, o, vmargs, ap);
2472 /* call the Java method */
2474 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2476 /* release dump area */
2478 dump_release(dumpsize);
2484 /* vm_call_method_long_jvalue **************************************************
2486 Calls a Java method with a variable number of arguments, passed via
2487 a jvalue array, and returns a long (s8).
2489 *******************************************************************************/
2491 s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2498 /* mark start of dump memory area */
2500 dumpsize = dump_size();
2502 /* get number of Java method arguments */
2504 vmargscount = m->parseddesc->paramcount;
2506 /* allocate vm_arg array */
2508 vmargs = DMNEW(vm_arg, vmargscount);
2510 /* fill the vm_arg array from a va_list */
2512 vm_vmargs_from_jvalue(m, o, vmargs, args);
2514 /* call the Java method */
2516 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2518 /* release dump area */
2520 dump_release(dumpsize);
2526 /* vm_call_method_long_vmarg ***************************************************
2528 Calls a Java method with a variable number of arguments, passed via
2529 a vm_arg array, and returns a long (s8).
2531 *******************************************************************************/
2533 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2537 #if defined(ENABLE_JIT)
2538 # if defined(ENABLE_INTRP)
2540 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2543 l = asm_vm_call_method_long(m, vmargscount, vmargs);
2545 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2552 /* vm_call_method_float ********************************************************
2554 Calls a Java method with a variable number of arguments and returns
2557 *******************************************************************************/
2559 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
2565 f = vm_call_method_float_valist(m, o, ap);
2572 /* vm_call_method_float_valist *************************************************
2574 Calls a Java method with a variable number of arguments, passed via
2575 a va_list, and returns a float.
2577 *******************************************************************************/
2579 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
2587 /* mark start of dump memory area */
2589 dumpsize = dump_size();
2591 /* get number of Java method arguments */
2593 vmargscount = m->parseddesc->paramcount;
2595 /* allocate vm_arg array */
2597 vmargs = DMNEW(vm_arg, vmargscount);
2599 /* fill the vm_arg array from a va_list */
2601 vm_vmargs_from_valist(m, o, vmargs, ap);
2603 /* call the Java method */
2605 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2607 /* release dump area */
2609 dump_release(dumpsize);
2615 /* vm_call_method_float_jvalue *************************************************
2617 Calls a Java method with a variable number of arguments, passed via
2618 a jvalue array, and returns a float.
2620 *******************************************************************************/
2622 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
2630 /* mark start of dump memory area */
2632 dumpsize = dump_size();
2634 /* get number of Java method arguments */
2636 vmargscount = m->parseddesc->paramcount;
2638 /* allocate vm_arg array */
2640 vmargs = DMNEW(vm_arg, vmargscount);
2642 /* fill the vm_arg array from a va_list */
2644 vm_vmargs_from_jvalue(m, o, vmargs, args);
2646 /* call the Java method */
2648 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2650 /* release dump area */
2652 dump_release(dumpsize);
2658 /* vm_call_method_float_vmarg **************************************************
2660 Calls a Java method with a variable number of arguments and returns
2663 *******************************************************************************/
2665 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2669 #if defined(ENABLE_JIT)
2670 # if defined(ENABLE_INTRP)
2672 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2675 f = asm_vm_call_method_float(m, vmargscount, vmargs);
2677 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2684 /* vm_call_method_double *******************************************************
2686 Calls a Java method with a variable number of arguments and returns
2689 *******************************************************************************/
2691 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
2697 d = vm_call_method_double_valist(m, o, ap);
2704 /* vm_call_method_double_valist ************************************************
2706 Calls a Java method with a variable number of arguments, passed via
2707 a va_list, and returns a double.
2709 *******************************************************************************/
2711 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
2719 /* mark start of dump memory area */
2721 dumpsize = dump_size();
2723 /* get number of Java method arguments */
2725 vmargscount = m->parseddesc->paramcount;
2727 /* allocate vm_arg array */
2729 vmargs = DMNEW(vm_arg, vmargscount);
2731 /* fill the vm_arg array from a va_list */
2733 vm_vmargs_from_valist(m, o, vmargs, ap);
2735 /* call the Java method */
2737 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2739 /* release dump area */
2741 dump_release(dumpsize);
2747 /* vm_call_method_double_jvalue ************************************************
2749 Calls a Java method with a variable number of arguments, passed via
2750 a jvalue array, and returns a double.
2752 *******************************************************************************/
2754 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
2762 /* mark start of dump memory area */
2764 dumpsize = dump_size();
2766 /* get number of Java method arguments */
2768 vmargscount = m->parseddesc->paramcount;
2770 /* allocate vm_arg array */
2772 vmargs = DMNEW(vm_arg, vmargscount);
2774 /* fill the vm_arg array from a va_list */
2776 vm_vmargs_from_jvalue(m, o, vmargs, args);
2778 /* call the Java method */
2780 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2782 /* release dump area */
2784 dump_release(dumpsize);
2790 /* vm_call_method_double_vmarg *************************************************
2792 Calls a Java method with a variable number of arguments and returns
2795 *******************************************************************************/
2797 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
2802 #if defined(ENABLE_JIT)
2803 # if defined(ENABLE_INTRP)
2805 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2808 d = asm_vm_call_method_double(m, vmargscount, vmargs);
2810 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2818 * These are local overrides for various environment variables in Emacs.
2819 * Please do not remove this and leave it at the end of the file, where
2820 * Emacs will automagically detect them.
2821 * ---------------------------------------------------------------------
2824 * indent-tabs-mode: t