1 /* src/vm/finalizer.c - finalizer linked list and thread
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
31 $Id: finalizer.c 4357 2006-01-22 23:33:38Z twisti $
44 #include "native/jni.h"
45 #include "native/native.h"
47 #if defined(USE_THREADS)
48 # if defined(NATIVE_THREADS)
49 # include "threads/native/threads.h"
51 # include "threads/green/threads.h"
52 # include "threads/green/locks.h"
56 #include "vm/classcache.h"
57 #include "vm/exceptions.h"
58 #include "vm/finalizer.h"
59 #include "vm/global.h"
60 #include "vm/initialize.h"
61 #include "vm/options.h"
62 #include "vm/properties.h"
63 #include "vm/signallocal.h"
64 #include "vm/stringlocal.h"
66 #include "vm/jit/asmpart.h"
67 #include "vm/jit/profile/profile.h"
70 /* Invocation API variables ***************************************************/
72 JavaVM *_Jv_jvm; /* denotes a Java VM */
73 _Jv_JNIEnv *_Jv_env; /* pointer to native method interface */
76 /* global variables ***********************************************************/
78 s4 vms = 0; /* number of VMs created */
80 bool vm_initializing = false;
81 bool vm_exiting = false;
83 #if defined(ENABLE_INTRP)
84 u1 *intrp_main_stack = NULL;
87 void **stackbottom = NULL;
89 char *mainstring = NULL;
90 classinfo *mainclass = NULL;
92 char *specificmethodname = NULL;
93 char *specificsignature = NULL;
98 /* define heap sizes **********************************************************/
100 #define HEAP_MAXSIZE 64 * 1024 * 1024 /* default 64MB */
101 #define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */
102 #define STACK_SIZE 128 * 1024 /* default 128kB */
105 /* define command line options ************************************************/
120 #if defined(ENABLE_STATISTICS)
137 OPT_VERBOSEEXCEPTION,
140 /* optimization options */
142 #if defined(ENABLE_IFCONV)
146 #if defined(ENABLE_LSRA)
167 #if defined(ENABLE_INTRP)
168 /* interpreter options */
189 opt_struct opts[] = {
190 { "classpath", true, OPT_CLASSPATH },
191 { "cp", true, OPT_CLASSPATH },
192 { "D", true, OPT_D },
193 { "noasyncgc", false, OPT_IGNORE },
194 { "noverify", false, OPT_NOVERIFY },
195 { "liberalutf", false, OPT_LIBERALUTF },
196 { "v", false, OPT_VERBOSE1 },
197 { "verbose", false, OPT_VERBOSE },
198 { "verbose:", true, OPT_VERBOSESPECIFIC },
199 { "verbosecall", false, OPT_VERBOSECALL },
200 { "verboseexception", false, OPT_VERBOSEEXCEPTION },
201 #ifdef TYPECHECK_VERBOSE
202 { "verbosetc", false, OPT_VERBOSETC },
204 #if defined(__ALPHA__)
205 { "noieee", false, OPT_NOIEEE },
207 { "softnull", false, OPT_SOFTNULL },
208 { "time", false, OPT_TIME },
209 #if defined(ENABLE_STATISTICS)
210 { "stat", false, OPT_STAT },
212 { "log", true, OPT_LOG },
213 { "c", true, OPT_CHECK },
214 { "l", false, OPT_LOAD },
215 { "eager", false, OPT_EAGER },
216 { "sig", true, OPT_SIGNATURE },
217 { "all", false, OPT_ALL },
218 { "oloop", false, OPT_OLOOP },
219 #if defined(ENABLE_IFCONV)
220 { "ifconv", false, OPT_IFCONV },
222 #if defined(ENABLE_LSRA)
223 { "lsra", false, OPT_LSRA },
225 { "jar", false, OPT_JAR },
226 { "version", false, OPT_VERSION },
227 { "showversion", false, OPT_SHOWVERSION },
228 { "fullversion", false, OPT_FULLVERSION },
229 { "help", false, OPT_HELP },
230 { "?", false, OPT_HELP },
232 #if defined(ENABLE_INTRP)
233 /* interpreter options */
235 { "trace", false, OPT_TRACE },
236 { "static-supers", true, OPT_STATIC_SUPERS },
237 { "no-dynamic", false, OPT_NO_DYNAMIC },
238 { "no-replication", false, OPT_NO_REPLICATION },
239 { "no-quicksuper", false, OPT_NO_QUICKSUPER },
242 /* JVMTI Agent Command Line Options */
244 { "agentlib:", true, OPT_AGENTLIB },
245 { "agentpath:", true, OPT_AGENTPATH },
250 { "X", false, OPT_X },
251 { "Xjit", false, OPT_JIT },
252 { "Xint", false, OPT_INTRP },
253 { "Xbootclasspath:", true, OPT_BOOTCLASSPATH },
254 { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A },
255 { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P },
257 { "Xdebug", false, OPT_DEBUG },
259 { "Xms", true, OPT_MS },
260 { "Xmx", true, OPT_MX },
261 { "Xprof:", true, OPT_PROF_OPTION },
262 { "Xprof", false, OPT_PROF },
263 { "Xss", true, OPT_SS },
264 { "ms", true, OPT_MS },
265 { "mx", true, OPT_MX },
266 { "ss", true, OPT_SS },
268 /* keep these at the end of the list */
270 { "i", true, OPT_INLINING },
271 { "m", true, OPT_METHOD },
272 { "s", true, OPT_SHOW },
278 /* usage ***********************************************************************
280 Prints the correct usage syntax to stdout.
282 *******************************************************************************/
286 printf("Usage: cacao [-options] classname [arguments]\n");
287 printf(" (to run a class file)\n");
288 printf(" cacao [-options] -jar jarfile [arguments]\n");
289 printf(" (to run a standalone jar file)\n\n");
291 printf("Java options:\n");
292 printf(" -cp <path> specify a path to look for classes\n");
293 printf(" -classpath <path> specify a path to look for classes\n");
294 printf(" -D<name>=<value> add an entry to the property list\n");
295 printf(" -verbose[:class|gc|jni] enable specific verbose output\n");
296 printf(" -version print product version and exit\n");
297 printf(" -fullversion print jpackage-compatible product version and exit\n");
298 printf(" -showversion print product version and continue\n");
299 printf(" -help, -? print this help message\n");
300 printf(" -X print help on non-standard Java options\n\n");
303 printf(" -agentlib:<agent-lib-name>=<options> library to load containg JVMTI agent\n");
304 printf(" -agentpath:<path-to-agent>=<options> path to library containg JVMTI agent\n");
307 printf("CACAO options:\n");
308 printf(" -v write state-information\n");
309 printf(" -verbose write more information\n");
310 printf(" -verbosegc write message for each GC\n");
311 printf(" -verbosecall write message for each call\n");
312 printf(" -verboseexception write message for each step of stack unwinding\n");
313 #ifdef TYPECHECK_VERBOSE
314 printf(" -verbosetc write debug messages while typechecking\n");
316 #if defined(__ALPHA__)
317 printf(" -noieee don't use ieee compliant arithmetic\n");
319 printf(" -noverify don't verify classfiles\n");
320 printf(" -liberalutf don't warn about overlong UTF-8 sequences\n");
321 printf(" -softnull use software nullpointer check\n");
322 printf(" -time measure the runtime\n");
323 #if defined(ENABLE_STATISTICS)
324 printf(" -stat detailed compiler statistics\n");
326 printf(" -log logfile specify a name for the logfile\n");
327 printf(" -c(heck)b(ounds) don't check array bounds\n");
328 printf(" s(ync) don't check for synchronization\n");
329 printf(" -oloop optimize array accesses in loops\n");
330 printf(" -l don't start the class after loading\n");
331 printf(" -eager perform eager class loading and linking\n");
332 printf(" -all compile all methods, no execution\n");
333 printf(" -m compile only a specific method\n");
334 printf(" -sig specify signature for a specific method\n");
335 printf(" -s(how)a(ssembler) show disassembled listing\n");
336 printf(" c(onstants) show the constant pool\n");
337 printf(" d(atasegment) show data segment listing\n");
338 printf(" e(xceptionstubs) show disassembled exception stubs (only with -sa)\n");
339 printf(" i(ntermediate) show intermediate representation\n");
340 printf(" m(ethods) show class fields and methods\n");
341 printf(" n(ative) show disassembled native stubs\n");
342 printf(" u(tf) show the utf - hash\n");
343 printf(" -i n(line) activate inlining\n");
344 printf(" v(irtual) inline virtual methods (uses/turns rt option on)\n");
345 printf(" e(exception) inline methods with exceptions\n");
346 printf(" p(aramopt) optimize argument renaming\n");
347 printf(" o(utsiders) inline methods of foreign classes\n");
348 #if defined(ENABLE_IFCONV)
349 printf(" -ifconv use if-conversion\n");
351 #if defined(ENABLE_LSRA)
352 printf(" -lsra use linear scan register allocation\n");
355 /* exit with error code */
361 static void Xusage(void)
363 #if defined(ENABLE_JIT)
364 printf(" -Xjit JIT mode execution (default)\n");
366 #if defined(ENABLE_INTRP)
367 printf(" -Xint interpreter mode execution\n");
369 printf(" -Xbootclasspath:<zip/jar files and directories separated by :>\n");
370 printf(" value is set as bootstrap class path\n");
371 printf(" -Xbootclasspath/a:<zip/jar files and directories separated by :>\n");
372 printf(" value is appended to the bootstrap class path\n");
373 printf(" -Xbootclasspath/p:<zip/jar files and directories separated by :>\n");
374 printf(" value is prepended to the bootstrap class path\n");
375 printf(" -Xms<size> set the initial size of the heap (default: 2MB)\n");
376 printf(" -Xmx<size> set the maximum size of the heap (default: 64MB)\n");
377 printf(" -Xss<size> set the thread stack size (default: 128kB)\n");
378 printf(" -Xprof[:bb] collect and print profiling data\n");
379 #if defined(ENABLE_JVMTI)
380 printf(" -Xdebug<transport> enable remote debugging\n");
383 /* exit with error code */
389 /* version *********************************************************************
391 Only prints cacao version information.
393 *******************************************************************************/
395 static void version(void)
397 printf("java version \""JAVA_VERSION"\"\n");
398 printf("CACAO version "VERSION"\n");
400 printf("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,\n");
401 printf("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,\n");
402 printf("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,\n");
403 printf("J. Wenninger, Institut f. Computersprachen - TU Wien\n\n");
405 printf("This program is free software; you can redistribute it and/or\n");
406 printf("modify it under the terms of the GNU General Public License as\n");
407 printf("published by the Free Software Foundation; either version 2, or (at\n");
408 printf("your option) any later version.\n\n");
410 printf("This program is distributed in the hope that it will be useful, but\n");
411 printf("WITHOUT ANY WARRANTY; without even the implied warranty of\n");
412 printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n");
413 printf("General Public License for more details.\n");
417 /* fullversion *****************************************************************
419 Prints a Sun compatible version information (required e.g. by
420 jpackage, www.jpackage.org).
422 *******************************************************************************/
424 static void fullversion(void)
426 printf("java full version \"cacao-"JAVA_VERSION"\"\n");
434 /* vm_create *******************************************************************
436 Creates a JVM. Called by JNI_CreateJavaVM.
438 *******************************************************************************/
440 bool vm_create(JavaVMInitArgs *vm_args)
449 /* check the JNI version requested */
451 switch (vm_args->version) {
452 case JNI_VERSION_1_1:
454 case JNI_VERSION_1_2:
455 case JNI_VERSION_1_4:
461 /* we only support 1 JVM instance */
467 /* get stuff from the environment *****************************************/
469 #if defined(DISABLE_GC)
470 nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
473 /* set the bootclasspath */
475 cp = getenv("BOOTCLASSPATH");
478 bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
479 strcpy(bootclasspath, cp);
482 cplen = strlen(CACAO_VM_ZIP_PATH) +
484 strlen(CLASSPATH_GLIBJ_ZIP_PATH) +
487 bootclasspath = MNEW(char, cplen);
488 strcat(bootclasspath, CACAO_VM_ZIP_PATH);
489 strcat(bootclasspath, ":");
490 strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP_PATH);
494 /* set the classpath */
496 cp = getenv("CLASSPATH");
499 classpath = MNEW(char, strlen(cp) + strlen("0"));
500 strcat(classpath, cp);
503 classpath = MNEW(char, strlen(".") + strlen("0"));
504 strcpy(classpath, ".");
508 /* interpret the options **************************************************/
513 heapmaxsize = HEAP_MAXSIZE;
514 heapstartsize = HEAP_STARTSIZE;
515 opt_stacksize = STACK_SIZE;
517 /* initialize properties before commandline handling */
519 if (!properties_init())
520 throw_cacao_exception_exit(string_java_lang_InternalError,
521 "Unable to init properties");
523 /* iterate over all passed options */
525 while ((opt = options_get(opts, vm_args)) != OPT_DONE) {
530 case OPT_BOOTCLASSPATH:
531 /* Forget default bootclasspath and set the argument as
532 new boot classpath. */
533 MFREE(bootclasspath, char, strlen(bootclasspath));
535 bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
536 strcpy(bootclasspath, opt_arg);
539 case OPT_BOOTCLASSPATH_A:
540 /* append to end of bootclasspath */
541 cplen = strlen(bootclasspath);
543 bootclasspath = MREALLOC(bootclasspath,
546 cplen + strlen(":") +
547 strlen(opt_arg) + strlen("0"));
549 strcat(bootclasspath, ":");
550 strcat(bootclasspath, opt_arg);
553 case OPT_BOOTCLASSPATH_P:
554 /* prepend in front of bootclasspath */
558 bootclasspath = MNEW(char, strlen(opt_arg) + strlen(":") +
559 cplen + strlen("0"));
561 strcpy(bootclasspath, opt_arg);
562 strcat(bootclasspath, ":");
563 strcat(bootclasspath, cp);
565 MFREE(cp, char, cplen);
569 /* forget old classpath and set the argument as new classpath */
570 MFREE(classpath, char, strlen(classpath));
572 classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
573 strcpy(classpath, opt_arg);
580 #if defined(ENABLE_JVMTI)
588 set_jvmti_phase(JVMTI_PHASE_ONLOAD);
590 set_jvmti_phase(JVMTI_PHASE_PRIMORDIAL);
595 for (j = 0; j < strlen(opt_arg); j++) {
596 if (opt_arg[j] == '=') {
598 properties_add(opt_arg, opt_arg + j + 1);
603 /* if no '=' is given, just create an empty property */
605 properties_add(opt_arg, "");
615 c = opt_arg[strlen(opt_arg) - 1];
617 if ((c == 'k') || (c == 'K')) {
618 j = atoi(opt_arg) * 1024;
620 } else if ((c == 'm') || (c == 'M')) {
621 j = atoi(opt_arg) * 1024 * 1024;
628 else if (opt == OPT_MS)
644 compileverbose = true;
647 case OPT_VERBOSESPECIFIC:
648 if (strcmp("class", opt_arg) == 0)
649 opt_verboseclass = true;
651 else if (strcmp("gc", opt_arg) == 0)
652 opt_verbosegc = true;
654 else if (strcmp("jni", opt_arg) == 0)
655 opt_verbosejni = true;
658 case OPT_VERBOSEEXCEPTION:
659 opt_verboseexception = true;
662 #ifdef TYPECHECK_VERBOSE
664 typecheckverbose = true;
668 case OPT_VERBOSECALL:
677 case OPT_FULLVERSION:
681 case OPT_SHOWVERSION:
694 opt_liberalutf = true;
702 getcompilingtime = true;
703 getloadingtime = true;
706 #if defined(ENABLE_STATISTICS)
717 for (j = 0; j < strlen(opt_arg); j++) {
718 switch (opt_arg[j]) {
733 makeinitializations = false;
742 opt_method = opt_arg;
743 makeinitializations = false;
747 opt_signature = opt_arg;
753 makeinitializations = false;
756 case OPT_SHOW: /* Display options */
757 for (j = 0; j < strlen(opt_arg); j++) {
758 switch (opt_arg[j]) {
760 opt_showdisassemble = true;
761 compileverbose = true;
764 showconstantpool = true;
767 opt_showddatasegment = true;
770 opt_showexceptionstubs = true;
773 opt_showintermediate = true;
774 compileverbose = true;
780 opt_shownativestub = true;
796 for (j = 0; j < strlen(opt_arg); j++) {
797 switch (opt_arg[j]) {
799 /* define in options.h; Used in main.c, jit.c
800 & inline.c inlining is currently
804 inlinevirtuals = true;
807 inlineexceptions = true;
810 inlineparamopt = true;
813 inlineoutsiders = true;
821 #if defined(ENABLE_IFCONV)
827 #if defined(ENABLE_LSRA)
841 case OPT_PROF_OPTION:
842 /* use <= to get the last \0 too */
844 for (j = 0, k = 0; j <= strlen(opt_arg); j++) {
845 if (opt_arg[j] == ',')
848 if (opt_arg[j] == '\0') {
849 if (strcmp("bb", opt_arg + k) == 0)
853 printf("Unknown option: -Xprof:%s\n", opt_arg + k);
857 /* set k to next char */
869 #if defined(ENABLE_JIT)
872 printf("-Xjit option not enabled.\n");
878 #if defined(ENABLE_INTRP)
881 printf("-Xint option not enabled.\n");
886 #if defined(ENABLE_INTRP)
887 case OPT_STATIC_SUPERS:
888 opt_static_supers = atoi(opt_arg);
892 opt_no_dynamic = true;
895 case OPT_NO_REPLICATION:
896 opt_no_replication = true;
899 case OPT_NO_QUICKSUPER:
900 opt_no_quicksuper = true;
909 printf("Unknown option: %s\n",
910 vm_args->options[opt_index].optionString);
916 /* get the main class *****************************************************/
918 if (opt_index < vm_args->nOptions) {
919 mainstring = vm_args->options[opt_index++].optionString;
921 if (opt_jar == true) {
923 /* prepend the jar file to the classpath (if any) */
925 if (opt_jar == true) {
926 /* put jarfile in classpath */
930 classpath = MNEW(char, strlen(mainstring) + strlen(":") +
931 strlen(classpath) + strlen("0"));
933 strcpy(classpath, mainstring);
934 strcat(classpath, ":");
935 strcat(classpath, cp);
937 MFREE(cp, char, strlen(cp));
940 /* replace .'s with /'s in classname */
942 for (i = strlen(mainstring) - 1; i >= 0; i--)
943 if (mainstring[i] == '.')
950 /* initialize this JVM ****************************************************/
952 vm_initializing = true;
954 /* initialize the garbage collector */
956 gc_init(heapmaxsize, heapstartsize);
958 #if defined(ENABLE_INTRP)
959 /* allocate main thread stack */
962 intrp_main_stack = (u1 *) alloca(opt_stacksize);
963 MSET(intrp_main_stack, 0, u1, opt_stacksize);
967 #if defined(USE_THREADS)
968 #if defined(NATIVE_THREADS)
974 /* initialize the string hashtable stuff: lock (must be done
975 _after_ threads_preinit) */
978 throw_main_exception_exit();
980 /* initialize the utf8 hashtable stuff: lock, often used utf8
981 strings (must be done _after_ threads_preinit) */
984 throw_main_exception_exit();
986 /* initialize the classcache hashtable stuff: lock, hashtable
987 (must be done _after_ threads_preinit) */
989 if (!classcache_init())
990 throw_main_exception_exit();
992 /* initialize the loader with bootclasspath (must be done _after_
996 throw_main_exception_exit();
998 suck_add_from_property("java.endorsed.dirs");
999 suck_add(bootclasspath);
1001 /* initialize the memory subsystem (must be done _after_
1005 throw_main_exception_exit();
1007 /* initialize the finalizer stuff (must be done _after_
1010 if (!finalizer_init())
1011 throw_main_exception_exit();
1013 /* install architecture dependent signal handler used for exceptions */
1017 /* initialize the codegen subsystems */
1021 /* initializes jit compiler */
1025 /* machine dependent initialization */
1027 #if defined(ENABLE_JIT)
1028 # if defined(ENABLE_INTRP)
1038 /* initialize the loader subsystems (must be done _after_
1041 if (!loader_init((u1 *) stackbottom))
1042 throw_main_exception_exit();
1045 throw_main_exception_exit();
1048 throw_main_exception_exit();
1050 if (!exceptions_init())
1051 throw_main_exception_exit();
1053 if (!builtin_init())
1054 throw_main_exception_exit();
1056 #if defined(USE_THREADS)
1057 if (!threads_init((u1 *) stackbottom))
1058 throw_main_exception_exit();
1061 /* That's important, otherwise we get into trouble, if the Runtime
1062 static initializer is called before (circular dependency. This
1063 is with classpath 0.09. Another important thing is, that this
1064 has to happen after initThreads!!! */
1066 if (!initialize_class(class_java_lang_System))
1067 throw_main_exception_exit();
1069 /* JNI init creates a Java object (this means running Java code) */
1072 throw_main_exception_exit();
1074 /* initialize profiling */
1076 if (!profile_init())
1077 throw_main_exception_exit();
1079 #if defined(USE_THREADS)
1080 /* finally, start the finalizer thread */
1082 if (!finalizer_start_thread())
1083 throw_main_exception_exit();
1085 /* start the profile sampling thread */
1087 /* if (!profile_start_thread()) */
1088 /* throw_main_exception_exit(); */
1091 /* increment the number of VMs */
1095 /* initialization is done */
1097 vm_initializing = false;
1099 /* everything's ok */
1105 /* vm_destroy ******************************************************************
1107 Unloads a Java VM and reclaims its resources.
1109 *******************************************************************************/
1111 s4 vm_destroy(JavaVM *vm)
1113 #if defined(USE_THREADS)
1114 #if defined(NATIVE_THREADS)
1117 killThread(currentThread);
1121 /* everything's ok */
1127 /* vm_exit *********************************************************************
1129 Calls java.lang.System.exit(I)V to exit the JavaVM correctly.
1131 *******************************************************************************/
1133 void vm_exit(s4 status)
1137 /* signal that we are exiting */
1141 assert(class_java_lang_System);
1142 assert(class_java_lang_System->state & CLASS_LOADED);
1144 #if defined(ENABLE_JVMTI)
1145 set_jvmti_phase(JVMTI_PHASE_DEAD);
1149 if (!link_class(class_java_lang_System))
1150 throw_main_exception_exit();
1152 /* call java.lang.System.exit(I)V */
1154 m = class_resolveclassmethod(class_java_lang_System,
1155 utf_new_char("exit"),
1157 class_java_lang_Object,
1161 throw_main_exception_exit();
1163 /* call the exit function with passed exit status */
1165 ASM_CALLJAVAFUNCTION(m, (void *) (ptrint) status, NULL, NULL, NULL);
1167 /* this should never happen */
1170 throw_exception_exit();
1172 throw_cacao_exception_exit(string_java_lang_InternalError,
1173 "System.exit(I)V returned without exception");
1177 /* vm_shutdown *****************************************************************
1179 Terminates the system immediately without freeing memory explicitly
1180 (to be used only for abnormal termination).
1182 *******************************************************************************/
1184 void vm_shutdown(s4 status)
1186 #if defined(ENABLE_JVMTI)
1190 if (opt_verbose || getcompilingtime || opt_stat) {
1191 log_text("CACAO terminated by shutdown");
1192 dolog("Exit status: %d\n", (s4) status);
1199 /* vm_exit_handler *************************************************************
1201 The exit_handler function is called upon program termination.
1203 ATTENTION: Don't free system resources here! Some threads may still
1204 be running as this is called from VMRuntime.exit(). The OS does the
1207 *******************************************************************************/
1209 void vm_exit_handler(void)
1211 #if !defined(NDEBUG)
1213 class_showmethods(mainclass);
1215 if (showconstantpool)
1216 class_showconstantpool(mainclass);
1222 profile_printstats();
1225 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
1226 clear_thread_flags(); /* restores standard file descriptor
1230 if (opt_verbose || getcompilingtime || opt_stat) {
1231 log_text("CACAO terminated");
1233 #if defined(ENABLE_STATISTICS)
1236 #ifdef TYPECHECK_STATISTICS
1237 typecheck_print_statistics(get_logfile());
1243 if (getcompilingtime)
1247 /* vm_print_profile(stderr);*/
1252 * These are local overrides for various environment variables in Emacs.
1253 * Please do not remove this and leave it at the end of the file, where
1254 * Emacs will automagically detect them.
1255 * ---------------------------------------------------------------------
1258 * indent-tabs-mode: t