PatchSet 4870 
Date: 2004/06/26 18:21:33
Author: rob
Branch: HEAD
Tag: (none) 
Log:
* kaffe/kaffevm/verify*.[ch]
More refactoring, code cleaning up, etc.
Error methods removed and simplified.

* kaffe/kaffevm/verify-type.c
Fixed compilation bug with gcc-2.95 (hopefully)

Members: 
        ChangeLog:1.2436->1.2437 
        kaffe/kaffevm/verifier/verify-errors.h:1.2->1.3 
        kaffe/kaffevm/verifier/verify-type.c:1.2->1.3 
        kaffe/kaffevm/verifier/verify-type.h:1.2->1.3 
        kaffe/kaffevm/verifier/verify.c:1.2->1.3 
        kaffe/kaffevm/verifier/verify.h:1.2->1.3 
        kaffe/kaffevm/verifier/verify2.c:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2436 kaffe/ChangeLog:1.2437
--- kaffe/ChangeLog:1.2436      Sat Jun 26 05:57:37 2004
+++ kaffe/ChangeLog     Sat Jun 26 18:21:33 2004
@@ -1,3 +1,11 @@
+2004-06-26  Rob Gonzalez <[EMAIL PROTECTED]>
+       * kaffe/kaffevm/verify*.[ch]
+       More refactoring, code cleaning up, etc.
+       Error methods removed and simplified.
+
+       * kaffe/kaffevm/verify-type.c
+       Fixed compilation bug with gcc-2.95 (hopefully)
+
 2004-06-26  Guilhem Lavaux <[EMAIL PROTECTED]>
 
        * kaffe/kaffevm/jni/jni.c, kaffe/kaffevm/jni/jni_i.h:
Index: kaffe/kaffe/kaffevm/verifier/verify-errors.h
diff -u kaffe/kaffe/kaffevm/verifier/verify-errors.h:1.2 
kaffe/kaffe/kaffevm/verifier/verify-errors.h:1.3
--- kaffe/kaffe/kaffevm/verifier/verify-errors.h:1.2    Fri Jun 25 14:43:45 2004
+++ kaffe/kaffe/kaffevm/verifier/verify-errors.h        Sat Jun 26 18:21:35 2004
@@ -13,52 +13,51 @@
 #define _VERIFY_ERRORS_H
 
 /*
- * Helper function for error reporting in verifyMethod3a.
+ * General verification error method.
+ * Returns false to allow statements such as:
+ *   return verifyError(...);
  */
 static inline
-void
-verifyErrorInVerifyMethod3a(errorInfo* einfo,
-                           const Verifier* v,
-                           const char * msg)
-{
-       if (einfo->type == 0) {
-               postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+bool
+verifyError(Verifier* v, const char* msg) {
+       if (v->einfo->type == 0) {
+               postExceptionMessage(v->einfo, JAVA_LANG(VerifyError),
                                     "in method \"%s.%s\": %s",
                                     CLASS_CNAME(v->method->class), 
METHOD_NAMED(v->method), msg);
        }
+       return false;
 }
 
+
 /*
  * Helper function for error reporting in BRANCH_IN_BOUNDS macro in verifyMethod3a.
  */
 static inline
-void
-branchInBoundsErrorInVerifyMethod3a(errorInfo* einfo,
-                                   const Verifier* v,
+bool
+branchInBoundsErrorInVerifyMethod3a(Verifier* v,
                                    uint32 codelen,
                                    uint32 n)
 {
-  DBG(VERIFY3, dprintf("ERROR: branch to (%d) out of bound (%d) \n", n, codelen); );
-  verifyErrorInVerifyMethod3a(einfo, v, "branch out of method code");
+       DBG(VERIFY3, dprintf("ERROR: branch to (%d) out of bound (%d) \n", n, 
codelen); );
+       return verifyError(v, "branch out of method code");
 }
 
 /*
  * Helper function for error reporting in CHECK_LOCAL_INDEX macro in verifyMethod3a.
  */
 static inline
-void
-checkLocalIndexErrorInVerifyMethod3a(errorInfo* einfo,
-                                    const Verifier* v,
+bool
+checkLocalIndexErrorInVerifyMethod3a(Verifier* v,
                                     uint32 pc,
                                     unsigned char* code,
                                     uint32 n)
 {
-  DBG(VERIFY3,
-      dprintf("ERROR:  pc = %d, instruction = ", pc);
-      printInstruction(code[pc]);
-      dprintf(", localsz = %d, localindex = %d\n", v->method->localsz, n);
-      );
-  verifyErrorInVerifyMethod3a(einfo, v, "attempting to access a local variable beyond 
local array");
+       DBG(VERIFY3,
+           dprintf("ERROR:  pc = %d, instruction = ", pc);
+           printInstruction(code[pc]);
+           dprintf(", localsz = %d, localindex = %d\n", v->method->localsz, n);
+           );
+       return verifyError(v, "attempting to access a local variable beyond local 
array");
 }
 
 #endif
Index: kaffe/kaffe/kaffevm/verifier/verify-type.c
diff -u kaffe/kaffe/kaffevm/verifier/verify-type.c:1.2 
kaffe/kaffe/kaffevm/verifier/verify-type.c:1.3
--- kaffe/kaffe/kaffevm/verifier/verify-type.c:1.2      Fri Jun 25 14:43:45 2004
+++ kaffe/kaffe/kaffevm/verifier/verify-type.c  Sat Jun 26 18:21:35 2004
@@ -43,18 +43,18 @@
 Type* TWIDE = &_WIDE;
 
 bool
-isWide(const Type * tinfo)
+isWide(const Type * t)
 {
-       return (tinfo->data.class == TWIDE->data.class);
+       return (t->data.class == TWIDE->data.class);
 }
 
 static Type  verify_NULL;
 Type* TNULL = &verify_NULL;
 
 bool
-isNull(const Type * tinfo)
+isNull(const Type * t)
 {
-       return (tinfo->data.class == TNULL->data.class);
+       return (t->data.class == TNULL->data.class);
 }
 
 static const char* OBJECT_SIG  = "Ljava/lang/Object;";
@@ -172,13 +172,13 @@
  *  resolve it to be a pointer to an actual Class object in memory.
  */
 void
-resolveType(errorInfo* einfo, Hjava_lang_Class* this, Type *type)
+resolveType(Verifier* v, Type *t)
 {
        const char* sig;
        char* tmp = NULL;
 
-       if (type->tinfo & TINFO_NAME) {
-               sig = type->data.sig;
+       if (t->tinfo & TINFO_NAME) {
+               sig = t->data.sig;
                
                if (*sig != '[') {
                        tmp = checkPtr(gc_malloc((strlen(sig) + 3) * sizeof(char), 
GC_ALLOC_VERIFIER));
@@ -186,16 +186,16 @@
                        sig = tmp;
                }
                
-               type->tinfo = TINFO_CLASS;
-               type->data.class = getClassFromSignature(sig, this->loader, einfo);
+               t->tinfo = TINFO_CLASS;
+               t->data.class = getClassFromSignature(sig, v->class->loader, v->einfo);
                
                if (tmp) {
                        gc_free(tmp);
                }
        }
-       else if (type->tinfo & TINFO_SIG) {
-               type->tinfo = TINFO_CLASS;
-               type->data.class = getClassFromSignature(type->data.sig, this->loader, 
einfo);
+       else if (t->tinfo & TINFO_SIG) {
+               t->tinfo = TINFO_CLASS;
+               t->data.class = getClassFromSignature(t->data.sig, v->class->loader, 
v->einfo);
        }
 }
 
@@ -243,8 +243,7 @@
  * @return whether an actual merger was made (i.e. they two types given were not the 
same type)
  */
 bool
-mergeTypes(errorInfo* einfo, Hjava_lang_Class* this,
-          Type* t1, Type* t2)
+mergeTypes(Verifier* v, Type* t1, Type* t2)
 {
        if (IS_ADDRESS(t1) || IS_ADDRESS(t2)) {
                /* if one of the types is TADDR, the other one must also be TADDR */
@@ -276,8 +275,8 @@
        
        
        /* must resolve them to go on */
-       resolveType(einfo, this, t1);
-       resolveType(einfo, this, t2);
+       resolveType(v, t1);
+       resolveType(v, t2);
        if ((t1->tinfo & TINFO_CLASS && t1->data.class == NULL) ||
            (t2->tinfo & TINFO_CLASS && t2->data.class == NULL)) {
                return false;
@@ -314,12 +313,14 @@
         *   1) both are classes
         *   2) 
                 *  1) both are classes
-               /* TODO: create supertypes here */
+                * TODO: create supertypes here */
+       {
                Hjava_lang_Class *tmp = t2->data.class;
                
                t2->data.class = getCommonSuperclass(t1->data.class, t2->data.class);
                
                return tmp != t2->data.class;
+       }
 }
 
 
@@ -353,13 +354,13 @@
  *    returns whether the type is a reference type
  */
 bool
-isReference(const Type* type)
+isReference(const Type* t)
 {
-       return (type->tinfo & TINFO_NAME ||
-               type->tinfo & TINFO_SIG ||
-               type->tinfo & TINFO_CLASS ||
-               type->tinfo & TINFO_UNINIT ||
-               type->tinfo & TINFO_SUPERTYPES);
+       return (t->tinfo & TINFO_NAME ||
+               t->tinfo & TINFO_SIG ||
+               t->tinfo & TINFO_CLASS ||
+               t->tinfo & TINFO_UNINIT ||
+               t->tinfo & TINFO_SUPERTYPES);
 }
 
 /*
@@ -367,25 +368,25 @@
  *     returns whether the Type is an array Type
  */
 bool
-isArray(const Type* type)
+isArray(const Type* t)
 {
-       if (!isReference(type)) {
+       if (!isReference(t)) {
                return false;
        }
-       else if (type->tinfo & TINFO_NAME || type->tinfo & TINFO_SIG) {
-               return (*(type->data.sig) == '[');
+       else if (t->tinfo & TINFO_NAME || t->tinfo & TINFO_SIG) {
+               return (*(t->data.sig) == '[');
        }
-       else if (type->tinfo & TINFO_SUPERTYPES) {
+       else if (t->tinfo & TINFO_SUPERTYPES) {
                /* if one of the supertypes is an array, it follows that
                 * all supertypes in the list must be arrays
                 */
-               return ((*CLASS_CNAME(type->data.supertypes->list[0])) == '[');
+               return ((*CLASS_CNAME(t->data.supertypes->list[0])) == '[');
        }
-       else if (type->tinfo != TINFO_CLASS) {
+       else if (t->tinfo != TINFO_CLASS) {
                return false;
        }
        else {
-               return (*(CLASS_CNAME(type->data.class)) == '[');
+               return (*(CLASS_CNAME(t->data.class)) == '[');
        }
 }
 
@@ -419,6 +420,9 @@
        case TINFO_SUPERTYPES:
                /* if we're unsure as to what type t1 might be, then
                 * we have to perform a merge
+                * TODO: compare the supertype lists.  since we're merging
+                * them in the order of the type hirearchy, then we simply
+                * traverse each list until we get to a pair that doesn't match.
                 */
                return false;
                
@@ -554,7 +558,7 @@
  * @return whether t2 can be a t1.
  */
 bool
-typecheck(errorInfo* einfo, Verifier* v, Type* t1, Type* t2)
+typecheck(Verifier* v, Type* t1, Type* t2)
 {
        DBG(VERIFY3, dprintf("%stypechecking ", indent); printType(t1); dprintf("  vs. 
 "); printType(t2); dprintf("\n"); );
        
@@ -581,12 +585,12 @@
        }
        
        
-       resolveType(einfo, v->class, t1);
+       resolveType(v, t1);
        if (t1->data.class == NULL) {
                return false;
        }
 
-       resolveType(einfo, v->class, t2);
+       resolveType(v, t2);
        if (t2->data.class == NULL) {
                return false;
        }
Index: kaffe/kaffe/kaffevm/verifier/verify-type.h
diff -u kaffe/kaffe/kaffevm/verifier/verify-type.h:1.2 
kaffe/kaffe/kaffevm/verifier/verify-type.h:1.3
--- kaffe/kaffe/kaffevm/verifier/verify-type.h:1.2      Fri Jun 25 14:43:45 2004
+++ kaffe/kaffe/kaffevm/verifier/verify-type.h  Sat Jun 26 18:21:35 2004
@@ -85,7 +85,7 @@
 #define TINFO_CLASS        16
 #define TINFO_UNINIT       32
 #define TINFO_UNINIT_SUPER 96
-#define TINFO_SUPERTYPES    128
+#define TINFO_SUPERTYPES   128
 
 #define IS_ADDRESS(_TINFO) ((_TINFO)->tinfo & TINFO_ADDR)
 #define IS_PRIMITIVE_TYPE(_TINFO) ((_TINFO)->tinfo & TINFO_PRIMITIVE)
@@ -116,25 +116,35 @@
 extern Type* TSTRING;
 
 extern void initVerifierPrimTypes(void);
-extern bool isNull(const Type * tinfo);
-extern bool isWide(const Type * tinfo);
 
-extern bool isReference(const Type* type);
-extern bool isArray(const Type* type);
-extern bool sameRefType(Type* t1, Type* t2);
-extern bool sameType(Type* t1, Type* t2);
-extern void resolveType(errorInfo* einfo, Hjava_lang_Class* this, Type *type);
+extern bool isNull(const Type * t);
+extern bool isWide(const Type * t);
 
-extern bool mergeTypes(errorInfo*, Hjava_lang_Class* this,
-                      Type* t1, Type* t2);
+extern bool isReference(const Type* t);
+extern bool isArray(const Type* t);
+
+extern bool sameRefType(Type* t1,
+                       Type* t2);
+extern bool sameType(Type* t1,
+                    Type* t2);
+extern void resolveType(struct Verifier* v,
+                       Type *t);
+
+extern bool mergeTypes(struct Verifier* v,
+                      Type* t1,
+                      Type* t2);
 extern Hjava_lang_Class*  getCommonSuperclass(Hjava_lang_Class* t1,
                                              Hjava_lang_Class* t2);
 
-extern bool typecheck(errorInfo*, struct Verifier* v, Type* t1, Type* t2);
+extern bool typecheck(struct Verifier* v,
+                     Type* t1,
+                     Type* t2);
 
 
 /* for dealing with the supertype lists */
-extern void mergeSupersets(SupertypeSet* supertypes, Type* t1, Type* t2);
+extern void mergeSupersets(SupertypeSet* supertypes,
+                          Type* t1,
+                          Type* t2);
 extern void freeSupertypes(SupertypeSet* supertypes);
 
 
Index: kaffe/kaffe/kaffevm/verifier/verify.c
diff -u kaffe/kaffe/kaffevm/verifier/verify.c:1.2 
kaffe/kaffe/kaffevm/verifier/verify.c:1.3
--- kaffe/kaffe/kaffevm/verifier/verify.c:1.2   Fri Jun 25 14:43:45 2004
+++ kaffe/kaffe/kaffevm/verifier/verify.c       Sat Jun 26 18:21:35 2004
@@ -262,13 +262,11 @@
                                         Verifier* v);
 
 
-static bool               loadInitialArgs(errorInfo* einfo,
-                                         Verifier* v);
+static bool               loadInitialArgs(Verifier* v);
 static bool               verifyBasicBlock(errorInfo*,
                                           Verifier* v,
                                           BlockInfo*);
-static bool               mergeBasicBlocks(errorInfo* einfo,
-                                          const Method* method,
+static bool               mergeBasicBlocks(Verifier* v,
                                           BlockInfo* fromBlock,
                                           BlockInfo* toBlock);
 
@@ -411,6 +409,7 @@
        int codelen  = METHOD_BYTECODE_LEN(method);
        
        Verifier v;
+       v.einfo = einfo;
        v.class = method->class;
        v.method = method;
        v.numBlocks = 0;
@@ -445,7 +444,7 @@
        
        /* load initial arguments into local variable array */
        DBG(VERIFY3, dprintf("    about to load initial args...\n"); );
-       if (!loadInitialArgs(einfo, &v)) {
+       if (!loadInitialArgs(&v)) {
                /* propagate error */
                return failInVerifyMethod(einfo, &v);
        }
@@ -516,12 +515,14 @@
 
 #define ENSURE_NON_WIDE \
        if (wide) { \
-               return verifyErrorInVerifyMethod3a(einfo, v, "illegal instruction 
following wide instruction"); \
+               verifyError(v, "illegal instruction following wide instruction"); \
+                return; \
        }
 
 #define CHECK_POOL_IDX(_IDX) \
        if (_IDX > pool->size) { \
-               return verifyErrorInVerifyMethod3a(einfo, v, "attempt to access a 
constant pool index beyond constant pool range"); \
+               verifyError(v, "attempt to access a constant pool index beyond 
constant pool range"); \
+                return; \
        }
 
        
@@ -535,14 +536,14 @@
 
 #define BRANCH_IN_BOUNDS(_N, _INST) \
        if (_N >= codelen) { \
-               branchInBoundsErrorInVerifyMethod3a(einfo, v, codelen, _N); \
+               branchInBoundsErrorInVerifyMethod3a(v, codelen, _N); \
                return; \
        }
 
         /* makes sure the index given for a local variable is within the correct 
index */
 #define CHECK_LOCAL_INDEX(_N) \
        if ((_N) >= v->method->localsz) { \
-               checkLocalIndexErrorInVerifyMethod3a(einfo, v, pc, code, _N); \
+               checkLocalIndexErrorInVerifyMethod3a(v, pc, code, _N); \
                return; \
        }
        
@@ -567,7 +568,7 @@
        
        DBG(VERIFY3, dprintf("    Verifier Pass 3a: checking static constraints and 
finding basic blocks...\n"); );
        if (METHOD_BYTECODE_LEN(v->method) < 0) {
-               verifyErrorInVerifyMethod3a(einfo, v, "method bytecode length is less 
than 0");
+               verifyError(v, "method bytecode length is less than 0");
        }
        
        /* find the start of every instruction and basic block to determine legal 
branches
@@ -583,7 +584,8 @@
                DBG(VERIFY3, dprintf("        instruction: (%d) ", pc); 
printInstruction(code[pc]); dprintf("\n"); );
                
                if (codelen < getNextPC(code, pc)) {
-                       return verifyErrorInVerifyMethod3a(einfo, v, "last operand in 
code array is cut off");
+                       verifyError(v, "last operand in code array is cut off");
+                       return;
                }
                
                switch(code[pc]) {
@@ -633,7 +635,7 @@
                        n = CONST_TAG(idx, pool);
                        if (n != CONSTANT_Integer && n != CONSTANT_Float &&
                            n != CONSTANT_String && n != CONSTANT_ResolvedString) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "ldc* on 
constant pool entry other than int/float/string");
+                               verifyError(v, "ldc* on constant pool entry other than 
int/float/string");
                                return;
                        }
                        break;
@@ -642,7 +644,7 @@
                        GET_WIDX(idx, pc);
                        n = CONST_TAG(idx, pool);
                        if (n != CONSTANT_Double && n != CONSTANT_Long) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "ldc2_w on 
constant pool entry other than long or double");
+                               verifyError(v, "ldc2_w on constant pool entry other 
than long or double");
                                return;
                        }
                        break;
@@ -654,7 +656,7 @@
                        GET_WIDX(idx, pc);
                        idx = CONST_TAG(idx, pool);
                        if (idx != CONSTANT_Fieldref) {
-                               verifyErrorInVerifyMethod3a(einfo, v, 
"[get/put][field/static] accesses something in the constant pool that is not a 
CONSTANT_Fieldref");
+                               verifyError(v, "[get/put][field/static] accesses 
something in the constant pool that is not a CONSTANT_Fieldref");
                                return;
                        }
                        break;
@@ -667,7 +669,7 @@
                        GET_WIDX(idx, pc);
                        n = CONST_TAG(idx, pool);
                        if (n != CONSTANT_Methodref) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "invoke* 
accesses something in the constant pool that is not a CONSTANT_Methodref");
+                               verifyError(v, "invoke* accesses something in the 
constant pool that is not a CONSTANT_Methodref");
                                return;
                        }
                        
@@ -675,11 +677,11 @@
                        if (*sig == '<') {
                                if (!strcmp(constructor_name->data, sig)) {
                                        if (code[pc] != INVOKESPECIAL) {
-                                                verifyErrorInVerifyMethod3a(einfo, v, 
"only invokespecial can be used to execute <init> methods");
+                                                verifyError(v, "only invokespecial 
can be used to execute <init> methods");
                                                 return;
                                        }
                                } else {
-                                       verifyErrorInVerifyMethod3a(einfo, v, "no 
method with a name whose first character is '<' may be called by an invoke 
instruction");
+                                       verifyError(v, "no method with a name whose 
first character is '<' may be called by an invoke instruction");
                                        return;
                                }
                        }
@@ -700,21 +702,21 @@
                        GET_WIDX(idx, pc);
                        n = CONST_TAG(idx, pool);
                        if (n != CONSTANT_InterfaceMethodref) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "invokeinterface 
accesses something in the constant pool that is not a CONSTANT_InterfaceMethodref");
+                               verifyError(v, "invokeinterface accesses something in 
the constant pool that is not a CONSTANT_InterfaceMethodref");
                                return;
                        }
                        
                        sig = INTERFACEMETHODREF_SIGD(idx, pool);
                        if (*sig == '<') {
-                               verifyErrorInVerifyMethod3a(einfo, v, "invokeinterface 
cannot be used to invoke any instruction with a name starting with '<'");
+                               verifyError(v, "invokeinterface cannot be used to 
invoke any instruction with a name starting with '<'");
                                return;
                        }
                        
                        if (code[pc + 3] == 0) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "fourth byte of 
invokeinterface is zero");
+                               verifyError(v, "fourth byte of invokeinterface is 
zero");
                                return;
                        } else if (code[pc + 4] != 0) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "fifth byte of 
invokeinterface is not zero");
+                               verifyError(v, "fifth byte of invokeinterface is not 
zero");
                                return;
                        }
                        
@@ -728,7 +730,7 @@
                        GET_WIDX(n, pc);
                        n = CONST_TAG(n, pool);
                        if (n != CONSTANT_Class && n != CONSTANT_ResolvedClass) {
-                               verifyErrorInVerifyMethod3a(einfo, v, 
"instanceof/checkcast indexes a constant pool entry that is not type CONSTANT_Class or 
CONSTANT_ResolvedClass");
+                               verifyError(v, "instanceof/checkcast indexes a 
constant pool entry that is not type CONSTANT_Class or CONSTANT_ResolvedClass");
                                return;
                        }
                        
@@ -741,7 +743,7 @@
                        GET_WIDX(idx, pc);
                        n = CONST_TAG(idx, pool);
                        if (n != CONSTANT_Class && n != CONSTANT_ResolvedClass) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "multinewarray 
indexes a constant pool entry that is not type CONSTANT_Class or 
CONSTANT_ResolvedClass");
+                               verifyError(v, "multinewarray indexes a constant pool 
entry that is not type CONSTANT_Class or CONSTANT_ResolvedClass");
                                return;
                        }
                        
@@ -749,12 +751,12 @@
                        sig = CLASS_NAMED(idx, pool);
                        newpc = code[pc + 3];
                        if (newpc == 0) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "dimensions 
operand of multianewarray must be non-zero");
+                               verifyError(v, "dimensions operand of multianewarray 
must be non-zero");
                                return;
                        }
                        for(n = 0; *sig == '['; sig++, n++);
                        if (n < newpc) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "dimensions 
operand of multianewarray is > the number of dimensions in array being created");
+                               verifyError(v, "dimensions operand of multianewarray 
is > the number of dimensions in array being created");
                                return;
                        }
                        
@@ -767,14 +769,14 @@
                        GET_WIDX(idx, pc);
                        n = CONST_TAG(idx, pool);
                        if (n != CONSTANT_Class && n != CONSTANT_ResolvedClass) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "new indexes a 
constant pool entry that is not type CONSTANT_Class or CONSTANT_ResolvedClass");
+                               verifyError(v, "new indexes a constant pool entry that 
is not type CONSTANT_Class or CONSTANT_ResolvedClass");
                                return;
                        }
                        
                        /* cannot create arrays with NEW */
                        sig = CLASS_NAMED(idx, pool);
                        if (*sig == '[') {
-                               verifyErrorInVerifyMethod3a(einfo, v, "new instruction 
used to create a new array");
+                               verifyError(v, "new instruction used to create a new 
array");
                                return;
                        }
                        break;
@@ -786,7 +788,7 @@
                        GET_WIDX(idx, pc);
                        n = CONST_TAG(idx, pool);
                        if (n != CONSTANT_Class && n != CONSTANT_ResolvedClass) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "anewarray 
indexes a constant pool entry that is not type CONSTANT_Class or 
CONSTANT_ResolvedClass");
+                               verifyError(v, "anewarray indexes a constant pool 
entry that is not type CONSTANT_Class or CONSTANT_ResolvedClass");
                                return;
                        }
                        
@@ -794,7 +796,7 @@
                        sig = CLASS_NAMED(idx, pool);
                        for (n = 0; *sig == '['; sig++, n++);
                        if (n > 255) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "anewarray used 
to create an array of > 255 dimensions");
+                               verifyError(v, "anewarray used to create an array of > 
255 dimensions");
                                return;
                        }
                        
@@ -805,7 +807,7 @@
                        
                        n = code[pc + 1];
                        if (n < 4 || n > 11) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "newarray 
operand must be in the range [4,11]");
+                               verifyError(v, "newarray operand must be in the range 
[4,11]");
                                return;
                        }
                        
@@ -989,7 +991,7 @@
                        n += 4;
                        low = getDWord(code, n);
                        if (low < 0) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "lookupswitch 
with npairs < 0");
+                               verifyError(v, "lookupswitch with npairs < 0");
                                return;
                        }
                        
@@ -1035,7 +1037,7 @@
                        high = getDWord(code, n + 8);
                        if (high < low) {
                                DBG(VERIFY3, dprintf("ERROR: low = %d, high = %d\n", 
low, high); );
-                               verifyErrorInVerifyMethod3a(einfo, v, "tableswitch 
high val < low val");
+                               verifyError(v, "tableswitch high val < low val");
                                return;
                        }
                        n += 12;
@@ -1075,7 +1077,7 @@
                        
                default:
                        if (wide == true) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "illegal 
instruction following wide instruction");
+                               verifyError(v, "illegal instruction following wide 
instruction");
                                return;
                        }
                }
@@ -1105,7 +1107,7 @@
                        newpc = pc;
                }
                else if (v->status[pc] & START_BLOCK) {
-                       verifyErrorInVerifyMethod3a(einfo, v, "branch into middle of 
instruction");
+                       verifyError(v, "branch into middle of instruction");
                        return;
                }
        }
@@ -1119,35 +1121,35 @@
 
                        pc = entry->start_pc;
                        if (pc >= codelen) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "try block is 
beyond bound of method code");
+                               verifyError(v, "try block is beyond bound of method 
code");
                                return;
                        }
                        else if (!(v->status[pc] & IS_INSTRUCTION)) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "try block 
starts in the middle of an instruction");
+                               verifyError(v, "try block starts in the middle of an 
instruction");
                                return;
                        }
                        
                        pc = entry->end_pc;
                        if (pc <= entry->start_pc) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "try block ends 
before its starts");
+                               verifyError(v, "try block ends before its starts");
                                return;
                        }
                        else if (pc > codelen) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "try block ends 
beyond bound of method code");
+                               verifyError(v, "try block ends beyond bound of method 
code");
                                return;
                        }
                        else if (!(v->status[pc] & IS_INSTRUCTION)) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "try block ends 
in the middle of an instruction");
+                               verifyError(v, "try block ends in the middle of an 
instruction");
                                return;
                        }
                        
                        pc = entry->handler_pc;
                        if (pc >= codelen) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "exception 
handler is beyond bound of method code");
+                               verifyError(v, "exception handler is beyond bound of 
method code");
                                return;
                        }
                        else if (!(v->status[pc] & IS_INSTRUCTION)) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "exception 
handler starts in the middle of an instruction");
+                               verifyError(v, "exception handler starts in the middle 
of an instruction");
                                return;
                        }
                        
@@ -1166,11 +1168,11 @@
                                        DBG(VERIFY3, dprintf("        ERROR: could not 
resolve catch type...\n"); );
                                        entry->catch_type = UNRESOLVABLE_CATCHTYPE;
                                        
-                                       verifyErrorInVerifyMethod3a(einfo, v, 
"unresolvable catch type");
+                                       verifyError(v, "unresolvable catch type");
                                        return;
                                }
                                if (!instanceof(javaLangThrowable, entry->catch_type)) 
{
-                                       verifyErrorInVerifyMethod3a(einfo, v, 
"Exception to be handled by exception handler is not a subclass of 
Java/Lang/Throwable");
+                                       verifyError(v, "Exception to be handled by 
exception handler is not a subclass of Java/Lang/Throwable");
                                        return;
                                }
                        }
@@ -1185,16 +1187,16 @@
 
                        pc = lve->start_pc;
                        if (pc >= codelen) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "local variable 
is beyond bound of method code");
+                               verifyError(v, "local variable is beyond bound of 
method code");
                                return;
                        }
                        else if (!(v->status[pc] & IS_INSTRUCTION)) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "local variable 
starts in the middle of an instruction");
+                               verifyError(v, "local variable starts in the middle of 
an instruction");
                                return;
                        }
                        
                        if ((pc + lve->length) > codelen) {
-                               verifyErrorInVerifyMethod3a(einfo, v, "local variable 
is beyond bound of method code");
+                               verifyError(v, "local variable is beyond bound of 
method code");
                                return;
                        }
                }
@@ -1253,15 +1255,10 @@
  */
 static inline 
 bool
-verifyErrorInVerifyMethod3b(errorInfo* einfo, Verifier* v, BlockInfo* curBlock, const 
char * msg)
+verifyErrorInVerifyMethod3b(Verifier* v, BlockInfo* curBlock, const char * msg)
 {
         gc_free(curBlock);
-        if (einfo->type == 0) {
-               postExceptionMessage(einfo, JAVA_LANG(VerifyError),
-                                    "in method \"%s.%s\": %s",
-                                    CLASS_CNAME(v->method->class), 
METHOD_NAMED(v->method), msg);
-       }
-       return(false);
+       return verifyError(v, msg);
 }
 
 /*
@@ -1361,12 +1358,12 @@
                copyBlockData(v->method, blocks[curIndex], curBlock);
                
                if (curBlock->status & EXCEPTION_HANDLER && curBlock->stacksz > 0) {
-                       return verifyErrorInVerifyMethod3b(einfo, v, curBlock, "it's 
possible to reach an exception handler with a nonempty stack");
+                       return verifyErrorInVerifyMethod3b(v, curBlock, "it's possible 
to reach an exception handler with a nonempty stack");
                }
                
                
                if (!verifyBasicBlock(einfo, v, curBlock)) {
-                       return verifyErrorInVerifyMethod3b(einfo, v, curBlock, 
"failure to verify basic block");
+                       return verifyErrorInVerifyMethod3b(v, curBlock, "failure to 
verify basic block");
                }
                
                
@@ -1386,8 +1383,8 @@
                                newpc = pc + getWord(code, newpc);
                                nextBlock = inWhichBlock(newpc, blocks, v->numBlocks);
                                
-                               if (!mergeBasicBlocks(einfo, v->method, curBlock, 
nextBlock)) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "error merging operand stacks");
+                               if (!mergeBasicBlocks(v, curBlock, nextBlock)) {
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging operand stacks");
                                }
                                break;
                                
@@ -1396,8 +1393,8 @@
                                newpc = pc + getDWord(code, newpc);
                                nextBlock = inWhichBlock(newpc, blocks, v->numBlocks);
                                
-                               if (!mergeBasicBlocks(einfo, v->method, curBlock, 
nextBlock)) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "error merging operand stacks");
+                               if (!mergeBasicBlocks(v, curBlock, nextBlock)) {
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging operand stacks");
                                }
                                break;
                                        
@@ -1411,8 +1408,8 @@
                        JSR_common:
                                nextBlock = inWhichBlock(newpc, blocks, v->numBlocks);
                                
-                               if (!mergeBasicBlocks(einfo, v->method, curBlock, 
nextBlock)) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "jsr: error merging operand stacks");
+                               if (!mergeBasicBlocks(v, curBlock, nextBlock)) {
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "jsr: error merging operand stacks");
                                }
        
                                /* TODO:
@@ -1431,7 +1428,7 @@
                                }
                                
                                if (!IS_ADDRESS(&curBlock->locals[n])) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "ret instruction does not refer to a variable with type returnAddress");
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "ret instruction does not refer to a variable with type returnAddress");
                                }
                                
                                newpc = curBlock->locals[n].tinfo;
@@ -1440,8 +1437,8 @@
                                curBlock->locals[n] = *TUNSTABLE;
                                
                                nextBlock = inWhichBlock(newpc, blocks, v->numBlocks);
-                               if (!mergeBasicBlocks(einfo, v->method, curBlock, 
nextBlock)) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "error merging opstacks when returning from a subroutine");
+                               if (!mergeBasicBlocks(v, curBlock, nextBlock)) {
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging opstacks when returning from a subroutine");
                                }
 
                                /* 
@@ -1463,17 +1460,17 @@
                                newpc     = pc + getWord(code, newpc);
                                nextBlock = inWhichBlock(newpc, blocks, v->numBlocks);
                                
-                               if (!mergeBasicBlocks(einfo, v->method, curBlock, 
nextBlock)) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "error merging operand stacks");
+                               if (!mergeBasicBlocks(v, curBlock, nextBlock)) {
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging operand stacks");
                                }
                                
                                /* if the condition is false, then the next block is 
the one that will be executed */
                                curIndex++;
                                if (curIndex >= v->numBlocks) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "execution falls off the end of a basic block");
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "execution falls off the end of a basic block");
                                }
-                               else if (!mergeBasicBlocks(einfo, v->method, curBlock, 
blocks[curIndex])) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "error merging operand stacks");
+                               else if (!mergeBasicBlocks(v, curBlock, 
blocks[curIndex])) {
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging operand stacks");
                                }
                                break;
                                
@@ -1487,8 +1484,8 @@
                                else   n = pc + 1;
                                newpc = pc + getDWord(code, n);
                                nextBlock = inWhichBlock(newpc, blocks, v->numBlocks);
-                               if (!mergeBasicBlocks(einfo, v->method, curBlock, 
nextBlock)) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "error merging into the default branch of a lookupswitch instruction");
+                               if (!mergeBasicBlocks(v, curBlock, nextBlock)) {
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging into the default branch of a lookupswitch instruction");
                                }
                                
                                /* get number of key/target pairs */
@@ -1500,8 +1497,8 @@
                                for (n += 4, high = n + 8*low; n < (uint32)high; n += 
8) {
                                        newpc = pc + getDWord(code, n+4);
                                        nextBlock = inWhichBlock(newpc, blocks, 
v->numBlocks);
-                                       if (!mergeBasicBlocks(einfo, v->method, 
curBlock, nextBlock)) {
-                                               return 
verifyErrorInVerifyMethod3b(einfo, v, curBlock, "error merging into a branch of a 
lookupswitch instruction");
+                                       if (!mergeBasicBlocks(v, curBlock, nextBlock)) 
{
+                                               return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging into a branch of a lookupswitch instruction");
                                        }
                                }
                                
@@ -1529,8 +1526,8 @@
                                for (high = n + 4*(high - low + 1); n < (uint32)high; 
n += 4) {
                                        newpc = pc + getDWord(code, n);
                                        nextBlock = inWhichBlock(newpc, blocks, 
v->numBlocks);
-                                       if (!mergeBasicBlocks(einfo, v->method, 
curBlock, nextBlock)) {
-                                               return 
verifyErrorInVerifyMethod3b(einfo, v, curBlock, "error merging into a branch of a 
tableswitch instruction");
+                                       if (!mergeBasicBlocks(v, curBlock, nextBlock)) 
{
+                                               return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging into a branch of a tableswitch instruction");
                                        }
                                }
                                break;
@@ -1552,10 +1549,10 @@
                                        if (v->status[n] & IS_INSTRUCTION) break;
                                }
                                if (n == codelen) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "execution falls off the end of a code block");
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "execution falls off the end of a code block");
                                }
-                               else if (!mergeBasicBlocks(einfo, v->method, curBlock, 
blocks[curIndex+1])) {
-                                       return verifyErrorInVerifyMethod3b(einfo, v, 
curBlock, "error merging operand stacks");
+                               else if (!mergeBasicBlocks(v, curBlock, 
blocks[curIndex+1])) {
+                                       return verifyErrorInVerifyMethod3b(v, 
curBlock, "error merging operand stacks");
                                }
                        }
                
@@ -1574,24 +1571,6 @@
 
 
 /*
- * Helper function for error reporting in merge.
- */
-static inline
-bool
-verifyErrorInMergeBasicBlocks(errorInfo* einfo,
-                             const Method* method,
-                             const char * msg)
-{
-        if (einfo->type == 0) {
-               postExceptionMessage(einfo, JAVA_LANG(VerifyError),
-                                    "in method \"%s.%s\": %s",
-                                    CLASS_CNAME(method->class), METHOD_NAMED(method), 
msg);
-       }
-       return(false);
-}
-
-
-/*
  * merges two operand stacks.  just to repeat what the JVML 2 spec says about this:
  *   Merge the state of the operand stack and local variable array at the end of the
  *   execution of the current instruction into each of the successor instructions.  In
@@ -1622,8 +1601,7 @@
  */
 static
 bool
-mergeBasicBlocks(errorInfo* einfo,
-                const Method* method,
+mergeBasicBlocks(Verifier* v,
                 BlockInfo* fromBlock,
                 BlockInfo* toBlock)
 {
@@ -1634,14 +1612,14 @@
         * or on the operand stack during a backwards branch
         */
        if (toBlock->startAddr < fromBlock->startAddr) {
-               for (n = 0; n < method->localsz; n++) {
+               for (n = 0; n < v->method->localsz; n++) {
                        if (fromBlock->locals[n].tinfo & TINFO_UNINIT) {
-                               return verifyErrorInMergeBasicBlocks(einfo, method, 
"uninitialized object reference in a local variable during a backwards branch");
+                               return verifyError(v, "uninitialized object reference 
in a local variable during a backwards branch");
                        }
                }
                for (n = 0; n < fromBlock->stacksz; n++) {
                        if (fromBlock->opstack[n].tinfo & TINFO_UNINIT) {
-                               return verifyErrorInMergeBasicBlocks(einfo, method, 
"uninitialized object reference on operand stack during a backwards branch");
+                               return verifyError(v, "uninitialized object reference 
on operand stack during a backwards branch");
                        }
                }
        }
@@ -1650,7 +1628,7 @@
                DBG(VERIFY3, dprintf("          visiting block starting at %d for the 
first time\n",
                                     toBlock->startAddr); );
                
-               copyBlockState(method, fromBlock, toBlock);
+               copyBlockState(v->method, fromBlock, toBlock);
                toBlock->status |= CHANGED;
                return(true);
        }
@@ -1658,25 +1636,21 @@
        DBG(VERIFY3,
            dprintf("%snot a first time merge\n", indent);
            dprintf("%s  from block (%d - %d):\n", indent, fromBlock->startAddr, 
fromBlock->lastAddr);
-           printBlock(method, fromBlock, indent2);
+           printBlock(v->method, fromBlock, indent2);
            dprintf("%s  to block (%d - %d):\n", indent, toBlock->startAddr, 
toBlock->lastAddr);
-           printBlock(method, toBlock, indent2);
+           printBlock(v->method, toBlock, indent2);
            dprintf("\n");
            );
        
        
        if (fromBlock->stacksz != toBlock->stacksz) {
-               postExceptionMessage(einfo, JAVA_LANG(VerifyError),
-                                    "in method %s.%s: merging two operand stacks of 
unequal size",
-                                    METHOD_NAMED(method), CLASS_CNAME(method->class));
-               return(false);
+               return verifyError(v, "merging two operand stacks of unequal size");
        }
        
        
        /* merge the local variable arrays */
-       for (n = 0; n < method->localsz; n++) {
-               if (mergeTypes(einfo, method->class,
-                              &fromBlock->locals[n], &toBlock->locals[n])) {
+       for (n = 0; n < v->method->localsz; n++) {
+               if (mergeTypes(v, &fromBlock->locals[n], &toBlock->locals[n])) {
                        toBlock->status |= CHANGED;
                }
        }
@@ -1687,8 +1661,7 @@
                 * i mean, we could get an unstable value and then immediately pop it 
off the stack,
                 * for instance.
                 */
-               if (mergeTypes(einfo, method->class,
-                              &fromBlock->opstack[n], &toBlock->opstack[n])) {
+               if (mergeTypes(v, &fromBlock->opstack[n], &toBlock->opstack[n])) {
                        toBlock->status |= CHANGED;
                }
        }
@@ -1696,44 +1669,27 @@
        
        DBG(VERIFY3,
            dprintf("%s  result block:\n", indent);
-           printBlock(method, toBlock, indent2);
+           printBlock(v->method, toBlock, indent2);
            );
        
        
        return(true);
 }
 
-/*
- * Helper function for error reporting in verifyBasicBlock.
- */
-static inline
-bool
-verifyErrorInVerifyBasicBlock(errorInfo* einfo,

*** Patch too long, truncated ***

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to