[vmkit-commits] [vmkit] r63013 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathConstructor.cpp Classpath/ClasspathMethod.cpp VMCore/JavaMetaJIT.cpp VMCore/JavaThread.h VMCore/Jnjvm.cpp VMCore/JnjvmClassLoader.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Jan 26 08:46:05 PST 2009


Author: geoffray
Date: Mon Jan 26 10:46:04 2009
New Revision: 63013

URL: http://llvm.org/viewvc/llvm-project?rev=63013&view=rev
Log:
Simplify exception handling by throwing a current exception in
the catch clause.


Modified:
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp?rev=63013&r1=63012&r2=63013&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp Mon Jan 26 10:46:04 2009
@@ -107,18 +107,16 @@
       JavaThread* th = JavaThread::get();
       try {
         meth->invokeIntSpecialBuf(vm, cl, obj, startBuf);
-      }catch(...) {
+      } catch(...) {
         excp = th->getJavaException();
-        th->clearException();
-      }
-      if (excp) {
         if (excp->getClass()->isAssignableFrom(vm->upcalls->newException)) {
+          th->clearException();
           // If it's an exception, we encapsule it in an
           // invocationTargetException
           vm->invocationTargetException(excp);
         } else {
           // If it's an error, throw it again.
-          th->throwException(excp);
+          th->throwPendingException();
         }
       }
     

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp?rev=63013&r1=63012&r2=63013&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp Mon Jan 26 10:46:04 2009
@@ -150,17 +150,13 @@
       } else { \
         val = meth->invoke##TYPE##StaticBuf(vm, cl, _buf); \
       } \
-    }catch(...) { \
+    } catch(...) { \
       exc = th->getJavaException(); \
-      assert(exc && "no exception?"); \
-      th->clearException(); \
-    } \
-    \
-    if (exc) { \
       if (exc->getClass()->isAssignableFrom(vm->upcalls->newException)) { \
+        th->clearException(); \
         th->getJVM()->invocationTargetException(exc); \
       } else { \
-        th->throwException(exc); \
+        th->throwPendingException(); \
       } \
     } \
     

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=63013&r1=63012&r2=63013&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Mon Jan 26 10:46:04 2009
@@ -66,16 +66,12 @@
   void* _buf = (void*)buf; \
   readArgs(buf, sign, ap); \
   void* func = (((void***)obj)[0])[offset];\
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_VIRTUAL_BUF)sign->getVirtualCallBuf())(cl->getConstantPool(), func, obj, _buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -94,16 +90,12 @@
   void* _buf = (void*)buf; \
   readArgs(buf, sign, ap); \
   void* func = this->compiledPtr();\
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_VIRTUAL_BUF)sign->getVirtualCallBuf())(cl->getConstantPool(), func, obj, _buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -121,16 +113,12 @@
   void* _buf = (void*)buf; \
   readArgs(buf, sign, ap); \
   void* func = this->compiledPtr();\
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_STATIC_BUF)sign->getStaticCallBuf())(cl->getConstantPool(), func, _buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -147,16 +135,12 @@
   \
   Signdef* sign = getSignature(); \
   void* func = (((void***)obj)[0])[offset];\
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_VIRTUAL_BUF)sign->getVirtualCallBuf())(cl->getConstantPool(), func, obj, buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -172,16 +156,12 @@
   verifyNull(obj);\
   void* func = this->compiledPtr();\
   Signdef* sign = getSignature(); \
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_VIRTUAL_BUF)sign->getVirtualCallBuf())(cl->getConstantPool(), func, obj, buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -196,16 +176,12 @@
   \
   void* func = this->compiledPtr();\
   Signdef* sign = getSignature(); \
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_STATIC_BUF)sign->getStaticCallBuf())(cl->getConstantPool(), func, buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -249,16 +225,12 @@
   verifyNull(obj); \
   void* func = (((void***)obj)[0])[offset];\
   Signdef* sign = getSignature(); \
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_VIRTUAL_AP)sign->getVirtualCallAP())(cl->getConstantPool(), func, obj, ap);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -274,16 +246,12 @@
   verifyNull(obj);\
   void* func = this->compiledPtr();\
   Signdef* sign = getSignature(); \
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_VIRTUAL_AP)sign->getVirtualCallAP())(cl->getConstantPool(), func, obj, ap);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -298,16 +266,12 @@
   \
   void* func = this->compiledPtr();\
   Signdef* sign = getSignature(); \
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_STATIC_AP)sign->getStaticCallAP())(cl->getConstantPool(), func, ap);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -323,16 +287,12 @@
   verifyNull(obj);\
   void* func = (((void***)obj)[0])[offset];\
   Signdef* sign = getSignature(); \
-  bool exc = false; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_VIRTUAL_BUF)sign->getVirtualCallBuf())(cl->getConstantPool(), func, obj, buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -348,16 +308,12 @@
   verifyNull(obj);\
   void* func = this->compiledPtr();\
   Signdef* sign = getSignature(); \
-  bool exc = 0; \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_VIRTUAL_BUF)sign->getVirtualCallBuf())(cl->getConstantPool(), func, obj, buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \
@@ -374,14 +330,10 @@
   Signdef* sign = getSignature(); \
   JavaThread* th = JavaThread::get(); \
   th->startJava(); \
-  bool exc = false; \
   TYPE res = 0; \
   try { \
     res = ((FUNC_TYPE_STATIC_BUF)sign->getStaticCallBuf())(cl->getConstantPool(), func, buf);\
   } catch (...) { \
-    exc = true; \
-  } \
-  if (exc) { \
     th->throwFromJava(); \
   } \
   th->endJava(); \

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=63013&r1=63012&r2=63013&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Mon Jan 26 10:46:04 2009
@@ -29,28 +29,20 @@
 #define BEGIN_NATIVE_EXCEPTION(level) \
   JavaThread* __th = JavaThread::get(); \
   __th->startNative(level); \
-  bool __exc = false; \
   try {
 
 #define END_NATIVE_EXCEPTION \
   } catch(...) { \
-    __exc = true; \
-  } \
-  if (__exc) { \
     __th->throwFromNative(); \
   } \
   __th->endNative();
 
 #define BEGIN_JNI_EXCEPTION \
   JavaThread* th = JavaThread::get(); \
-  bool __exc = 0; \
   try {
 
 #define END_JNI_EXCEPTION \
   } catch(...) { \
-    __exc = true; \
-  } \
-  if (__exc) { \
     th->throwFromJNI(); \
   }
 
@@ -174,7 +166,7 @@
   ///
   void throwException(JavaObject* obj);
 
-  /// throwPendingException - Throw a pending exception created by JNI.
+  /// throwPendingException - Throw a pending exception.
   ///
   void throwPendingException();
   

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=63013&r1=63012&r2=63013&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Mon Jan 26 10:46:04 2009
@@ -143,22 +143,15 @@
     //    the initializing the superclass.
     UserClass* super = getSuper();
     if (super) {
-      JavaObject *exc = 0;
       try {
         super->initialiseClass(vm);
       } catch(...) {
-        exc = self->getJavaException();
-        assert(exc && "no exception?");
-        self->clearException();
-      }
-      
-      if (exc) {
         acquire();
         setErroneous();
         setOwnerClass(0);
         broadcastClass();
         release();
-        self->throwException(exc);
+        self->throwPendingException();
       }
     }
  

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=63013&r1=63012&r2=63013&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Mon Jan 26 10:46:04 2009
@@ -162,6 +162,8 @@
   // Now that native types have been loaded, try to find if we have a
   // pre-compiled rt.jar
   nativeHandle = dlopen("libvmjc"DYLD_EXTENSION, RTLD_LAZY | RTLD_GLOBAL);
+	fprintf(stderr, "%s\n", dlerror());
+	fprintf(stderr, "alors %p\n", dlsym(0, "JnJVM_java_io_PrintStream_append__Ljava_lang_CharSequence_2II1"));
   if (nativeHandle) {
     // Found it!
     SuperArray = (Class*)dlsym(nativeHandle, "java.lang.Object");
@@ -1004,6 +1006,10 @@
   char* soName = (char*)alloca(strlen(name) + strlen(DYLD_EXTENSION));
   sprintf(soName, "%s%s", name, DYLD_EXTENSION);
   void* handle = dlopen(soName, RTLD_LAZY | RTLD_LOCAL);
+	if (!handle) {
+  	handle = dlopen("source.so", RTLD_LAZY | RTLD_LOCAL);
+		fprintf(stderr, "%s\n", dlerror());
+	}
   if (handle) {
     Class* cl = (Class*)dlsym(handle, name);
     if (cl) {





More information about the vmkit-commits mailing list