[vmkit-commits] [vmkit] r58287 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaThread.cpp JavaThread.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Oct 27 15:34:19 PDT 2008


Author: geoffray
Date: Mon Oct 27 17:34:19 2008
New Revision: 58287

URL: http://llvm.org/viewvc/llvm-project?rev=58287&view=rev
Log:
Who knew that gcc compiles the throw keyword differently if you
declare the __cxa_throw function?


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Mon Oct 27 17:34:19 2008
@@ -19,6 +19,7 @@
 #include "JavaThread.h"
 #include "Jnjvm.h"
 
+
 using namespace jnjvm;
 
 const unsigned int JavaThread::StateRunning = 0;
@@ -78,3 +79,27 @@
 #endif
   }
 }
+
+// We define these here because gcc compiles the 'throw' keyword
+// differently, whether these are defined in a file or not. Since many
+// cpp files import JavaThread.h, they couldn't use the keyword.
+
+extern "C" void* __cxa_allocate_exception(unsigned);
+extern "C" void __cxa_throw(void*, void*, void*);
+
+void JavaThread::throwException(JavaObject* obj) {
+  JavaThread* th = JavaThread::get();
+  assert(th->pendingException == 0 && "pending exception already there?");
+  th->pendingException = obj;
+  void* exc = __cxa_allocate_exception(0);
+  th->internalPendingException = exc;
+  __cxa_throw(exc, 0, 0);
+}
+
+void JavaThread::throwPendingException() {
+  JavaThread* th = JavaThread::get();
+  assert(th->pendingException);
+  void* exc = __cxa_allocate_exception(0);
+  th->internalPendingException = exc;
+  __cxa_throw(exc, 0, 0);
+}

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Mon Oct 27 17:34:19 2008
@@ -20,9 +20,6 @@
 
 #include "JavaObject.h"
 
-extern "C" void* __cxa_allocate_exception(unsigned);
-extern "C" void __cxa_throw(void*, void*, void*);
-
 namespace jnjvm {
 
 class Class;
@@ -69,23 +66,14 @@
     return (void*)
       ((char*)JavaThread::get()->internalPendingException - 8 * sizeof(void*));
   }
-  
-  static void throwException(JavaObject* obj) {
-    JavaThread* th = JavaThread::get();
-    assert(th->pendingException == 0 && "pending exception already there?");
-    th->pendingException = obj;
-    void* exc = __cxa_allocate_exception(0);
-    th->internalPendingException = exc;
-    __cxa_throw(exc, 0, 0);
-  }
-
-  static void throwPendingException() {
-    JavaThread* th = JavaThread::get();
-    assert(th->pendingException);
-    void* exc = __cxa_allocate_exception(0);
-    th->internalPendingException = exc;
-    __cxa_throw(exc, 0, 0);
-  }
+ 
+  /// throwException - Throws the given exception in the current thread.
+  ///
+  static void throwException(JavaObject* obj);
+
+  /// throwPendingException - Throws a pending exception created by JNI.
+  ///
+  static void throwPendingException();
   
   static bool compareException(UserClass* cl) {
     JavaObject* pe = JavaThread::get()->pendingException;





More information about the vmkit-commits mailing list