* src/vm/builtin.h (builtin_retrieve_exception): Added prototype.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Thu, 18 Oct 2007 13:39:22 +0000 (15:39 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Thu, 18 Oct 2007 13:39:22 +0000 (15:39 +0200)
* src/vm/builtin.c (builtin_retrieve_exception): Implemented.

* src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Use above builtin.
* src/vm/jit/i386/linux/md-os.c,
* src/vm/jit/powerpc/darwin/md-os.c,
* src/vm/jit/powerpc/linux/md-os.c,
* src/vm/jit/powerpc64/linux/md-os.c,
* src/vm/jit/x86_64/linux/md-os.c: Likewise.

src/vm/builtin.c
src/vm/builtin.h
src/vm/jit/alpha/linux/md-os.c
src/vm/jit/i386/linux/md-os.c
src/vm/jit/powerpc/darwin/md-os.c
src/vm/jit/powerpc/linux/md-os.c
src/vm/jit/powerpc64/linux/md-os.c
src/vm/jit/x86_64/linux/md-os.c

index 1460e6a70b6ffe9eacd7eab6ef272156ec0088b5..0c4f1b50da7ecda5bd5cde5bf5e1d1f8b3c8ad99 100644 (file)
@@ -597,6 +597,32 @@ void *builtin_throw_exception(java_object_t *xptr)
 }
 
 
+/* builtin_retrieve_exception **************************************************
+
+   Gets and clears the exception pointer of the current thread.
+
+   RETURN VALUE:
+      the exception object, or NULL if no exception was thrown.
+
+   NOTE: This is a FAST builtin and can be called from JIT code,
+   or from the signal handlers.
+
+*******************************************************************************/
+
+java_object_t *builtin_retrieve_exception(void)
+{
+       java_handle_t *h;
+       java_object_t *o;
+
+       /* actually get and clear the exception */
+
+       h = exceptions_get_and_clear_exception();
+       o = LLNI_UNWRAP(h);
+
+       return o;
+}
+
+
 /* builtin_canstore ************************************************************
 
    Checks, if an object can be stored in an array.
index 9d09630905141ccf462a200e434723c93e781b6d..a68519d629085635154fba8fad19037167a55fe5 100644 (file)
@@ -140,6 +140,8 @@ s4 builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o);
 
 void *builtin_throw_exception(java_object_t *exception);
 /* NOT AN OP */
+java_object_t *builtin_retrieve_exception(void);
+/* NOT AN OP */
 
 java_handle_t *builtin_new(classinfo *c);
 /* NOT AN OP */
index 013bd02b18fbb79d1da608874df5b5c2a4f5d8af..64179d8aaeb2058a3c22f3178c6d83fdf91ba85b 100644 (file)
@@ -40,6 +40,7 @@
 # include "threads/native/threads.h"
 #endif
 
+#include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/signallocal.h"
 
@@ -133,7 +134,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                /* Get the exception object. */
 
-               p = exceptions_get_and_clear_exception();
+               p = builtin_retrieve_exception();
 
                assert(p != NULL);
 
index 418fbc9f86ab9fa17d4aa1adc3f1f4669937379b..ca69b31193187d55b81ef857aeb49f273a2c5fa0 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "threads/threads-common.h"
 
+#include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/signallocal.h"
 #include "vm/stringlocal.h"
@@ -138,7 +139,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        if (type == EXCEPTION_HARDWARE_COMPILER) {
                if (p == NULL) {
-                       o = exceptions_get_and_clear_exception();
+                       o = builtin_retrieve_exception();
 
                        _mc->gregs[REG_ESP] = (uintptr_t) sp;    /* Remove RA from stack. */
 
index 89a7c9441df2c228981525dd6999c2bbba1035a7..7a9e683727cecd4a5185a88a9f51327a997122d6 100644 (file)
@@ -41,6 +41,7 @@
 # include "threads/native/threads.h"
 #endif
 
+#include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
 #include "vm/signallocal.h"
@@ -148,7 +149,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                /* Get the exception object. */
 
-               p = exceptions_get_and_clear_exception();
+               p = builtin_retrieve_exception();
 
                assert(p != NULL);
 
index 6628953d6290968ab9e55ea16747087a3eda6b60..81863aee40306b211eb3b7fe9feb7ca57862e73b 100644 (file)
@@ -40,6 +40,7 @@
 # include "threads/native/threads.h"
 #endif
 
+#include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/signallocal.h"
 #include "vm/stringlocal.h"
@@ -148,7 +149,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                /* Get the exception object. */
 
-               p = exceptions_get_and_clear_exception();
+               p = builtin_retrieve_exception();
 
                assert(p != NULL);
 
index 7f8d23bf538dd4a5aed2f1c984b31a3aded48ec7..7701801b3255c5718c0f1a69defcc2c686fa4958 100644 (file)
@@ -40,6 +40,7 @@
 # include "threads/native/threads.h"
 #endif
 
+#include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/signallocal.h"
 
@@ -134,7 +135,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                /* Get the exception object. */
 
-               p = exceptions_get_and_clear_exception();
+               p = builtin_retrieve_exception();
 
                assert(p != NULL);
 
index de459ad69c84e68c3443e1882b79aa980cc49d4c..ced1cbee47c3965e4e7c78c5f8aaf40a28f5daff 100644 (file)
@@ -42,6 +42,7 @@
 # include "threads/native/threads.h"
 #endif
 
+#include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/signallocal.h"
 
@@ -71,7 +72,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        int             type;
        intptr_t        val;
        void           *p;
-       java_handle_t  *o;
+       java_object_t  *o;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -188,7 +189,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        if (type == EXCEPTION_HARDWARE_COMPILER) {
                if (p == NULL) {
-                       o = exceptions_get_and_clear_exception();
+                       o = builtin_retrieve_exception();
 
                        _mc->gregs[REG_RSP] = (uintptr_t) sp;    /* Remove RA from stack. */