* src/vm/jit/intrp/codegen.c (nativecall): Store return valud of
authoredwin <none@none>
Wed, 4 Oct 2006 16:01:53 +0000 (16:01 +0000)
committeredwin <none@none>
Wed, 4 Oct 2006 16:01:53 +0000 (16:01 +0000)
codegen_finish_native_call in *exceptionptr.

* src/vm/jit/intrp/asmpart.c (intrp_asm_handle_exception): Resolve
unresolved catchtype references.

src/vm/jit/intrp/asmpart.c
src/vm/jit/intrp/codegen.c

index 4fb36857a750e3083a347de000b49f7da5ab142d..288fa7c3a96673bbf9b590a34c3cf6da826c227e 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes:
 
-   $Id: asmpart.c 5666 2006-10-04 15:04:52Z twisti $
+   $Id: asmpart.c 5668 2006-10-04 16:01:53Z edwin $
 
 */
 
@@ -175,11 +175,12 @@ double intrp_asm_vm_call_method_double(methodinfo *m, s4 vmargscount,
 
 Inst *intrp_asm_handle_exception(Inst *ip, java_objectheader *o, Cell *fp, Cell **new_spp, Cell **new_fpp)
 {
-       classinfo      *c;
-       s4              framesize;
-       exceptionentry *ex;
-       s4              exceptiontablelength;
-       s4              i;
+       classinfo            *c;
+       classref_or_classinfo cr;
+       s4                    framesize;
+       exceptionentry       *ex;
+       s4                    exceptiontablelength;
+       s4                    i;
 
   /* for a description of the stack see IRETURN in java.vmg */
 
@@ -202,17 +203,42 @@ Inst *intrp_asm_handle_exception(Inst *ip, java_objectheader *o, Cell *fp, Cell
 
          for (i = 0; i < exceptiontablelength; i++) {
                  ex--;
-                 c = ex->catchtype.cls; /* XXX this may also be a classref! */
 
-                 if (c != NULL) {
-                         if (!(c->state & CLASS_LOADED))
-                                 /* XXX fix me! */
-                                 if (!load_class_bootstrap(c->name))
-                                         assert(0);
+                 cr = ex->catchtype;
+
+                 if (cr.any != NULL) {
+                         if (IS_CLASSREF(cr)) {
+                                 /* The exception class reference is unresolved. */
+                                 /* We have to do _eager_ resolving here. While the class of */
+                                 /* the exception object is guaranteed to be loaded, it may  */
+                                 /* well have been loaded by a different loader than the     */
+                                 /* defining loader of m's class, which is the one we must   */
+                                 /* use to resolve the catch class. Thus lazy resolving      */
+                                 /* might fail, even if the result of the resolution would   */
+                                 /* be an already loaded class.                              */
+
+                                 c = resolve_classref_eager(cr.ref);
 
-                         if (!(c->state & CLASS_LINKED))
-                                 if (!link_class(c))
+                                 if (c == NULL) {
+                                         /* Exception resolving the exception class, argh! */
+                                         /* XXX how to report that error? */
                                          assert(0);
+                                 }
+
+                                 /* Ok, we resolved it. Enter it in the table, so we don't */
+                                 /* have to do this again.                                 */
+                                 /* XXX this write should be atomic. Is it?                */
+
+                                 ex->catchtype.cls = c;
+                         }
+                         else {
+                                 c = cr.cls;
+                               
+                                 /* If the class is not linked, the exception object cannot */
+                                 /* be an instance of it.                                   */
+                                 if (!(c->state & CLASS_LINKED))
+                                         continue;
+                         }
                  }
 
                  if (ip-1 >= (Inst *) ex->startpc && ip-1 < (Inst *) ex->endpc &&
index c462594e8ba13acb7dbd3ce4f925719ca5d10a6a..79ad25463a944153edafd5eb471bcdc4552bfc5a 100644 (file)
@@ -29,7 +29,7 @@
                        
    Changes: Edwin Steiner
 
-   $Id: codegen.c 5667 2006-10-04 15:14:19Z edwin $
+   $Id: codegen.c 5668 2006-10-04 16:01:53Z edwin $
 
 */
 
@@ -2100,7 +2100,7 @@ Cell *nativecall(functionptr f, methodinfo *m, Cell *sp, Inst *ra, Cell *fp, u1
 
        av_call(alist);
 
-       codegen_finish_native_call(((u1 *) &s) + sizeof(s));
+       *exceptionptr = codegen_finish_native_call(((u1 *) &s) + sizeof(s));
 
        CLEAR_global_sp;
 
@@ -2159,7 +2159,7 @@ Cell *nativecall(functionptr f, methodinfo *m, Cell *sp, Inst *ra, Cell *fp, u1
 
        ffi_call(pcif, FFI_FN(f), endsp, values);
 
-       codegen_finish_native_call(((u1 *) &s) + sizeof(s));
+       *exceptionptr = codegen_finish_native_call(((u1 *) &s) + sizeof(s));
 
        CLEAR_global_sp;