[vmkit-commits] [vmkit] r57419 - in /vmkit/trunk: include/mvm/Threads/Thread.h lib/JnJVM/VMCore/JavaThread.h lib/Mvm/GCMmap2/gccollector.cpp lib/N3/VMCore/VMThread.cpp lib/N3/VMCore/VMThread.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Oct 12 11:45:53 PDT 2008


Author: geoffray
Date: Sun Oct 12 13:45:52 2008
New Revision: 57419

URL: http://llvm.org/viewvc/llvm-project?rev=57419&view=rev
Log:
Catch exceptions and clean them when the destructor throws an exception.


Modified:
    vmkit/trunk/include/mvm/Threads/Thread.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
    vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
    vmkit/trunk/lib/N3/VMCore/VMThread.cpp
    vmkit/trunk/lib/N3/VMCore/VMThread.h

Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=57419&r1=57418&r2=57419&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Sun Oct 12 13:45:52 2008
@@ -13,6 +13,7 @@
 #include "types.h"
 
 #include "MvmGC.h"
+#include "mvm/Allocator.h"
 #include "mvm/JIT.h"
 #include "mvm/Threads/Key.h"
 
@@ -64,9 +65,7 @@
   static mvm::Key<Thread>* threadKey;
  
 public:
-  /// GC - The collector of this thread.
-  ///
-  Collector* GC;
+  Allocator* allocator;
   
   /// baseSP - The base stack pointer.
   ///
@@ -95,6 +94,20 @@
     mvm::jit::setExecutionEnvironment(th);
 #endif
   }
+
+private:
+  
+  /// internalClearException - Clear any pending exception.
+  virtual void internalClearException() {
+  }
+
+public:
+
+  /// clearException - Clear any pending exception of the current thread.
+  static void clearException() {
+    Thread* th = Thread::get();
+    th->internalClearException();
+  }
 };
 
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Sun Oct 12 13:45:52 2008
@@ -94,12 +94,6 @@
     __cxa_throw(exc, 0, 0);
   }
   
-  static void clearException() {
-    JavaThread* th = JavaThread::get();
-    th->pendingException = 0;
-    th->internalPendingException = 0;
-  }
-
   static bool compareException(UserClass* cl) {
     JavaObject* pe = JavaThread::get()->pendingException;
     assert(pe && "no pending exception?");
@@ -119,6 +113,12 @@
     longjmp((__jmp_buf_tag*)sjlj_buffers.back(), 1);
 #endif
   }
+  
+private:
+  virtual void internalClearException() {
+    pendingException = 0;
+    internalPendingException = 0;
+  }
 };
 
 } // end namespace jnjvm

Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=57419&r1=57418&r2=57419&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Sun Oct 12 13:45:52 2008
@@ -95,8 +95,13 @@
     next = cur->next();
     
     destructor_t dest = c->getDestructor();
-    if (dest)
-      dest(c);
+    if (dest) {
+      try {
+        dest(c);
+      } catch(...) {
+        mvm::Thread::clearException();
+      }
+    }
   }
   
   next = 0;

Modified: vmkit/trunk/lib/N3/VMCore/VMThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.cpp?rev=57419&r1=57418&r2=57419&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.cpp Sun Oct 12 13:45:52 2008
@@ -94,10 +94,9 @@
   __cxa_throw(exc, 0, 0); 
 }
 
-void VMThread::clearException() {
-  VMThread* th = VMThread::get();
-  th->pendingException = 0;
-  th->internalPendingException = 0;
+void VMThread::internalClearException() {
+  pendingException = 0;
+  internalPendingException = 0;
 }
 
 bool VMThread::compareException(VMClass* cl) {

Modified: vmkit/trunk/lib/N3/VMCore/VMThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.h?rev=57419&r1=57418&r2=57419&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.h Sun Oct 12 13:45:52 2008
@@ -57,11 +57,13 @@
   static VMObject* getCLIException();
   static void* getCppException();
   static void throwException(VMObject*);
-  static void clearException();
   static bool compareException(VMClass*);
 
   llvm::FunctionPassManager* perFunctionPasses;
   std::vector<jmp_buf*> sjlj_buffers;
+  
+private:
+  virtual void internalClearException();
 };
 
 } // end namespace n3





More information about the vmkit-commits mailing list