[vmkit-commits] [vmkit] r120566 - in /vmkit/branches/multi-vm: include/mvm/Threads/ lib/J3/Classpath/ lib/J3/VMCore/ lib/Mvm/CommonThread/
Gael Thomas
gael.thomas at lip6.fr
Wed Dec 1 01:29:26 PST 2010
Author: gthomas
Date: Wed Dec 1 03:29:25 2010
New Revision: 120566
URL: http://llvm.org/viewvc/llvm-project?rev=120566&view=rev
Log:
move function that accesses to the pendingException in mvm::Thread. JNIReference contains now gc* to preserve an exception
Modified:
vmkit/branches/multi-vm/include/mvm/Threads/Thread.h
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClass.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc
vmkit/branches/multi-vm/lib/J3/VMCore/JNIReferences.h
vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h
vmkit/branches/multi-vm/lib/J3/VMCore/Jni.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h
vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp
vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
Modified: vmkit/branches/multi-vm/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/Threads/Thread.h?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/Threads/Thread.h (original)
+++ vmkit/branches/multi-vm/include/mvm/Threads/Thread.h Wed Dec 1 03:29:25 2010
@@ -265,11 +265,26 @@
/// clearPendingException - Clear any pending exception of the current thread.
void clearPendingException() {
+ pendingException = 0;
#ifdef RUNTIME_DWARF_EXCEPTIONS
internalPendingException = 0;
#endif
}
+ /// setException - only set the pending exception
+ ///
+ Thread* setPendingException(gc *obj);
+
+ /// throwIt - Throw a pending exception.
+ ///
+ void throwIt();
+
+ /// getPendingException - Return the pending exception.
+ ///
+ gc* getPendingException() {
+ return pendingException;
+ }
+
bool isMvmThread() {
if (!baseAddr) return false;
else return (((uintptr_t)this) & MvmThreadMask) == baseAddr;
@@ -346,8 +361,6 @@
ExceptionBuffer* lastExceptionBuffer;
#endif
- void internalThrowException();
-
void startKnownFrame(KnownFrame& F) __attribute__ ((noinline));
void endKnownFrame();
void startUnknownFrame(KnownFrame& F) __attribute__ ((noinline));
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc Wed Dec 1 03:29:25 2010
@@ -78,7 +78,7 @@
ArrayObject* args,
JavaObject* Clazz, jint index) {
JavaObject* res = 0;
- JavaObject* excp = 0;
+ gc* excp = 0;
llvm_gcroot(cons, 0);
llvm_gcroot(args, 0);
@@ -120,19 +120,21 @@
TRY {
meth->invokeIntSpecialBuf(vm, cl, res, buf);
} CATCH {
- excp = JavaThread::get()->getPendingException();
+ excp = mvm::Thread::get()->getPendingException();
} END_CATCH;
mvm::Thread* mut = mvm::Thread::get();
- JavaThread* th = JavaThread::j3Thread(mut);
if (excp) {
- if (JavaObject::getClass(excp)->isAssignableFrom(vm->upcalls->newException)) {
+ JavaObject* jexcp;
+ llvm_gcroot(jexcp, 0);
+ jexcp = Jnjvm::asJavaException(excp);
+ if (jexcp && JavaObject::getClass(jexcp)->isAssignableFrom(vm->upcalls->newException)) {
mut->clearPendingException();
// If it's an exception, we encapsule it in an
// invocationTargetException
- vm->invocationTargetException(excp);
+ vm->invocationTargetException(jexcp);
} else {
// If it's an error, throw it again.
- th->throwIt();
+ mut->throwIt();
}
return NULL;
}
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc Wed Dec 1 03:29:25 2010
@@ -98,7 +98,8 @@
ArrayObject* args, JavaObject* Cl, jint index) {
JavaObject* res = 0;
- JavaObject* exc = 0;
+ JavaObject* jexc = 0;
+ gc* exc = 0;
llvm_gcroot(res, 0);
llvm_gcroot(Meth, 0);
@@ -106,6 +107,7 @@
llvm_gcroot(args, 0);
llvm_gcroot(Cl, 0);
llvm_gcroot(exc, 0);
+ llvm_gcroot(jexc, 0);
Jnjvm* vm = JavaThread::get()->getJVM();
@@ -164,17 +166,18 @@
VAR = meth->invoke##TYPE##StaticBuf(vm, cl, buf); \
} \
} CATCH { \
- exc = JavaThread::get()->getPendingException(); \
+ exc = mvm::Thread::get()->getPendingException(); \
} END_CATCH; \
- mvm::Thread* mut = mvm::Thread::get(); \
- JavaThread* th = JavaThread::j3Thread(mut); \
+ \
if (exc) { \
- if (JavaObject::getClass(exc)->isAssignableFrom( \
+ mvm::Thread* mut = mvm::Thread::get(); \
+ jexc = Jnjvm::asJavaException(exc); \
+ if (jexc && JavaObject::getClass(jexc)->isAssignableFrom( \
vm->upcalls->newException)) { \
mut->clearPendingException(); \
- th->getJVM()->invocationTargetException(exc); \
+ JavaThread::j3Thread(mut)->getJVM()->invocationTargetException(jexc); \
} else { \
- th->throwIt(); \
+ mut->throwIt(); \
} \
return NULL; \
}
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClass.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClass.inc?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClass.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClass.inc Wed Dec 1 03:29:25 2010
@@ -584,7 +584,7 @@
llvm_gcroot(throwable, 0);
assert(throwable && "Using internal VM throw exception without exception");
- JavaThread::get()->setPendingException(throwable);
+ mvm::Thread::get()->setPendingException(throwable);
}
JNIEXPORT ArrayObject* Java_java_lang_VMClass_getDeclaredAnnotations(
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClassLoader.inc Wed Dec 1 03:29:25 2010
@@ -157,7 +157,7 @@
res = cl->getClassDelegatee(vm, pd);
} else {
excp = vm->CreateLinkageError("duplicate class definition");
- JavaThread::get()->throwException(excp);
+ mvm::Thread::get()->setPendingException(excp)->throwIt();
}
END_NATIVE_EXCEPTION
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc Wed Dec 1 03:29:25 2010
@@ -38,17 +38,17 @@
assert(src->getVirtualTable());
assert(dst->getVirtualTable());
- JavaThread* th = JavaThread::get();
- Jnjvm *vm = th->getJVM();
+ mvm::Thread* mut = mvm::Thread::get();
+ Jnjvm *vm = JavaThread::j3Thread(mut)->getJVM();
if (src == NULL || dst == NULL) {
- th->setPendingException(vm->CreateNullPointerException());
+ mut->setPendingException(vm->CreateNullPointerException());
return;
}
if (!(JavaObject::getClass(src)->isArray() &&
JavaObject::getClass(dst)->isArray())) {
- th->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
+ mut->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
return;
}
@@ -61,24 +61,24 @@
sint32 dstSize = JavaArray::getSize(dst);
if (len > srcSize) {
- th->setPendingException(vm->CreateIndexOutOfBoundsException(len));
+ mut->setPendingException(vm->CreateIndexOutOfBoundsException(len));
} else if (len > dstSize) {
- th->setPendingException(vm->CreateIndexOutOfBoundsException(len));
+ mut->setPendingException(vm->CreateIndexOutOfBoundsException(len));
} else if (len + sstart > srcSize) {
- th->setPendingException(vm->CreateIndexOutOfBoundsException(len + sstart));
+ mut->setPendingException(vm->CreateIndexOutOfBoundsException(len + sstart));
} else if (len + dstart > dstSize) {
- th->setPendingException(vm->CreateIndexOutOfBoundsException(len + dstart));
+ mut->setPendingException(vm->CreateIndexOutOfBoundsException(len + dstart));
} else if (dstart < 0) {
- th->setPendingException(vm->CreateIndexOutOfBoundsException(dstart));
+ mut->setPendingException(vm->CreateIndexOutOfBoundsException(dstart));
} else if (sstart < 0) {
- th->setPendingException(vm->CreateIndexOutOfBoundsException(sstart));
+ mut->setPendingException(vm->CreateIndexOutOfBoundsException(sstart));
} else if (len < 0) {
- th->setPendingException(vm->CreateIndexOutOfBoundsException(len));
+ mut->setPendingException(vm->CreateIndexOutOfBoundsException(len));
} else if ((dstType->isPrimitive() || srcType->isPrimitive()) &&
srcType != dstType) {
- th->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
+ mut->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
}
- if (th->getPendingException() != NULL) return;
+ if (mut->getPendingException() != NULL) return;
jint i = sstart;
jint length = len;
@@ -104,7 +104,7 @@
memmove(ptrDst, ptrSrc, length << logSize);
if (doThrow) {
- th->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
+ mut->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
}
}
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JNIReferences.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JNIReferences.h?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JNIReferences.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JNIReferences.h Wed Dec 1 03:29:25 2010
@@ -25,7 +25,7 @@
private:
JNILocalReferences* prev;
uint32_t length;
- JavaObject* localReferences[MAXIMUM_REFERENCES];
+ gc* localReferences[MAXIMUM_REFERENCES];
public:
@@ -34,7 +34,7 @@
length = 0;
}
- JavaObject** addJNIReference(JavaThread* th, JavaObject* obj);
+ gc** addJNIReference(JavaThread* th, gc* obj);
void removeJNIReferences(JavaThread* th, uint32_t num);
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp Wed Dec 1 03:29:25 2010
@@ -64,7 +64,7 @@
#else
#define DO_TRY
-#define DO_CATCH if (th->getPendingException()) { th->throwFromJava(); }
+#define DO_CATCH if (th->mut->getPendingException()) { th->throwFromJava(); }
#endif
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp Wed Dec 1 03:29:25 2010
@@ -52,8 +52,8 @@
// Since the function is marked readnone, LLVM may move it after the
// exception check. Therefore, we trick LLVM to check the return value of the
// function.
-#define hack_check(type) \
- JavaObject* obj = JavaThread::get()->getPendingException(); \
+#define hack_check(type) \
+ gc* obj = mvm::Thread::get()->getPendingException(); \
if (obj) return (type)obj;
hack_check(void*);
@@ -372,7 +372,7 @@
// Does not call any Java code. Can not yield a GC.
extern "C" void j3ThrowException(JavaObject* obj) {
llvm_gcroot(obj, 0);
- return JavaThread::get()->throwException(obj);
+ return mvm::Thread::get()->setPendingException(obj)->throwIt();
}
// Creates a Java object and then throws it.
@@ -387,7 +387,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
return exc;
}
@@ -404,7 +405,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
return exc;
}
@@ -421,7 +423,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
return exc;
}
@@ -438,7 +441,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
return exc;
}
@@ -455,7 +459,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
return exc;
}
@@ -475,7 +480,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
return exc;
}
@@ -495,7 +501,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
return exc;
}
@@ -512,7 +519,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
return exc;
}
@@ -530,7 +538,8 @@
END_NATIVE_EXCEPTION
- th->setPendingException(exc)->throwFromNative();
+ th->mut->setPendingException(exc);
+ th->throwFromNative();
}
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp Wed Dec 1 03:29:25 2010
@@ -63,23 +63,6 @@
#endif
}
-JavaThread* JavaThread::setPendingException(JavaObject *obj) {
- llvm_gcroot(obj, 0);
- assert(mvm::Thread::get()->pendingException == 0 && "pending exception already there?");
- mvm::Thread::get()->pendingException = obj;
-}
-
-void JavaThread::throwIt() {
- assert(mvm::Thread::get()->pendingException);
- mvm::Thread::get()->internalThrowException();
-}
-
-void JavaThread::throwException(JavaObject* obj) {
- llvm_gcroot(obj, 0);
- setPendingException(obj);
- throwIt();
-}
-
void JavaThread::startJNI() {
// Interesting, but no need to do anything.
}
@@ -158,8 +141,8 @@
}
}
-JavaObject** JNILocalReferences::addJNIReference(JavaThread* th,
- JavaObject* obj) {
+gc** JNILocalReferences::addJNIReference(JavaThread* th,
+ gc* obj) {
llvm_gcroot(obj, 0);
if (length == MAXIMUM_REFERENCES) {
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h Wed Dec 1 03:29:25 2010
@@ -93,7 +93,7 @@
///
Jnjvm *jnjvm;
- JavaObject** pushJNIRef(JavaObject* obj) {
+ gc** pushJNIRef(gc* obj) {
llvm_gcroot(obj, 0);
if (!obj) return 0;
@@ -152,28 +152,6 @@
return javaThread;
}
- /// setException - only set the pending exception
- ///
- JavaThread* setPendingException(JavaObject *obj);
-
- /// throwException - Throw the given exception in the current thread.
- ///
- void throwException(JavaObject* obj);
-
- /// throwIt - Throw a pending exception.
- ///
- void throwIt();
-
- /// clearPendingException - Clear the pending exception.
- //
- void clearPendingException() { mut->pendingException = 0; }
-
- /// getPendingException - Return the pending exception.
- ///
- JavaObject* getPendingException() {
- return (JavaObject*)mut->pendingException;
- }
-
/// throwFromJNI - Throw an exception after executing JNI code.
///
void throwFromJNI(void* SP) {
@@ -185,14 +163,14 @@
///
void throwFromNative() {
#ifdef DWARF_EXCEPTIONS
- throwIt();
+ mut->throwIt();
#endif
}
/// throwFromJava - Throw an exception after executing Java code.
///
void throwFromJava() {
- throwIt();
+ mut->throwIt();
}
/// startJava - Interesting, but actually does nothing :)
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Jni.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Jni.cpp?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jni.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jni.cpp Wed Dec 1 03:29:25 2010
@@ -173,7 +173,7 @@
false, true, 0);
str = vm->asciizToStr(msg);
init->invokeIntSpecial(vm, realCl, res, &str);
- JavaThread::j3Thread(mut)->setPendingException(res);
+ mut->setPendingException(res);
RETURN_FROM_JNI(1);
@@ -187,7 +187,7 @@
BEGIN_JNI_EXCEPTION
- JavaObject* obj = JavaThread::get()->getPendingException();
+ gc* obj = mut->getPendingException();
llvm_gcroot(obj, 0);
if (obj == NULL) RETURN_FROM_JNI(NULL);
jthrowable res = (jthrowable)JavaThread::j3Thread(mut)->pushJNIRef(obj);
@@ -3584,7 +3584,7 @@
jboolean ExceptionCheck(JNIEnv *env) {
BEGIN_JNI_EXCEPTION
- if (JavaThread::get()->getPendingException()) {
+ if (mut->getPendingException()) {
RETURN_FROM_JNI(JNI_TRUE);
} else {
RETURN_FROM_JNI(JNI_FALSE);
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Wed Dec 1 03:29:25 2010
@@ -46,7 +46,7 @@
/// initialiseClass - Java class initialisation. Java specification §2.17.5.
void UserClass::initialiseClass(Jnjvm* vm) {
- JavaObject* exc = NULL;
+ gc* exc = NULL;
JavaObject* obj = NULL;
llvm_gcroot(exc, 0);
llvm_gcroot(obj, 0);
@@ -147,9 +147,8 @@
release();
} END_CATCH;
- JavaThread* th = JavaThread::get();
- if (th->getPendingException() != NULL) {
- th->throwIt();
+ if (mut->getPendingException() != NULL) {
+ mut->throwIt();
return;
}
}
@@ -183,9 +182,9 @@
TRY {
meth->invokeIntStatic(vm, cl);
} CATCH {
- exc = JavaThread::get()->getPendingException();
+ exc = mut->getPendingException();
assert(exc && "no exception?");
- mvm::Thread::get()->clearPendingException();
+ mut->clearPendingException();
} END_CATCH;
}
@@ -209,11 +208,13 @@
// ExceptionInInitializerError cannot be created because an
// OutOfMemoryError occurs, then instead use an OutOfMemoryError object
// in place of E in the following step.
- JavaThread* th = JavaThread::get();
- if (JavaObject::getClass(exc)->isAssignableFrom(vm->upcalls->newException)) {
+ JavaObject* jexc;
+ llvm_gcroot(jexc, 0);
+ jexc = Jnjvm::asJavaException(exc);
+ if (jexc && JavaObject::getClass(jexc)->isAssignableFrom(vm->upcalls->newException)) {
Classpath* upcalls = classLoader->bootstrapLoader->upcalls;
UserClass* clExcp = upcalls->ExceptionInInitializerError;
- Jnjvm* vm = th->getJVM();
+ Jnjvm* vm = JavaThread::get()->getJVM();
obj = clExcp->doNew(vm);
if (obj == NULL) {
fprintf(stderr, "implement me");
@@ -232,7 +233,7 @@
setOwnerClass(0);
broadcastClass();
release();
- th->throwException(exc);
+ mut->setPendingException(exc)->throwIt();
return;
}
}
@@ -245,7 +246,7 @@
obj = cl->doNew(this);
init->invokeIntSpecial(this, cl, obj, &excp);
- JavaThread::get()->throwException(obj);
+ mvm::Thread::get()->setPendingException(obj)->throwIt();
}
JavaObject* Jnjvm::CreateError(UserClass* cl, JavaMethod* init,
@@ -277,7 +278,7 @@
llvm_gcroot(obj, 0);
llvm_gcroot(str, 0);
obj = CreateError(cl, init, str);
- JavaThread::get()->throwException(obj);
+ mvm::Thread::get()->setPendingException(obj)->throwIt();
}
void Jnjvm::arrayStoreException() {
@@ -1175,7 +1176,7 @@
}
void Jnjvm::executeClass(const char* className, ArrayObject* args) {
- JavaObject* exc = NULL;
+ gc* exc = NULL;
JavaObject* obj = NULL;
JavaObject* group = NULL;
@@ -1208,11 +1209,12 @@
} CATCH {
} END_CATCH;
- exc = JavaThread::get()->getPendingException();
+ mvm::Thread* mut = mvm::Thread::get();
+ exc = mut->getPendingException();
if (exc != NULL) {
JavaThread* th = JavaThread::get();
- th->clearPendingException();
+ mut->clearPendingException();
obj = th->currentThread();
group = upcalls->group->getInstanceObjectField(obj);
TRY {
@@ -1262,7 +1264,7 @@
JavaString* str = NULL;
JavaObject* instrumenter = NULL;
ArrayObject* args = NULL;
- JavaObject* exc = NULL;
+ gc* exc = NULL;
llvm_gcroot(str, 0);
llvm_gcroot(instrumenter, 0);
@@ -1286,12 +1288,15 @@
TRY {
vm->loadBootstrap();
} CATCH {
- exc = JavaThread::get()->getPendingException();
+ exc = mvm::Thread::get()->getPendingException();
} END_CATCH;
if (exc != NULL) {
+ JavaObject *jexc;
+ llvm_gcroot(jexc, 0);
+ jexc = Jnjvm::asJavaException(exc);
fprintf(stderr, "Exception %s while bootstrapping VM.",
- UTF8Buffer(JavaObject::getClass(exc)->name).cString());
+ exc ? UTF8Buffer(JavaObject::getClass(jexc)->name).cString() : " foreign exception");
} else {
ClArgumentsInfo& info = vm->argumentsInfo;
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h Wed Dec 1 03:29:25 2010
@@ -356,6 +356,10 @@
/// mapping the initial thread.
///
void loadBootstrap();
+
+ // asjavaException - convert from gc to JavaObject. Will be used to identify the points
+ // where we must test the original vm of the exception
+ static JavaObject* asJavaException(gc* o) { llvm_gcroot(o, 0); return (JavaObject*)o; }
};
} // end namespace j3
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp Wed Dec 1 03:29:25 2010
@@ -669,7 +669,7 @@
UserClass* JnjvmClassLoader::constructClass(const UTF8* name,
ClassBytes* bytes) {
- JavaObject* excp = NULL;
+ gc* excp = NULL;
llvm_gcroot(excp, 0);
UserClass* res = NULL;
lock.lock();
@@ -694,12 +694,13 @@
classes->lock.unlock();
assert(success && "Could not add class in map");
} CATCH {
- excp = JavaThread::get()->getPendingException();
- mvm::Thread::get()->clearPendingException();
+ mvm::Thread* mut = mvm::Thread::get();
+ excp = mut->getPendingException();
+ mut->clearPendingException();
} END_CATCH;
}
if (excp != NULL) {
- JavaThread::get()->throwException(excp);
+ mvm::Thread::get()->setPendingException(excp)->throwIt();
}
lock.unlock();
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/VirtualTables.cpp Wed Dec 1 03:29:25 2010
@@ -336,7 +336,7 @@
JNILocalReferences* end = localJNIRefs;
while (end != NULL) {
for (uint32 i = 0; i < end->length; ++i) {
- JavaObject** obj = end->localReferences + i;
+ gc** obj = end->localReferences + i;
mvm::Collector::markAndTraceRoot(obj, closure);
}
end = end->prev;
Modified: vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp?rev=120566&r1=120565&r2=120566&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp Wed Dec 1 03:29:25 2010
@@ -104,7 +104,16 @@
#define SELF_HANDLE 0
#endif
-void Thread::internalThrowException() {
+Thread* Thread::setPendingException(gc *obj) {
+ llvm_gcroot(obj, 0);
+ assert(pendingException == 0 && "pending exception already there?");
+ pendingException = obj;
+ return this;
+}
+
+void Thread::throwIt() {
+ assert(pendingException);
+
#ifdef RUNTIME_DWARF_EXCEPTIONS
// Use dlsym instead of getting the functions statically with extern "C"
// because gcc compiles exceptions differently.
More information about the vmkit-commits
mailing list