X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fthreads%2Fnative%2Fthreads.h;h=417b273d1849ff2236f6a5fe6b4dc10d7cfc5d9c;hb=9f859ad50d3d5d98c185d40b86b2179bc4dc9aeb;hp=023fc7050f156ef79f8dcd6b7c22be80f58b8b28;hpb=1a5936d6482a092cdaefbe625f0a942ce33ae96c;p=cacao.git diff --git a/src/threads/native/threads.h b/src/threads/native/threads.h index 023fc7050..417b273d1 100644 --- a/src/threads/native/threads.h +++ b/src/threads/native/threads.h @@ -1,6 +1,6 @@ /* src/threads/native/threads.h - native threads header - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, + Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, Institut f. Computersprachen - TU Wien @@ -22,14 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Stefan Ring - Edwin Steiner - Christian Thalinger - - $Id: threads.h 6228 2006-12-26 19:56:58Z twisti $ - */ @@ -38,9 +30,7 @@ /* forward typedefs ***********************************************************/ -typedef struct threadobject threadobject; -typedef union threads_table_entry_t threads_table_entry_t; -typedef struct threads_table_t threads_table_t; +typedef struct threadobject threadobject; #include "config.h" @@ -52,11 +42,15 @@ typedef struct threads_table_t threads_table_t; #include "mm/memory.h" #include "native/jni.h" +#include "native/localref.h" #include "native/include/java_lang_Thread.h" -#include "vm/global.h" #include "threads/native/lock.h" +#include "vm/global.h" + +#include "vm/jit/stacktrace.h" + #if defined(ENABLE_INTRP) #include "vm/jit/intrp/intrp.h" #endif @@ -75,13 +69,6 @@ typedef struct { #endif -/* thread priorities **********************************************************/ - -#define MIN_PRIORITY 1 -#define NORM_PRIORITY 5 -#define MAX_PRIORITY 10 - - /* current threadobject *******************************************************/ #if defined(HAVE___THREAD) @@ -102,55 +89,25 @@ extern pthread_key_t threads_current_threadobject_key; #endif /* defined(HAVE___THREAD) */ -/* threads_table_entry_t ******************************************************* - - An entry in the global threads table. - -*******************************************************************************/ - -union threads_table_entry_t { - threadobject *thread; /* an existing thread */ - ptrint nextfree; /* next free index */ -}; - - -/* threads_table_t ************************************************************* - - Struct for the global threads table. - -*******************************************************************************/ - -struct threads_table_t { - threads_table_entry_t *table; /* the table, threads[0] is the head */ - /* of the free list. Real entries */ - /* start at threads[1]. */ - s4 size; /* current size of the table */ -}; - - /* threadobject **************************************************************** - Every java.lang.Thread object is actually an instance of this - structure. + Struct holding thread local variables. *******************************************************************************/ #define THREAD_FLAG_JAVA 0x01 /* a normal Java thread */ #define THREAD_FLAG_INTERNAL 0x02 /* CACAO internal thread */ +#define THREAD_FLAG_DAEMON 0x04 /* daemon thread */ struct threadobject { - java_lang_Thread o; /* the java.lang.Thread object */ - - lock_execution_env_t ee; /* data for the lock implementation */ - - threadobject *next; /* next thread in list, or self */ - threadobject *prev; /* prev thread in list, or self */ + java_lang_Thread *object; /* link to java.lang.Thread object */ ptrint thinlock; /* pre-computed thin lock value */ s4 index; /* thread index, starting with 1 */ - u1 flags; /* flag field */ + u4 flags; /* flag field */ + u4 state; /* state field */ pthread_t tid; /* pthread id */ @@ -158,9 +115,6 @@ struct threadobject { mach_port_t mach_thread; /* Darwin thread id */ #endif - pthread_mutex_t joinmutex; - pthread_cond_t joincond; - /* these are used for the wait/notify implementation */ pthread_mutex_t waitmutex; pthread_cond_t waitcond; @@ -171,7 +125,7 @@ struct threadobject { u1 *pc; /* current PC (used for profiling) */ - java_objectheader *_exceptionptr; /* current exception */ + java_object_t *_exceptionptr; /* current exception */ stackframeinfo *_stackframeinfo; /* current native stackframeinfo */ localref_table *_localref_table; /* JNI local references */ @@ -180,13 +134,41 @@ struct threadobject { #endif dumpinfo_t dumpinfo; /* dump memory info structure */ + +#if defined(ENABLE_DEBUG_FILTER) + u2 filterverbosecallctr[2]; /* counters for verbose call filter */ +#endif + +#if !defined(NDEBUG) + s4 tracejavacallindent; + u4 tracejavacallcount; +#endif + + listnode_t linkage; /* threads-list */ }; -/* variables ******************************************************************/ +/* exception pointer **********************************************************/ + +#define exceptionptr (&(THREADOBJECT->_exceptionptr)) + + +/* stackframeinfo *************************************************************/ + +#define STACKFRAMEINFO (THREADOBJECT->_stackframeinfo) -extern threadobject *mainthreadobj; +/* counter for verbose call filter ********************************************/ +#if defined(ENABLE_DEBUG_FILTER) +# define FILTERVERBOSECALLCTR (THREADOBJECT->filterverbosecallctr) +#endif + +/* state for trace java call **************************************************/ + +#if !defined(NDEBUG) +# define TRACEJAVACALLINDENT (THREADOBJECT->tracejavacallindent) +# define TRACEJAVACALLCOUNT (THREADOBJECT->tracejavacallcount) +#endif /* functions ******************************************************************/ @@ -196,7 +178,6 @@ void threads_sem_post(sem_t *sem); threadobject *threads_get_current_threadobject(void); -void threads_preinit(void); bool threads_init(void); void threads_start_thread(threadobject *thread, functionptr function); @@ -209,7 +190,6 @@ bool threads_detach_thread(threadobject *thread); void threads_join_all_threads(void); void threads_sleep(s8 millis, s4 nanos); -void threads_yield(void); bool threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos); @@ -220,8 +200,6 @@ bool threads_thread_has_been_interrupted(threadobject *thread); void threads_cast_stopworld(void); void threads_cast_startworld(void); -void threads_dump(void); - #endif /* _THREADS_H */