From: edwin Date: Wed, 4 Oct 2006 18:23:19 +0000 (+0000) Subject: * src/vm/jit/intrp/engine.c (THROW_CLASSCASTEXCEPTION): Really throw a X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=f475edd333dd05c6cca06ed0b94b25a9e94f126d;p=cacao.git * src/vm/jit/intrp/engine.c (THROW_CLASSCASTEXCEPTION): Really throw a ClassCastException, not a NullPointerException. * src/vm/jit/intrp/asmpart.c (intrp_asm_handle_exception): Set global_sp, in case the resolving of the catchtype involves the execution of Java code. * src/vm/jit/intrp/java.vmg (MONITORENTER): Check for exception. (MONITOREXIT): Likewise. --- diff --git a/src/vm/jit/intrp/asmpart.c b/src/vm/jit/intrp/asmpart.c index 288fa7c3a..ac13697f3 100644 --- a/src/vm/jit/intrp/asmpart.c +++ b/src/vm/jit/intrp/asmpart.c @@ -29,7 +29,7 @@ Changes: - $Id: asmpart.c 5668 2006-10-04 16:01:53Z edwin $ + $Id: asmpart.c 5670 2006-10-04 18:23:19Z edwin $ */ @@ -217,6 +217,11 @@ Inst *intrp_asm_handle_exception(Inst *ip, java_objectheader *o, Cell *fp, Cell /* might fail, even if the result of the resolution would */ /* be an already loaded class. */ + /* The resolving may involve Java code, so we need a usable */ + /* global_sp. XXX is this a correct value for global_sp? */ + + global_sp = (Cell *)(((u1 *)fp) - framesize - SIZEOF_VOID_P); + c = resolve_classref_eager(cr.ref); if (c == NULL) { diff --git a/src/vm/jit/intrp/engine.c b/src/vm/jit/intrp/engine.c index 0b163d3c8..1f617ee4f 100644 --- a/src/vm/jit/intrp/engine.c +++ b/src/vm/jit/intrp/engine.c @@ -29,7 +29,7 @@ Changes: - $Id: engine.c 5666 2006-10-04 15:04:52Z twisti $ + $Id: engine.c 5670 2006-10-04 18:23:19Z edwin $ */ @@ -150,7 +150,7 @@ #define THROW_CLASSCASTEXCEPTION(o) \ { \ classcastexception_object = o; \ - THROW(nullpointerexception); \ + THROW(classcastexception); \ } #define CHECK_OUT_OF_BOUNDS(_array, _idx) \ diff --git a/src/vm/jit/intrp/java.vmg b/src/vm/jit/intrp/java.vmg index a8ee027ee..e32bb61bf 100644 --- a/src/vm/jit/intrp/java.vmg +++ b/src/vm/jit/intrp/java.vmg @@ -1247,16 +1247,21 @@ ARRAYINSTANCEOF ( aRef aClass -- iResult ) MONITORENTER ( aRef -- ) { #if defined(ENABLE_THREADS) - /* CHECK_NULL_PTR(aRef); is now done explicitly */ - lock_monitor_enter(aRef); + /* CHECK_NULL_PTR(aRef); is now done explicitly inside lock_monitor_enter */ + global_sp = sp; + if (!lock_monitor_enter(aRef)) + THROW0; + CLEAR_global_sp; #endif } MONITOREXIT ( aRef -- ) { #if defined(ENABLE_THREADS) - /* CHECK_NULL_PTR(aRef); cannot happen */ - lock_monitor_exit(aRef); + global_sp = sp; + if (!lock_monitor_exit(aRef)) + THROW0; + CLEAR_global_sp; #endif }