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 properties before commandline handling */
774 if (!properties_init())
775 throw_cacao_exception_exit(string_java_lang_InternalError,
776 "Unable to init properties");
778 /* add some default properties */
780 properties_add("java.endorsed.dirs", ""CACAO_PREFIX"/jre/lib/endorsed");
782 /* iterate over all passed options */
784 while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
798 #if SIZEOF_VOID_P == 8
799 puts("Running a 32-bit JVM is not supported on this platform.");
805 #if SIZEOF_VOID_P == 4
806 puts("Running a 64-bit JVM is not supported on this platform.");
812 /* forget old classpath and set the argument as new classpath */
813 MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
815 _Jv_classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
816 strcpy(_Jv_classpath, opt_arg);
820 for (i = 0; i < strlen(opt_arg); i++) {
821 if (opt_arg[i] == '=') {
823 properties_add(opt_arg, opt_arg + i + 1);
828 /* if no '=' is given, just create an empty property */
830 properties_add(opt_arg, "");
835 case OPT_BOOTCLASSPATH:
836 /* Forget default bootclasspath and set the argument as
837 new boot classpath. */
839 MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
841 _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
842 strcpy(_Jv_bootclasspath, opt_arg);
845 case OPT_BOOTCLASSPATH_A:
846 /* append to end of bootclasspath */
848 len = strlen(_Jv_bootclasspath);
850 _Jv_bootclasspath = MREALLOC(_Jv_bootclasspath,
854 strlen(opt_arg) + strlen("0"));
856 strcat(_Jv_bootclasspath, ":");
857 strcat(_Jv_bootclasspath, opt_arg);
860 case OPT_BOOTCLASSPATH_P:
861 /* prepend in front of bootclasspath */
863 cp = _Jv_bootclasspath;
866 _Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
869 strcpy(_Jv_bootclasspath, opt_arg);
870 strcat(_Jv_bootclasspath, ":");
871 strcat(_Jv_bootclasspath, cp);
873 MFREE(cp, char, len);
876 case OPT_BOOTCLASSPATH_C:
877 /* use as Java core library, but prepend VM interface classes */
879 MFREE(_Jv_bootclasspath, char, strlen(_Jv_bootclasspath));
881 len = strlen(CACAO_VM_ZIP) +
886 _Jv_bootclasspath = MNEW(char, len);
888 strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
889 strcat(_Jv_bootclasspath, ":");
890 strcat(_Jv_bootclasspath, opt_arg);
893 #if defined(ENABLE_JVMTI)
895 /* this option exists only for compatibility reasons */
899 /* I don't know yet what Xnoagent should do. This is only for
900 compatiblity with eclipse - motse */
909 strlen(CACAO_LIBDIR) +
910 strlen("/libjdwp.so=") +
914 agentarg = MNEW(char, len);
916 strcpy(agentarg, CACAO_LIBDIR);
917 strcat(agentarg, "/libjdwp.so=");
918 strcat(agentarg, &opt_arg[1]);
935 c = opt_arg[strlen(opt_arg) - 1];
937 if ((c == 'k') || (c == 'K')) {
938 j = atoi(opt_arg) * 1024;
940 } else if ((c == 'm') || (c == 'M')) {
941 j = atoi(opt_arg) * 1024 * 1024;
948 else if (opt == OPT_MS)
949 opt_heapstartsize = j;
960 if (strcmp("class", opt_arg) == 0)
961 opt_verboseclass = true;
963 else if (strcmp("gc", opt_arg) == 0)
964 opt_verbosegc = true;
966 else if (strcmp("jni", opt_arg) == 0)
967 opt_verbosejni = true;
969 else if (strcmp("call", opt_arg) == 0)
970 opt_verbosecall = true;
972 else if (strcmp("jit", opt_arg) == 0) {
977 compileverbose = true;
979 else if (strcmp("exception", opt_arg) == 0)
980 opt_verboseexception = true;
983 opt_debugcolor = true;
986 #if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE)
988 opt_typecheckverbose = true;
997 case OPT_FULLVERSION:
1001 case OPT_SHOWVERSION:
1009 #if defined(ENABLE_VERIFIER)
1019 #if defined(ENABLE_STATISTICS)
1021 opt_getcompilingtime = true;
1022 opt_getloadingtime = true;
1035 for (i = 0; i < strlen(opt_arg); i++) {
1036 switch (opt_arg[i]) {
1038 checkbounds = false;
1051 makeinitializations = false;
1058 #if !defined(NDEBUG)
1062 makeinitializations = false;
1067 opt_method = opt_arg;
1068 makeinitializations = false;
1072 opt_signature = opt_arg;
1076 case OPT_SHOW: /* Display options */
1077 for (i = 0; i < strlen(opt_arg); i++) {
1078 switch (opt_arg[i]) {
1080 showconstantpool = true;
1092 opt_showintermediate = true;
1093 compileverbose = true;
1096 #if defined(ENABLE_DISASSEMBLER)
1098 opt_showdisassemble = true;
1099 compileverbose = true;
1103 opt_shownops = true;
1107 opt_showexceptionstubs = true;
1111 opt_shownativestub = true;
1116 opt_showddatasegment = true;
1125 #if defined(ENABLE_LOOP)
1131 #if defined(ENABLE_INLINING)
1133 for (i = 0; i < strlen(opt_arg); i++) {
1134 switch (opt_arg[i]) {
1136 /* define in options.h; Used in main.c, jit.c
1137 & inline.c inlining is currently
1141 inlinevirtuals = true;
1144 inlineexceptions = true;
1147 inlineparamopt = true;
1150 inlineoutsiders = true;
1157 #endif /* defined(ENABLE_INLINING) */
1159 #if defined(ENABLE_IFCONV)
1165 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1180 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = true;
1184 _Jv_jvm->Java_java_lang_VMClassLoader_defaultAssertionStatus = false;
1187 #if defined(ENABLE_PROFILING)
1188 case OPT_PROF_OPTION:
1189 /* use <= to get the last \0 too */
1191 for (i = 0, j = 0; i <= strlen(opt_arg); i++) {
1192 if (opt_arg[i] == ',')
1195 if (opt_arg[i] == '\0') {
1196 if (strcmp("bb", opt_arg + j) == 0)
1200 printf("Unknown option: -Xprof:%s\n", opt_arg + j);
1204 /* set k to next char */
1217 #if defined(ENABLE_JIT)
1220 printf("-Xjit option not enabled.\n");
1226 #if defined(ENABLE_INTRP)
1229 printf("-Xint option not enabled.\n");
1234 #if defined(ENABLE_INTRP)
1235 case OPT_STATIC_SUPERS:
1236 opt_static_supers = atoi(opt_arg);
1239 case OPT_NO_DYNAMIC:
1240 opt_no_dynamic = true;
1243 case OPT_NO_REPLICATION:
1244 opt_no_replication = true;
1247 case OPT_NO_QUICKSUPER:
1248 opt_no_quicksuper = true;
1257 printf("Unknown option: %s\n",
1258 vm_args->options[opt_index].optionString);
1264 /* Now we have all options handled and we can print the version
1271 /* get the main class *****************************************************/
1273 if (opt_index < vm_args->nOptions) {
1274 mainstring = vm_args->options[opt_index++].optionString;
1276 /* Put the jar file into the classpath (if any). */
1278 if (opt_jar == true) {
1279 /* free old classpath */
1281 MFREE(_Jv_classpath, char, strlen(_Jv_classpath));
1283 /* put jarfile into classpath */
1285 _Jv_classpath = MNEW(char, strlen(mainstring) + strlen("0"));
1287 strcpy(_Jv_classpath, mainstring);
1290 /* replace .'s with /'s in classname */
1292 for (i = strlen(mainstring) - 1; i >= 0; i--)
1293 if (mainstring[i] == '.')
1294 mainstring[i] = '/';
1298 #if defined(ENABLE_JVMTI)
1300 jvmti_set_phase(JVMTI_PHASE_ONLOAD);
1301 jvmti_agentload(agentarg, agentbypath, &handle, &libname);
1304 MFREE(agentarg, char, strlen(agentarg));
1306 jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL);
1312 /* initialize this JVM ****************************************************/
1314 vm_initializing = true;
1316 #if defined(ENABLE_THREADS)
1317 /* pre-initialize some core thread stuff, like the stopworldlock,
1318 thus this has to happen _before_ gc_init()!!! */
1323 /* initialize the garbage collector */
1325 gc_init(opt_heapmaxsize, opt_heapstartsize);
1327 #if defined(ENABLE_INTRP)
1328 /* Allocate main thread stack on the Java heap. */
1331 intrp_main_stack = GCMNEW(u1, opt_stacksize);
1332 MSET(intrp_main_stack, 0, u1, opt_stacksize);
1336 /* initialize the string hashtable stuff: lock (must be done
1337 _after_ threads_preinit) */
1340 throw_main_exception_exit();
1342 /* initialize the utf8 hashtable stuff: lock, often used utf8
1343 strings (must be done _after_ threads_preinit) */
1346 throw_main_exception_exit();
1348 /* initialize the classcache hashtable stuff: lock, hashtable
1349 (must be done _after_ threads_preinit) */
1351 if (!classcache_init())
1352 throw_main_exception_exit();
1354 /* initialize the loader with bootclasspath (must be done _after_
1358 throw_main_exception_exit();
1360 suck_add_from_property("java.endorsed.dirs");
1361 suck_add(_Jv_bootclasspath);
1363 /* initialize the memory subsystem (must be done _after_
1367 throw_main_exception_exit();
1369 /* initialize the finalizer stuff (must be done _after_
1372 if (!finalizer_init())
1373 throw_main_exception_exit();
1375 /* install architecture dependent signal handler used for exceptions */
1379 /* initialize the codegen subsystems */
1383 /* initializes jit compiler */
1387 /* machine dependent initialization */
1389 #if defined(ENABLE_JIT)
1390 # if defined(ENABLE_INTRP)
1400 /* initialize the loader subsystems (must be done _after_
1404 throw_main_exception_exit();
1407 throw_main_exception_exit();
1410 throw_main_exception_exit();
1412 if (!exceptions_init())
1413 throw_main_exception_exit();
1415 if (!builtin_init())
1416 throw_main_exception_exit();
1418 /* Initialize the JNI subsystem (must be done _before_
1419 threads_init, as threads_init can call JNI methods
1420 (e.g. NewGlobalRef). */
1423 throw_main_exception_exit();
1425 #if defined(ENABLE_THREADS)
1426 if (!threads_init())
1427 throw_main_exception_exit();
1430 /* That's important, otherwise we get into trouble, if the Runtime
1431 static initializer is called before (circular dependency. This
1432 is with classpath 0.09. Another important thing is, that this
1433 has to happen after initThreads!!! */
1435 if (!initialize_class(class_java_lang_System))
1436 throw_main_exception_exit();
1438 #if defined(ENABLE_PROFILING)
1439 /* initialize profiling */
1441 if (!profile_init())
1442 throw_main_exception_exit();
1445 #if defined(ENABLE_THREADS)
1446 /* initialize recompilation */
1448 if (!recompile_init())
1449 throw_main_exception_exit();
1451 /* finally, start the finalizer thread */
1453 if (!finalizer_start_thread())
1454 throw_main_exception_exit();
1456 /* start the recompilation thread (must be done before the
1457 profiling thread) */
1459 if (!recompile_start_thread())
1460 throw_main_exception_exit();
1462 # if defined(ENABLE_PROFILING)
1463 /* start the profile sampling thread */
1466 /* if (!profile_start_thread()) */
1467 /* throw_main_exception_exit(); */
1471 #if defined(ENABLE_JVMTI)
1473 /* add agent library to native library hashtable */
1474 native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle);
1478 /* increment the number of VMs */
1482 /* initialization is done */
1484 vm_initializing = false;
1486 /* everything's ok */
1492 /* vm_run **********************************************************************
1494 Runs the main-method of the passed class.
1496 *******************************************************************************/
1498 void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args)
1501 classinfo *mainclass;
1503 java_objectarray *oa;
1506 java_lang_String *s;
1510 #if !defined(NDEBUG)
1516 if (opt_method != NULL) {
1517 vm_compile_method();
1520 #endif /* !defined(NDEBUG) */
1522 /* should we run the main-method? */
1524 if (mainstring == NULL)
1527 /* set return value to OK */
1531 if (opt_jar == true)
1532 /* open jar file with java.util.jar.JarFile */
1533 mainstring = vm_get_mainclass_from_jar(mainstring);
1535 /* load the main class */
1537 mainutf = utf_new_char(mainstring);
1539 if (!(mainclass = load_class_from_sysloader(mainutf)))
1540 throw_main_exception_exit();
1542 /* error loading class */
1544 if ((*exceptionptr != NULL) || (mainclass == NULL))
1545 throw_main_exception_exit();
1547 if (!link_class(mainclass))
1548 throw_main_exception_exit();
1550 /* find the `main' method of the main class */
1552 m = class_resolveclassmethod(mainclass,
1553 utf_new_char("main"),
1554 utf_new_char("([Ljava/lang/String;)V"),
1555 class_java_lang_Object,
1558 if (*exceptionptr) {
1559 throw_main_exception_exit();
1562 /* there is no main method or it isn't static */
1564 if ((m == NULL) || !(m->flags & ACC_STATIC)) {
1565 *exceptionptr = NULL;
1568 new_exception_message(string_java_lang_NoSuchMethodError, "main");
1569 throw_main_exception_exit();
1572 /* build argument array */
1574 oalength = vm_args->nOptions - opt_index;
1576 oa = builtin_anewarray(oalength, class_java_lang_String);
1578 for (i = 0; i < oalength; i++) {
1579 u = utf_new_char(vm_args->options[opt_index + i].optionString);
1580 s = javastring_new(u);
1582 oa->data[i] = (java_objectheader *) s;
1585 #ifdef TYPEINFO_DEBUG_TEST
1586 /* test the typeinfo system */
1589 /*class_showmethods(currentThread->group->header.vftbl->class); */
1591 #if defined(ENABLE_JVMTI)
1592 jvmti_set_phase(JVMTI_PHASE_LIVE);
1595 /* increase total started thread count */
1597 _Jv_jvm->total_started_thread_count++;
1599 /* start the main thread */
1601 (void) vm_call_method(m, NULL, oa);
1603 /* exception occurred? */
1605 if (*exceptionptr) {
1606 throw_main_exception();
1610 /* unload the JavaVM */
1620 /* vm_destroy ******************************************************************
1622 Unloads a Java VM and reclaims its resources.
1624 *******************************************************************************/
1626 s4 vm_destroy(JavaVM *vm)
1628 #if defined(ENABLE_THREADS)
1629 threads_join_all_threads();
1632 /* everything's ok */
1638 /* vm_exit *********************************************************************
1640 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1642 *******************************************************************************/
1644 void vm_exit(s4 status)
1648 /* signal that we are exiting */
1652 assert(class_java_lang_System);
1653 assert(class_java_lang_System->state & CLASS_LOADED);
1655 #if defined(ENABLE_JVMTI)
1656 if (jvmti || (dbgcom!=NULL)) {
1657 jvmti_set_phase(JVMTI_PHASE_DEAD);
1658 if (jvmti) jvmti_agentunload();
1662 if (!link_class(class_java_lang_System))
1663 throw_main_exception_exit();
1665 /* call java.lang.System.exit(I)V */
1667 m = class_resolveclassmethod(class_java_lang_System,
1668 utf_new_char("exit"),
1670 class_java_lang_Object,
1674 throw_main_exception_exit();
1676 /* call the exit function with passed exit status */
1678 (void) vm_call_method(m, NULL, status);
1680 /* If we had an exception, just ignore the exception and exit with
1683 vm_shutdown(status);
1687 /* vm_shutdown *****************************************************************
1689 Terminates the system immediately without freeing memory explicitly
1690 (to be used only for abnormal termination).
1692 *******************************************************************************/
1694 void vm_shutdown(s4 status)
1697 #if defined(ENABLE_STATISTICS)
1698 || opt_getcompilingtime || opt_stat
1702 log_text("CACAO terminated by shutdown");
1703 dolog("Exit status: %d\n", (s4) status);
1707 #if defined(ENABLE_JVMTI)
1708 /* terminate cacaodbgserver */
1710 pthread_mutex_lock(&dbgcomlock);
1712 pthread_mutex_unlock(&dbgcomlock);
1713 jvmti_cacaodbgserver_quit();
1721 /* vm_exit_handler *************************************************************
1723 The exit_handler function is called upon program termination.
1725 ATTENTION: Don't free system resources here! Some threads may still
1726 be running as this is called from VMRuntime.exit(). The OS does the
1729 *******************************************************************************/
1731 void vm_exit_handler(void)
1733 #if !defined(NDEBUG)
1735 class_showmethods(mainclass);
1737 if (showconstantpool)
1738 class_showconstantpool(mainclass);
1743 # if defined(ENABLE_PROFILING)
1745 profile_printstats();
1747 #endif /* !defined(NDEBUG) */
1749 #if defined(ENABLE_RT_TIMING)
1750 rt_timing_print_time_stats(stderr);
1753 #if defined(ENABLE_CYCLES_STATS)
1754 builtin_print_cycles_stats(stderr);
1755 stacktrace_print_cycles_stats(stderr);
1759 #if defined(ENABLE_STATISTICS)
1760 || opt_getcompilingtime || opt_stat
1764 log_text("CACAO terminated");
1766 #if defined(ENABLE_STATISTICS)
1769 #ifdef TYPECHECK_STATISTICS
1770 typecheck_print_statistics(get_logfile());
1776 if (opt_getcompilingtime)
1778 #endif /* defined(ENABLE_STATISTICS) */
1780 /* vm_print_profile(stderr);*/
1784 /* vm_abort ********************************************************************
1786 Prints an error message and aborts the VM.
1788 *******************************************************************************/
1790 void vm_abort(const char *text, ...)
1794 /* print the log message */
1799 log_vprint(text, ap);
1804 /* now abort the VM */
1810 /* vm_get_mainclass_from_jar ***************************************************
1812 Gets the name of the main class from a JAR's manifest file.
1814 *******************************************************************************/
1816 static char *vm_get_mainclass_from_jar(char *mainstring)
1819 java_objectheader *o;
1821 java_lang_String *s;
1823 c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile"));
1826 throw_main_exception_exit();
1828 /* create JarFile object */
1833 throw_main_exception_exit();
1836 m = class_resolveclassmethod(c,
1838 utf_java_lang_String__void,
1839 class_java_lang_Object,
1843 throw_main_exception_exit();
1845 s = javastring_new_from_ascii(mainstring);
1847 (void) vm_call_method(m, o, s);
1850 throw_main_exception_exit();
1852 /* get manifest object */
1854 m = class_resolveclassmethod(c,
1855 utf_new_char("getManifest"),
1856 utf_new_char("()Ljava/util/jar/Manifest;"),
1857 class_java_lang_Object,
1861 throw_main_exception_exit();
1863 o = vm_call_method(m, o);
1866 fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
1871 /* get Main Attributes */
1873 m = class_resolveclassmethod(o->vftbl->class,
1874 utf_new_char("getMainAttributes"),
1875 utf_new_char("()Ljava/util/jar/Attributes;"),
1876 class_java_lang_Object,
1880 throw_main_exception_exit();
1882 o = vm_call_method(m, o);
1885 fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
1890 /* get property Main-Class */
1892 m = class_resolveclassmethod(o->vftbl->class,
1893 utf_new_char("getValue"),
1894 utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"),
1895 class_java_lang_Object,
1899 throw_main_exception_exit();
1901 s = javastring_new_from_ascii("Main-Class");
1903 o = vm_call_method(m, o, s);
1906 throw_main_exception_exit();
1908 return javastring_tochar(o);
1912 /* vm_compile_all **************************************************************
1914 Compile all methods found in the bootclasspath.
1916 *******************************************************************************/
1918 #if !defined(NDEBUG)
1919 static void vm_compile_all(void)
1924 classcache_name_entry *nmen;
1925 classcache_class_entry *clsen;
1928 /* create all classes found in the bootclasspath */
1929 /* XXX currently only works with zip/jar's */
1931 loader_load_all_classes();
1933 /* link all classes */
1935 for (slot = 0; slot < hashtable_classcache.size; slot++) {
1936 nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot];
1938 for (; nmen; nmen = nmen->hashlink) {
1939 /* iterate over all class entries */
1941 for (clsen = nmen->classes; clsen; clsen = clsen->next) {
1942 c = clsen->classobj;
1947 if (!(c->state & CLASS_LINKED)) {
1948 if (!link_class(c)) {
1949 fprintf(stderr, "Error linking: ");
1950 utf_fprint_printable_ascii_classname(stderr, c->name);
1951 fprintf(stderr, "\n");
1953 /* print out exception and cause */
1955 exceptions_print_exception(*exceptionptr);
1957 /* goto next class */
1963 /* compile all class methods */
1965 for (i = 0; i < c->methodscount; i++) {
1966 m = &(c->methods[i]);
1968 if (m->jcode != NULL) {
1969 if (!jit_compile(m)) {
1970 fprintf(stderr, "Error compiling: ");
1971 utf_fprint_printable_ascii_classname(stderr, c->name);
1972 fprintf(stderr, ".");
1973 utf_fprint_printable_ascii(stderr, m->name);
1974 utf_fprint_printable_ascii(stderr, m->descriptor);
1975 fprintf(stderr, "\n");
1977 /* print out exception and cause */
1979 exceptions_print_exception(*exceptionptr);
1987 #endif /* !defined(NDEBUG) */
1990 /* vm_compile_method ***********************************************************
1992 Compile a specific method.
1994 *******************************************************************************/
1996 #if !defined(NDEBUG)
1997 static void vm_compile_method(void)
2001 /* create, load and link the main class */
2003 if (!(mainclass = load_class_bootstrap(utf_new_char(mainstring))))
2004 throw_main_exception_exit();
2006 if (!link_class(mainclass))
2007 throw_main_exception_exit();
2009 if (opt_signature != NULL) {
2010 m = class_resolveclassmethod(mainclass,
2011 utf_new_char(opt_method),
2012 utf_new_char(opt_signature),
2017 m = class_resolveclassmethod(mainclass,
2018 utf_new_char(opt_method),
2025 char message[MAXLOGTEXT];
2026 sprintf(message, "%s%s", opt_method,
2027 opt_signature ? opt_signature : "");
2030 new_exception_message(string_java_lang_NoSuchMethodException,
2033 throw_main_exception_exit();
2038 #endif /* !defined(NDEBUG) */
2041 /* vm_vmargs_from_valist *******************************************************
2045 *******************************************************************************/
2047 static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
2048 vm_arg *vmargs, va_list ap)
2050 typedesc *paramtypes;
2053 paramtypes = m->parseddesc->paramtypes;
2055 /* if method is non-static fill first block and skip `this' pointer */
2060 /* the `this' pointer */
2061 vmargs[0].type = TYPE_ADR;
2062 vmargs[0].data.l = (u8) (ptrint) o;
2068 for (; i < m->parseddesc->paramcount; i++, paramtypes++) {
2069 switch (paramtypes->decltype) {
2070 /* primitive types */
2071 case PRIMITIVETYPE_BOOLEAN:
2072 case PRIMITIVETYPE_BYTE:
2073 case PRIMITIVETYPE_CHAR:
2074 case PRIMITIVETYPE_SHORT:
2075 case PRIMITIVETYPE_INT:
2076 vmargs[i].type = TYPE_INT;
2077 vmargs[i].data.l = (s8) va_arg(ap, s4);
2080 case PRIMITIVETYPE_LONG:
2081 vmargs[i].type = TYPE_LNG;
2082 vmargs[i].data.l = (s8) va_arg(ap, s8);
2085 case PRIMITIVETYPE_FLOAT:
2086 vmargs[i].type = TYPE_FLT;
2087 #if defined(__ALPHA__)
2088 /* this keeps the assembler function much simpler */
2090 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2092 vmargs[i].data.f = (jfloat) va_arg(ap, jdouble);
2096 case PRIMITIVETYPE_DOUBLE:
2097 vmargs[i].type = TYPE_DBL;
2098 vmargs[i].data.d = (jdouble) va_arg(ap, jdouble);
2102 vmargs[i].type = TYPE_ADR;
2103 vmargs[i].data.l = (u8) (ptrint) va_arg(ap, void*);
2110 /* vm_vmargs_from_jvalue *******************************************************
2114 *******************************************************************************/
2116 static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
2117 vm_arg *vmargs, jvalue *args)
2119 typedesc *paramtypes;
2123 paramtypes = m->parseddesc->paramtypes;
2125 /* if method is non-static fill first block and skip `this' pointer */
2130 /* the `this' pointer */
2131 vmargs[0].type = TYPE_ADR;
2132 vmargs[0].data.l = (u8) (ptrint) o;
2138 for (j = 0; i < m->parseddesc->paramcount; i++, j++, paramtypes++) {
2139 switch (paramtypes->decltype) {
2140 /* primitive types */
2141 case PRIMITIVETYPE_BOOLEAN:
2142 case PRIMITIVETYPE_BYTE:
2143 case PRIMITIVETYPE_CHAR:
2144 case PRIMITIVETYPE_SHORT:
2145 case PRIMITIVETYPE_INT:
2146 vmargs[i].type = TYPE_INT;
2147 vmargs[i].data.l = (s8) args[j].i;
2150 case PRIMITIVETYPE_LONG:
2151 vmargs[i].type = TYPE_LNG;
2152 vmargs[i].data.l = (s8) args[j].j;
2155 case PRIMITIVETYPE_FLOAT:
2156 vmargs[i].type = TYPE_FLT;
2157 #if defined(__ALPHA__)
2158 /* this keeps the assembler function much simpler */
2160 vmargs[i].data.d = (jdouble) args[j].f;
2162 vmargs[i].data.f = args[j].f;
2166 case PRIMITIVETYPE_DOUBLE:
2167 vmargs[i].type = TYPE_DBL;
2168 vmargs[i].data.d = args[j].d;
2172 vmargs[i].type = TYPE_ADR;
2173 vmargs[i].data.l = (u8) (ptrint) args[j].l;
2180 /* vm_call_method **************************************************************
2182 Calls a Java method with a variable number of arguments and returns
2185 *******************************************************************************/
2187 java_objectheader *vm_call_method(methodinfo *m, java_objectheader *o, ...)
2190 java_objectheader *ro;
2193 ro = vm_call_method_valist(m, o, ap);
2200 /* vm_call_method_valist *******************************************************
2202 Calls a Java method with a variable number of arguments, passed via
2203 a va_list, and returns an address.
2205 *******************************************************************************/
2207 java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
2212 java_objectheader *ro;
2215 /* mark start of dump memory area */
2217 dumpsize = dump_size();
2219 /* get number of Java method arguments */
2221 vmargscount = m->parseddesc->paramcount;
2223 /* allocate vm_arg array */
2225 vmargs = DMNEW(vm_arg, vmargscount);
2227 /* fill the vm_arg array from a va_list */
2229 vm_vmargs_from_valist(m, o, vmargs, ap);
2231 /* call the Java method */
2233 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2235 /* release dump area */
2237 dump_release(dumpsize);
2243 /* vm_call_method_jvalue *******************************************************
2245 Calls a Java method with a variable number of arguments, passed via
2246 a jvalue array, and returns an address.
2248 *******************************************************************************/
2250 java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
2255 java_objectheader *ro;
2258 /* mark start of dump memory area */
2260 dumpsize = dump_size();
2262 /* get number of Java method arguments */
2264 vmargscount = m->parseddesc->paramcount;
2266 /* allocate vm_arg array */
2268 vmargs = DMNEW(vm_arg, vmargscount);
2270 /* fill the vm_arg array from a va_list */
2272 vm_vmargs_from_jvalue(m, o, vmargs, args);
2274 /* call the Java method */
2276 ro = vm_call_method_vmarg(m, vmargscount, vmargs);
2278 /* release dump area */
2280 dump_release(dumpsize);
2286 /* vm_call_method_vmarg ********************************************************
2288 Calls a Java method with a variable number of arguments, passed via
2289 a vm_arg array, and returns an address.
2291 *******************************************************************************/
2293 java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
2296 java_objectheader *o;
2298 #if defined(ENABLE_JIT)
2299 # if defined(ENABLE_INTRP)
2301 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2304 o = asm_vm_call_method(m, vmargscount, vmargs);
2306 o = intrp_asm_vm_call_method(m, vmargscount, vmargs);
2313 /* vm_call_method_int **********************************************************
2315 Calls a Java method with a variable number of arguments and returns
2318 *******************************************************************************/
2320 s4 vm_call_method_int(methodinfo *m, java_objectheader *o, ...)
2326 i = vm_call_method_int_valist(m, o, ap);
2333 /* vm_call_method_int_valist ***************************************************
2335 Calls a Java method with a variable number of arguments, passed via
2336 a va_list, and returns an integer (s4).
2338 *******************************************************************************/
2340 s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
2347 /* mark start of dump memory area */
2349 dumpsize = dump_size();
2351 /* get number of Java method arguments */
2353 vmargscount = m->parseddesc->paramcount;
2355 /* allocate vm_arg array */
2357 vmargs = DMNEW(vm_arg, vmargscount);
2359 /* fill the vm_arg array from a va_list */
2361 vm_vmargs_from_valist(m, o, vmargs, ap);
2363 /* call the Java method */
2365 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2367 /* release dump area */
2369 dump_release(dumpsize);
2375 /* vm_call_method_int_jvalue ***************************************************
2377 Calls a Java method with a variable number of arguments, passed via
2378 a jvalue array, and returns an integer (s4).
2380 *******************************************************************************/
2382 s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2389 /* mark start of dump memory area */
2391 dumpsize = dump_size();
2393 /* get number of Java method arguments */
2395 vmargscount = m->parseddesc->paramcount;
2397 /* allocate vm_arg array */
2399 vmargs = DMNEW(vm_arg, vmargscount);
2401 /* fill the vm_arg array from a va_list */
2403 vm_vmargs_from_jvalue(m, o, vmargs, args);
2405 /* call the Java method */
2407 i = vm_call_method_int_vmarg(m, vmargscount, vmargs);
2409 /* release dump area */
2411 dump_release(dumpsize);
2417 /* vm_call_method_int_vmarg ****************************************************
2419 Calls a Java method with a variable number of arguments, passed via
2420 a vm_arg array, and returns an integer (s4).
2422 *******************************************************************************/
2424 s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2428 #if defined(ENABLE_JIT)
2429 # if defined(ENABLE_INTRP)
2431 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2434 i = asm_vm_call_method_int(m, vmargscount, vmargs);
2436 i = intrp_asm_vm_call_method_int(m, vmargscount, vmargs);
2443 /* vm_call_method_long *********************************************************
2445 Calls a Java method with a variable number of arguments and returns
2448 *******************************************************************************/
2450 s8 vm_call_method_long(methodinfo *m, java_objectheader *o, ...)
2456 l = vm_call_method_long_valist(m, o, ap);
2463 /* vm_call_method_long_valist **************************************************
2465 Calls a Java method with a variable number of arguments, passed via
2466 a va_list, and returns a long (s8).
2468 *******************************************************************************/
2470 s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
2477 /* mark start of dump memory area */
2479 dumpsize = dump_size();
2481 /* get number of Java method arguments */
2483 vmargscount = m->parseddesc->paramcount;
2485 /* allocate vm_arg array */
2487 vmargs = DMNEW(vm_arg, vmargscount);
2489 /* fill the vm_arg array from a va_list */
2491 vm_vmargs_from_valist(m, o, vmargs, ap);
2493 /* call the Java method */
2495 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2497 /* release dump area */
2499 dump_release(dumpsize);
2505 /* vm_call_method_long_jvalue **************************************************
2507 Calls a Java method with a variable number of arguments, passed via
2508 a jvalue array, and returns a long (s8).
2510 *******************************************************************************/
2512 s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o, jvalue *args)
2519 /* mark start of dump memory area */
2521 dumpsize = dump_size();
2523 /* get number of Java method arguments */
2525 vmargscount = m->parseddesc->paramcount;
2527 /* allocate vm_arg array */
2529 vmargs = DMNEW(vm_arg, vmargscount);
2531 /* fill the vm_arg array from a va_list */
2533 vm_vmargs_from_jvalue(m, o, vmargs, args);
2535 /* call the Java method */
2537 l = vm_call_method_long_vmarg(m, vmargscount, vmargs);
2539 /* release dump area */
2541 dump_release(dumpsize);
2547 /* vm_call_method_long_vmarg ***************************************************
2549 Calls a Java method with a variable number of arguments, passed via
2550 a vm_arg array, and returns a long (s8).
2552 *******************************************************************************/
2554 s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2558 #if defined(ENABLE_JIT)
2559 # if defined(ENABLE_INTRP)
2561 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2564 l = asm_vm_call_method_long(m, vmargscount, vmargs);
2566 l = intrp_asm_vm_call_method_long(m, vmargscount, vmargs);
2573 /* vm_call_method_float ********************************************************
2575 Calls a Java method with a variable number of arguments and returns
2578 *******************************************************************************/
2580 float vm_call_method_float(methodinfo *m, java_objectheader *o, ...)
2586 f = vm_call_method_float_valist(m, o, ap);
2593 /* vm_call_method_float_valist *************************************************
2595 Calls a Java method with a variable number of arguments, passed via
2596 a va_list, and returns a float.
2598 *******************************************************************************/
2600 float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
2608 /* mark start of dump memory area */
2610 dumpsize = dump_size();
2612 /* get number of Java method arguments */
2614 vmargscount = m->parseddesc->paramcount;
2616 /* allocate vm_arg array */
2618 vmargs = DMNEW(vm_arg, vmargscount);
2620 /* fill the vm_arg array from a va_list */
2622 vm_vmargs_from_valist(m, o, vmargs, ap);
2624 /* call the Java method */
2626 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2628 /* release dump area */
2630 dump_release(dumpsize);
2636 /* vm_call_method_float_jvalue *************************************************
2638 Calls a Java method with a variable number of arguments, passed via
2639 a jvalue array, and returns a float.
2641 *******************************************************************************/
2643 float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
2651 /* mark start of dump memory area */
2653 dumpsize = dump_size();
2655 /* get number of Java method arguments */
2657 vmargscount = m->parseddesc->paramcount;
2659 /* allocate vm_arg array */
2661 vmargs = DMNEW(vm_arg, vmargscount);
2663 /* fill the vm_arg array from a va_list */
2665 vm_vmargs_from_jvalue(m, o, vmargs, args);
2667 /* call the Java method */
2669 f = vm_call_method_float_vmarg(m, vmargscount, vmargs);
2671 /* release dump area */
2673 dump_release(dumpsize);
2679 /* vm_call_method_float_vmarg **************************************************
2681 Calls a Java method with a variable number of arguments and returns
2684 *******************************************************************************/
2686 float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
2690 #if defined(ENABLE_JIT)
2691 # if defined(ENABLE_INTRP)
2693 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2696 f = asm_vm_call_method_float(m, vmargscount, vmargs);
2698 f = intrp_asm_vm_call_method_float(m, vmargscount, vmargs);
2705 /* vm_call_method_double *******************************************************
2707 Calls a Java method with a variable number of arguments and returns
2710 *******************************************************************************/
2712 double vm_call_method_double(methodinfo *m, java_objectheader *o, ...)
2718 d = vm_call_method_double_valist(m, o, ap);
2725 /* vm_call_method_double_valist ************************************************
2727 Calls a Java method with a variable number of arguments, passed via
2728 a va_list, and returns a double.
2730 *******************************************************************************/
2732 double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
2740 /* mark start of dump memory area */
2742 dumpsize = dump_size();
2744 /* get number of Java method arguments */
2746 vmargscount = m->parseddesc->paramcount;
2748 /* allocate vm_arg array */
2750 vmargs = DMNEW(vm_arg, vmargscount);
2752 /* fill the vm_arg array from a va_list */
2754 vm_vmargs_from_valist(m, o, vmargs, ap);
2756 /* call the Java method */
2758 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2760 /* release dump area */
2762 dump_release(dumpsize);
2768 /* vm_call_method_double_jvalue ************************************************
2770 Calls a Java method with a variable number of arguments, passed via
2771 a jvalue array, and returns a double.
2773 *******************************************************************************/
2775 double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
2783 /* mark start of dump memory area */
2785 dumpsize = dump_size();
2787 /* get number of Java method arguments */
2789 vmargscount = m->parseddesc->paramcount;
2791 /* allocate vm_arg array */
2793 vmargs = DMNEW(vm_arg, vmargscount);
2795 /* fill the vm_arg array from a va_list */
2797 vm_vmargs_from_jvalue(m, o, vmargs, args);
2799 /* call the Java method */
2801 d = vm_call_method_double_vmarg(m, vmargscount, vmargs);
2803 /* release dump area */
2805 dump_release(dumpsize);
2811 /* vm_call_method_double_vmarg *************************************************
2813 Calls a Java method with a variable number of arguments and returns
2816 *******************************************************************************/
2818 double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
2823 #if defined(ENABLE_JIT)
2824 # if defined(ENABLE_INTRP)
2826 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2829 d = asm_vm_call_method_double(m, vmargscount, vmargs);
2831 d = intrp_asm_vm_call_method_double(m, vmargscount, vmargs);
2839 * These are local overrides for various environment variables in Emacs.
2840 * Please do not remove this and leave it at the end of the file, where
2841 * Emacs will automagically detect them.
2842 * ---------------------------------------------------------------------
2845 * indent-tabs-mode: t