[vmkit-commits] [vmkit] r100978 - in /vmkit/trunk: include/mvm/Threads/Thread.h lib/J3/Classpath/ClasspathConstructor.inc lib/J3/Classpath/ClasspathMethod.inc lib/J3/VMCore/JavaClass.cpp lib/J3/VMCore/JavaThread.h lib/J3/VMCore/Jnjvm.cpp lib/Mvm/Runtime/Object.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Apr 11 12:13:38 PDT 2010
Author: geoffray
Date: Sun Apr 11 14:13:38 2010
New Revision: 100978
URL: http://llvm.org/viewvc/llvm-project?rev=100978&view=rev
Log:
Put macros for exception handling in the runtime.
Modified:
vmkit/trunk/include/mvm/Threads/Thread.h
vmkit/trunk/lib/J3/Classpath/ClasspathConstructor.inc
vmkit/trunk/lib/J3/Classpath/ClasspathMethod.inc
vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
vmkit/trunk/lib/J3/VMCore/JavaThread.h
vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
vmkit/trunk/lib/Mvm/Runtime/Object.cpp
Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=100978&r1=100977&r2=100978&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Sun Apr 11 14:13:38 2010
@@ -16,6 +16,10 @@
#include "types.h"
+#define TRY try
+#define CATCH catch(...)
+#define IGNORE catch(...) { mvm::Thread::get()->clearException(); }
+
namespace mvm {
class MethodInfo;
Modified: vmkit/trunk/lib/J3/Classpath/ClasspathConstructor.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathConstructor.inc?rev=100978&r1=100977&r2=100978&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Classpath/ClasspathConstructor.inc (original)
+++ vmkit/trunk/lib/J3/Classpath/ClasspathConstructor.inc Sun Apr 11 14:13:38 2010
@@ -117,9 +117,9 @@
}
JavaThread* th = JavaThread::get();
- try {
+ TRY {
meth->invokeIntSpecialBuf(vm, cl, res, buf);
- } catch(...) {
+ } CATCH {
excp = th->getJavaException();
if (excp->getClass()->isAssignableFrom(vm->upcalls->newException)) {
th->clearException();
@@ -130,6 +130,7 @@
// If it's an error, throw it again.
th->throwPendingException();
}
+ return NULL;
}
} else {
Modified: vmkit/trunk/lib/J3/Classpath/ClasspathMethod.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathMethod.inc?rev=100978&r1=100977&r2=100978&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Classpath/ClasspathMethod.inc (original)
+++ vmkit/trunk/lib/J3/Classpath/ClasspathMethod.inc Sun Apr 11 14:13:38 2010
@@ -152,7 +152,7 @@
JavaThread* th = JavaThread::get();
#define RUN_METH(TYPE, VAR) \
- try{ \
+ TRY { \
if (isVirtual(meth->access)) { \
if (isPublic(meth->access) && !isFinal(meth->access) && \
!isFinal(meth->classDef->access)) { \
@@ -163,7 +163,7 @@
} else { \
VAR = meth->invoke##TYPE##StaticBuf(vm, cl, buf); \
} \
- } catch(...) { \
+ } CATCH { \
exc = th->getJavaException(); \
if (exc->getClass()->isAssignableFrom(vm->upcalls->newException)) { \
th->clearException(); \
@@ -171,6 +171,7 @@
} else { \
th->throwPendingException(); \
} \
+ return NULL; \
} \
Typedef* retType = sign->getReturnType();
@@ -225,7 +226,8 @@
RUN_METH(JavaObject, res);
}
} else {
- vm->illegalArgumentException("wrong number of arguments");
+ vm->illegalArgumentException("wrong number of arguments");
+ return NULL;
}
return res;
Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=100978&r1=100977&r2=100978&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Sun Apr 11 14:13:38 2010
@@ -893,9 +893,9 @@
setOwnerClass(JavaThread::get());
JavaObject* exc = 0;
- try {
+ TRY {
readClass();
- } catch (...) {
+ } CATCH {
exc = JavaThread::get()->pendingException;
JavaThread::get()->clearException();
}
@@ -910,9 +910,9 @@
release();
- try {
+ TRY {
loadParents();
- } catch (...) {
+ } CATCH {
setInitializationState(loaded);
exc = JavaThread::get()->pendingException;
JavaThread::get()->clearException();
Modified: vmkit/trunk/lib/J3/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaThread.h?rev=100978&r1=100977&r2=100978&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaThread.h Sun Apr 11 14:13:38 2010
@@ -30,10 +30,10 @@
#define BEGIN_NATIVE_EXCEPTION(level) \
JavaThread* __th = JavaThread::get(); \
- try {
+ TRY {
#define END_NATIVE_EXCEPTION \
- } catch(...) { \
+ } CATCH { \
__th->throwFromNative(); \
} \
@@ -43,10 +43,10 @@
th->leaveUncooperativeCode(); \
mvm::KnownFrame Frame; \
th->startKnownFrame(Frame); \
- try {
+ TRY {
#define END_JNI_EXCEPTION \
- } catch(...) { \
+ } CATCH { \
th->throwFromJNI(SP); \
}
Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=100978&r1=100977&r2=100978&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Sun Apr 11 14:13:38 2010
@@ -145,15 +145,16 @@
// the initializing the superclass.
UserClass* super = getSuper();
if (super) {
- try {
+ TRY {
super->initialiseClass(vm);
- } catch(...) {
+ } CATCH {
acquire();
setErroneous();
setOwnerClass(0);
broadcastClass();
release();
self->throwPendingException();
+ return;
}
}
@@ -192,9 +193,9 @@
true, false, 0);
if (meth) {
- try{
+ TRY {
meth->invokeIntStatic(vm, cl);
- } catch(...) {
+ } CATCH {
exc = self->getJavaException();
assert(exc && "no exception?");
self->clearException();
@@ -247,6 +248,7 @@
broadcastClass();
release();
self->throwException(exc);
+ return;
}
}
@@ -1149,8 +1151,7 @@
llvm_gcroot(obj, 0);
llvm_gcroot(group, 0);
- try {
-
+ TRY {
// First try to see if we are a self-contained executable.
UserClass* cl = appClassLoader->loadClassFromSelf(this, className);
@@ -1168,7 +1169,7 @@
JavaMethod* method = cl->lookupMethod(funcName, funcSign, true, true, 0);
method->invokeIntStatic(this, method->classDef, &args);
- }catch(...) {
+ } CATCH {
}
exc = JavaThread::get()->pendingException;
@@ -1177,10 +1178,10 @@
th->clearException();
obj = th->currentThread();
group = upcalls->group->getObjectField(obj);
- try{
+ TRY {
upcalls->uncaughtException->invokeIntSpecial(this, upcalls->threadGroup,
group, &obj, &exc);
- }catch(...) {
+ } CATCH {
fprintf(stderr, "Exception in thread \"main\": "
"Can not print stack trace.\n");
}
@@ -1190,7 +1191,7 @@
void Jnjvm::executePremain(const char* className, JavaString* args,
JavaObject* instrumenter) {
llvm_gcroot(instrumenter, 0);
- try {
+ TRY {
const UTF8* name = appClassLoader->asciizConstructUTF8(className);
UserClass* cl = (UserClass*)appClassLoader->loadName(name, true, true);
cl->initialiseClass(this);
@@ -1201,9 +1202,7 @@
JavaMethod* method = cl->lookupMethod(funcName, funcSign, true, true, 0);
method->invokeIntStatic(this, method->classDef, &args, &instrumenter);
- } catch(...) {
- JavaThread::get()->clearException();
- }
+ } IGNORE;
}
void Jnjvm::waitForExit() {
@@ -1234,9 +1233,9 @@
Jnjvm* vm = thread->getJVM();
vm->mainThread = thread;
- try {
+ TRY {
vm->loadBootstrap();
- } catch (...) {
+ } CATCH {
exc = JavaThread::get()->pendingException;
}
Modified: vmkit/trunk/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/Object.cpp?rev=100978&r1=100977&r2=100978&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/Object.cpp Sun Apr 11 14:13:38 2010
@@ -82,7 +82,7 @@
vm->FinalizationQueueLock.release();
if (!res) break;
- try {
+ TRY {
VirtualTable* VT = res->getVirtualTable();
if (VT->operatorDelete) {
destructor_t dest = (destructor_t)VT->destructor;
@@ -90,8 +90,7 @@
} else {
vm->invokeFinalizer(res);
}
- } catch(...) {
- }
+ } IGNORE;
res = 0;
th->clearException();
}
@@ -118,10 +117,9 @@
vm->ToEnqueueLock.release();
if (!res) break;
- try {
+ TRY {
vm->enqueueReference(res);
- } catch(...) {
- }
+ } IGNORE;
res = 0;
th->clearException();
}
More information about the vmkit-commits
mailing list