changed exception types and innerclass references to classref_or_classinfo
authoredwin <none@none>
Sat, 2 Apr 2005 10:07:44 +0000 (10:07 +0000)
committeredwin <none@none>
Sat, 2 Apr 2005 10:07:44 +0000 (10:07 +0000)
13 files changed:
src/native/native.c
src/native/vm/VMClass.c
src/vm/class.h
src/vm/classcache.c
src/vm/jit/alpha/codegen.c
src/vm/jit/i386/codegen.c
src/vm/jit/mips/codegen.c
src/vm/jit/powerpc/codegen.c
src/vm/jit/verify/typecheck.c
src/vm/jit/x86_64/codegen.c
src/vm/linker.c
src/vm/loader.c
src/vm/method.h

index 5eec7e1e66466304b0c39cfb16df8ee0360e2e77..90139d840d98edc4ad9ec009dc58466f376949db 100644 (file)
@@ -30,7 +30,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: native.c 2186 2005-04-02 00:43:25Z edwin $
+   $Id: native.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -606,6 +606,7 @@ java_objectarray* get_exceptiontypes(methodinfo *m)
     u2 excount;
     u2 i;
     java_objectarray *result;
+       classinfo *cls;
 
        excount = m->thrownexceptionscount;
 
@@ -613,9 +614,10 @@ java_objectarray* get_exceptiontypes(methodinfo *m)
     result = builtin_anewarray(excount, class_java_lang_Class);
 
     for (i = 0; i < excount; i++) {
-               java_objectheader *o = (java_objectheader *) (m->thrownexceptions[i]);
-               use_class_as_object((classinfo *) o);
-               result->data[i] = o;
+               if (!resolve_classref_or_classinfo(NULL,m->thrownexceptions[i],resolveEager,false,&cls))
+                       return NULL; /* exception */
+               use_class_as_object(cls);
+               result->data[i] = (java_objectheader *)cls;
     }
 
     return result;
index 8b2a4f617a8e4ca0e852763b560abd6c0b96fbdc..4e3d7b495ef014a0cc9e0e42faecfaa5b315e4c4 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Joseph Wenninger
             Christian Thalinger
 
-   $Id: VMClass.c 2186 2005-04-02 00:43:25Z edwin $
+   $Id: VMClass.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -252,7 +252,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JN
        if (!Java_java_lang_VMClass_isPrimitive(env, clazz, (java_lang_Class *) c) && (c->name->text[0] != '[')) {
                /* determine number of declared classes */
                for (i = 0; i < c->innerclasscount; i++) {
-                       if ( (c->innerclass[i].outer_class == c) && (notPublicOnly || (c->innerclass[i].flags & ACC_PUBLIC)))
+                       if ( (c->innerclass[i].outer_class.cls == c) && (notPublicOnly || (c->innerclass[i].flags & ACC_PUBLIC)))
                                /* outer class is this class */
                                declaredclasscount++;
                }
@@ -263,8 +263,8 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JN
        result = builtin_anewarray(declaredclasscount, class_java_lang_Class);          
 
        for (i = 0; i < c->innerclasscount; i++) {
-               classinfo *inner = c->innerclass[i].inner_class;
-               classinfo *outer = c->innerclass[i].outer_class;
+               classinfo *inner = c->innerclass[i].inner_class.cls;
+               classinfo *outer = c->innerclass[i].outer_class.cls;
                
                if ((outer == c) && (notPublicOnly || (inner->flags & ACC_PUBLIC))) {
                        /* outer class is this class, store innerclass in array */
@@ -296,8 +296,8 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIE
                        return NULL;
     
                for (i = 0; i < c->innerclasscount; i++) {
-                       classinfo *inner =  c->innerclass[i].inner_class;
-                       classinfo *outer =  c->innerclass[i].outer_class;
+                       classinfo *inner =  c->innerclass[i].inner_class.cls;
+                       classinfo *outer =  c->innerclass[i].outer_class.cls;
       
                        if (inner == c) {
                                /* innerclass is this class */
index 942b690cf12b5841449ecd30ce28d2b1e1491eb7..37fed6e6ba059e1896721538616503001001084d 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: class.h 2186 2005-04-02 00:43:25Z edwin $
+   $Id: class.h 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -125,10 +125,10 @@ struct classinfo {                /* class structure                          */
 /* innerclassinfo *************************************************************/
 
 struct innerclassinfo {
-       classinfo *inner_class;       /* inner class pointer                      */
-       classinfo *outer_class;       /* outer class pointer                      */
-       utf       *name;              /* innerclass name                          */
-       s4         flags;             /* ACC flags                                */
+       classref_or_classinfo inner_class; /* inner class pointer                 */
+       classref_or_classinfo outer_class; /* outer class pointer                 */
+       utf                  *name;        /* innerclass name                     */
+       s4                    flags;       /* ACC flags                           */
 };
 
 
index 5fb5101869fba462ef7e84638a1dd4d429631d3c..040e7b86a4fa8bdfb733191480631caeb59bcdb8 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: classcache.c 2186 2005-04-02 00:43:25Z edwin $
+   $Id: classcache.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -386,6 +386,12 @@ classcache_store(classloader *initloader,classinfo *cls)
 
        CLASSCACHE_ASSERT(cls);
 
+#ifdef CLASSCACHE_VERBOSE
+       fprintf(stderr,"classcache_store(%p,",initloader);
+       utf_fprint_classname(stderr,cls->name);
+       fprintf(stderr,")\n");
+#endif
+
        CLASSCACHE_LOCK();
 
        en = classcache_new_name(cls->name);
index 200bfbc9649c8bb2664d3a446694db0750e843c0..432d5cd9faa877f4425cd0d9532838a862d98d97 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Joseph Wenninger
             Christian Thalinger
 
-   $Id: codegen.c 2184 2005-04-01 21:19:05Z edwin $
+   $Id: codegen.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -316,7 +316,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                dseg_addtarget(cd, ex->start);
                dseg_addtarget(cd, ex->end);
                dseg_addtarget(cd, ex->handler);
-               (void) dseg_addaddress(cd, ex->catchtype);
+               (void) dseg_addaddress(cd, ex->catchtype.cls);
        }
        
        /* initialize mcode variables */
index 435321e399b92a0562534cad8841b61beb91e20e..1b7a6641cee0392785654e36a066ad08437f4d68 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Joseph Wenninger
 
-   $Id: codegen.c 2184 2005-04-01 21:19:05Z edwin $
+   $Id: codegen.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -305,7 +305,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                dseg_addtarget(cd, ex->start);
                dseg_addtarget(cd, ex->end);
                dseg_addtarget(cd, ex->handler);
-               (void) dseg_addaddress(cd, ex->catchtype);
+               (void) dseg_addaddress(cd, ex->catchtype.cls);
        }
 
        
index b5180f7f37a58da8a12d07fe2b93e7513175541e..552812a9044ca7fa77ed2ac595fcb9d29d45b9d2 100644 (file)
@@ -33,7 +33,7 @@
    This module generates MIPS machine code for a sequence of
    intermediate code commands (ICMDs).
 
-   $Id: codegen.c 2184 2005-04-01 21:19:05Z edwin $
+   $Id: codegen.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -288,7 +288,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                dseg_addtarget(cd, ex->start);
                dseg_addtarget(cd, ex->end);
                dseg_addtarget(cd, ex->handler);
-               (void) dseg_addaddress(cd, ex->catchtype);
+               (void) dseg_addaddress(cd, ex->catchtype.cls);
        }
        
        /* initialize mcode variables */
index ba8302a1db0380c4449b57d1981b956dda9f4c09..ff68f1f20cc0020f10b02e6917d07b4d5f575742 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: codegen.c 2184 2005-04-01 21:19:05Z edwin $
+   $Id: codegen.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -318,7 +318,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                dseg_addtarget(cd, ex->start);
                dseg_addtarget(cd, ex->end);
                dseg_addtarget(cd, ex->handler);
-               (void) dseg_addaddress(cd, ex->catchtype);
+               (void) dseg_addaddress(cd, ex->catchtype.cls);
        }
        
        /* initialize mcode variables */
index bfcc9979ae1f71ec648b3aef6dd5e6137e1c5762..f059979d37a09a00abd6620c254c330ba3852deb 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Edwin Steiner
 
-   $Id: typecheck.c 2186 2005-04-02 00:43:25Z edwin $
+   $Id: typecheck.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -2133,9 +2133,10 @@ methodinfo *typecheck(methodinfo *m, codegendata *cd, registerdata *rd)
                         i = 0;
                         while (handlers[i]) {
                                                        TYPECHECK_COUNT(stat_handlers_reached);
-                                                       cls = handlers[i]->catchtype; /* XXX change to classref */
-                                                       excstack.typeinfo.typeclass.cls = (cls) ? cls
-                                                               : class_java_lang_Throwable;
+                                                       if (handlers[i]->catchtype.any)
+                                                               excstack.typeinfo.typeclass = handlers[i]->catchtype;
+                                                       else
+                                                               excstack.typeinfo.typeclass.cls = class_java_lang_Throwable;
                                                        repeat |= typestate_reach(cd,rd, localbuf,bptr,
                                                                                                          handlers[i]->handler,
                                                                                                          &excstack,localset,
index 324c0dee5b3c2d36ed0ca991fc6a06cd56840ec8..719211618f6dcbe4134a20594339199109cabcef 100644 (file)
@@ -27,7 +27,7 @@
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 2184 2005-04-01 21:19:05Z edwin $
+   $Id: codegen.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -267,7 +267,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                dseg_addtarget(cd, ex->start);
                dseg_addtarget(cd, ex->end);
                dseg_addtarget(cd, ex->handler);
-               (void) dseg_addaddress(cd, ex->catchtype);
+               (void) dseg_addaddress(cd, ex->catchtype.cls);
        }
        
        /* initialize mcode variables */
index 2ba7652baefbbeb81a3936b1c38146c9de763cd3..f660e9091143f9daf2d131de40f473620ae089ee 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: linker.c 2186 2005-04-02 00:43:25Z edwin $
+   $Id: linker.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -329,14 +329,14 @@ static classinfo *link_class_intern(classinfo *c)
        if (c->linked)
                return c;
 
+       if (linkverbose)
+               log_message_class("Linking class: ", c);
+
        /* the class must be loaded */
        if (!c->loaded)
                throw_cacao_exception_exit(string_java_lang_InternalError,
                                                                   "Trying to link unloaded class");
 
-       if (linkverbose)
-               log_message_class("Linking class: ", c);
-
        /* ok, this class is somewhat linked */
        c->linked = true;
 
index 614cf2c9d393a7ac59b5f7abdd72a5f23ceb774f..797eefa4c13167ed9188f0ee885057de0f453291 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: loader.c 2189 2005-04-02 02:05:59Z edwin $
+   $Id: loader.c 2190 2005-04-02 10:07:44Z edwin $
 
 */
 
@@ -67,6 +67,7 @@
 #include "vm/statistics.h"
 #include "vm/stringlocal.h"
 #include "vm/tables.h"
+#include "vm/classcache.h"
 
 #if defined(USE_ZLIB)
 # include "vm/unzip.h"
@@ -1614,10 +1615,10 @@ static bool load_method(classbuffer *cb, methodinfo *m,descriptor_pool *descpool
 
                                idx = suck_u2(cb);
                                if (!idx) {
-                                       m->exceptiontable[j].catchtype = NULL;
+                                       m->exceptiontable[j].catchtype.any = NULL;
 
                                } else {
-                                       if (!(m->exceptiontable[j].catchtype =
+                                       if (!(m->exceptiontable[j].catchtype.cls =
                                                  class_getconstant(c, idx, CONSTANT_Class)))
                                                return false;
                                }
@@ -1687,10 +1688,10 @@ static bool load_method(classbuffer *cb, methodinfo *m,descriptor_pool *descpool
                        if (!check_classbuffer_size(cb, 2 * m->thrownexceptionscount))
                                return false;
 
-                       m->thrownexceptions = MNEW(classinfo*, m->thrownexceptionscount);
+                       m->thrownexceptions = MNEW(classref_or_classinfo, m->thrownexceptionscount);
 
                        for (j = 0; j < m->thrownexceptionscount; j++) {
-                               if (!((m->thrownexceptions)[j] =
+                               if (!((m->thrownexceptions)[j].cls =
                                          class_getconstant(c, suck_u2(cb), CONSTANT_Class)))
                                        return false;
                        }
@@ -1767,9 +1768,9 @@ static bool load_attributes(classbuffer *cb, u4 num)
                                                                
                                innerclassinfo *info = c->innerclass + j;
 
-                               info->inner_class =
+                               info->inner_class.cls =
                                        innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
-                               info->outer_class =
+                               info->outer_class.cls =
                                        innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
                                info->name =
                                        innerclass_getconstant(c, suck_u2(cb), CONSTANT_Utf8);
@@ -1816,6 +1817,11 @@ classinfo *load_class_from_classloader(classinfo *c, java_objectheader *cl)
 {
        classinfo *r;
 
+       /* lookup if this class has already been loaded */
+       r = classcache_lookup(cl,c->name);
+       if (r)
+               return r;
+
        /* if other class loader than bootstrap, call it */
 
        if (cl) {
@@ -1835,6 +1841,14 @@ classinfo *load_class_from_classloader(classinfo *c, java_objectheader *cl)
                                                                                           javastring_new(c->name),
                                                                                           NULL, NULL);
 
+               /* store this class in the loaded class cache */
+               if (r && !classcache_store(cl,r)) {
+                       log_message_class("Could not cache:",c);
+                       r->loaded = false;
+                       class_remove(r);
+                       r = NULL; /* exception */
+               }
+
                return r;
 
        } else {
@@ -1854,6 +1868,11 @@ classinfo *load_class_bootstrap(classinfo *c)
        classbuffer *cb;
        classinfo *r;
 
+       /* lookup if this class has already been loaded */
+       r = classcache_lookup(NULL,c->name);
+       if (r)
+               return r;
+
 #if defined(USE_THREADS)
        /* enter a monitor on the class */
 
@@ -1924,6 +1943,14 @@ classinfo *load_class_bootstrap(classinfo *c)
                compilingtime_start();
 #endif
 
+       /* store this class in the loaded class cache */
+       if (r && !classcache_store(NULL,c)) {
+               log_message_class("Could not cache:",c);
+               c->loaded = false;
+               class_remove(c);
+               r = NULL; /* exception */
+       }
+
 #if defined(USE_THREADS)
        /* leave the monitor */
 
index 9595c9268f1e78d953edb75635c32121a5a431f9..7e6f8d1a47ad3c2a181a342015fdfef78502cdd7 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: method.h 2184 2005-04-01 21:19:05Z edwin $
+   $Id: method.h 2190 2005-04-02 10:07:44Z edwin $
 */
 
 
@@ -93,7 +93,7 @@ struct methodinfo {                 /* method structure                       */
        exceptiontable *exceptiontable; /* the exceptiontable                     */
 
        u2          thrownexceptionscount;/* number of exceptions attribute       */
-       classinfo **thrownexceptions;   /* checked exceptions a method may throw  */
+       classref_or_classinfo *thrownexceptions; /* except. a method may throw    */
 
        u2          linenumbercount;    /* number of linenumber attributes        */
        lineinfo   *linenumbers;        /* array of lineinfo items                */
@@ -133,7 +133,7 @@ struct exceptiontable {         /* exceptiontable entry in a method           */
        s4              handlerpc;  /* pc of exception handler                    */
        basicblock     *handler;
 
-       classinfo      *catchtype;  /* catchtype of exception (NULL == catchall)  */
+       classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall)  */
        exceptiontable *next;       /* used to build a list of exception when     */
                                    /* loops are copied */
        exceptiontable *down;       /* instead of the old array, a list is used   */