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
30 $Id: vm.c 4357 2006-01-22 23:33:38Z twisti $
41 #if defined(WITH_JRE_LAYOUT)
48 #include "mm/gc-common.h"
49 #include "mm/memory.h"
50 #include "native/jni.h"
51 #include "native/native.h"
53 #if defined(ENABLE_THREADS)
54 # include "threads/native/threads.h"
57 #include "vm/classcache.h"
58 #include "vm/exceptions.h"
59 #include "vm/finalizer.h"
60 #include "vm/global.h"
61 #include "vm/initialize.h"
62 #include "vm/options.h"
63 #include "vm/properties.h"
64 #include "vm/rt-timing.h"
65 #include "vm/signallocal.h"
66 #include "vm/stringlocal.h"
69 #include "vm/jit/jit.h"
70 #include "vm/jit/asmpart.h"
72 #if defined(ENABLE_PROFILING)
73 # include "vm/jit/optimizing/profile.h"
76 #include "vm/jit/optimizing/recompile.h"
78 #if defined(ENABLE_JVMTI)
79 # include "native/jvmti/cacaodbg.h"
83 /* Invocation API variables ***************************************************/
85 _Jv_JavaVM *_Jv_jvm; /* denotes a Java VM */
86 _Jv_JNIEnv *_Jv_env; /* pointer to native method interface */
89 /* global variables ***********************************************************/
91 s4 vms = 0; /* number of VMs created */
93 bool vm_initializing = false;
94 bool vm_exiting = false;
96 char *cacao_prefix = NULL;
97 char *cacao_libjvm = NULL;
98 char *classpath_libdir = NULL;
100 char *_Jv_bootclasspath; /* contains the boot classpath */
101 char *_Jv_classpath; /* contains the classpath */
102 char *_Jv_java_library_path;
104 char *mainstring = NULL;
105 classinfo *mainclass = NULL;
107 char *specificmethodname = NULL;
108 char *specificsignature = NULL;
112 #if defined(ENABLE_INTRP)
113 u1 *intrp_main_stack = NULL;
117 /* define heap sizes **********************************************************/
119 #define HEAP_MAXSIZE 128 * 1024 * 1024 /* default 128MB */
120 #define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
121 #define STACK_SIZE 64 * 1024 /* default 64kB */
124 /* define command line options ************************************************/
151 /* Java non-standard options */
162 #if defined(ENABLE_PROFILING)
176 #if defined(ENABLE_STATISTICS)
193 #if defined(ENABLE_VERIFIER)
195 #if defined(TYPECHECK_VERBOSE)
198 #endif /* defined(ENABLE_VERIFIER) */
201 /* optimization options */
203 #if defined(ENABLE_LOOP)
207 #if defined(ENABLE_IFCONV)
211 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
215 #if defined(ENABLE_INLINING)
219 #if defined(ENABLE_INTRP)
220 /* interpreter options */
243 opt_struct opts[] = {
244 { "foo", false, OPT_FOO },
248 { "jar", false, OPT_JAR },
250 { "d32", false, OPT_D32 },
251 { "d64", false, OPT_D64 },
252 { "client", false, OPT_IGNORE },
253 { "server", false, OPT_IGNORE },
254 { "jvm", false, OPT_IGNORE },
255 { "hotspot", false, OPT_IGNORE },
257 { "classpath", true, OPT_CLASSPATH },
258 { "cp", true, OPT_CLASSPATH },
259 { "D", true, OPT_D },
260 { "version", false, OPT_VERSION },
261 { "showversion", false, OPT_SHOWVERSION },
262 { "fullversion", false, OPT_FULLVERSION },
263 { "help", false, OPT_HELP },
264 { "?", false, OPT_HELP },
265 { "X", false, OPT_X },
267 { "esa", false, OPT_ESA },
268 { "enablesystemassertions", false, OPT_ESA },
269 { "dsa", false, OPT_DSA },
270 { "disablesystemassertions", false, OPT_DSA },
272 { "noasyncgc", false, OPT_IGNORE },
273 #if defined(ENABLE_VERIFIER)
274 { "noverify", false, OPT_NOVERIFY },
276 { "v", false, OPT_VERBOSE1 },
277 { "verbose:", true, OPT_VERBOSE },
279 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
280 { "verbosetc", false, OPT_VERBOSETC },
282 #if defined(__ALPHA__)
283 { "noieee", false, OPT_NOIEEE },
285 { "softnull", false, OPT_SOFTNULL },
286 #if defined(ENABLE_STATISTICS)
287 { "time", false, OPT_TIME },
288 { "stat", false, OPT_STAT },
290 { "log", true, OPT_LOG },
291 { "c", true, OPT_CHECK },
292 { "l", false, OPT_LOAD },
293 { "eager", false, OPT_EAGER },
296 { "all", false, OPT_ALL },
297 { "sig", true, OPT_SIGNATURE },
300 #if defined(ENABLE_LOOP)
301 { "oloop", false, OPT_OLOOP },
303 #if defined(ENABLE_IFCONV)
304 { "ifconv", false, OPT_IFCONV },
306 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
307 { "lsra", false, OPT_LSRA },
310 #if defined(ENABLE_INTRP)
311 /* interpreter options */
313 { "trace", false, OPT_TRACE },
314 { "static-supers", true, OPT_STATIC_SUPERS },
315 { "no-dynamic", false, OPT_NO_DYNAMIC },
316 { "no-replication", false, OPT_NO_REPLICATION },
317 { "no-quicksuper", false, OPT_NO_QUICKSUPER },
320 /* JVMTI Agent Command Line Options */
322 { "agentlib:", true, OPT_AGENTLIB },
323 { "agentpath:", true, OPT_AGENTPATH },
326 /* Java non-standard options */
328 { "Xjit", false, OPT_JIT },
329 { "Xint", false, OPT_INTRP },
330 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
331 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
332 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
333 { "Xbootclasspath/c:", true, OPT_BOOTCLASSPATH_C },
336 { "Xdebug", false, OPT_DEBUG },
337 { "Xnoagent", false, OPT_NOAGENT },
338 { "Xrunjdwp", true, OPT_XRUNJDWP },
341 { "Xms", true, OPT_MS },
342 { "ms", true, OPT_MS },
343 { "Xmx", true, OPT_MX },
344 { "mx", true, OPT_MX },
345 { "Xss", true, OPT_SS },
346 { "ss", true, OPT_SS },
348 #if defined(ENABLE_PROFILING)
349 { "Xprof:", true, OPT_PROF_OPTION },
350 { "Xprof", false, OPT_PROF },
353 /* keep these at the end of the list */
355 #if defined(ENABLE_INLINING)
356 { "i", true, OPT_INLINING },
360 { "m", true, OPT_METHOD },
363 { "s", true, OPT_SHOW },
364 { "debug-color", false, OPT_DEBUGCOLOR },
370 /* usage ***********************************************************************
372 Prints the correct usage syntax to stdout.
374 *******************************************************************************/
378 puts("Usage: cacao [-options] classname [arguments]");
379 puts(" (to run a class file)");
380 puts(" or cacao [-options] -jar jarfile [arguments]");
381 puts(" (to run a standalone jar file)\n");
383 puts("Java options:");
384 puts(" -d32 use 32-bit data model if available");
385 puts(" -d64 use 64-bit data model if available");
386 puts(" -client compatibility (currently ignored)");
387 puts(" -server compatibility (currently ignored)");
388 puts(" -jvm compatibility (currently ignored)");
389 puts(" -hotspot compatibility (currently ignored)\n");
391 puts(" -cp <path> specify a path to look for classes");
392 puts(" -classpath <path> specify a path to look for classes");
393 puts(" -D<name>=<value> add an entry to the property list");
394 puts(" -verbose[:class|gc|jni] enable specific verbose output");
395 puts(" -version print product version and exit");
396 puts(" -fullversion print jpackage-compatible product version and exit");
397 puts(" -showversion print product version and continue");
398 puts(" -help, -? print this help message");
399 puts(" -X print help on non-standard Java options");
400 puts(" -esa | -enablesystemassertions");
401 puts(" enable system assertions");
402 puts(" -dsa | -disablesystemassertions");
403 puts(" disable system assertions");
407 puts(" -agentlib:<agent-lib-name>=<options> library to load containg JVMTI agent");
408 puts (" for jdwp help use: -agentlib:jdwp=help");
409 puts(" -agentpath:<path-to-agent>=<options> path to library containg JVMTI agent");
412 puts("CACAO options:");
413 puts(" -v write state-information");
414 puts(" -verbose[:call|exception|jit]");
415 puts(" enable specific verbose output");
416 puts(" -debug-color colored output for ANSI terms");
417 #ifdef TYPECHECK_VERBOSE
418 puts(" -verbosetc write debug messages while typechecking");
420 #if defined(__ALPHA__)
421 puts(" -noieee don't use ieee compliant arithmetic");
423 #if defined(ENABLE_VERIFIER)
424 puts(" -noverify don't verify classfiles");
426 puts(" -softnull use software nullpointer check");
427 #if defined(ENABLE_STATISTICS)
428 puts(" -time measure the runtime");
429 puts(" -stat detailed compiler statistics");
431 puts(" -log logfile specify a name for the logfile");
432 puts(" -c(heck)b(ounds) don't check array bounds");
433 puts(" s(ync) don't check for synchronization");
434 #if defined(ENABLE_LOOP)
435 puts(" -oloop optimize array accesses in loops");
437 puts(" -l don't start the class after loading");
438 puts(" -eager perform eager class loading and linking");
440 puts(" -all compile all methods, no execution");
441 puts(" -m compile only a specific method");
442 puts(" -sig specify signature for a specific method");
445 puts(" -s... show...");
446 puts(" (c)onstants the constant pool");
447 puts(" (m)ethods class fields and methods");
448 puts(" (u)tf the utf - hash");
449 puts(" (i)ntermediate intermediate representation");
450 #if defined(ENABLE_DISASSEMBLER)
451 puts(" (a)ssembler disassembled listing");
452 puts(" n(o)ps show NOPs in disassembler output");
453 puts(" (e)xceptionstubs disassembled exception stubs (only with -sa)");
454 puts(" (n)ative disassembled native stubs");
456 puts(" (d)atasegment data segment listing");
457 #if defined(ENABLE_INLINING)
458 puts(" -i n(line) activate inlining");
459 puts(" v(irtual) inline virtual methods (uses/turns rt option on)");
460 puts(" e(exception) inline methods with exceptions");
461 puts(" p(aramopt) optimize argument renaming");
462 puts(" o(utsiders) inline methods of foreign classes");
463 #endif /* defined(ENABLE_INLINING) */
464 #if defined(ENABLE_IFCONV)
465 puts(" -ifconv use if-conversion");
467 #if defined(ENABLE_LSRA)
468 puts(" -lsra use linear scan register allocation");
470 #if defined(ENABLE_SSA)
471 puts(" -lsra use linear scan register allocation (with SSA)");
474 /* exit with error code */
480 static void Xusage(void)
482 #if defined(ENABLE_JIT)
483 puts(" -Xjit JIT mode execution (default)");
485 #if defined(ENABLE_INTRP)
486 puts(" -Xint interpreter mode execution");
488 puts(" -Xbootclasspath:<zip/jar files and directories separated by :>");
489 puts(" value is set as bootstrap class path");
490 puts(" -Xbootclasspath/a:<zip/jar files and directories separated by :>");
491 puts(" value is appended to the bootstrap class path");
492 puts(" -Xbootclasspath/p:<zip/jar files and directories separated by :>");
493 puts(" value is prepended to the bootstrap class path");
494 puts(" -Xbootclasspath/c:<zip/jar files and directories separated by :>");
495 puts(" value is used as Java core library, but the");
496 puts(" hardcoded VM interface classes are prepended");
497 printf(" -Xms<size> set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024);
498 printf(" -Xmx<size> set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024);
499 printf(" -Xss<size> set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024);
501 #if defined(ENABLE_PROFILING)
502 puts(" -Xprof[:bb] collect and print profiling data");
505 #if defined(ENABLE_JVMTI)
506 /* -Xdebug option depend on gnu classpath JDWP options. options:
507 transport=dt_socket,address=<hostname:port>,server=(y|n),suspend(y|n) */
508 puts(" -Xdebug enable remote debugging\n");
509 puts(" -Xrunjdwp transport=[dt_socket|...],address=<hostname:port>,server=[y|n],suspend=[y|n]\n");
510 puts(" enable remote debugging\n");
513 /* exit with error code */
519 /* version *********************************************************************
521 Only prints cacao version information.
523 *******************************************************************************/
525 static void version(bool opt_exit)
527 puts("java version \""JAVA_VERSION"\"");
528 puts("CACAO version "VERSION"");
530 puts("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,");
531 puts("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,");
532 puts("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,");
533 puts("J. Wenninger, Institut f. Computersprachen - TU Wien\n");
535 puts("This program is free software; you can redistribute it and/or");
536 puts("modify it under the terms of the GNU General Public License as");
537 puts("published by the Free Software Foundation; either version 2, or (at");
538 puts("your option) any later version.\n");
540 puts("This program is distributed in the hope that it will be useful, but");
541 puts("WITHOUT ANY WARRANTY; without even the implied warranty of");
542 puts("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU");
543 puts("General Public License for more details.\n");
545 puts("Configure/Build options:\n");
546 puts(" ./configure: "VERSION_CONFIGURE_ARGS"");
547 #if defined(__VERSION__)
548 puts(" CC : "VERSION_CC" ("__VERSION__")");
550 puts(" CC : "VERSION_CC"");
552 puts(" CFLAGS : "VERSION_CFLAGS"\n");
554 puts("Default variables:\n");
555 printf(" maximum heap size : %d\n", HEAP_MAXSIZE);
556 printf(" initial heap size : %d\n", HEAP_STARTSIZE);
557 printf(" stack size : %d\n", STACK_SIZE);
558 puts(" java.boot.class.path : "CACAO_VM_ZIP":"CLASSPATH_GLIBJ_ZIP"");
559 puts(" gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR"/classpath\n");
561 puts("Runtime variables:\n");
562 printf(" maximum heap size : %d\n", opt_heapmaxsize);
563 printf(" initial heap size : %d\n", opt_heapstartsize);
564 printf(" stack size : %d\n", opt_stacksize);
565 printf(" java.boot.class.path : %s\n", _Jv_bootclasspath);
566 printf(" gnu.classpath.boot.library.path: %s\n", classpath_libdir);
568 /* exit normally, if requested */
575 /* fullversion *****************************************************************
577 Prints a Sun compatible version information (required e.g. by
578 jpackage, www.jpackage.org).
580 *******************************************************************************/
582 static void fullversion(void)
584 puts("java full version \"cacao-"JAVA_VERSION"\"");
592 /* forward declarations *******************************************************/
594 static char *vm_get_mainclass_from_jar(char *mainstring);
596 static void vm_compile_all(void);
597 static void vm_compile_method(void);
601 /* vm_create *******************************************************************
603 Creates a JVM. Called by JNI_CreateJavaVM.
605 *******************************************************************************/
607 bool vm_create(JavaVMInitArgs *vm_args)
616 #if defined(ENABLE_JVMTI)
618 char *libname, *agentarg;
619 bool jdwp,agentbypath;
620 jdwp = agentbypath = false;
623 /* check the JNI version requested */
625 switch (vm_args->version) {
626 case JNI_VERSION_1_1:
628 case JNI_VERSION_1_2:
629 case JNI_VERSION_1_4:
635 /* we only support 1 JVM instance */
640 if (atexit(vm_exit_handler))
641 vm_abort("atexit failed: %s\n", strerror(errno));
644 log_text("CACAO started -------------------------------------------------------");
646 /* set the VM starttime */
648 _Jv_jvm->starttime = builtin_currenttimemillis();
650 /* get stuff from the environment *****************************************/
652 #if defined(DISABLE_GC)
653 nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
656 #if defined(WITH_JRE_LAYOUT)
657 /* SUN also uses a buffer of 4096-bytes (strace is your friend). */
659 cacao_prefix = MNEW(char, 4096);
661 if (readlink("/proc/self/exe", cacao_prefix, 4095) == -1)
662 vm_abort("readlink failed: %s\n", strerror(errno));
664 /* get the path of the current executable */
666 cacao_prefix = dirname(cacao_prefix);
668 if ((strlen(cacao_prefix) + strlen("/..") + strlen("0")) > 4096)
669 vm_abort("libjvm name to long for buffer\n");
671 /* concatenate the library name */
673 strcat(cacao_prefix, "/..");
675 /* now set path to libjvm.so */
677 len = strlen(cacao_prefix) + strlen("/lib/libjvm") + strlen("0");
679 cacao_libjvm = MNEW(char, len);
680 strcpy(cacao_libjvm, cacao_prefix);
681 strcat(cacao_libjvm, "/lib/libjvm");
683 /* and finally set the path to GNU Classpath libraries */
685 len = strlen(cacao_prefix) + strlen("/lib/classpath") + strlen("0");
687 classpath_libdir = MNEW(char, len);
688 strcpy(classpath_libdir, cacao_prefix);
689 strcat(classpath_libdir, "/lib/classpath");
691 cacao_prefix = CACAO_PREFIX;
692 cacao_libjvm = CACAO_LIBDIR"/libjvm";
693 classpath_libdir = CLASSPATH_LIBDIR"/classpath";
696 /* set the bootclasspath */
698 cp = getenv("BOOTCLASSPATH");
701 _Jv_bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
702 strcpy(_Jv_bootclasspath, cp);
705 #if defined(WITH_JRE_LAYOUT)
707 strlen(cacao_prefix) +
708 strlen("/share/cacao/vm.zip") +
710 strlen(cacao_prefix) +
711 strlen("/share/classpath/glibj.zip") +
714 _Jv_bootclasspath = MNEW(char, len);
715 strcat(_Jv_bootclasspath, cacao_prefix);
716 strcat(_Jv_bootclasspath, "/share/cacao/vm.zip");
717 strcat(_Jv_bootclasspath, ":");
718 strcat(_Jv_bootclasspath, cacao_prefix);
719 strcat(_Jv_bootclasspath, "/share/classpath/glibj.zip");
722 strlen(CACAO_VM_ZIP) +
724 strlen(CLASSPATH_GLIBJ_ZIP) +
727 _Jv_bootclasspath = MNEW(char, len);
728 strcat(_Jv_bootclasspath, CACAO_VM_ZIP);
729 strcat(_Jv_bootclasspath, ":");
730 strcat(_Jv_bootclasspath, CLASSPATH_GLIBJ_ZIP);
734 /* set the classpath */
736 cp = getenv("CLASSPATH");
739 _Jv_classpath = MNEW(char, strlen(cp) + strlen("0"));
740 strcat(_Jv_classpath, cp);
743 _Jv_classpath = MNEW(char, strlen(".") + strlen("0"));
744 strcpy(_Jv_classpath, ".");
747 /* get and set java.library.path */
749 _Jv_java_library_path = getenv("LD_LIBRARY_PATH");
751 if (_Jv_java_library_path == NULL)
752 _Jv_java_library_path = "";
754 /* interpret the options **************************************************/
762 opt_heapmaxsize = HEAP_MAXSIZE;
763 opt_heapstartsize = HEAP_STARTSIZE;
764 opt_stacksize = STACK_SIZE;
767 #if defined(ENABLE_JVMTI)
768 /* initialize JVMTI related **********************************************/
772 /* initialize and fill properties before command-line handling */
774 if (!properties_init())
775 vm_abort("properties_init failed");
777 /* iterate over all passed options */
779 while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
793 #if SIZEOF_VOID_P == 8
794 puts("Running a 32-bit JVM is not supported on this platform.");
800 #if SIZEOF_VOID_P == 4
801 puts("Running a 64-bit JVM is not supported on this platform.");
807 /* forget old classpath and set the argument as new classpath */
808 MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
810 _Jv_classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
811 strcpy(_Jv_classpath, opt_arg);
815 for (i = 0; i < strlen(opt_arg); i++) {
816 if (opt_arg[i] == '=') {
818 properties_add(opt_arg, opt_arg + i + 1);
823 /* if no '=' is given, just create an empty property */
825 properties_add(opt_arg, "");
830 case OPT_BOOTCLASSPATH:
831 /* Forget default bootclasspath and set the argument as
832 new boot classpath. */
834 MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
836 _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
837 strcpy(_Jv_bootclasspath, opt_arg);
840 case OPT_BOOTCLASSPATH_A:
841 /* append to end of bootclasspath */
843 len = strlen(_Jv_bootclasspath);
845 _Jv_bootclasspath = MREALLOC(_Jv_bootclasspath,
849 strlen(opt_arg) + strlen("0"));
851 strcat(_Jv_bootclasspath, ":");
852 strcat(_Jv_bootclasspath, opt_arg);
855 case OPT_BOOTCLASSPATH_P:
856 /* prepend in front of bootclasspath */
858 cp = _Jv_bootclasspath;
861 _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
864 strcpy(_Jv_bootclasspath, opt_arg);
865 strcat(_Jv_bootclasspath, ":");
866 strcat(_Jv_bootclasspath, cp);
868 MFREE(cp, char, len);
871 case OPT_BOOTCLASSPATH_C:
872 /* use as Java core library, but prepend VM interface classes */
874 MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
876 len = strlen(CACAO_VM_ZIP) +
881 _Jv_bootclasspath = MNEW(char, len);
883 strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
884 strcat(_Jv_bootclasspath, ":");
885 strcat(_Jv_bootclasspath, opt_arg);
888 #if defined(ENABLE_JVMTI)
890 /* this option exists only for compatibility reasons */
894 /* I don't know yet what Xnoagent should do. This is only for
895 compatiblity with eclipse - motse */
904 strlen(CACAO_LIBDIR) +
905 strlen("/libjdwp.so=") +
909 agentarg = MNEW(char, len);
911 strcpy(agentarg, CACAO_LIBDIR);
912 strcat(agentarg, "/libjdwp.so=");
913 strcat(agentarg, &opt_arg[1]);
930 c = opt_arg[strlen(opt_arg) - 1];
932 if ((c == 'k') || (c == 'K')) {
933 j = atoi(opt_arg) * 1024;
935 } else if ((c == 'm') || (c == 'M')) {
936 j = atoi(opt_arg) * 1024 * 1024;
943 else if (opt == OPT_MS)
944 opt_heapstartsize = j;
955 if (strcmp("class", opt_arg) == 0)
956 opt_verboseclass = true;
958 else if (strcmp("gc", opt_arg) == 0)
959 opt_verbosegc = true;
961 else if (strcmp("jni", opt_arg) == 0)
962 opt_verbosejni = true;
964 else if (strcmp("call", opt_arg) == 0)
965 opt_verbosecall = true;
967 else if (strcmp("jit", opt_arg) == 0) {
972 compileverbose = true;
974 else if (strcmp("exception", opt_arg) == 0)
975 opt_verboseexception = true;
978 opt_debugcolor = true;
981 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
983 opt_typecheckverbose = true;
992 case OPT_FULLVERSION:
996 case OPT_SHOWVERSION:
1004 #if defined(ENABLE_VERIFIER)
1014 #if defined(ENABLE_STATISTICS)
1016 opt_getcompilingtime = true;
1017 opt_getloadingtime = true;
1030 for (i = 0; i < strlen(opt_arg); i++) {
1031 switch (opt_arg[i]) {
1033 checkbounds = false;
1046 makeinitializations = false;
1053 #if !defined(NDEBUG)
1057 makeinitializations = false;
1062 opt_method = opt_arg;
1063 makeinitializations = false;
1067 opt_signature = opt_arg;
1071 case OPT_SHOW: /* Display options */
1072 for (i = 0; i < strlen(opt_arg); i++) {
1073 switch (opt_arg[i]) {
1075 showconstantpool = true;
1087 opt_showintermediate = true;
1088 compileverbose = true;
1091 #if defined(ENABLE_DISASSEMBLER)
1093 opt_showdisassemble = true;
1094 compileverbose = true;
1098 opt_shownops = true;
1102 opt_showexceptionstubs = true;
1106 opt_shownativestub = true;
1111 opt_showddatasegment = true;
1120 #if defined(ENABLE_LOOP)
1126 #if defined(ENABLE_INLINING)
1128 for (i = 0; i < strlen(opt_arg); i++) {
1129 switch (opt_arg[i]) {
1131 /* define in options.h; Used in main.c, jit.c
1132 & inline.c inlining is currently
1136 inlinevirtuals = true;
1139 inlineexceptions = true;
1142 inlineparamopt = true;
1145 inlineoutsiders = true;
1152 #endif /* defined(ENABLE_INLINING) */
1154 #if defined(ENABLE_IFCONV)
1160 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1175 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = true;
1179 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = false;
1182 #if defined(ENABLE_PROFILING)
1183 case OPT_PROF_OPTION:
1184 /* use <= to get the last \0 too */
1186 for (i = 0, j = 0; i <= strlen(opt_arg); i++) {
1187 if (opt_arg[i] == ',')
1190 if (opt_arg[i] == '\0') {
1191 if (strcmp("bb", opt_arg + j) == 0)
1195 printf("Unknown option: -Xprof:%s\n", opt_arg + j);
1199 /* set k to next char */
1212 #if defined(ENABLE_JIT)
1215 printf("-Xjit option not enabled.\n");
1221 #if defined(ENABLE_INTRP)
1224 printf("-Xint option not enabled.\n");
1229 #if defined(ENABLE_INTRP)
1230 case OPT_STATIC_SUPERS:
1231 opt_static_supers = atoi(opt_arg);
1234 case OPT_NO_DYNAMIC:
1235 opt_no_dynamic = true;
1238 case OPT_NO_REPLICATION:
1239 opt_no_replication = true;
1242 case OPT_NO_QUICKSUPER:
1243 opt_no_quicksuper = true;
1252 printf("Unknown option: %s\n",
1253 vm_args->options[opt_index].optionString);
1258 /* now re-set some of the properties that may have changed */
1260 if (!properties_postinit())
1261 vm_abort("properties_postinit failed");
1263 /* Now we have all options handled and we can print the version
1270 /* get the main class *****************************************************/
1272 if (opt_index < vm_args->nOptions) {
1273 mainstring = vm_args->options[opt_index++].optionString;
1275 /* Put the jar file into the classpath (if any). */
1277 if (opt_jar == true) {
1278 /* free old classpath */
1280 MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
1282 /* put jarfile into classpath */
1284 _Jv_classpath = MNEW(char, strlen(mainstring) + strlen("0"));
1286 strcpy(_Jv_classpath, mainstring);
1289 /* replace .'s with /'s in classname */
1291 for (i = strlen(mainstring) - 1; i >= 0; i--)
1292 if (mainstring[i] == '.')
1293 mainstring[i] = '/';
1297 #if defined(ENABLE_JVMTI)
1299 jvmti_set_phase(JVMTI_PHASE_ONLOAD);
1300 jvmti_agentload(agentarg, agentbypath, &handle, &libname);
1303 MFREE(agentarg, char, strlen(agentarg));
1305 jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
1311 /* initialize this JVM ****************************************************/
1313 vm_initializing = true;
1315 #if defined(ENABLE_THREADS)
1316 /* pre-initialize some core thread stuff, like the stopworldlock,
1317 thus this has to happen _before_ gc_init()!!! */
1322 /* initialize the garbage collector */
1324 gc_init(opt_heapmaxsize, opt_heapstartsize);
1326 #if defined(ENABLE_INTRP)
1327 /* Allocate main thread stack on the Java heap. */
1330 intrp_main_stack = GCMNEW(u1, opt_stacksize);
1331 MSET(intrp_main_stack, 0, u1, opt_stacksize);
1335 /* initialize the string hashtable stuff: lock (must be done
1336 _after_ threads_preinit) */
1339 throw_main_exception_exit();
1341 /* initialize the utf8 hashtable stuff: lock, often used utf8
1342 strings (must be done _after_ threads_preinit) */
1345 throw_main_exception_exit();
1347 /* initialize the classcache hashtable stuff: lock, hashtable
1348 (must be done _after_ threads_preinit) */
1350 if (!classcache_init())
1351 throw_main_exception_exit();
1353 /* initialize the loader with bootclasspath (must be done _after_
1357 throw_main_exception_exit();
1359 suck_add_from_property("java.endorsed.dirs");
1360 suck_add(_Jv_bootclasspath);
1362 /* initialize the memory subsystem (must be done _after_
1366 throw_main_exception_exit();
1368 /* initialize the finalizer stuff (must be done _after_
1371 if (!finalizer_init())
1372 throw_main_exception_exit();
1374 /* install architecture dependent signal handler used for exceptions */
1378 /* initialize the codegen subsystems */
1382 /* initializes jit compiler */
1386 /* machine dependent initialization */
1388 #if defined(ENABLE_JIT)
1389 # if defined(ENABLE_INTRP)
1399 /* initialize the loader subsystems (must be done _after_
1403 throw_main_exception_exit();
1406 throw_main_exception_exit();
1409 throw_main_exception_exit();
1411 if (!exceptions_init())
1412 throw_main_exception_exit();
1414 if (!builtin_init())
1415 throw_main_exception_exit();
1417 /* Initialize the JNI subsystem (must be done _before_
1418 threads_init, as threads_init can call JNI methods
1419 (e.g. NewGlobalRef). */
1422 throw_main_exception_exit();
1424 #if defined(ENABLE_THREADS)
1425 if (!threads_init())
1426 throw_main_exception_exit();
1429 #if defined(ENABLE_PROFILING)
1430 /* initialize profiling */
1432 if (!profile_init())
1433 throw_main_exception_exit();
1436 #if defined(ENABLE_THREADS)
1437 /* initialize recompilation */
1439 if (!recompile_init())
1440 throw_main_exception_exit();
1442 /* finally, start the finalizer thread */
1444 if (!finalizer_start_thread())
1445 throw_main_exception_exit();
1447 /* start the recompilation thread (must be done before the
1448 profiling thread) */
1450 if (!recompile_start_thread())
1451 throw_main_exception_exit();
1453 # if defined(ENABLE_PROFILING)
1454 /* start the profile sampling thread */
1457 /* if (!profile_start_thread()) */
1458 /* throw_main_exception_exit(); */
1462 #if defined(ENABLE_JVMTI)
1464 /* add agent library to native library hashtable */
1465 native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
1469 /* increment the number of VMs */
1473 /* initialization is done */
1475 vm_initializing = false;
1477 /* everything's ok */
1483 /* vm_run **********************************************************************
1485 Runs the main-method of the passed class.
1487 *******************************************************************************/
1489 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
1492 classinfo *mainclass;
1494 java_objectarray *oa;
1497 java_lang_String *s;
1501 #if !defined(NDEBUG)
1507 if (opt_method != NULL) {
1508 vm_compile_method();
1511 #endif /* !defined(NDEBUG) */
1513 /* should we run the main-method? */
1515 if (mainstring == NULL)
1518 /* set return value to OK */
1522 if (opt_jar == true)
1523 /* open jar file with java.util.jar.JarFile */
1524 mainstring = vm_get_mainclass_from_jar(mainstring);
1526 /* load the main class */
1528 mainutf = utf_new_char(mainstring);
1530 #if defined(ENABLE_JAVAME_CLDC1_1)
1531 if (!(mainclass = load_class_bootstrap(mainutf)))
1532 throw_main_exception_exit();
1534 if (!(mainclass = load_class_from_sysloader(mainutf)))
1535 throw_main_exception_exit();
1538 /* error loading class */
1540 if ((*exceptionptr != NULL) || (mainclass == NULL))
1541 throw_main_exception_exit();
1543 if (!link_class(mainclass))
1544 throw_main_exception_exit();
1546 /* find the `main' method of the main class */
1548 m = class_resolveclassmethod(mainclass,
1549 utf_new_char("main"),
1550 utf_new_char("([Ljava/lang/String;)V"),
1551 class_java_lang_Object,
1554 if (*exceptionptr) {
1555 throw_main_exception_exit();
1558 /* there is no main method or it isn't static */
1560 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
1561 *exceptionptr = NULL;
1564 new_exception_message(string_java_lang_NoSuchMethodError, "main");
1565 throw_main_exception_exit();
1568 /* build argument array */
1570 oalength = vm_args->nOptions - opt_index;
1572 oa = builtin_anewarray(oalength, class_java_lang_String);
1574 for (i = 0; i < oalength; i++) {
1575 u = utf_new_char(vm_args->options[opt_index + i].optionString);
1576 s = javastring_new(u);
1578 oa->data[i] = (java_objectheader *) s;
1581 #ifdef TYPEINFO_DEBUG_TEST
1582 /* test the typeinfo system */
1585 /*class_showmethods(currentThread->group->header.vftbl->class); */
1587 #if defined(ENABLE_JVMTI)
1588 jvmti_set_phase(JVMTI_PHASE_LIVE);
1591 /* increase total started thread count */
1593 _Jv_jvm->total_started_thread_count++;
1595 /* start the main thread */
1597 (void) vm_call_method(m, NULL, oa);
1599 /* exception occurred? */
1601 if (*exceptionptr) {
1602 throw_main_exception();
1606 /* unload the JavaVM */
1616 /* vm_destroy ******************************************************************
1618 Unloads a Java VM and reclaims its resources.
1620 *******************************************************************************/
1622 s4 vm_destroy(JavaVM *vm)
1624 #if defined(ENABLE_THREADS)
1625 threads_join_all_threads();
1628 /* everything's ok */
1634 /* vm_exit *********************************************************************
1636 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1638 *******************************************************************************/
1640 void vm_exit(s4 status)
1644 /* signal that we are exiting */
1648 assert(class_java_lang_System);
1649 assert(class_java_lang_System->state & CLASS_LOADED);
1651 #if defined(ENABLE_JVMTI)
1652 if (jvmti || (dbgcom!=NULL)) {
1653 jvmti_set_phase(JVMTI_PHASE_DEAD);
1654 if (jvmti) jvmti_agentunload();
1658 if (!link_class(class_java_lang_System))
1659 throw_main_exception_exit();
1661 /* call java.lang.System.exit(I)V */
1663 m = class_resolveclassmethod(class_java_lang_System,
1664 utf_new_char("exit"),
1666 class_java_lang_Object,
1670 throw_main_exception_exit();
1672 /* call the exit function with passed exit status */
1674 (void) vm_call_method(m, NULL, status);
1676 /* If we had an exception, just ignore the exception and exit with
1679 vm_shutdown(status);
1683 /* vm_shutdown *****************************************************************
1685 Terminates the system immediately without freeing memory explicitly
1686 (to be used only for abnormal termination).
1688 *******************************************************************************/
1690 void vm_shutdown(s4 status)
1693 #if defined(ENABLE_STATISTICS)
1694 || opt_getcompilingtime || opt_stat
1698 log_text("CACAO terminated by shutdown");
1699 dolog("Exit status: %d\n", (s4) status);
1703 #if defined(ENABLE_JVMTI)
1704 /* terminate cacaodbgserver */
1706 pthread_mutex_lock(&dbgcomlock);
1708 pthread_mutex_unlock(&dbgcomlock);
1709 jvmti_cacaodbgserver_quit();
1717 /* vm_exit_handler *************************************************************
1719 The exit_handler function is called upon program termination.
1721 ATTENTION: Don't free system resources here! Some threads may still
1722 be running as this is called from VMRuntime.exit(). The OS does the
1725 *******************************************************************************/
1727 void vm_exit_handler(void)
1729 #if !defined(NDEBUG)
1731 class_showmethods(mainclass);
1733 if (showconstantpool)
1734 class_showconstantpool(mainclass);
1739 # if defined(ENABLE_PROFILING)
1741 profile_printstats();
1743 #endif /* !defined(NDEBUG) */
1745 #if defined(ENABLE_RT_TIMING)
1746 rt_timing_print_time_stats(stderr);
1749 #if defined(ENABLE_CYCLES_STATS)
1750 builtin_print_cycles_stats(stderr);
1751 stacktrace_print_cycles_stats(stderr);
1755 #if defined(ENABLE_STATISTICS)
1756 || opt_getcompilingtime || opt_stat
1760 log_text("CACAO terminated");
1762 #if defined(ENABLE_STATISTICS)
1765 #ifdef TYPECHECK_STATISTICS
1766 typecheck_print_statistics(get_logfile());
1772 if (opt_getcompilingtime)
1774 #endif /* defined(ENABLE_STATISTICS) */
1776 /* vm_print_profile(stderr);*/
1780 /* vm_abort ********************************************************************
1782 Prints an error message and aborts the VM.
1784 *******************************************************************************/
1786 void vm_abort(const char *text, ...)
1790 /* print the log message */
1795 log_vprint(text, ap);
1800 /* now abort the VM */
1806 /* vm_get_mainclass_from_jar ***************************************************
1808 Gets the name of the main class from a JAR's manifest file.
1810 *******************************************************************************/
1812 static char *vm_get_mainclass_from_jar(char *mainstring)
1815 java_objectheader *o;
1817 java_lang_String *s;
1819 c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
1822 throw_main_exception_exit();
1824 /* create JarFile object */
1829 throw_main_exception_exit();
1832 m = class_resolveclassmethod(c,
1834 utf_java_lang_String__void,
1835 class_java_lang_Object,
1839 throw_main_exception_exit();
1841 s = javastring_new_from_ascii(mainstring);
1843 (void) vm_call_method(m, o, s);
1846 throw_main_exception_exit();
1848 /* get manifest object */
1850 m = class_resolveclassmethod(c,
1851 utf_new_char("getManifest"),
1852 utf_new_char("()Ljava/util/jar/Manifest;"),
1853 class_java_lang_Object,
1857 throw_main_exception_exit();
1859 o = vm_call_method(m, o);
1862 fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
1867 /* get Main Attributes */
1869 m = class_resolveclassmethod(o->vftbl->class,
1870 utf_new_char("getMainAttributes"),
1871 utf_new_char("()Ljava/util/jar/Attributes;"),
1872 class_java_lang_Object,
1876 throw_main_exception_exit();
1878 o = vm_call_method(m, o);
1881 fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
1886 /* get property Main-Class */
1888 m = class_resolveclassmethod(o->vftbl->class,
1889 utf_new_char("getValue"),
1890 utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
1891 class_java_lang_Object,
1895 throw_main_exception_exit();
1897 s = javastring_new_from_ascii("Main-Class");
1899 o = vm_call_method(m, o, s);
1902 throw_main_exception_exit();
1904 return javastring_tochar(o);
1908 /* vm_compile_all **************************************************************
1910 Compile all methods found in the bootclasspath.
1912 *******************************************************************************/
1914 #if !defined(NDEBUG)
1915 static void vm_compile_all(void)
1920 classcache_name_entry *nmen;
1921 classcache_class_entry *clsen;
1924 /* create all classes found in the bootclasspath */
1925 /* XXX currently only works with zip/jar's */
1927 loader_load_all_classes();
1929 /* link all classes */
1931 for (slot = 0; slot < hashtable_classcache.size; slot++) {
1932 nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
1934 for (; nmen; nmen = nmen->hashlink) {
1935 /* iterate over all class entries */
1937 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1938 c = clsen->classobj;
1943 if (!(c->state & CLASS_LINKED)) {
1944 if (!link_class(c)) {
1945 fprintf(stderr, "Error linking: ");
1946 utf_fprint_printable_ascii_classname(stderr, c->name);
1947 fprintf(stderr, "\n");
1949 /* print out exception and cause */
1951 exceptions_print_exception(*exceptionptr);
1953 /* goto next class */
1959 /* compile all class methods */
1961 for (i = 0; i < c->methodscount; i++) {
1962 m = &(c->methods[i]);
1964 if (m->jcode != NULL) {
1965 if (!jit_compile(m)) {
1966 fprintf(stderr, "Error compiling: ");
1967 utf_fprint_printable_ascii_classname(stderr, c->name);
1968 fprintf(stderr, ".");
1969 utf_fprint_printable_ascii(stderr, m->name);
1970 utf_fprint_printable_ascii(stderr, m->descriptor);
1971 fprintf(stderr, "\n");
1973 /* print out exception and cause */
1975 exceptions_print_exception(*exceptionptr);
1983 #endif /* !defined(NDEBUG) */
1986 /* vm_compile_method ***********************************************************
1988 Compile a specific method.
1990 *******************************************************************************/
1992 #if !defined(NDEBUG)
1993 static void vm_compile_method(void)
1997 /* create, load and link the main class */
1999 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
2000 throw_main_exception_exit();
2002 if (!link_class(mainclass))
2003 throw_main_exception_exit();
2005 if (opt_signature != NULL) {
2006 m = class_resolveclassmethod(mainclass,
2007 utf_new_char(opt_method),
2008 utf_new_char(opt_signature),
2013 m = class_resolveclassmethod(mainclass,
2014 utf_new_char(opt_method),
2021 char message[MAXLOGTEXT];
2022 sprintf(message, "%s%s", opt_method,
2023 opt_signature ? opt_signature : "");
2026 new_exception_message(string_java_lang_NoSuchMethodException,
2029 throw_main_exception_exit();
2034 #endif /* !defined(NDEBUG) */
2037 /* vm_vmargs_from_valist *******************************************************
2041 *******************************************************************************/
2043 static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
2044 vm_arg *vmargs, va_list ap)
2046 typedesc *paramtypes;
2049 paramtypes = m->parseddesc->paramtypes;
2051 /* if method is non-static fill first block and skip `this' pointer */
2056 /* the `this' pointer */
2057 vmargs[0].type = TYPE_ADR;
2058 vmargs[0].data.l = (u8) (ptrint) o;
2064 for (; i < m->parseddesc->paramcount; i++, paramtypes++) {
2065 switch (paramtypes->decltype) {
2066 /* primitive types */
2067 case PRIMITIVETYPE_BOOLEAN:
2068 case PRIMITIVETYPE_BYTE:
2069 case PRIMITIVETYPE_CHAR:
2070 case PRIMITIVETYPE_SHORT:
2071 case PRIMITIVETYPE_INT:
2072 vmargs[i].type = TYPE_INT;
2073 vmargs[i].data.l = (s8) va_arg(ap, s4);
2076 case PRIMITIVETYPE_LONG:
2077 vmargs[i].type = TYPE_LNG;
2078 vmargs[i].data.l = (s8) va_arg(ap, s8);
2081 case PRIMITIVETYPE_FLOAT:
2082 vmargs[i].type = TYPE_FLT;
2083 #if defined(__ALPHA__)
2084 /* this keeps the assembler function much simpler */
2086 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2088 vmargs[i].data.f = (jfloat) va_arg(ap, jdouble);
2092 case PRIMITIVETYPE_DOUBLE:
2093 vmargs[i].type = TYPE_DBL;
2094 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2098 vmargs[i].type = TYPE_ADR;
2099 vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*);
2106 /* vm_vmargs_from_jvalue *******************************************************
2110 *******************************************************************************/
2112 static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
2113 vm_arg *vmargs, jvalue *args)
2115 typedesc *paramtypes;
2119 paramtypes = m->parseddesc->paramtypes;
2121 /* if method is non-static fill first block and skip `this' pointer */
2126 /* the `this' pointer */
2127 vmargs[0].type = TYPE_ADR;
2128 vmargs[0].data.l = (u8) (ptrint) o;
2134 for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) {
2135 switch (paramtypes->decltype) {
2136 /* primitive types */
2137 case PRIMITIVETYPE_BOOLEAN:
2138 case PRIMITIVETYPE_BYTE:
2139 case PRIMITIVETYPE_CHAR:
2140 case PRIMITIVETYPE_SHORT:
2141 case PRIMITIVETYPE_INT:
2142 vmargs[i].type = TYPE_INT;
2143 vmargs[i].data.l = (s8) args[j].i;
2146 case PRIMITIVETYPE_LONG:
2147 vmargs[i].type = TYPE_LNG;
2148 vmargs[i].data.l = (s8) args[j].j;
2151 case PRIMITIVETYPE_FLOAT:
2152 vmargs[i].type = TYPE_FLT;
2153 #if defined(__ALPHA__)
2154 /* this keeps the assembler function much simpler */
2156 vmargs[i].data.d = (jdouble) args[j].f;
2158 vmargs[i].data.f = args[j].f;
2162 case PRIMITIVETYPE_DOUBLE:
2163 vmargs[i].type = TYPE_DBL;
2164 vmargs[i].data.d = args[j].d;
2168 vmargs[i].type = TYPE_ADR;
2169 vmargs[i].data.l = (u8) (ptrint) args[j].l;
2176 /* vm_call_method **************************************************************
2178 Calls a Java method with a variable number of arguments and returns
2181 *******************************************************************************/
2183 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
2186 java_objectheader *ro;
2189 ro = vm_call_method_valist(m, o, ap);
2196 /* vm_call_method_valist *******************************************************
2198 Calls a Java method with a variable number of arguments, passed via
2199 a va_list, and returns an address.
2201 *******************************************************************************/
2203 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
2208 java_objectheader *ro;
2211 /* mark start of dump memory area */
2213 dumpsize = dump_size();
2215 /* get number of Java method arguments */
2217 vmargscount = m->parseddesc->paramcount;
2219 /* allocate vm_arg array */
2221 vmargs = DMNEW(vm_arg, vmargscount);
2223 /* fill the vm_arg array from a va_list */
2225 vm_vmargs_from_valist(m, o, vmargs, ap);
2227 /* call the Java method */
2229 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2231 /* release dump area */
2233 dump_release(dumpsize);
2239 /* vm_call_method_jvalue *******************************************************
2241 Calls a Java method with a variable number of arguments, passed via
2242 a jvalue array, and returns an address.
2244 *******************************************************************************/
2246 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
2251 java_objectheader *ro;
2254 /* mark start of dump memory area */
2256 dumpsize = dump_size();
2258 /* get number of Java method arguments */
2260 vmargscount = m->parseddesc->paramcount;
2262 /* allocate vm_arg array */
2264 vmargs = DMNEW(vm_arg, vmargscount);
2266 /* fill the vm_arg array from a va_list */
2268 vm_vmargs_from_jvalue(m, o, vmargs, args);
2270 /* call the Java method */
2272 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2274 /* release dump area */
2276 dump_release(dumpsize);
2282 /* vm_call_method_vmarg ********************************************************
2284 Calls a Java method with a variable number of arguments, passed via
2285 a vm_arg array, and returns an address.
2287 *******************************************************************************/
2289 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
2292 java_objectheader *o;
2294 #if defined(ENABLE_JIT)
2295 # if defined(ENABLE_INTRP)
2297 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2300 o = asm_vm_call_method(m, vmargscount, vmargs);
2302 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2309 /* vm_call_method_int **********************************************************
2311 Calls a Java method with a variable number of arguments and returns
2314 *******************************************************************************/
2316 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
2322 i = vm_call_method_int_valist(m, o, ap);
2329 /* vm_call_method_int_valist ***************************************************
2331 Calls a Java method with a variable number of arguments, passed via
2332 a va_list, and returns an integer (s4).
2334 *******************************************************************************/
2336 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
2343 /* mark start of dump memory area */
2345 dumpsize = dump_size();
2347 /* get number of Java method arguments */
2349 vmargscount = m->parseddesc->paramcount;
2351 /* allocate vm_arg array */
2353 vmargs = DMNEW(vm_arg, vmargscount);
2355 /* fill the vm_arg array from a va_list */
2357 vm_vmargs_from_valist(m, o, vmargs, ap);
2359 /* call the Java method */
2361 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2363 /* release dump area */
2365 dump_release(dumpsize);
2371 /* vm_call_method_int_jvalue ***************************************************
2373 Calls a Java method with a variable number of arguments, passed via
2374 a jvalue array, and returns an integer (s4).
2376 *******************************************************************************/
2378 s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2385 /* mark start of dump memory area */
2387 dumpsize = dump_size();
2389 /* get number of Java method arguments */
2391 vmargscount = m->parseddesc->paramcount;
2393 /* allocate vm_arg array */
2395 vmargs = DMNEW(vm_arg, vmargscount);
2397 /* fill the vm_arg array from a va_list */
2399 vm_vmargs_from_jvalue(m, o, vmargs, args);
2401 /* call the Java method */
2403 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2405 /* release dump area */
2407 dump_release(dumpsize);
2413 /* vm_call_method_int_vmarg ****************************************************
2415 Calls a Java method with a variable number of arguments, passed via
2416 a vm_arg array, and returns an integer (s4).
2418 *******************************************************************************/
2420 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2424 #if defined(ENABLE_JIT)
2425 # if defined(ENABLE_INTRP)
2427 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2430 i = asm_vm_call_method_int(m, vmargscount, vmargs);
2432 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2439 /* vm_call_method_long *********************************************************
2441 Calls a Java method with a variable number of arguments and returns
2444 *******************************************************************************/
2446 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
2452 l = vm_call_method_long_valist(m, o, ap);
2459 /* vm_call_method_long_valist **************************************************
2461 Calls a Java method with a variable number of arguments, passed via
2462 a va_list, and returns a long (s8).
2464 *******************************************************************************/
2466 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
2473 /* mark start of dump memory area */
2475 dumpsize = dump_size();
2477 /* get number of Java method arguments */
2479 vmargscount = m->parseddesc->paramcount;
2481 /* allocate vm_arg array */
2483 vmargs = DMNEW(vm_arg, vmargscount);
2485 /* fill the vm_arg array from a va_list */
2487 vm_vmargs_from_valist(m, o, vmargs, ap);
2489 /* call the Java method */
2491 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2493 /* release dump area */
2495 dump_release(dumpsize);
2501 /* vm_call_method_long_jvalue **************************************************
2503 Calls a Java method with a variable number of arguments, passed via
2504 a jvalue array, and returns a long (s8).
2506 *******************************************************************************/
2508 s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2515 /* mark start of dump memory area */
2517 dumpsize = dump_size();
2519 /* get number of Java method arguments */
2521 vmargscount = m->parseddesc->paramcount;
2523 /* allocate vm_arg array */
2525 vmargs = DMNEW(vm_arg, vmargscount);
2527 /* fill the vm_arg array from a va_list */
2529 vm_vmargs_from_jvalue(m, o, vmargs, args);
2531 /* call the Java method */
2533 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2535 /* release dump area */
2537 dump_release(dumpsize);
2543 /* vm_call_method_long_vmarg ***************************************************
2545 Calls a Java method with a variable number of arguments, passed via
2546 a vm_arg array, and returns a long (s8).
2548 *******************************************************************************/
2550 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2554 #if defined(ENABLE_JIT)
2555 # if defined(ENABLE_INTRP)
2557 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2560 l = asm_vm_call_method_long(m, vmargscount, vmargs);
2562 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2569 /* vm_call_method_float ********************************************************
2571 Calls a Java method with a variable number of arguments and returns
2574 *******************************************************************************/
2576 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
2582 f = vm_call_method_float_valist(m, o, ap);
2589 /* vm_call_method_float_valist *************************************************
2591 Calls a Java method with a variable number of arguments, passed via
2592 a va_list, and returns a float.
2594 *******************************************************************************/
2596 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
2604 /* mark start of dump memory area */
2606 dumpsize = dump_size();
2608 /* get number of Java method arguments */
2610 vmargscount = m->parseddesc->paramcount;
2612 /* allocate vm_arg array */
2614 vmargs = DMNEW(vm_arg, vmargscount);
2616 /* fill the vm_arg array from a va_list */
2618 vm_vmargs_from_valist(m, o, vmargs, ap);
2620 /* call the Java method */
2622 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2624 /* release dump area */
2626 dump_release(dumpsize);
2632 /* vm_call_method_float_jvalue *************************************************
2634 Calls a Java method with a variable number of arguments, passed via
2635 a jvalue array, and returns a float.
2637 *******************************************************************************/
2639 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
2647 /* mark start of dump memory area */
2649 dumpsize = dump_size();
2651 /* get number of Java method arguments */
2653 vmargscount = m->parseddesc->paramcount;
2655 /* allocate vm_arg array */
2657 vmargs = DMNEW(vm_arg, vmargscount);
2659 /* fill the vm_arg array from a va_list */
2661 vm_vmargs_from_jvalue(m, o, vmargs, args);
2663 /* call the Java method */
2665 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2667 /* release dump area */
2669 dump_release(dumpsize);
2675 /* vm_call_method_float_vmarg **************************************************
2677 Calls a Java method with a variable number of arguments and returns
2680 *******************************************************************************/
2682 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2686 #if defined(ENABLE_JIT)
2687 # if defined(ENABLE_INTRP)
2689 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2692 f = asm_vm_call_method_float(m, vmargscount, vmargs);
2694 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2701 /* vm_call_method_double *******************************************************
2703 Calls a Java method with a variable number of arguments and returns
2706 *******************************************************************************/
2708 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
2714 d = vm_call_method_double_valist(m, o, ap);
2721 /* vm_call_method_double_valist ************************************************
2723 Calls a Java method with a variable number of arguments, passed via
2724 a va_list, and returns a double.
2726 *******************************************************************************/
2728 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
2736 /* mark start of dump memory area */
2738 dumpsize = dump_size();
2740 /* get number of Java method arguments */
2742 vmargscount = m->parseddesc->paramcount;
2744 /* allocate vm_arg array */
2746 vmargs = DMNEW(vm_arg, vmargscount);
2748 /* fill the vm_arg array from a va_list */
2750 vm_vmargs_from_valist(m, o, vmargs, ap);
2752 /* call the Java method */
2754 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2756 /* release dump area */
2758 dump_release(dumpsize);
2764 /* vm_call_method_double_jvalue ************************************************
2766 Calls a Java method with a variable number of arguments, passed via
2767 a jvalue array, and returns a double.
2769 *******************************************************************************/
2771 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
2779 /* mark start of dump memory area */
2781 dumpsize = dump_size();
2783 /* get number of Java method arguments */
2785 vmargscount = m->parseddesc->paramcount;
2787 /* allocate vm_arg array */
2789 vmargs = DMNEW(vm_arg, vmargscount);
2791 /* fill the vm_arg array from a va_list */
2793 vm_vmargs_from_jvalue(m, o, vmargs, args);
2795 /* call the Java method */
2797 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2799 /* release dump area */
2801 dump_release(dumpsize);
2807 /* vm_call_method_double_vmarg *************************************************
2809 Calls a Java method with a variable number of arguments and returns
2812 *******************************************************************************/
2814 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
2819 #if defined(ENABLE_JIT)
2820 # if defined(ENABLE_INTRP)
2822 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2825 d = asm_vm_call_method_double(m, vmargscount, vmargs);
2827 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2835 * These are local overrides for various environment variables in Emacs.
2836 * Please do not remove this and leave it at the end of the file, where
2837 * Emacs will automagically detect them.
2838 * ---------------------------------------------------------------------
2841 * indent-tabs-mode: t