[vmkit-commits] [vmkit] r120502 - in /vmkit/branches/multi-vm/lib/J3: Classpath/ClasspathConstructor.inc Classpath/ClasspathMethod.inc Classpath/ClasspathVMClass.inc Classpath/ClasspathVMSystem.inc VMCore/JavaMetaJIT.cpp VMCore/JavaRuntimeJIT.cpp VMCore/JavaThread.cpp VMCore/JavaThread.h VMCore/Jni.cpp VMCore/Jnjvm.cpp VMCore/JnjvmClassLoader.cpp

Gael Thomas gael.thomas at lip6.fr
Tue Nov 30 15:56:44 PST 2010


Author: gthomas
Date: Tue Nov 30 17:56:44 2010
New Revision: 120502

URL: http://llvm.org/viewvc/llvm-project?rev=120502&view=rev
Log:
don't access directly to pendingException anymore (except in JavaThread.* and VirtualTable.cpp)

Modified:
    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/ClasspathVMSystem.inc
    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/JnjvmClassLoader.cpp

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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc Tue Nov 30 17:56:44 2010
@@ -132,7 +132,7 @@
           vm->invocationTargetException(excp);
         } else {
           // If it's an error, throw it again.
-          th->throwPendingException();
+          th->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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathMethod.inc Tue Nov 30 17:56:44 2010
@@ -174,7 +174,7 @@
         mut->clearPendingException();																		\
 				th->getJVM()->invocationTargetException(exc);										\
       } else {																													\
-        th->throwPendingException();																		\
+        th->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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClass.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMClass.inc Tue Nov 30 17:56:44 2010
@@ -584,7 +584,7 @@
   llvm_gcroot(throwable, 0);
 
   assert(throwable && "Using internal VM throw exception without exception");
-  JavaThread::get()->pendingException = (JavaObject*)throwable;
+  JavaThread::get()->setPendingException(throwable);
 }
 
 JNIEXPORT ArrayObject* Java_java_lang_VMClass_getDeclaredAnnotations(

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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMSystem.inc Tue Nov 30 17:56:44 2010
@@ -42,14 +42,13 @@
   Jnjvm *vm = th->getJVM();
 
   if (src == NULL || dst == NULL) {
-    th->pendingException = vm->CreateNullPointerException();
+    th->setPendingException(vm->CreateNullPointerException());
     return;
   }
   
   if (!(JavaObject::getClass(src)->isArray() &&
         JavaObject::getClass(dst)->isArray())) {
-    th->pendingException = vm->CreateArrayStoreException(
-      (JavaVirtualTable*)dst->getVirtualTable());
+    th->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
     return;
   }
   
@@ -62,25 +61,24 @@
   sint32 dstSize = JavaArray::getSize(dst);
 
   if (len > srcSize) {
-    th->pendingException = vm->CreateIndexOutOfBoundsException(len);
+    th->setPendingException(vm->CreateIndexOutOfBoundsException(len));
   } else if (len > dstSize) {
-    th->pendingException = vm->CreateIndexOutOfBoundsException(len);
+    th->setPendingException(vm->CreateIndexOutOfBoundsException(len));
   } else if (len + sstart > srcSize) {
-    th->pendingException = vm->CreateIndexOutOfBoundsException(len + sstart);
+    th->setPendingException(vm->CreateIndexOutOfBoundsException(len + sstart));
   } else if (len + dstart > dstSize) {
-    th->pendingException = vm->CreateIndexOutOfBoundsException(len + dstart);
+    th->setPendingException(vm->CreateIndexOutOfBoundsException(len + dstart));
   } else if (dstart < 0) {
-    th->pendingException = vm->CreateIndexOutOfBoundsException(dstart);
+    th->setPendingException(vm->CreateIndexOutOfBoundsException(dstart));
   } else if (sstart < 0) {
-    th->pendingException = vm->CreateIndexOutOfBoundsException(sstart);
+    th->setPendingException(vm->CreateIndexOutOfBoundsException(sstart));
   } else if (len < 0) {
-    th->pendingException = vm->CreateIndexOutOfBoundsException(len);
+    th->setPendingException(vm->CreateIndexOutOfBoundsException(len));
   } else if ((dstType->isPrimitive() || srcType->isPrimitive()) &&
              srcType != dstType) {
-    th->pendingException = vm->CreateArrayStoreException(
-      (JavaVirtualTable*)dst->getVirtualTable());
+    th->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
   }
-  if (th->pendingException != NULL) return;
+  if (th->getPendingException() != NULL) return;
   
   jint i = sstart;
   jint length = len;
@@ -106,8 +104,7 @@
   memmove(ptrDst, ptrSrc, length << logSize);
 
   if (doThrow) {
-    th->pendingException = vm->CreateArrayStoreException(
-      (JavaVirtualTable*)dst->getVirtualTable());
+    th->setPendingException(vm->CreateArrayStoreException((JavaVirtualTable*)dst->getVirtualTable()));
   }
 }
 

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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaMetaJIT.cpp Tue Nov 30 17:56:44 2010
@@ -64,7 +64,7 @@
 #else
 
 #define DO_TRY
-#define DO_CATCH if (th->pendingException) { th->throwFromJava(); }
+#define DO_CATCH if (th->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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaRuntimeJIT.cpp Tue Nov 30 17:56:44 2010
@@ -52,8 +52,12 @@
   // 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.
-  JavaObject* obj = JavaThread::get()->pendingException;
-  if (obj) return (JavaMethod*)obj;
+#define hack_check(type)																				\
+		JavaObject* obj = JavaThread::get()->getPendingException(); \
+		if (obj) return (type)obj;
+
+	hack_check(void*);
+
   return res;
 }
 
@@ -85,11 +89,8 @@
 
   END_NATIVE_EXCEPTION
 
-  // 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.
-  JavaObject* obj = JavaThread::get()->pendingException;
-  if (obj) return (void*)obj;
+	hack_check(void*);
+
   return res;
 }
 
@@ -130,11 +131,8 @@
 
   END_NATIVE_EXCEPTION
 
-  // 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.
-  JavaObject* obj = JavaThread::get()->pendingException;
-  if (obj) return (void*)obj;
+	hack_check(void*);
+
   return res;
 }
 
@@ -208,11 +206,9 @@
 
   END_NATIVE_EXCEPTION
   
-  // 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.
-  JavaObject* obj = JavaThread::get()->pendingException;
-  if (obj) return (void*)obj;
+
+	hack_check(void*);
+
   return res;
 }
 
@@ -226,11 +222,8 @@
   
   END_NATIVE_EXCEPTION
 
-  // 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.
-  JavaObject* obj = JavaThread::get()->pendingException;
-  if (obj) return (UserCommonClass*)obj;
+	hack_check(UserCommonClass*);
+
   return cl;
 }
 
@@ -244,11 +237,8 @@
   res = cl->getClassDelegatee(vm);
   END_NATIVE_EXCEPTION
   
-  // 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.
-  JavaObject* obj = JavaThread::get()->pendingException;
-  if (obj) return obj;
+	hack_check(JavaObject*);
+
   return res;
 }
 
@@ -328,11 +318,8 @@
 
   END_NATIVE_EXCEPTION
 
-  // 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.
-  JavaObject* obj = JavaThread::get()->pendingException;
-  if (obj) return (JavaVirtualTable*)obj;
+	hack_check(JavaVirtualTable*);
+
   return res;
 }
 
@@ -400,11 +387,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->throwFromNative();
 
   return exc;
 }
@@ -421,11 +404,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->throwFromNative();
 
   return exc;
 }
@@ -442,11 +421,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->throwFromNative();
 
   return exc;
 }
@@ -463,11 +438,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->throwFromNative();
 
   return exc;
 }
@@ -484,11 +455,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->throwFromNative();
 
   return exc;
 }
@@ -508,11 +475,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->throwFromNative();
 
   return exc;
 }
@@ -532,11 +495,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->throwFromNative();
   
   return exc;
 }
@@ -553,11 +512,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->throwFromNative();
   
   return exc;
 }
@@ -575,11 +530,7 @@
 
   END_NATIVE_EXCEPTION
 
-#ifdef DWARF_EXCEPTIONS
-  th->throwException(exc);
-#else
-  th->pendingException = exc;
-#endif
+	th->setPendingException(exc)->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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.cpp Tue Nov 30 17:56:44 2010
@@ -64,29 +64,24 @@
 #endif
 }
 
-void JavaThread::preparePendingException(JavaObject *obj) {
+JavaThread* JavaThread::setPendingException(JavaObject *obj) {
 	llvm_gcroot(obj, 0);
   assert(JavaThread::get()->pendingException == 0 && "pending exception already there?");
 	mvm::Thread* mut = mvm::Thread::get();
   j3Thread(mut)->pendingException = obj;	
-#ifdef DWARF_EXCEPTIONS
-	throwPendingException();
-#endif
 }
 
-void JavaThread::throwException(JavaObject* obj) {
-  llvm_gcroot(obj, 0);
-  assert(JavaThread::get()->pendingException == 0 && "pending exception already there?");
-	mvm::Thread* mut = mvm::Thread::get();
-  j3Thread(mut)->pendingException = obj;
-	throwPendingException();
-}
-
-void JavaThread::throwPendingException() {
+void JavaThread::throwIt() {
   assert(JavaThread::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.
 }

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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JavaThread.h Tue Nov 30 17:56:44 2010
@@ -157,17 +157,17 @@
     return javaThread;
   }
 
-  /// preparePendingException - set the pending exception and throw it if in dwarf
+  /// setException - only set the pending exception
 	///
-	void preparePendingException(JavaObject *obj);
+	JavaThread* setPendingException(JavaObject *obj);
  
   /// throwException - Throw the given exception in the current thread.
   ///
   void throwException(JavaObject* obj);
 
-  /// throwPendingException - Throw a pending exception.
+  /// throwIt - Throw a pending exception.
   ///
-  void throwPendingException();
+  void throwIt();
 
   /// clearPendingException - Clear the pending exception.
 	//
@@ -190,14 +190,14 @@
   ///
   void throwFromNative() {
 #ifdef DWARF_EXCEPTIONS
-    throwPendingException();
+    throwIt();
 #endif
   }
   
   /// throwFromJava - Throw an exception after executing Java code.
   ///
   void throwFromJava() {
-    throwPendingException();
+    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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jni.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jni.cpp Tue Nov 30 17:56:44 2010
@@ -173,7 +173,7 @@
                                           false, true, 0);
   str = vm->asciizToStr(msg);
   init->invokeIntSpecial(vm, realCl, res, &str);
-	JavaThread::j3Thread(mut)->pendingException = res;
+	JavaThread::j3Thread(mut)->setPendingException(res);
   
   RETURN_FROM_JNI(1);
   
@@ -187,7 +187,7 @@
   
   BEGIN_JNI_EXCEPTION
 
-  JavaObject* obj = JavaThread::get()->pendingException;
+	JavaObject* obj = JavaThread::get()->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()->pendingException) {
+	if (JavaThread::get()->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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Tue Nov 30 17:56:44 2010
@@ -149,7 +149,7 @@
 
 			JavaThread* th = JavaThread::get();
       if (th->getPendingException() != NULL) {
-        th->throwPendingException();
+        th->throwIt();
         return;
       }
     }
@@ -1208,11 +1208,11 @@
   } CATCH {
   } END_CATCH;
 
-  exc = JavaThread::get()->pendingException;
+  exc = JavaThread::get()->getPendingException();
+	printf("Exception: %p\n", exc);
   if (exc != NULL) {
-		mvm::Thread* mut = mvm::Thread::get();
-    mut->clearPendingException();
-    JavaThread* th   = JavaThread::j3Thread(mut);
+    JavaThread* th   = JavaThread::get();
+    th->clearPendingException();
     obj = th->currentThread();
     group = upcalls->group->getInstanceObjectField(obj);
     TRY {
@@ -1286,7 +1286,7 @@
   TRY {
     vm->loadBootstrap();
   } CATCH {
-    exc = JavaThread::get()->pendingException;
+    exc = JavaThread::get()->getPendingException();
   } END_CATCH;
 
   if (exc != NULL) {

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=120502&r1=120501&r2=120502&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/JnjvmClassLoader.cpp Tue Nov 30 17:56:44 2010
@@ -694,7 +694,7 @@
       classes->lock.unlock();
       assert(success && "Could not add class in map");
     } CATCH {
-      excp = JavaThread::get()->pendingException;
+      excp = JavaThread::get()->getPendingException();
       mvm::Thread::get()->clearPendingException();    
     } END_CATCH;
   }





More information about the vmkit-commits mailing list