Authors: Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at
Changes: Andi Krall EMAIL: cacao@complang.tuwien.ac.at
Mark Probst EMAIL: cacao@complang.tuwien.ac.at
+ Philipp Tomsich EMAIL: cacao@complang.tuwien.ac.at
- Last Change: 1997/10/29
+ Last Change: $Id: cacao.c 132 1999-09-27 15:54:42Z chris $
*******************************************************************************/
#include "builtin.h"
#include "native.h"
-#include "threads/thread.h" /* schani */
+#include "threads/thread.h"
bool compileall = false;
int newcompiler = true;
bool new_gc = false;
#endif
+static bool showmethods = false;
+static bool showconstantpool = false;
+static bool showunicode = false;
+static classinfo *topclass;
+
#ifndef USE_THREADS
void **stackbottom = 0;
#endif
#define OPT_GC1 22
#define OPT_GC2 23
#endif
+#define OPT_OLOOP 24
struct {char *name; bool arg; int value;} opts[] = {
{"classpath", true, OPT_CLASSPATH},
{"gc1", false, OPT_GC1},
{"gc2", false, OPT_GC2},
#endif
+ {"oloop", false, OPT_OLOOP},
{NULL, false, 0}
};
printf (" -time ................ measure the runtime\n");
printf (" -stat ................ detailed compiler statistics\n");
printf (" -log logfile ......... specify a name for the logfile\n");
- printf (" -c(heck) b(ounds...... don't check array bounds\n");
- printf (" s(ync) ...... don't check for synchronization\n");
+ printf (" -c(heck)b(ounds) ..... don't check array bounds\n");
+ printf (" s(ync) ....... don't check for synchronization\n");
+ printf (" -oloop ............... optimize array accesses in loops\n");
printf (" -l ................... don't start the class after loading\n");
printf (" -all ................. compile all methods, no execution\n");
#ifdef OLD_COMPILER
printf (" -old ................. use old JIT compiler\n");
#endif
-#ifdef NEW_GC
+#if 0
printf (" -gc1 ................. use the old garbage collector (default)\n");
printf (" -gc2 ................. use the new garbage collector\n");
#endif
printf (" -m ................... compile only a specific method\n");
printf (" -sig ................. specify signature for a specific method\n");
- printf (" -s(how)m(ethods) ..... show all methods&fields of a class\n");
- printf (" a(ssembler) ... show disassembled listing\n");
+ printf (" -s(how)a(ssembler) ... show disassembled listing\n");
printf (" c(onstants) ... show the constant pool\n");
printf (" d(atasegment).. show data segment listing\n");
printf (" i(ntermediate). show intermediate representation\n");
}
}
+/*
+ * void exit_handler(void)
+ * -----------------------
+ * The exit_handler function is called upon program termination to shutdown
+ * the various subsystems and release the resources allocated to the VM.
+ */
+
+void exit_handler(void)
+{
+ /********************* Debug-Tabellen ausgeben ************************/
+
+ if (showmethods) class_showmethods (topclass);
+ if (showconstantpool) class_showconstantpool (topclass);
+ if (showunicode) unicode_show ();
+
+#ifdef USE_THREADS
+ clear_thread_flags(); /* restores standard file descriptor
+ flags */
+#endif
+
+ /************************ Freigeben aller Resourcen *******************/
+
+ heap_close (); /* must be called before compiler_close and
+ loader_close because finalization occurs
+ here */
+
+#ifdef OLD_COMPILER
+ compiler_close ();
+#endif
+ loader_close ();
+ unicode_close ( literalstring_free );
+
+ if (verbose || getcompilingtime || statistics) {
+ log_text ("CACAO terminated");
+ if (statistics)
+ print_stats ();
+ if (getcompilingtime)
+ print_times ();
+ mem_usagelog(1);
+ }
+}
/************************** Funktion: main *******************************
**************************************************************************/
-
int main(int argc, char **argv)
{
s4 i,j;
char *cp;
- classinfo *topclass;
java_objectheader *exceptionptr;
void *dummy;
u4 heapsize = 16000000;
u4 heapstartsize = 200000;
char classpath[500] = ".:/usr/local/lib/java/classes";
- bool showmethods = false;
- bool showconstantpool = false;
- bool showunicode = false;
bool startit = true;
char *specificmethodname = NULL;
char *specificsignature = NULL;
#ifndef USE_THREADS
stackbottom = &dummy;
#endif
-
-
-#ifdef USE_THREADS
- atexit(clear_thread_flags);
-#endif
+
+ if (0 != atexit(exit_handler))
+ panic("unable to register exit_handler");
/************ Infos aus der Environment lesen ************************/
}
break;
+ case OPT_OLOOP:
+ opt_loops = true;
+ break;
+
default:
print_usage();
exit(10);
printf ("\n");
}
- /* killThread(currentThread); */
-
+#ifdef USE_THREADS
+ killThread(currentThread);
+#endif
+ fprintf(stderr, "still here\n");
}
/************* Auf Wunsch alle Methode "ubersetzen ********************/
#endif
}
- /********************* Debug-Tabellen ausgeben ************************/
-
- if (showmethods) class_showmethods (topclass);
- if (showconstantpool) class_showconstantpool (topclass);
- if (showunicode) unicode_show ();
-
-
-
- /************************ Freigeben aller Resourcen *******************/
-
- heap_close (); /* must be called before compiler_close and
- loader_close because finalization occurs
- here */
-#ifdef OLD_COMPILER
- compiler_close ();
-#endif
- loader_close ();
- unicode_close ( literalstring_free );
-
-
- /* Endemeldung ausgeben und mit entsprechendem exit-Status terminieren */
-
- if (verbose || getcompilingtime || statistics) {
- log_text ("CACAO terminated");
- if (statistics)
- print_stats ();
- if (getcompilingtime)
- print_times ();
- mem_usagelog(1);
- }
-
exit(0);
- return 1;
}
sprintf (logtext, "Exit status: %d\n", (int) status);
dolog();
}
-
+
exit(status);
}