From 56467e61d7307b98fc5859a60ae0c87d07f9bd60 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 4 Jul 2007 20:44:01 -0600 Subject: [PATCH] exception handler selection bugfixes --- src/vm.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/vm.cpp b/src/vm.cpp index 1e7a4bb860..cfce5184b6 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -4584,19 +4584,26 @@ run(Thread* t) if (eht) { for (unsigned i = 0; i < exceptionHandlerTableLength(t, eht); ++i) { ExceptionHandler* eh = exceptionHandlerTableBody(t, eht, i); - object catchType = - arrayBody(t, codePool(t, code), exceptionHandlerCatchType(eh) - 1); - - if (catchType == 0 or - (objectClass(t, catchType) - == arrayBody(t, t->vm->types, Machine::ClassType) and - instanceOf(t, catchType, exception))) + if (frameIp(t, frame) >= exceptionHandlerStart(eh) + and frameIp(t, frame) >= exceptionHandlerEnd(eh)) { - sp = frameStackBase(t, frame); - ip = exceptionHandlerIp(eh); - pushObject(t, exception); - exception = 0; - goto loop; + object catchType = 0; + if (exceptionHandlerCatchType(eh)) { + catchType = arrayBody + (t, codePool(t, code), exceptionHandlerCatchType(eh) - 1); + } + + if (catchType == 0 or + (objectClass(t, catchType) + == arrayBody(t, t->vm->types, Machine::ClassType) and + instanceOf(t, catchType, exception))) + { + sp = frameStackBase(t, frame); + ip = exceptionHandlerIp(eh); + pushObject(t, exception); + exception = 0; + goto loop; + } } } }