From: edwin Date: Wed, 4 Oct 2006 16:01:53 +0000 (+0000) Subject: * src/vm/jit/intrp/codegen.c (nativecall): Store return valud of X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=f8791fc87c974ed0e47c8f5342e09357cf2f6dd2;p=cacao.git * src/vm/jit/intrp/codegen.c (nativecall): Store return valud of codegen_finish_native_call in *exceptionptr. * src/vm/jit/intrp/asmpart.c (intrp_asm_handle_exception): Resolve unresolved catchtype references. --- diff --git a/src/vm/jit/intrp/asmpart.c b/src/vm/jit/intrp/asmpart.c index 4fb36857a..288fa7c3a 100644 --- a/src/vm/jit/intrp/asmpart.c +++ b/src/vm/jit/intrp/asmpart.c @@ -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 && diff --git a/src/vm/jit/intrp/codegen.c b/src/vm/jit/intrp/codegen.c index c462594e8..79ad25463 100644 --- a/src/vm/jit/intrp/codegen.c +++ b/src/vm/jit/intrp/codegen.c @@ -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;