See file COPYRIGHT for information on usage and disclaimer of warranties
- Enthaelt die Funktion main() und die Variablen fuer die
- globalen Optionen.
- Dieser Modul erledigt folgende Aufgaben:
- - Bearbeiten der command-line-options
- - Aufrufen aller Initialisierungsroutinen
- - Aufrufen des Classloaders
- - Starten der main - Methode
+ Contains main() and variables for the global options.
+ This module does the following tasks:
+ - Command line option handling
+ - Calling initialization routines
+ - Calling the class loader
+ - Running the main method
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: $Id: main.c 135 1999-10-04 10:35:09Z roman $
+ Last Change: $Id: main.c 285 2003-05-12 20:05:38Z carolyn $
*******************************************************************************/
#define OPT_GC2 23
#endif
#define OPT_OLOOP 24
+#define OPT_RT 25
+#define OPT_XTA 26
struct {char *name; bool arg; int value;} opts[] = {
{"classpath", true, OPT_CLASSPATH},
{"gc2", false, OPT_GC2},
#endif
{"oloop", false, OPT_OLOOP},
+ {"rt", false, OPT_RT},
+ {"xta", false, OPT_XTA},
{NULL, false, 0}
};
-/******************** interne Funktion: print_usage ************************
+/******************** interne Function: print_usage ************************
-Gibt die richtige Aufrufsyntax des JavaVM-Compilers auf stdout aus.
+Prints the correct usage syntax to stdout.
***************************************************************************/
#ifdef OLD_COMPILER
printf (" -old ................. use old JIT compiler\n");
#endif
-#if 0
+#ifdef NEW_GC
printf (" -gc1 ................. use the old garbage collector (default)\n");
printf (" -gc2 ................. use the new garbage collector\n");
#endif
printf (" s(tack) ....... show stack for every javaVM-command\n");
#endif
printf (" u(tf) ......... show the utf - hash\n");
+ printf (" -rt .................. use rapid type analysis\n");
+ printf (" -xta ................. use xta\n");
}
-/***************************** Funktion: print_times *********************
+/***************************** Function: print_times *********************
- gibt eine Aufstellung der verwendeten CPU-Zeit aus
+ Prints a summary of CPU time usage.
**************************************************************************/
-/***************************** Funktion: print_stats *********************
+/***************************** Function: print_stats *********************
outputs detailed compiler statistics
dolog();
sprintf (logtext, "Size of ExTable (Kb): %10.3f", (float) count_extable_len / 1024);
dolog();
+ sprintf (logtext, "Number of class loads: %d", count_class_loads);
+ dolog();
+ sprintf (logtext, "Number of class inits: %d", count_class_inits);
+ dolog();
sprintf (logtext, "Number of loaded Methods: %d\n\n", count_all_methods);
dolog();
}
-/********** Funktion: class_compile_methods (nur f"ur Debug-Zwecke) ********/
+/********** Function: class_compile_methods (debugging only) ********/
void class_compile_methods ()
{
void exit_handler(void)
{
- /********************* Debug-Tabellen ausgeben ************************/
+ /********************* Print debug tables ************************/
if (showmethods) class_showmethods (topclass);
if (showconstantpool) class_showconstantpool (topclass);
flags */
#endif
- /************************ Freigeben aller Resourcen *******************/
+ /************************ Free all resources *******************/
heap_close (); /* must be called before compiler_close and
loader_close because finalization occurs
}
}
-/************************** Funktion: main *******************************
+/************************** Function: main *******************************
- Das Hauptprogramm.
- Wird vom System zu Programstart aufgerufen (eh klar).
+ The main program.
**************************************************************************/
{
s4 i,j;
char *cp;
- java_objectheader *exceptionptr;
+ java_objectheader *local_exceptionptr = 0;
void *dummy;
/********** interne (nur fuer main relevante Optionen) **************/
char logfilename[200] = "";
- u4 heapsize = 16000000;
+ u4 heapsize = 64000000;
u4 heapstartsize = 200000;
char classpath[500] = ".:/usr/local/lib/java/classes";
bool startit = true;
if (0 != atexit(exit_handler))
panic("unable to register exit_handler");
- /************ Infos aus der Environment lesen ************************/
+ /************ Collect info from the environment ************************/
cp = getenv ("CLASSPATH");
if (cp) {
strcpy (classpath, cp);
}
- /***************** Interpretieren der Kommandozeile *****************/
+ /***************** Interpret the command line *****************/
checknull = false;
checkfloats = false;
break;
#endif
- case OPT_SHOW: /* Anzeigeoptionen */
+ case OPT_SHOW: /* Display options */
for (j=0; j<strlen(opt_arg); j++) {
switch (opt_arg[j]) {
case 'a': showdisassemble=true; compileverbose=true; break;
opt_loops = true;
break;
+ case OPT_RT:
+ opt_rt = true;
+ break;
+
+ case OPT_XTA:
+ opt_xta = true;
+ break;
+
default:
print_usage();
exit(10);
}
- /**************************** Programmstart *****************************/
+ /**************************** Program start *****************************/
log_init (logfilename);
if (verbose) {
tables_init();
heap_init(heapsize, heapstartsize, &dummy);
- loader_init();
#ifdef OLD_COMPILER
compiler_init();
#endif
jit_init();
+ loader_init();
native_loadclasses ();
- /*********************** JAVA-Klassen laden ***************************/
+ /*********************** Load JAVA classes ***************************/
cp = argv[opt_ind++];
- for (i=strlen(cp)-1; i>=0; i--) { /* Punkte im Klassennamen */
- if (cp[i]=='.') cp[i]='/'; /* auf slashes umbauen */
+ for (i=strlen(cp)-1; i>=0; i--) { /* Transform dots into slashes */
+ if (cp[i]=='.') cp[i]='/'; /* in the class name */
}
topclass = loader_load ( utf_new_char (cp) );
- loader_compute_subclasses();
+ if (exceptionptr != 0)
+ {
+ printf ("#### Class loader has thrown: ");
+ utf_display (exceptionptr->vftbl->class->name);
+ printf ("\n");
+
+ exceptionptr = 0;
+ }
+
+ if (topclass == 0)
+ {
+ printf("#### Could not find top class - exiting\n");
+ exit(1);
+ }
gc_init();
initThreads((u1*)&dummy); /* schani */
#endif
- /************************* Arbeitsroutinen starten ********************/
+ /************************* Start worker routines ********************/
if (startit) {
methodinfo *mainmethod;
for (i=opt_ind; i<argc; i++) {
a->data[i-opt_ind] = javastring_new (utf_new_char (argv[i]) );
}
- exceptionptr = asm_calljavamethod (mainmethod, a, NULL,NULL,NULL );
+ local_exceptionptr = asm_calljavamethod (mainmethod, a, NULL,NULL,NULL );
- if (exceptionptr) {
+ if (local_exceptionptr) {
printf ("#### Program has thrown: ");
- utf_display (exceptionptr->vftbl->class->name);
+ utf_display (local_exceptionptr->vftbl->class->name);
printf ("\n");
}
+ /*RTAprint*/ if ((pCallgraph >= 1) && (opt_rt)) {
+ /*RTAprint*/ printCallgraph (); }
+
+ /*RTprint*/ if ((pClassHeir >= 1) && (opt_rt)) {
+ /*RTprint*/ printf("Last RTA Class Heirarchy -");
+ /*RTprint*/ printRThierarchyInfo(mainmethod); }
#ifdef USE_THREADS
killThread(currentThread);
fprintf(stderr, "still here\n");
}
- /************* Auf Wunsch alle Methode "ubersetzen ********************/
+ /************* If requested, compile all methods ********************/
if (compileall) {
class_compile_methods();
}
- /******** Auf Wunsch eine spezielle Methode "ubersetzen ***************/
+ /******** If requested, compile a specific method ***************/
if (specificmethodname) {
methodinfo *m;
-/************************************ SHUTDOWN-Funktion *********************************
+/************************************ Shutdown function *********************************
- Terminiert das System augenblicklich, ohne den Speicher
- explizit freizugeben (eigentlich nur f"ur abnorme
- Programmterminierung)
+ Terminates the system immediately without freeing memory explicitly (to be
+ used only for abnormal termination)
*****************************************************************************************/
void cacao_shutdown(s4 status)
{
+ /*RTAprint*/ if ((pCallgraph >= 1) && (opt_rt)) {
+ /*RTAprint*/ printCallgraph (NULL); }
+
+ /*RTprint*/ if ((pClassHeir >= 1) && (opt_rt)) {
+ /*RTprint*/ printf("Last RTA Class Heirarchy -");
+ /*RTprint*/ printRThierarchyInfo(NULL); }
+
if (verbose || getcompilingtime || statistics) {
log_text ("CACAO terminated by shutdown");
if (statistics)