Native threads
authorstefan <none@none>
Mon, 5 Jan 2004 23:59:28 +0000 (23:59 +0000)
committerstefan <none@none>
Mon, 5 Jan 2004 23:59:28 +0000 (23:59 +0000)
builtin.c
builtin.h
src/threads/green/threads.c
src/threads/green/threads.h
src/vm/builtin.c
src/vm/builtin.h
threads/thread.c
threads/thread.h

index 825a66e3acc285b520f18c041186f2e7f8b26234..4aadbfa8b8a299d552a8831791dfcd08fc44d921 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 793 2003-12-16 18:50:39Z edwin $
+   $Id: builtin.c 851 2004-01-05 23:59:28Z stefan $
 
 */
 
@@ -392,6 +392,33 @@ java_objectheader *builtin_throw_exception(java_objectheader *local_exceptionptr
        return local_exceptionptr;
 }
 
+java_objectheader *builtin_get_exceptionptr()
+{
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#ifdef HAVE___THREAD
+       return exceptionptr;
+#else
+       pthread_getspecific(tkey_exceptionptr);
+#endif
+#else
+       panic("builtin_get_exceptionptr should not be used in this configuration");
+       return NULL;
+#endif
+}
+
+void builtin_set_exceptionptr(java_objectheader *e)
+{
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#ifdef HAVE___THREAD
+       exceptionptr = e;
+#else
+       pthread_setspecific(tkey_exceptionptr, e);
+#endif
+#else
+       panic("builtin_set_exceptionptr should not be used in this configuration");
+#endif
+}
+
 
 /******************* function: builtin_canstore *******************************
 
index ae49650a1c718d11884f907c4f7a3d172892dd48..e2d48bd7501b6b2a30d4c5021433a5f3483ca0fd 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: builtin.h 821 2003-12-31 14:14:01Z twisti $
+   $Id: builtin.h 851 2004-01-05 23:59:28Z stefan $
 
 */
 
@@ -172,6 +172,11 @@ java_objectheader *builtin_trace_exception(java_objectheader *exceptionptr,
                                                                                   int *pos, int noindent);
 /* NOT AN OP */
 
+java_objectheader *builtin_get_exceptionptr();
+/* NOT AN OP */
+void builtin_set_exceptionptr(java_objectheader*);
+/* NOT AN OP */
+
 java_objectheader *builtin_new(classinfo *c);
 #define BUILTIN_new (functionptr) builtin_new
 
index 5ea8d5d794ab66a031d99476a7797401b55d0c13..bba20c00b291c069923d8e90802b76c82c2a9d7c 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 
+#include "global.h"
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
 #if defined(NATIVE_THREADS)
 pthread_mutex_t cast_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t compiler_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t compiler_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
+int cast_counter;
+
+#ifndef HAVE___THREAD
+pthread_key_t tkey_exceptionptr;
+#endif
 #endif
 
 static classinfo *class_java_lang_ThreadDeath;
@@ -121,6 +128,10 @@ freeThreadStack (thread *tid)
 void
 initThreads(u1 *stackbottom)
 {
+#if defined(NATIVE_THREADS) && !defined(HAVE___THREAD)
+       pthread_key_create(&tkey_exceptionptr, NULL);
+#endif
+
        thread *the_main_thread;
     int i;
        char mainname[] = "main";
@@ -770,3 +781,11 @@ reschedule(void)
                checkEvents(true);
     }
 }
+
+void cast_lock()
+{
+}
+
+void cast_unlock()
+{
+}
index 2dd27bb3e18847cf045aba729a98a7fcde519e19..f3d43adf69d85d20532fc34866a294c94a3d4711 100644 (file)
@@ -170,6 +170,10 @@ extern thread *threadQhead[MAX_THREAD_PRIO + 1];
 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop);
 u1*  asm_initialize_thread_stack(void *func, u1 *stack);
 
+#if defined(NATIVE_THREADS) && !defined(HAVE___THREAD)
+extern pthread_key_t tkey_exceptionptr;
+#endif
+
 #else
 
 #define intsDisable()
index 825a66e3acc285b520f18c041186f2e7f8b26234..4aadbfa8b8a299d552a8831791dfcd08fc44d921 100644 (file)
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 793 2003-12-16 18:50:39Z edwin $
+   $Id: builtin.c 851 2004-01-05 23:59:28Z stefan $
 
 */
 
@@ -392,6 +392,33 @@ java_objectheader *builtin_throw_exception(java_objectheader *local_exceptionptr
        return local_exceptionptr;
 }
 
+java_objectheader *builtin_get_exceptionptr()
+{
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#ifdef HAVE___THREAD
+       return exceptionptr;
+#else
+       pthread_getspecific(tkey_exceptionptr);
+#endif
+#else
+       panic("builtin_get_exceptionptr should not be used in this configuration");
+       return NULL;
+#endif
+}
+
+void builtin_set_exceptionptr(java_objectheader *e)
+{
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#ifdef HAVE___THREAD
+       exceptionptr = e;
+#else
+       pthread_setspecific(tkey_exceptionptr, e);
+#endif
+#else
+       panic("builtin_set_exceptionptr should not be used in this configuration");
+#endif
+}
+
 
 /******************* function: builtin_canstore *******************************
 
index ae49650a1c718d11884f907c4f7a3d172892dd48..e2d48bd7501b6b2a30d4c5021433a5f3483ca0fd 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: builtin.h 821 2003-12-31 14:14:01Z twisti $
+   $Id: builtin.h 851 2004-01-05 23:59:28Z stefan $
 
 */
 
@@ -172,6 +172,11 @@ java_objectheader *builtin_trace_exception(java_objectheader *exceptionptr,
                                                                                   int *pos, int noindent);
 /* NOT AN OP */
 
+java_objectheader *builtin_get_exceptionptr();
+/* NOT AN OP */
+void builtin_set_exceptionptr(java_objectheader*);
+/* NOT AN OP */
+
 java_objectheader *builtin_new(classinfo *c);
 #define BUILTIN_new (functionptr) builtin_new
 
index 5ea8d5d794ab66a031d99476a7797401b55d0c13..bba20c00b291c069923d8e90802b76c82c2a9d7c 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 
+#include "global.h"
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
 #if defined(NATIVE_THREADS)
 pthread_mutex_t cast_mutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t compiler_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t compiler_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
+int cast_counter;
+
+#ifndef HAVE___THREAD
+pthread_key_t tkey_exceptionptr;
+#endif
 #endif
 
 static classinfo *class_java_lang_ThreadDeath;
@@ -121,6 +128,10 @@ freeThreadStack (thread *tid)
 void
 initThreads(u1 *stackbottom)
 {
+#if defined(NATIVE_THREADS) && !defined(HAVE___THREAD)
+       pthread_key_create(&tkey_exceptionptr, NULL);
+#endif
+
        thread *the_main_thread;
     int i;
        char mainname[] = "main";
@@ -770,3 +781,11 @@ reschedule(void)
                checkEvents(true);
     }
 }
+
+void cast_lock()
+{
+}
+
+void cast_unlock()
+{
+}
index 2dd27bb3e18847cf045aba729a98a7fcde519e19..f3d43adf69d85d20532fc34866a294c94a3d4711 100644 (file)
@@ -170,6 +170,10 @@ extern thread *threadQhead[MAX_THREAD_PRIO + 1];
 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop);
 u1*  asm_initialize_thread_stack(void *func, u1 *stack);
 
+#if defined(NATIVE_THREADS) && !defined(HAVE___THREAD)
+extern pthread_key_t tkey_exceptionptr;
+#endif
+
 #else
 
 #define intsDisable()