cacao is now again able to run kjc on i386
[cacao.git] / headers.c
index 6320ac10b6a43420402b992ee9087afd555e035f..576203d7c2b3c449a75edce8fd33bf9966e75f9c 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -29,7 +29,7 @@
    Changes: Mark Probst
             Philipp Tomsich
 
-   $Id: headers.c 689 2003-12-05 18:03:47Z stefan $
+   $Id: headers.c 930 2004-03-02 21:18:23Z jowenn $
 
 */
 
 #include "global.h"
 #include "tables.h"
 #include "loader.h"
+#include "builtin.h"
+#include "mm/boehm.h"
 #include "toolbox/chain.h"
 #include "toolbox/memory.h"
 #include "toolbox/loging.h"
 
 
+/* replace command line options */
+
+bool verbose =  false;
+bool compileall = false;
+bool runverbose = false;
+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_verify = true;        /* true if classfiles should be verified      */
+bool opt_liberalutf = false;   /* Don't check overlong UTF-8 sequences       */
+
+bool showmethods = false;
+bool showconstantpool = false;
+bool showutf = false;
+
+bool makeinitializations = true;
+
+bool getloadingtime = false;
+s8 loadingtime = 0;
+
+
 /******* replace some external functions  *********/
  
-functionptr native_findfunction (utf *cname, utf *mname, utf *desc, bool isstatic)
+functionptr native_findfunction(utf *cname, utf *mname, utf *desc, bool isstatic)
 { return NULL; }
 
-java_objectheader *javastring_new (utf *text)         /* schani */
+java_objectheader *javastring_new(utf *text)
 { return NULL; }
 
-void throw_classnotfoundexception() 
-{ 
-       panic("class not found----------"); 
-}
-/*  */
 
-void throw_classnotfoundexception2(utf* classname) 
+void throw_noclassdeffounderror_message(utf* classname)
 { 
-       /* [stefan] code was useless
-       sprintf (logtext, "Loading class: ");
-       utf_sprint (logtext+strlen(logtext), classname);
-       */
-       panic("******class not found"); 
+       printf("Class not found: ");
+       utf_display(classname);
+       printf("\n");
+       exit(1);
 }
 
-/* this is here to avoid link errors. We are not interested in linkagerrors in cacaoh right now*/
-void throw_linkageerror2(utf* classname) 
+
+/* this is here to avoid link errors. 
+   We are not interested in linkagerrors in cacaoh right now
+*/
+void throw_linkageerror_message(utf* classname) 
 { 
 }
 
-java_objectheader *literalstring_new (utf *u)
-{ return NULL; }  
+
+java_objectheader *literalstring_new(utf *u) { return NULL; }  
+
 
 void literalstring_free(java_objectheader *o) { }
 void stringtable_update() { }
 void synchronize_caches() { }
 void asm_call_jit_compiler() { }
-void asm_calljavamethod() { }
+void asm_calljavafunction() { }
 void asm_dumpregistersandcall() { }
 s4 asm_builtin_checkcast(java_objectheader *obj, classinfo *class) { return 0; }
 
@@ -98,7 +125,8 @@ s8 asm_builtin_d2l(double a) { return 0; }
 void asm_builtin_monitorenter(java_objectheader *o) {}
 void asm_builtin_monitorexit(java_objectheader *o) {}
 
-s4 asm_builtin_checkarraycast(java_objectheader *o,arraydescriptor *d) {return 0;}
+s4 asm_builtin_checkarraycast(java_objectheader *obj, vftbl *target) {return 0;}
+
 
 #if defined(__I386__)
 s4 asm_builtin_arrayinstanceof(java_objectheader *obj, classinfo *class) { return 0; }
@@ -124,11 +152,7 @@ java_objectheader *native_new_and_init(void *p) { return NULL; }
 
 /************************ global variables **********************/
 
-java_objectheader *exceptionptr;
-
-bool verbose =  false;
-bool runverbose = false;
-bool collectverbose = false;
+THREADSPECIFIC java_objectheader *_exceptionptr;
 
 static chain *nativemethod_chain;    /* chain with native methods     */
 static chain *nativeclass_chain;                              /* chain with processed classes  */      
@@ -234,7 +258,7 @@ static char *printtype(char *utf_ptr)
 }
 
 
-/******* determine the number of entries of a utf string in the ident chain *****/
+/***** determine the number of entries of a utf string in the ident chain *****/
 
 static int searchidentchain_utf(utf *ident) 
 {
@@ -250,7 +274,7 @@ static int searchidentchain_utf(utf *ident)
 }
 
 
-/**************** print structure for direct access to objects ******************/     
+/************** print structure for direct access to objects ******************/
 
 static void printfields(classinfo *c)
 {
@@ -345,7 +369,7 @@ static void printmethod(methodinfo *m)
 }
 
 
-/****************** remove package-name in fully-qualified classname *********************/
+/******* remove package-name in fully-qualified classname *********************/
 
 static void gen_header_filename(char *buffer, utf *u)
 {
@@ -359,7 +383,7 @@ static void gen_header_filename(char *buffer, utf *u)
 }
 
 
-/*********** create headerfile for classes and store native methods in chain ************/
+/* create headerfile for classes and store native methods in chain ************/
 
 static void headerfile_generate(classinfo *c)
 {
@@ -429,20 +453,23 @@ static void headerfile_generate(classinfo *c)
        fclose(file);
 }
 
+
 /******** print classname, '$' used to seperate inner-class name ***********/
 
-void print_classname (classinfo *clazz)
+void print_classname(classinfo *clazz)
 {
        utf *u = clazz->name;
     char *endpos  = u->text + u->blength;
     char *utf_ptr = u->text; 
        u2 c;
 
-    while (utf_ptr<endpos) {
-               if ((c=utf_nextu2(&utf_ptr)) == '_')
-                       putc ('$',file);
-               else
-                       putc (c,file);
+    while (utf_ptr < endpos) {
+               if ((c = utf_nextu2(&utf_ptr)) == '_') {
+                       putc('$', file);
+
+               } else {
+                       putc(c, file);
+               }
        }
 } 
 
@@ -583,7 +610,7 @@ int main(int argc, char **argv)
        log_init(NULL);
        log_text("Java - header-generator started"); 
        
-       sprintf(offsets_filename, "jit/%s/offsets.h", ARCH_DIR); /* phil */
+       sprintf(offsets_filename, "jit/%s/offsets.h", ARCH_DIR);
        file = fopen(offsets_filename, "w");
        if (file == NULL) {
                fprintf(stderr, "Can not open file '%s' for write", offsets_filename);
@@ -598,12 +625,21 @@ int main(int argc, char **argv)
        fprintf(file, "#define offbaseval     %3d\n", (int) OFFSET(vftbl, baseval));
        fprintf(file, "#define offdiffval     %3d\n\n", (int) OFFSET(vftbl, diffval));
 
-       fprintf(file, "#define offclassvftbl    %3d\n", (int) OFFSET(classinfo, vftbl));
+       fprintf(file, "#define offclassvftbl  %3d\n", (int) OFFSET(classinfo, vftbl));
+       fprintf(file, "#define offclassinit   %3d\n\n", (int) OFFSET(classinfo, initialized));
 
        fprintf(file, "#define offjniitemtype %3d\n", (int) OFFSET(jni_callblock, itemtype));
        fprintf(file, "#define offjniitem     %3d\n", (int) OFFSET(jni_callblock, item));
        fprintf(file, "#define sizejniblock   %3d\n\n", (int) sizeof(jni_callblock));
 
+       fprintf(file, "#define offclassmethodinfo   %3d\n\n", (int) OFFSET(methodinfo,class));
+
+       fprintf(file, "#define offmethodnative %3d\n", (int) OFFSET(native_stackframeinfo,method));
+       fprintf(file, "#define offreturnfromnative %3d\n", (int) OFFSET(native_stackframeinfo,returnFromNative));
+       fprintf(file, "#define offaddrreturnfromnative %3d\n", (int) OFFSET(native_stackframeinfo,addrReturnFromNative));
+       fprintf(file, "#define offprevnative %3d\n", (int) OFFSET(native_stackframeinfo,prev));
+       fprintf(file, "#define offnextnative %3d\n", (int) OFFSET(native_stackframeinfo,next));
+       
 
        fclose(file);