From: phil Date: Wed, 11 Nov 1998 21:11:55 +0000 (+0000) Subject: Added an option to enable/disable the new gc X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=f157b7a036818cd63deb10717d7da9000f2b5538;p=cacao.git Added an option to enable/disable the new gc --- diff --git a/global.h b/global.h index fb818435c..0f632b6b5 100644 --- a/global.h +++ b/global.h @@ -12,7 +12,7 @@ Changes: Mark Probst (schani) EMAIL: cacao@complang.tuwien.ac.at Philipp Tomsich (phil) EMAIL: cacao@complang.tuwien.ac.at - Last Change: $Id: global.h 55 1998-11-10 17:33:40Z phil $ + Last Change: $Id: global.h 64 1998-11-11 21:11:55Z phil $ *******************************************************************************/ @@ -20,6 +20,7 @@ #define __global_h_ #define OLD_COMPILER /* if enabled makes old compiler available */ +#define NEW_GC /* if enabled, includes the new gc. -- phil. */ #define STATISTICS /* if enabled collects program statistics */ @@ -529,7 +530,7 @@ extern java_objectheader *proto_java_lang_ThreadDeath; extern bool compileall; extern bool runverbose; extern bool verbose; - + /* statistic variables ********************************************************/ diff --git a/main.c b/main.c index 126935964..e49362c9d 100644 --- a/main.c +++ b/main.c @@ -38,6 +38,9 @@ bool compileall = false; int newcompiler = true; bool verbose = false; +#ifdef NEW_GC +bool new_gc = false; +#endif #ifndef USE_THREADS void **stackbottom = 0; @@ -76,35 +79,43 @@ void **stackbottom = 0; #ifdef OLD_COMPILER #define OPT_OLD 21 #endif +#ifdef NEW_GC +#define OPT_GC1 22 +#define OPT_GC2 23 +#endif struct {char *name; bool arg; int value;} opts[] = { - {"classpath", true, OPT_CLASSPATH}, - {"D", true, OPT_D}, - {"ms", true, OPT_MS}, - {"mx", true, OPT_MX}, - {"noasyncgc", false, OPT_IGNORE}, - {"noverify", false, OPT_IGNORE}, - {"oss", true, OPT_IGNORE}, - {"ss", true, OPT_IGNORE}, - {"v", false, OPT_VERBOSE1}, - {"verbose", false, OPT_VERBOSE}, - {"verbosegc", false, OPT_VERBOSEGC}, - {"verbosecall", false, OPT_VERBOSECALL}, - {"ieee", false, OPT_IEEE}, - {"softnull", false, OPT_SOFTNULL}, - {"time", false, OPT_TIME}, - {"stat", false, OPT_STAT}, - {"log", true, OPT_LOG}, - {"c", true, OPT_CHECK}, - {"l", false, OPT_LOAD}, - {"m", true, OPT_METHOD}, - {"sig", true, OPT_SIGNATURE}, - {"s", true, OPT_SHOW}, - {"all", false, OPT_ALL}, + {"classpath", true, OPT_CLASSPATH}, + {"D", true, OPT_D}, + {"ms", true, OPT_MS}, + {"mx", true, OPT_MX}, + {"noasyncgc", false, OPT_IGNORE}, + {"noverify", false, OPT_IGNORE}, + {"oss", true, OPT_IGNORE}, + {"ss", true, OPT_IGNORE}, + {"v", false, OPT_VERBOSE1}, + {"verbose", false, OPT_VERBOSE}, + {"verbosegc", false, OPT_VERBOSEGC}, + {"verbosecall", false, OPT_VERBOSECALL}, + {"ieee", false, OPT_IEEE}, + {"softnull", false, OPT_SOFTNULL}, + {"time", false, OPT_TIME}, + {"stat", false, OPT_STAT}, + {"log", true, OPT_LOG}, + {"c", true, OPT_CHECK}, + {"l", false, OPT_LOAD}, + {"m", true, OPT_METHOD}, + {"sig", true, OPT_SIGNATURE}, + {"s", true, OPT_SHOW}, + {"all", false, OPT_ALL}, #ifdef OLD_COMPILER - {"old", false, OPT_OLD}, + {"old", false, OPT_OLD}, +#endif +#ifdef NEW_GC + {"gc1", false, OPT_GC1}, + {"gc2", false, OPT_GC2}, #endif - {NULL, false, 0} + {NULL, false, 0} }; static int opt_ind = 1; @@ -125,8 +136,8 @@ static int get_opt (int argc, char **argv) if (strcmp(a+1, opts[i].name) == 0) { /* boolean option found */ opt_ind++; return opts[i].value; - } } + } else { if (strcmp(a+1, opts[i].name) == 0) { /* parameter option found */ opt_ind++; @@ -134,9 +145,9 @@ static int get_opt (int argc, char **argv) opt_arg = argv[opt_ind]; opt_ind++; return opts[i].value; - } - return OPT_ERROR; } + return OPT_ERROR; + } else { size_t l = strlen(opts[i].name); if (strlen(a+1) > l) { @@ -144,11 +155,11 @@ static int get_opt (int argc, char **argv) opt_ind++; opt_arg = a+1+l; return opts[i].value; - } } } } - } /* end for */ + } + } /* end for */ return OPT_ERROR; } @@ -185,6 +196,10 @@ static void print_usage() printf (" -all ................. compile all methods, no execution\n"); #ifdef OLD_COMPILER printf (" -old ................. use old JIT compiler\n"); +#endif +#ifdef NEW_GC + 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"); @@ -438,7 +453,7 @@ int main(int argc, char **argv) java_objectheader *exceptionptr; void *dummy; - /********** interne (nur fuer main relevante Optionen) **************/ + /********** interne (nur fuer main relevante Optionen) **************/ char logfilename[200] = ""; u4 heapsize = 16000000; @@ -460,179 +475,189 @@ int main(int argc, char **argv) atexit(clear_thread_flags); #endif - /************ Infos aus der Environment lesen ************************/ + /************ Infos aus der Environment lesen ************************/ cp = getenv ("CLASSPATH"); if (cp) { strcpy (classpath, cp); - } + } - /***************** Interpretieren der Kommandozeile *****************/ + /***************** Interpretieren der Kommandozeile *****************/ - checknull = false; - checkfloats = false; + checknull = false; + checkfloats = false; while ( (i = get_opt(argc,argv)) != OPT_DONE) { switch (i) { - case OPT_IGNORE: break; + case OPT_IGNORE: break; - case OPT_CLASSPATH: - strcpy (classpath + strlen(classpath), ":"); - strcpy (classpath + strlen(classpath), opt_arg); - break; + case OPT_CLASSPATH: + strcpy (classpath + strlen(classpath), ":"); + strcpy (classpath + strlen(classpath), opt_arg); + break; - case OPT_D: - { + case OPT_D: + { int n,l=strlen(opt_arg); for (n=0; n= argc) { print_usage (); exit(10); - } + } - /**************************** Programmstart *****************************/ + /**************************** Programmstart *****************************/ log_init (logfilename); if (verbose) { log_text ( - "CACAO started -------------------------------------------------------"); - } + "CACAO started -------------------------------------------------------"); + } suck_init (classpath); native_setclasspath (classpath); @@ -648,12 +673,12 @@ int main(int argc, char **argv) native_loadclasses (); - /*********************** JAVA-Klassen laden ***************************/ + /*********************** JAVA-Klassen laden ***************************/ cp = argv[opt_ind++]; for (i=strlen(cp)-1; i>=0; i--) { /* Punkte im Klassennamen */ if (cp[i]=='.') cp[i]='/'; /* auf slashes umbauen */ - } + } topclass = loader_load ( unicode_new_char (cp) ); @@ -665,7 +690,7 @@ int main(int argc, char **argv) initThreads((u1*)&dummy); /* schani */ #endif - /************************* Arbeitsroutinen starten ********************/ + /************************* Arbeitsroutinen starten ********************/ if (startit) { methodinfo *mainmethod; @@ -674,34 +699,34 @@ int main(int argc, char **argv) heap_addreference((void**) &a); mainmethod = class_findmethod ( - topclass, - unicode_new_char ("main"), - unicode_new_char ("([Ljava/lang/String;)V") - ); + topclass, + unicode_new_char ("main"), + unicode_new_char ("([Ljava/lang/String;)V") + ); if (!mainmethod) panic ("Can not find method 'void main(String[])'"); if ((mainmethod->flags & ACC_STATIC) != ACC_STATIC) panic ("main is not static!"); a = builtin_anewarray (argc - opt_ind, class_java_lang_String); for (i=opt_ind; idata[i-opt_ind] = javastring_new (unicode_new_char (argv[i]) ); - } + } exceptionptr = asm_calljavamethod (mainmethod, a, NULL,NULL,NULL ); if (exceptionptr) { printf ("#### Program has thrown: "); unicode_display (exceptionptr->vftbl->class->name); printf ("\n"); - } + } -/* killThread(currentThread); */ + /* killThread(currentThread); */ - } + } /************* Auf Wunsch alle Methode "ubersetzen ********************/ if (compileall) { class_compile_methods(); - } + } /******** Auf Wunsch eine spezielle Methode "ubersetzen ***************/ @@ -710,11 +735,11 @@ int main(int argc, char **argv) methodinfo *m; if (specificsignature) m = class_findmethod(topclass, - unicode_new_char(specificmethodname), - unicode_new_char(specificsignature)); + unicode_new_char(specificmethodname), + unicode_new_char(specificsignature)); else m = class_findmethod(topclass, - unicode_new_char(specificmethodname), NULL); + unicode_new_char(specificmethodname), NULL); if (!m) panic ("Specific method not found"); #ifdef OLD_COMPILER if (newcompiler) @@ -724,7 +749,7 @@ int main(int argc, char **argv) else (void) compiler_compile(m); #endif - } + } /********************* Debug-Tabellen ausgeben ************************/ @@ -734,7 +759,7 @@ int main(int argc, char **argv) - /************************ Freigeben aller Resourcen *******************/ + /************************ Freigeben aller Resourcen *******************/ heap_close (); /* must be called before compiler_close and loader_close because finalization occurs @@ -746,7 +771,7 @@ int main(int argc, char **argv) unicode_close ( literalstring_free ); - /* Endemeldung ausgeben und mit entsprechendem exit-Status terminieren */ + /* Endemeldung ausgeben und mit entsprechendem exit-Status terminieren */ if (verbose || getcompilingtime || statistics) { log_text ("CACAO terminated"); @@ -755,7 +780,7 @@ int main(int argc, char **argv) if (getcompilingtime) print_times (); mem_usagelog(1); - } + } exit(0); return 1; diff --git a/src/cacao/cacao.c b/src/cacao/cacao.c index 126935964..e49362c9d 100644 --- a/src/cacao/cacao.c +++ b/src/cacao/cacao.c @@ -38,6 +38,9 @@ bool compileall = false; int newcompiler = true; bool verbose = false; +#ifdef NEW_GC +bool new_gc = false; +#endif #ifndef USE_THREADS void **stackbottom = 0; @@ -76,35 +79,43 @@ void **stackbottom = 0; #ifdef OLD_COMPILER #define OPT_OLD 21 #endif +#ifdef NEW_GC +#define OPT_GC1 22 +#define OPT_GC2 23 +#endif struct {char *name; bool arg; int value;} opts[] = { - {"classpath", true, OPT_CLASSPATH}, - {"D", true, OPT_D}, - {"ms", true, OPT_MS}, - {"mx", true, OPT_MX}, - {"noasyncgc", false, OPT_IGNORE}, - {"noverify", false, OPT_IGNORE}, - {"oss", true, OPT_IGNORE}, - {"ss", true, OPT_IGNORE}, - {"v", false, OPT_VERBOSE1}, - {"verbose", false, OPT_VERBOSE}, - {"verbosegc", false, OPT_VERBOSEGC}, - {"verbosecall", false, OPT_VERBOSECALL}, - {"ieee", false, OPT_IEEE}, - {"softnull", false, OPT_SOFTNULL}, - {"time", false, OPT_TIME}, - {"stat", false, OPT_STAT}, - {"log", true, OPT_LOG}, - {"c", true, OPT_CHECK}, - {"l", false, OPT_LOAD}, - {"m", true, OPT_METHOD}, - {"sig", true, OPT_SIGNATURE}, - {"s", true, OPT_SHOW}, - {"all", false, OPT_ALL}, + {"classpath", true, OPT_CLASSPATH}, + {"D", true, OPT_D}, + {"ms", true, OPT_MS}, + {"mx", true, OPT_MX}, + {"noasyncgc", false, OPT_IGNORE}, + {"noverify", false, OPT_IGNORE}, + {"oss", true, OPT_IGNORE}, + {"ss", true, OPT_IGNORE}, + {"v", false, OPT_VERBOSE1}, + {"verbose", false, OPT_VERBOSE}, + {"verbosegc", false, OPT_VERBOSEGC}, + {"verbosecall", false, OPT_VERBOSECALL}, + {"ieee", false, OPT_IEEE}, + {"softnull", false, OPT_SOFTNULL}, + {"time", false, OPT_TIME}, + {"stat", false, OPT_STAT}, + {"log", true, OPT_LOG}, + {"c", true, OPT_CHECK}, + {"l", false, OPT_LOAD}, + {"m", true, OPT_METHOD}, + {"sig", true, OPT_SIGNATURE}, + {"s", true, OPT_SHOW}, + {"all", false, OPT_ALL}, #ifdef OLD_COMPILER - {"old", false, OPT_OLD}, + {"old", false, OPT_OLD}, +#endif +#ifdef NEW_GC + {"gc1", false, OPT_GC1}, + {"gc2", false, OPT_GC2}, #endif - {NULL, false, 0} + {NULL, false, 0} }; static int opt_ind = 1; @@ -125,8 +136,8 @@ static int get_opt (int argc, char **argv) if (strcmp(a+1, opts[i].name) == 0) { /* boolean option found */ opt_ind++; return opts[i].value; - } } + } else { if (strcmp(a+1, opts[i].name) == 0) { /* parameter option found */ opt_ind++; @@ -134,9 +145,9 @@ static int get_opt (int argc, char **argv) opt_arg = argv[opt_ind]; opt_ind++; return opts[i].value; - } - return OPT_ERROR; } + return OPT_ERROR; + } else { size_t l = strlen(opts[i].name); if (strlen(a+1) > l) { @@ -144,11 +155,11 @@ static int get_opt (int argc, char **argv) opt_ind++; opt_arg = a+1+l; return opts[i].value; - } } } } - } /* end for */ + } + } /* end for */ return OPT_ERROR; } @@ -185,6 +196,10 @@ static void print_usage() printf (" -all ................. compile all methods, no execution\n"); #ifdef OLD_COMPILER printf (" -old ................. use old JIT compiler\n"); +#endif +#ifdef NEW_GC + 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"); @@ -438,7 +453,7 @@ int main(int argc, char **argv) java_objectheader *exceptionptr; void *dummy; - /********** interne (nur fuer main relevante Optionen) **************/ + /********** interne (nur fuer main relevante Optionen) **************/ char logfilename[200] = ""; u4 heapsize = 16000000; @@ -460,179 +475,189 @@ int main(int argc, char **argv) atexit(clear_thread_flags); #endif - /************ Infos aus der Environment lesen ************************/ + /************ Infos aus der Environment lesen ************************/ cp = getenv ("CLASSPATH"); if (cp) { strcpy (classpath, cp); - } + } - /***************** Interpretieren der Kommandozeile *****************/ + /***************** Interpretieren der Kommandozeile *****************/ - checknull = false; - checkfloats = false; + checknull = false; + checkfloats = false; while ( (i = get_opt(argc,argv)) != OPT_DONE) { switch (i) { - case OPT_IGNORE: break; + case OPT_IGNORE: break; - case OPT_CLASSPATH: - strcpy (classpath + strlen(classpath), ":"); - strcpy (classpath + strlen(classpath), opt_arg); - break; + case OPT_CLASSPATH: + strcpy (classpath + strlen(classpath), ":"); + strcpy (classpath + strlen(classpath), opt_arg); + break; - case OPT_D: - { + case OPT_D: + { int n,l=strlen(opt_arg); for (n=0; n= argc) { print_usage (); exit(10); - } + } - /**************************** Programmstart *****************************/ + /**************************** Programmstart *****************************/ log_init (logfilename); if (verbose) { log_text ( - "CACAO started -------------------------------------------------------"); - } + "CACAO started -------------------------------------------------------"); + } suck_init (classpath); native_setclasspath (classpath); @@ -648,12 +673,12 @@ int main(int argc, char **argv) native_loadclasses (); - /*********************** JAVA-Klassen laden ***************************/ + /*********************** JAVA-Klassen laden ***************************/ cp = argv[opt_ind++]; for (i=strlen(cp)-1; i>=0; i--) { /* Punkte im Klassennamen */ if (cp[i]=='.') cp[i]='/'; /* auf slashes umbauen */ - } + } topclass = loader_load ( unicode_new_char (cp) ); @@ -665,7 +690,7 @@ int main(int argc, char **argv) initThreads((u1*)&dummy); /* schani */ #endif - /************************* Arbeitsroutinen starten ********************/ + /************************* Arbeitsroutinen starten ********************/ if (startit) { methodinfo *mainmethod; @@ -674,34 +699,34 @@ int main(int argc, char **argv) heap_addreference((void**) &a); mainmethod = class_findmethod ( - topclass, - unicode_new_char ("main"), - unicode_new_char ("([Ljava/lang/String;)V") - ); + topclass, + unicode_new_char ("main"), + unicode_new_char ("([Ljava/lang/String;)V") + ); if (!mainmethod) panic ("Can not find method 'void main(String[])'"); if ((mainmethod->flags & ACC_STATIC) != ACC_STATIC) panic ("main is not static!"); a = builtin_anewarray (argc - opt_ind, class_java_lang_String); for (i=opt_ind; idata[i-opt_ind] = javastring_new (unicode_new_char (argv[i]) ); - } + } exceptionptr = asm_calljavamethod (mainmethod, a, NULL,NULL,NULL ); if (exceptionptr) { printf ("#### Program has thrown: "); unicode_display (exceptionptr->vftbl->class->name); printf ("\n"); - } + } -/* killThread(currentThread); */ + /* killThread(currentThread); */ - } + } /************* Auf Wunsch alle Methode "ubersetzen ********************/ if (compileall) { class_compile_methods(); - } + } /******** Auf Wunsch eine spezielle Methode "ubersetzen ***************/ @@ -710,11 +735,11 @@ int main(int argc, char **argv) methodinfo *m; if (specificsignature) m = class_findmethod(topclass, - unicode_new_char(specificmethodname), - unicode_new_char(specificsignature)); + unicode_new_char(specificmethodname), + unicode_new_char(specificsignature)); else m = class_findmethod(topclass, - unicode_new_char(specificmethodname), NULL); + unicode_new_char(specificmethodname), NULL); if (!m) panic ("Specific method not found"); #ifdef OLD_COMPILER if (newcompiler) @@ -724,7 +749,7 @@ int main(int argc, char **argv) else (void) compiler_compile(m); #endif - } + } /********************* Debug-Tabellen ausgeben ************************/ @@ -734,7 +759,7 @@ int main(int argc, char **argv) - /************************ Freigeben aller Resourcen *******************/ + /************************ Freigeben aller Resourcen *******************/ heap_close (); /* must be called before compiler_close and loader_close because finalization occurs @@ -746,7 +771,7 @@ int main(int argc, char **argv) unicode_close ( literalstring_free ); - /* Endemeldung ausgeben und mit entsprechendem exit-Status terminieren */ + /* Endemeldung ausgeben und mit entsprechendem exit-Status terminieren */ if (verbose || getcompilingtime || statistics) { log_text ("CACAO terminated"); @@ -755,7 +780,7 @@ int main(int argc, char **argv) if (getcompilingtime) print_times (); mem_usagelog(1); - } + } exit(0); return 1; diff --git a/src/vm/global.h b/src/vm/global.h index fb818435c..0f632b6b5 100644 --- a/src/vm/global.h +++ b/src/vm/global.h @@ -12,7 +12,7 @@ Changes: Mark Probst (schani) EMAIL: cacao@complang.tuwien.ac.at Philipp Tomsich (phil) EMAIL: cacao@complang.tuwien.ac.at - Last Change: $Id: global.h 55 1998-11-10 17:33:40Z phil $ + Last Change: $Id: global.h 64 1998-11-11 21:11:55Z phil $ *******************************************************************************/ @@ -20,6 +20,7 @@ #define __global_h_ #define OLD_COMPILER /* if enabled makes old compiler available */ +#define NEW_GC /* if enabled, includes the new gc. -- phil. */ #define STATISTICS /* if enabled collects program statistics */ @@ -529,7 +530,7 @@ extern java_objectheader *proto_java_lang_ThreadDeath; extern bool compileall; extern bool runverbose; extern bool verbose; - + /* statistic variables ********************************************************/