- added comments
[cacao.git] / main.c
diff --git a/main.c b/main.c
index 7354e8f2e542486732e45eb6939aed457bfc0505..108651b793c3a4c75d544bc0319a1e4c32122c80 100644 (file)
--- a/main.c
+++ b/main.c
@@ -37,7 +37,7 @@
      - Calling the class loader
      - Running the main method
 
-   $Id: main.c 771 2003-12-13 23:11:08Z stefan $
+   $Id: main.c 841 2004-01-05 00:43:03Z twisti $
 
 */
 
 
 bool verbose =  false;
 bool compileall = false;
-bool runverbose = false;
+bool runverbose = false;       /* trace all method invocation                */
 bool collectverbose = false;
 
 bool loadverbose = false;
 bool linkverbose = false;
 bool initverbose = false;
 
-bool opt_rt = false;            /* true if RTA parse should be used     RT-CO */
-bool opt_xta = false;           /* true if XTA parse should be used    XTA-CO */
-bool opt_vta = false;           /* true if VTA parse should be used    VTA-CO */
+bool opt_rt = false;           /* true if RTA parse should be used     RT-CO */
+bool opt_xta = false;          /* true if XTA parse should be used    XTA-CO */
+bool opt_vta = false;          /* true if VTA parse should be used    VTA-CO */
 
 bool showmethods = false;
 bool showconstantpool = false;
 bool showutf = false;
 
-bool compileverbose =  false;
+bool compileverbose =  false;  /* trace compiler actions                     */
 bool showstack = false;
-bool showdisassemble = false; 
-bool showddatasegment = false; 
-bool showintermediate = false;
-
-bool useinlining = false;
-bool inlinevirtuals = false;
-bool inlineexceptions = false;
-bool inlineparamopt = false;
-bool inlineoutsiders = false;
-
-bool checkbounds = true;
-bool checknull = true;
-bool opt_noieee = false;
-bool checksync = true;
-bool opt_loops = false;
+bool showdisassemble = false;  /* generate disassembler listing              */
+bool showddatasegment = false; /* generate data segment listing              */
+bool showintermediate = false; /* generate intermediate code listing         */
+
+bool useinlining = false;      /* use method inlining                        */
+bool inlinevirtuals = false;   /* inline unique virtual methods              */
+bool inlineexceptions = false; /* inline methods, that contain excptions     */
+bool inlineparamopt = false;   /* optimize parameter passing to inlined methods */
+bool inlineoutsiders = false;  /* inline methods, that are not member of the invoker's class */
+
+bool checkbounds = true;       /* check array bounds                         */
+bool checknull = true;         /* check null pointers                        */
+bool opt_noieee = false;       /* don't implement ieee compliant floats      */
+bool checksync = true;         /* do synchronization                         */
+bool opt_loops = false;        /* optimize array accesses in loops           */
 
 bool makeinitializations = true;
 
 bool getloadingtime = false;   /* to measure the runtime                     */
 s8 loadingtime = 0;
 
+bool getcompilingtime = false; /* compute compile time                       */
+s8 compilingtime = 0;          /* accumulated compile time                   */
+
+int has_ext_instr_set = 0;     /* has instruction set extensions */
+
+bool statistics = false;
+
+bool opt_verify = true;        /* true if classfiles should be verified      */
+
 
 static classinfo *topclass;
 
@@ -146,6 +155,7 @@ void **stackbottom = 0;
 #define OPT_XTA         27 
 #define OPT_VTA         28
 #define OPT_VERBOSETC   29
+#define OPT_NOVERIFY    30
 
 
 struct {char *name; bool arg; int value;} opts[] = {
@@ -154,7 +164,7 @@ struct {char *name; bool arg; int value;} opts[] = {
        {"ms",          true,   OPT_MS},
        {"mx",          true,   OPT_MX},
        {"noasyncgc",   false,  OPT_IGNORE},
-       {"noverify",    false,  OPT_IGNORE},
+       {"noverify",    false,  OPT_NOVERIFY},
        {"oss",         true,   OPT_IGNORE},
        {"ss",          true,   OPT_IGNORE},
        {"v",           false,  OPT_VERBOSE1},
@@ -259,6 +269,7 @@ static void print_usage()
 #if defined(__ALPHA__)
        printf("          -noieee .............. don't use ieee compliant arithmetic\n");
 #endif
+       printf("          -noverify ............ don't verify classfiles\n");
        printf("          -softnull ............ use software nullpointer check\n");
        printf("          -time ................ measure the runtime\n");
        printf("          -stat ................ detailed compiler statistics\n");
@@ -300,16 +311,35 @@ static void print_times()
        s8 runtime = totaltime - loadingtime - compilingtime;
        char logtext[MAXLOGTEXT];
 
+#if defined(__I386__)
        sprintf(logtext, "Time for loading classes: %lld secs, %lld millis",
+#else
+       sprintf(logtext, "Time for loading classes: %ld secs, %ld millis",
+#endif
                        loadingtime / 1000000, (loadingtime % 1000000) / 1000);
        log_text(logtext);
+
+#if defined(__I386__)
        sprintf(logtext, "Time for compiling code:  %lld secs, %lld millis",
+#else
+       sprintf(logtext, "Time for compiling code:  %ld secs, %ld millis",
+#endif
                        compilingtime / 1000000, (compilingtime % 1000000) / 1000);
        log_text(logtext);
+
+#if defined(__I386__)
        sprintf(logtext, "Time for running program: %lld secs, %lld millis",
+#else
+       sprintf(logtext, "Time for running program: %ld secs, %ld millis",
+#endif
                        runtime / 1000000, (runtime % 1000000) / 1000);
        log_text(logtext);
+
+#if defined(__I386__)
        sprintf(logtext, "Total time: %lld secs, %lld millis",
+#else
+       sprintf(logtext, "Total time: %ld secs, %ld millis",
+#endif
                        totaltime / 1000000, (totaltime % 1000000) / 1000);
        log_text(logtext);
 }
@@ -492,16 +522,15 @@ static void print_stats()
 }
 
 
-
 /********** Function: class_compile_methods   (debugging only) ********/
 
-void class_compile_methods ()
+void class_compile_methods()
 {
        int        i;
        classinfo  *c;
        methodinfo *m;
        
-       c = list_first (&linkedclasses);
+       c = list_first(&linkedclasses);
        while (c) {
                for (i = 0; i < c -> methodscount; i++) {
                        m = &(c->methods[i]);
@@ -514,7 +543,6 @@ void class_compile_methods ()
 }
 
 
-
 /*
  * void exit_handler(void)
  * -----------------------
@@ -571,7 +599,7 @@ int main(int argc, char **argv)
        char logfilename[200] = "";
        u4 heapsize = 64000000;
        u4 heapstartsize = 200000;
-       char classpath[500] = ".:/usr/local/lib/java/classes";
+       char classpath[500] = ".";
        bool startit = true;
        char *specificmethodname = NULL;
        char *specificsignature = NULL;
@@ -665,6 +693,10 @@ int main(int argc, char **argv)
                        opt_noieee = true;
                        break;
 
+               case OPT_NOVERIFY:
+                       opt_verify = false;
+                       break;
+
                case OPT_SOFTNULL:
                        checknull = true;
                        break;
@@ -810,10 +842,11 @@ int main(int argc, char **argv)
                log_text("CACAO started -------------------------------------------------------");
        }
 
-       suck_init(classpath);
        native_setclasspath(classpath);
                
        tables_init();
+       suck_init(classpath);
+
        heap_init(heapsize, heapstartsize, &dummy);
 
        log_text("calling jit_init");
@@ -833,7 +866,9 @@ int main(int argc, char **argv)
                if (cp[i] == '.') cp[i] = '/';          /* in the class name */
        }
 
+       /*printf("-------------------->%s\n",cp);*/
        topclass = loader_load(utf_new_char(cp));
+       /*class_showmethods(topclass);  */
 
        if (exceptionptr != 0) {
                printf("Exception in thread \"main\" ");
@@ -879,7 +914,8 @@ int main(int argc, char **argv)
 
                a = builtin_anewarray(argc - opt_ind, class_java_lang_String);
                for (i = opt_ind; i < argc; i++) {
-                       a->data[i - opt_ind] = javastring_new(utf_new_char(argv[i]));
+                       a->data[i - opt_ind] = 
+                               (java_objectheader *) javastring_new(utf_new_char(argv[i]));
                }
 
 #ifdef TYPEINFO_DEBUG_TEST