From 530ee4cb3c1223db18505eac94353792893a7328 Mon Sep 17 00:00:00 2001 From: twisti Date: Mon, 15 May 2006 14:24:36 +0000 Subject: [PATCH] * src/vm/hashtable.h, src/vm/class.c,, src/vm/suck.c, src/vm/loader.c, src/vm/builtin.c, src/vm/string.c, src/vm/suck.h, src/vm/builtin.h, src/vm/loader.h, src/vm/finalizer.c, src/vm/classcache.c, src/vm/initialize.c, src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/netbsd/md-os.c, src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/asmpart.S, src/vm/jit/codegen-common.h, src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/freebsd/md-os.c, src/vm/jit/stack.c, src/vm/jit/code.c, src/vm/jit/verify/typecheck.c, src/vm/jit/mips/codegen.c, src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/asmpart.S, src/vm/jit/mips/irix/md-os.c, src/vm/jit/patcher.h, src/vm/jit/inline/inline.c, src/vm/jit/allocator/simplereg.c, src/vm/jit/i386/codegen.c, src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/asmpart.S, src/vm/jit/i386/freebsd/md-os.c, src/vm/jit/parse.c, src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/engine.c, src/vm/jit/intrp/asmpart.c, src/vm/jit/intrp/dynamic-super.c, src/vm/jit/intrp/java.vmg, src/vm/jit/asmpart.h, src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/asmpart.S, src/vm/jit/profile/profile.c, src/vm/jit/stacktrace.c, src/vm/jit/jit.c, src/vm/jit/stacktrace.h, src/vm/jit/codegen-common.c, src/vm/jit/jit.h, src/vm/global.h, src/vm/builtintable.inc, src/vm/signal.c, src/vm/exceptions.c, src/vm/vm.c, src/vm/linker.c, src/vm/exceptions.h, src/vm/utf8.c, src/vm/hashtable.c, src/cacao/cacao.c, src/cacao/Makefile.am, src/native/tools/Makefile.am, src/native/tools/gennativetable.c, src/native/jni.c, src/native/vm/VMObject.c, src/native/vm/VMThread.c, src/native/jni.h, src/native/native.c, src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h, src/native/jvmti/jvmti.c, src/toolbox/avl.c, src/toolbox/logging.c, src/toolbox/avl.h, src/mm/boehm.h, src/mm/memory.c, src/mm/boehm.c, src/threads/green, src/threads/native/threads.h, src/threads/native/threads.c, src/threads/Makefile.am, src/cacaoh/cacaoh.c, src/cacaoh/headers.h, src/cacaoh/Makefile.am, src/cacaoh/headers.c, configure.ac: Green threads removal, USE_THREADS renamed to ENABLE_THREADS, NATIVE_THREADS define removed. --- configure.ac | 47 +- src/cacao/Makefile.am | 14 +- src/cacao/cacao.c | 13 +- src/cacaoh/Makefile.am | 12 +- src/cacaoh/cacaoh.c | 18 +- src/cacaoh/headers.c | 11 +- src/cacaoh/headers.h | 13 +- src/mm/boehm.c | 71 +-- src/mm/boehm.h | 13 +- src/mm/memory.c | 26 +- src/native/jni.c | 30 +- src/native/jni.h | 4 +- src/native/jvmti/cacaodbg.c | 2 +- src/native/jvmti/cacaodbg.h | 4 +- src/native/jvmti/jvmti.c | 30 +- src/native/native.c | 8 +- src/native/tools/Makefile.am | 4 +- src/native/tools/gennativetable.c | 19 +- src/native/vm/VMObject.c | 29 +- src/native/vm/VMThread.c | 66 +- src/threads/Makefile.am | 8 +- src/threads/green/.cvsignore | 8 - src/threads/green/Makefile.am | 54 -- src/threads/green/locks.c | 578 ------------------ src/threads/green/locks.h | 147 ----- src/threads/green/threadio.c | 492 --------------- src/threads/green/threadio.h | 33 - src/threads/green/threads.c | 926 ----------------------------- src/threads/green/threads.h | 226 ------- src/threads/native/threads.c | 4 +- src/threads/native/threads.h | 4 +- src/toolbox/avl.c | 24 +- src/toolbox/avl.h | 8 +- src/toolbox/logging.c | 15 +- src/vm/builtin.c | 145 +---- src/vm/builtin.h | 14 +- src/vm/builtintable.inc | 6 +- src/vm/class.c | 13 +- src/vm/classcache.c | 10 +- src/vm/exceptions.c | 8 +- src/vm/exceptions.h | 6 +- src/vm/finalizer.c | 14 +- src/vm/global.h | 13 +- src/vm/hashtable.c | 16 +- src/vm/hashtable.h | 4 +- src/vm/initialize.c | 23 +- src/vm/jit/allocator/simplereg.c | 28 +- src/vm/jit/alpha/asmpart.S | 8 +- src/vm/jit/alpha/codegen.c | 30 +- src/vm/jit/alpha/freebsd/md-os.c | 4 +- src/vm/jit/alpha/linux/md-os.c | 4 +- src/vm/jit/asmpart.h | 20 +- src/vm/jit/code.c | 6 +- src/vm/jit/codegen-common.c | 18 +- src/vm/jit/codegen-common.h | 4 +- src/vm/jit/i386/asmpart.S | 8 +- src/vm/jit/i386/codegen.c | 38 +- src/vm/jit/i386/freebsd/md-os.c | 4 +- src/vm/jit/i386/linux/md-os.c | 4 +- src/vm/jit/inline/inline.c | 15 +- src/vm/jit/intrp/asmpart.c | 14 +- src/vm/jit/intrp/codegen.c | 14 +- src/vm/jit/intrp/dynamic-super.c | 30 +- src/vm/jit/intrp/engine.c | 6 +- src/vm/jit/intrp/intrp.h | 8 +- src/vm/jit/intrp/java.vmg | 4 +- src/vm/jit/jit.c | 95 ++- src/vm/jit/jit.h | 37 +- src/vm/jit/mips/asmpart.S | 8 +- src/vm/jit/mips/codegen.c | 32 +- src/vm/jit/mips/irix/md-os.c | 4 +- src/vm/jit/mips/linux/md-os.c | 4 +- src/vm/jit/parse.c | 8 +- src/vm/jit/patcher.h | 6 +- src/vm/jit/powerpc/asmpart.S | 185 +----- src/vm/jit/powerpc/codegen.c | 153 ++++- src/vm/jit/powerpc/darwin/md-asm.h | 4 +- src/vm/jit/powerpc/darwin/md-os.c | 4 +- src/vm/jit/powerpc/linux/md-os.c | 4 +- src/vm/jit/powerpc/netbsd/md-os.c | 2 +- src/vm/jit/profile/profile.c | 14 +- src/vm/jit/stack.c | 212 ++++++- src/vm/jit/stacktrace.c | 17 +- src/vm/jit/stacktrace.h | 4 +- src/vm/jit/verify/typecheck.c | 30 +- src/vm/jit/x86_64/asmpart.S | 8 +- src/vm/jit/x86_64/codegen.c | 34 +- src/vm/jit/x86_64/md.c | 4 +- src/vm/linker.c | 20 +- src/vm/loader.c | 24 +- src/vm/loader.h | 11 +- src/vm/signal.c | 10 +- src/vm/string.c | 16 +- src/vm/suck.c | 6 +- src/vm/suck.h | 9 +- src/vm/utf8.c | 16 +- src/vm/vm.c | 35 +- 97 files changed, 954 insertions(+), 3562 deletions(-) delete mode 100644 src/threads/green/.cvsignore delete mode 100644 src/threads/green/Makefile.am delete mode 100644 src/threads/green/locks.c delete mode 100644 src/threads/green/locks.h delete mode 100644 src/threads/green/threadio.c delete mode 100644 src/threads/green/threadio.h delete mode 100644 src/threads/green/threads.c delete mode 100644 src/threads/green/threads.h diff --git a/configure.ac b/configure.ac index 447c2d3c5..6d8aebfbf 100644 --- a/configure.ac +++ b/configure.ac @@ -449,37 +449,26 @@ AC_MSG_CHECKING(whether to include threads support) enable_threads=${enable_threads:-native} case "$enable_threads" in no | none | single) - AC_MSG_RESULT(no) - dnl no threads for boehm - ac_configure_args="$ac_configure_args --disable-boehm-threads" - AM_CONDITIONAL([USE_THREADS], [false]) - AM_CONDITIONAL([NATIVE_THREADS], [false]) - ;; - -green | native | posix | pthreads) - AC_DEFINE([USE_THREADS], 1, [use threads]) - - AM_CONDITIONAL([USE_THREADS], [true]) - - if test x"$enable_threads" != "xgreen"; then - AC_MSG_RESULT(yes, native) - AC_CHECK_LIB(pthread, main) - AC_DEFINE([NATIVE_THREADS], 1, [use pthreads]) - - CFLAGS="$CFLAGS -D_REENTRANT" - - dnl tell boehm to support threads as well - ac_configure_args="$ac_configure_args --enable-boehm-threads=posix" - AM_CONDITIONAL([NATIVE_THREADS], [true]) - - else - AC_MSG_RESULT(yes, green) + AC_MSG_RESULT(no) + dnl no threads for boehm + ac_configure_args="$ac_configure_args --disable-boehm-threads" + AM_CONDITIONAL([ENABLE_THREADS], [false]) + ;; - dnl no threads for boehm - ac_configure_args="$ac_configure_args --disable-boehm-threads" - AM_CONDITIONAL([NATIVE_THREADS], [false]) - fi +native | posix | pthreads) + AC_DEFINE([ENABLE_THREADS], 1, [enable threads]) + + AM_CONDITIONAL([ENABLE_THREADS], [true]) + + AC_MSG_RESULT(yes, native) + AC_CHECK_LIB(pthread, main) + + CFLAGS="$CFLAGS -D_REENTRANT" + + dnl tell boehm to support threads as well + ac_configure_args="$ac_configure_args --enable-boehm-threads=posix" ;; + *) AC_MSG_ERROR($enable_threads is an unknown thread package) ;; diff --git a/src/cacao/Makefile.am b/src/cacao/Makefile.am index 0fb0fa788..445d73893 100644 --- a/src/cacao/Makefile.am +++ b/src/cacao/Makefile.am @@ -28,30 +28,20 @@ ## ## Changes: ## -## $Id: Makefile.am 4737 2006-04-05 12:56:43Z edwin $ +## $Id: Makefile.am 4921 2006-05-15 14:24:36Z twisti $ ## Process this file with automake to produce Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) if DISABLE_GC -if NATIVE_THREADS -GC_LIB = $(top_builddir)/src/boehm-gc/libgc.la -else GC_LIB = -endif else GC_LIB = $(top_builddir)/src/boehm-gc/libgc.la endif -if USE_THREADS -if NATIVE_THREADS +if ENABLE_THREADS THREAD_LIB = $(top_builddir)/src/threads/native/libthreads.la -else -THREAD_LIB = $(top_builddir)/src/threads/green/libthreads.la -endif -else -THREAD_LIB = endif if ENABLE_STATICVM diff --git a/src/cacao/cacao.c b/src/cacao/cacao.c index 4c5fb2cc0..bf021ad16 100644 --- a/src/cacao/cacao.c +++ b/src/cacao/cacao.c @@ -31,7 +31,7 @@ Philipp Tomsich Christian Thalinger - $Id: cacao.c 4892 2006-05-06 18:29:55Z motse $ + $Id: cacao.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -51,7 +51,7 @@ #include "native/jvmti/jvmti.h" #include "native/jvmti/cacaodbg.h" -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) #include #endif #endif @@ -189,9 +189,6 @@ void exit_handler(void); int main(int argc, char **argv) { -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - void *dummy; -#endif s4 i; /* local variables ********************************************************/ @@ -199,10 +196,6 @@ int main(int argc, char **argv) JavaVMInitArgs *vm_args; JavaVM *jvm; /* denotes a Java VM */ -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - stackbottom = &dummy; -#endif - if (atexit(vm_exit_handler)) throw_cacao_exception_exit(string_java_lang_InternalError, "Unable to register exit_handler"); @@ -219,7 +212,7 @@ int main(int argc, char **argv) /* load and initialize a Java VM, return a JNI interface pointer in env */ - JNI_CreateJavaVM(&jvm, (void **) &_Jv_env, vm_args); + JNI_CreateJavaVM(&jvm, (void *) &_Jv_env, vm_args); #if defined(ENABLE_JVMTI) pthread_mutex_init(&dbgcomlock,NULL); diff --git a/src/cacaoh/Makefile.am b/src/cacaoh/Makefile.am index e5f9b0c4a..7649ad83f 100644 --- a/src/cacaoh/Makefile.am +++ b/src/cacaoh/Makefile.am @@ -28,26 +28,20 @@ ## ## Changes: ## -## $Id: Makefile.am 4768 2006-04-13 16:58:05Z edwin $ +## $Id: Makefile.am 4921 2006-05-15 14:24:36Z twisti $ ## Process this file with automake to produce Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) if DISABLE_GC -if NATIVE_THREADS -GC_LIB = $(top_builddir)/src/boehm-gc/libgc.la -endif +GC_LIB = else GC_LIB = $(top_builddir)/src/boehm-gc/libgc.la endif -if USE_THREADS -if NATIVE_THREADS +if ENABLE_THREADS THREAD_LIB = $(top_builddir)/src/threads/native/libthreads.la -else -THREAD_LIB = $(top_builddir)/src/threads/green/libthreads.la -endif endif if ENABLE_RT_TIMING diff --git a/src/cacaoh/cacaoh.c b/src/cacaoh/cacaoh.c index ebb5c8896..1b04689fb 100644 --- a/src/cacaoh/cacaoh.c +++ b/src/cacaoh/cacaoh.c @@ -30,7 +30,7 @@ Philipp Tomsich Christian Thalinger - $Id: cacaoh.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: cacaoh.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -48,12 +48,8 @@ #include "mm/memory.h" #include "native/include/java_lang_Throwable.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/logging.h" @@ -164,7 +160,6 @@ int main(int argc, char **argv) s4 opt; classinfo *c; char *opt_directory; - void *dummy; /********** internal (only used by main) *****************************/ @@ -288,12 +283,9 @@ int main(int argc, char **argv) gc_init(heapmaxsize, heapstartsize); -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) threads_preinit(); #endif - lock_init(); -#endif /* initialize the string hashtable stuff: lock (must be done _after_ threads_preinit) */ @@ -329,7 +321,7 @@ int main(int argc, char **argv) /* initialize the loader subsystems (must be done _after_ classcache_init) */ - if (!loader_init((u1 *) &dummy)) + if (!loader_init()) throw_main_exception_exit(); diff --git a/src/cacaoh/headers.c b/src/cacaoh/headers.c index fc751bbfe..f25c4ac2a 100644 --- a/src/cacaoh/headers.c +++ b/src/cacaoh/headers.c @@ -31,21 +31,22 @@ Christian Thalinger Edwin Steiner - $Id: headers.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: headers.c 4921 2006-05-15 14:24:36Z twisti $ */ +#include "config.h" + #include #include #include #include #include -#include "config.h" #include "vm/types.h" -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) # if defined(__DARWIN__) # include # endif @@ -77,7 +78,7 @@ u1 *intrp_main_stack; /* for raising exceptions from native methods *********************************/ -#if !defined(USE_THREADS) || !defined(NATIVE_THREADS) +#if !defined(ENABLE_THREADS) java_objectheader *_no_threads_exceptionptr = NULL; #endif @@ -460,7 +461,7 @@ void classnotfoundexception_to_noclassdeffounderror(void) /* machine dependent stuff ****************************************************/ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) critical_section_node_t asm_criticalsections; void thread_restartcriticalsection(ucontext_t *uc) {} #endif diff --git a/src/cacaoh/headers.h b/src/cacaoh/headers.h index 22714d31c..b143b64a9 100644 --- a/src/cacaoh/headers.h +++ b/src/cacaoh/headers.h @@ -26,20 +26,17 @@ Authors: Christian Thalinger - $Id: headers.h 4357 2006-01-22 23:33:38Z twisti $ + $Id: headers.h 4921 2006-05-15 14:24:36Z twisti $ */ #ifndef _HEADERS_H #define _HEADERS_H -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# include "threads/green/locks.h" -# endif +#include "config.h" + +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/chain.h" diff --git a/src/mm/boehm.c b/src/mm/boehm.c index 67f39ad4d..686d30984 100644 --- a/src/mm/boehm.c +++ b/src/mm/boehm.c @@ -28,7 +28,7 @@ Changes: Christian Thalinger - $Id: boehm.c 4357 2006-01-22 23:33:38Z twisti $ + $Id: boehm.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -36,10 +36,10 @@ #include "config.h" #include "vm/types.h" -#if defined(USE_THREADS) && defined(NATIVE_THREADS) && defined(__LINUX__) +#if defined(ENABLE_THREADS) && defined(__LINUX__) #define GC_LINUX_THREADS #endif -#if defined(USE_THREADS) && defined(NATIVE_THREADS) && defined(__IRIX__) +#if defined(ENABLE_THREADS) && defined(__IRIX__) #define GC_IRIX_THREADS #endif @@ -47,12 +47,8 @@ #include "mm/boehm.h" #include "mm/memory.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/logging.h" @@ -71,15 +67,6 @@ static bool in_gc_out_of_memory = false; /* is GC out of memory? */ -static void -#ifdef __GNUC__ - __attribute__ ((unused)) -#endif -*stackcall_twoargs(struct otherstackcall *p) -{ - return (*p->p2)(p->p, p->l); -} - /* prototype static functions *************************************************/ static void gc_ignore_warnings(char *msg, GC_word arg); @@ -132,12 +119,6 @@ static void gc_ignore_warnings(char *msg, GC_word arg) { } -static void *stackcall_malloc(void *p, u4 bytelength) -{ - return GC_MALLOC(bytelength); -} - - static void *stackcall_malloc_atomic(void *p, u4 bytelength) { return GC_MALLOC_ATOMIC(bytelength); @@ -150,37 +131,11 @@ static void *stackcall_malloc_uncollectable(void *p, u4 bytelength) } -static void *stackcall_free(void *p, u4 bytelength) -{ - GC_FREE(p); - return NULL; -} - - -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) -#define MAINTHREADCALL(r,m,pp,ll) \ - if (currentThread == NULL || currentThread == mainThread) { \ - r = m(pp, ll); \ - } else { \ - struct otherstackcall sc; \ - sc.p2 = m; \ - sc.p = pp; \ - sc.l = ll; \ - r = (*asm_switchstackandcall)(CONTEXT(mainThread).usedStackTop, \ - stackcall_twoargs, \ - (void**)&(CONTEXT(currentThread).usedStackTop), &sc); \ - } -#else -#define MAINTHREADCALL(r,m,pp,ll) \ - { r = m(pp, ll); } -#endif - - void *heap_alloc_uncollectable(u4 bytelength) { void *result; - MAINTHREADCALL(result, stackcall_malloc_uncollectable, NULL, bytelength); + result = stackcall_malloc_uncollectable(NULL, bytelength); /* clear allocated memory region */ @@ -194,12 +149,10 @@ void *heap_allocate(u4 bytelength, bool references, methodinfo *finalizer) { void *result; - if (references) { - MAINTHREADCALL(result, stackcall_malloc, NULL, bytelength); - - } else { - MAINTHREADCALL(result, stackcall_malloc_atomic, NULL, bytelength); - } + if (references) + result = GC_MALLOC(bytelength); + else + result = stackcall_malloc_atomic(NULL, bytelength); if (!result) return NULL; @@ -217,9 +170,7 @@ void *heap_allocate(u4 bytelength, bool references, methodinfo *finalizer) void heap_free(void *p) { - void *result; - - MAINTHREADCALL(result, stackcall_free, p, 0); + GC_FREE(p); } void gc_call(void) diff --git a/src/mm/boehm.h b/src/mm/boehm.h index 141c555f7..bcf92ca49 100644 --- a/src/mm/boehm.h +++ b/src/mm/boehm.h @@ -28,7 +28,7 @@ Changes: - $Id: boehm.h 4357 2006-01-22 23:33:38Z twisti $ + $Id: boehm.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -42,17 +42,6 @@ #include "vm/method.h" -struct otherstackcall; - -typedef void *(*calltwoargs)(void *, u4); - -struct otherstackcall { - calltwoargs p2; - void *p; - u4 l; -}; - - /* function prototypes ********************************************************/ void gc_init(u4 heapmaxsize, u4 heapstartsize); diff --git a/src/mm/memory.c b/src/mm/memory.c index 6c75b34ab..e16644305 100644 --- a/src/mm/memory.c +++ b/src/mm/memory.c @@ -29,7 +29,7 @@ Changes: Christian Thalinger Edwin Steiner - $Id: memory.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: memory.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -56,12 +56,8 @@ #include "mm/memory.h" #include "native/native.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/logging.h" @@ -79,11 +75,11 @@ *******************************************************************************/ -#if !defined(USE_THREADS) || (defined(USE_THREADS) && !defined(NATIVE_THREADS)) +#if !defined(ENABLE_THREADS) static dumpinfo _no_threads_dumpinfo; #endif -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) #define DUMPINFO &((threadobject *) THREADOBJECT)->dumpinfo #else #define DUMPINFO &_no_threads_dumpinfo @@ -94,7 +90,7 @@ static dumpinfo _no_threads_dumpinfo; #define DEFAULT_CODEMEM_SIZE 128 * 1024 /* defaulting to 128kB */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static java_objectheader *codememlock = NULL; #endif static int codememsize = 0; @@ -109,13 +105,11 @@ static void *codememptr = NULL; bool memory_init(void) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) codememlock = NEW(java_objectheader); -# if defined(NATIVE_THREADS) lock_init_object_lock(codememlock); -# endif -#endif /* defined(USE_THREADS) */ +#endif /* everything's ok */ @@ -157,7 +151,7 @@ void *memory_cnew(s4 size) void *p; int pagesize; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(codememlock); #endif @@ -215,7 +209,7 @@ void *memory_cnew(s4 size) codememptr = (void *) ((ptrint) codememptr + size); codememsize -= size; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(codememlock); #endif diff --git a/src/native/jni.c b/src/native/jni.c index dc8d6bfaf..17bf3d0ef 100644 --- a/src/native/jni.c +++ b/src/native/jni.c @@ -32,7 +32,7 @@ Christian Thalinger Edwin Steiner - $Id: jni.c 4909 2006-05-13 23:10:21Z edwin $ + $Id: jni.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -81,12 +81,8 @@ # include "native/jvmti/jvmti.h" #endif -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/logging.h" @@ -132,7 +128,7 @@ static methodinfo *dbbirw_init; /* local reference table ******************************************************/ -#if !defined(USE_THREADS) +#if !defined(ENABLE_THREADS) localref_table *_no_threads_localref_table; #endif @@ -4934,7 +4930,7 @@ jint MonitorEnter(JNIEnv *env, jobject obj) return JNI_ERR; } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(obj); #endif @@ -4961,7 +4957,7 @@ jint MonitorExit(JNIEnv *env, jobject obj) return JNI_ERR; } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(obj); #endif @@ -5120,7 +5116,7 @@ jobject NewGlobalRef(JNIEnv* env, jobject obj) STATISTICS(jniinvokation()); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(hashtable_global_ref->header); #endif @@ -5138,7 +5134,7 @@ jobject NewGlobalRef(JNIEnv* env, jobject obj) gre->refs++; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(hashtable_global_ref->header); #endif @@ -5165,7 +5161,7 @@ jobject NewGlobalRef(JNIEnv* env, jobject obj) hashtable_global_ref->entries++; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(hashtable_global_ref->header); #endif @@ -5188,7 +5184,7 @@ void DeleteGlobalRef(JNIEnv* env, jobject globalRef) STATISTICS(jniinvokation()); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(hashtable_global_ref->header); #endif @@ -5223,7 +5219,7 @@ void DeleteGlobalRef(JNIEnv* env, jobject globalRef) FREE(gre, hashtable_global_ref_entry); } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(hashtable_global_ref->header); #endif @@ -5236,7 +5232,7 @@ void DeleteGlobalRef(JNIEnv* env, jobject globalRef) log_println("JNI-DeleteGlobalRef: global reference not found"); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(hashtable_global_ref->header); #endif } @@ -5435,7 +5431,7 @@ jint GetEnv(JavaVM *vm, void **env, jint version) { STATISTICS(jniinvokation()); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) if (threads_get_current_threadobject() == NULL) { *env = NULL; diff --git a/src/native/jni.h b/src/native/jni.h index aa6a8af9e..ce329683e 100644 --- a/src/native/jni.h +++ b/src/native/jni.h @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: jni.h 4913 2006-05-14 14:02:51Z edwin $ + $Id: jni.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -95,7 +95,7 @@ struct localref_table { java_objectheader *refs[LOCALREFTABLE_CAPACITY]; /* references */ }; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) #define LOCALREFTABLE (THREADOBJECT->_localref_table) #else extern localref_table *_no_threads_localref_table; diff --git a/src/native/jvmti/cacaodbg.c b/src/native/jvmti/cacaodbg.c index aaddbcf0b..bfeee43b5 100644 --- a/src/native/jvmti/cacaodbg.c +++ b/src/native/jvmti/cacaodbg.c @@ -63,7 +63,7 @@ jvmtiError allthreads (jint * threads_count_ptr, threadobject*** threads_ptr) { int i = 0, cnt = 8; threadobject *thread, **tthreads; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) tthreads = MNEW(threadobject*, (sizeof(threadobject*) * cnt)); thread = mainthreadobj; diff --git a/src/native/jvmti/cacaodbg.h b/src/native/jvmti/cacaodbg.h index b5d1deb5e..928fe7d90 100644 --- a/src/native/jvmti/cacaodbg.h +++ b/src/native/jvmti/cacaodbg.h @@ -1,4 +1,4 @@ -/* src/native/jvmti/cacaodbg.h - contains cacao specifics for debugging support +/* src/native/jvmti/cacaodbg.h - contains cacao specifics for debugging support Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, @@ -99,7 +99,7 @@ typedef struct { cacaodbgcommunication *dbgcom; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) struct _jrawMonitorID { java_lang_String *name; }; diff --git a/src/native/jvmti/jvmti.c b/src/native/jvmti/jvmti.c index 911c9ea45..3fa86579f 100644 --- a/src/native/jvmti/jvmti.c +++ b/src/native/jvmti/jvmti.c @@ -31,7 +31,7 @@ Samuel Vinson - $Id: jvmti.c 4913 2006-05-14 14:02:51Z edwin $ + $Id: jvmti.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -75,7 +75,7 @@ #include #include -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) #include "threads/native/threads.h" #include #include @@ -690,7 +690,7 @@ GetOwnedMonitorInfo (jvmtiEnv * env, jthread thread, CHECK_THREAD_IS_ALIVE(thread); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) om=MNEW(java_objectheader*,size); @@ -753,7 +753,7 @@ GetCurrentContendedMonitor (jvmtiEnv * env, jthread thread, CHECK_THREAD_IS_ALIVE(thread); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) pthread_mutex_lock(&lock_global_pool_lock); @@ -826,7 +826,7 @@ RunAgentThread (jvmtiEnv * env, jthread thread, jvmtiStartFunction proc, rap.arg = (void*)arg; rap.jvmti_env = env; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) pthread_attr_init(&threadattr); pthread_attr_setdetachstate(&threadattr, PTHREAD_CREATE_DETACHED); if (priority == JVMTI_THREAD_MIN_PRIORITY) { @@ -871,7 +871,7 @@ GetTopThreadGroups (jvmtiEnv * env, jint * group_count_ptr, if ((groups_ptr == NULL) || (group_count_ptr == NULL)) return JVMTI_ERROR_NULL_POINTER; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) tg = MNEW(jthreadGroup*,size); x = 0; if (JVMTI_ERROR_NONE!=GetAllThreads(env,&threads_count_ptr,(jthread**)&threads_ptr)) @@ -1071,7 +1071,7 @@ GetThreadState (jvmtiEnv * env, jthread thread, jint * thread_state_ptr) if (thread_state_ptr == NULL) return JVMTI_ERROR_NULL_POINTER; *thread_state_ptr = 0; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) if((th->vmThread==NULL)&&(th->group==NULL)) { /* alive ? */ /* not alive */ if (((threadobject*)th->vmThread)->info.tid == 0) @@ -1379,7 +1379,7 @@ CreateRawMonitor (jvmtiEnv * env, const char *name, if ((name == NULL) || (monitor_ptr == NULL)) return JVMTI_ERROR_NULL_POINTER; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) monitor->name=javastring_new_from_ascii(name); #else log_text ("CreateRawMonitor not supported"); @@ -1406,7 +1406,7 @@ DestroyRawMonitor (jvmtiEnv * env, jrawMonitorID monitor) if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String)) return JVMTI_ERROR_INVALID_MONITOR; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) if (!lock_does_thread_hold_lock((threadobject*)THREADOBJECT, (java_objectheader*)monitor->name)) return JVMTI_ERROR_NOT_MONITOR_OWNER; @@ -1433,7 +1433,7 @@ RawMonitorEnter (jvmtiEnv * env, jrawMonitorID monitor) if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String)) return JVMTI_ERROR_INVALID_MONITOR; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter((java_objectheader*)monitor->name); #else log_text ("RawMonitorEnter not supported"); @@ -1455,7 +1455,7 @@ RawMonitorExit (jvmtiEnv * env, jrawMonitorID monitor) if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String)) return JVMTI_ERROR_INVALID_MONITOR; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* assure current thread owns this monitor */ if (!lock_does_thread_hold_lock((threadobject*)THREADOBJECT,(java_objectheader*)monitor->name)) return JVMTI_ERROR_NOT_MONITOR_OWNER; @@ -1481,7 +1481,7 @@ RawMonitorWait (jvmtiEnv * env, jrawMonitorID monitor, jlong millis) if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String)) return JVMTI_ERROR_INVALID_MONITOR; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* assure current thread owns this monitor */ if (!lock_does_thread_hold_lock((threadobject*)THREADOBJECT,(java_objectheader*)monitor->name)) return JVMTI_ERROR_NOT_MONITOR_OWNER; @@ -1510,7 +1510,7 @@ RawMonitorNotify (jvmtiEnv * env, jrawMonitorID monitor) if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String)) return JVMTI_ERROR_INVALID_MONITOR; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* assure current thread owns this monitor */ if (!lock_does_thread_hold_lock((threadobject*)THREADOBJECT,(java_objectheader*)monitor->name)) return JVMTI_ERROR_NOT_MONITOR_OWNER; @@ -1536,7 +1536,7 @@ RawMonitorNotifyAll (jvmtiEnv * env, jrawMonitorID monitor) if (!builtin_instanceof((java_objectheader*)monitor->name,class_java_lang_String)) return JVMTI_ERROR_INVALID_MONITOR; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* assure current thread owns this monitor */ if (!lock_does_thread_hold_lock((threadobject*)THREADOBJECT, (java_objectheader*)monitor->name)) return JVMTI_ERROR_NOT_MONITOR_OWNER; @@ -4103,7 +4103,7 @@ static jvmtiCapabilities JVMTI_Capabilities = { 1, /* can_get_bytecodes */ 0, /* can_get_synthetic_attribute */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) 1, /* can_get_owned_monitor_info */ 1, /* can_get_current_contended_monitor */ #else diff --git a/src/native/native.c b/src/native/native.c index ef54cef40..682fc9a2a 100644 --- a/src/native/native.c +++ b/src/native/native.c @@ -30,7 +30,7 @@ Changes: Christian Thalinger - $Id: native.c 4900 2006-05-11 09:18:28Z twisti $ + $Id: native.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -341,7 +341,7 @@ void native_hashtable_library_add(utf *filename, java_objectheader *loader, u4 key; /* hashkey */ u4 slot; /* slot in hashtable */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(hashtable_library->header); #endif @@ -386,7 +386,7 @@ void native_hashtable_library_add(utf *filename, java_objectheader *loader, while (ne) { if (ne->name == filename) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(hashtable_library->header); #endif @@ -408,7 +408,7 @@ void native_hashtable_library_add(utf *filename, java_objectheader *loader, ne->hashlink = le->namelink; le->namelink = ne; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(hashtable_library->header); #endif } diff --git a/src/native/tools/Makefile.am b/src/native/tools/Makefile.am index 75a6ffc76..0b802c88b 100644 --- a/src/native/tools/Makefile.am +++ b/src/native/tools/Makefile.am @@ -28,7 +28,7 @@ ## ## Changes: ## -## $Id: Makefile.am 4627 2006-03-16 12:53:32Z twisti $ +## $Id: Makefile.am 4921 2006-05-15 14:24:36Z twisti $ ## Process this file with automake to produce Makefile.in @@ -37,9 +37,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top LIBS = if DISABLE_GC -if NATIVE_THREADS GC_LIB = $(top_builddir)/src/boehm-gc/libgc.la -endif else GC_LIB = $(top_builddir)/src/boehm-gc/libgc.la endif diff --git a/src/native/tools/gennativetable.c b/src/native/tools/gennativetable.c index 25b7538ec..2daa62e02 100644 --- a/src/native/tools/gennativetable.c +++ b/src/native/tools/gennativetable.c @@ -28,7 +28,7 @@ Changes: - $Id: gennativetable.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: gennativetable.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -46,12 +46,8 @@ #include "mm/boehm.h" #include "mm/memory.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/chain.h" @@ -105,8 +101,6 @@ int main(int argc, char **argv) methodinfo *m2; bool nativelyoverloaded; - void *dummy; - #if defined(DISABLE_GC) nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE); #endif @@ -145,12 +139,9 @@ int main(int argc, char **argv) gc_init(HEAP_MAXSIZE, HEAP_STARTSIZE); -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) threads_preinit(); #endif - lock_init(); -#endif /* initialize the string hashtable stuff: lock (must be done _after_ threads_preinit) */ @@ -181,7 +172,7 @@ int main(int argc, char **argv) /* initialize the loader subsystems (must be done _after_ classcache_init) */ - if (!loader_init((u1 *) &dummy)) + if (!loader_init()) throw_main_exception_exit(); diff --git a/src/native/vm/VMObject.c b/src/native/vm/VMObject.c index 4782d013c..9bc68a404 100644 --- a/src/native/vm/VMObject.c +++ b/src/native/vm/VMObject.c @@ -29,14 +29,18 @@ Changes: Joseph Wenninger Christian Thalinger - $Id: VMObject.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: VMObject.c 4921 2006-05-15 14:24:36Z twisti $ */ +#include "config.h" + #include #include +#include "vm/types.h" + #include "mm/boehm.h" #include "mm/memory.h" #include "toolbox/logging.h" @@ -46,13 +50,8 @@ #include "native/include/java_lang_Cloneable.h" #include "native/include/java_lang_Object.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# include "threads/green/locks.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/builtin.h" @@ -100,12 +99,12 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, j new = (java_lang_Object *) heap_allocate(size, (desc->arraytype == ARRAYTYPE_OBJECT), NULL); - if (!new) + if (new == NULL) return NULL; MCOPY(new, this, u1, size); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) lock_init_object_lock((java_objectheader *) new); #endif @@ -124,12 +123,12 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, j c = this->header.vftbl->class; new = (java_lang_Object *) builtin_new(c); - if (!new) + if (new == NULL) return NULL; MCOPY(new, this, u1, c->instancesize); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) lock_init_object_lock((java_objectheader *) new); #endif @@ -144,7 +143,7 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, j */ JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *this) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) lock_notify_object(&this->header); #endif } @@ -157,7 +156,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, */ JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, java_lang_Object *this) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) lock_notify_all_object(&this->header); #endif } @@ -170,7 +169,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass cla */ JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, java_lang_Object *o, s8 ms, s4 ns) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) lock_wait_for_object(&o->header, ms, ns); #endif } diff --git a/src/native/vm/VMThread.c b/src/native/vm/VMThread.c index 359aaf651..8eb698958 100644 --- a/src/native/vm/VMThread.c +++ b/src/native/vm/VMThread.c @@ -29,7 +29,7 @@ Changes: Joseph Wenninger Christian Thalinger - $Id: VMThread.c 4909 2006-05-13 23:10:21Z edwin $ + $Id: VMThread.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -45,12 +45,8 @@ #include "native/include/java_lang_VMThread.h" #include "native/include/java_lang_Thread.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/logging.h" @@ -78,7 +74,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_ */ JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, s8 stacksize) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) this->thread->vmThread = this; /* don't pass a function pointer (NULL) since we want Thread.run()V here */ @@ -95,10 +91,8 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMTh */ JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this) { -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) threads_interrupt_thread(this); -#else - log_text("Java_java_lang_VMThread_interrupt called"); #endif } @@ -110,11 +104,8 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_ */ JNIEXPORT s4 JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this) { -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) return threads_thread_has_been_interrupted(this); -#else - log_text("Java_java_lang_VMThread_isInterrupted called"); - return 0; #endif } @@ -126,8 +117,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lan */ JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this) { -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - suspendThread((java_lang_Thread *) this->thread); +#if defined(ENABLE_THREADS) #endif } @@ -139,8 +129,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VM */ JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this) { -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - resumeThread((java_lang_Thread *) this->thread); +#if defined(ENABLE_THREADS) #endif } @@ -152,8 +141,9 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMT */ JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, s4 priority) { -#if defined(USE_THREADS) - threads_java_lang_Thread_set_priority((java_lang_Thread *) this->thread, priority); +#if defined(ENABLE_THREADS) + threads_java_lang_Thread_set_priority((java_lang_Thread *) this->thread, + priority); #endif } @@ -165,19 +155,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, ja */ JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t) { -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - if (currentThread == (java_lang_Thread *) this->thread) { - log_text("killing"); - killThread(0); - /* - exceptionptr = proto_java_lang_ThreadDeath; - return; - */ - - } else { - /*CONTEXT((java_lang_Thread*)this)*/ this->flags |= THREAD_FLAGS_KILLED; - resumeThread((java_lang_Thread *) this->thread); - } +#if defined(ENABLE_THREADS) #endif } @@ -191,12 +169,8 @@ JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv { java_lang_Thread *t; -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) t = ((threadobject*) THREADOBJECT)->o.thread; -#else - t = (java_lang_Thread *) currentThread; -#endif if (t == NULL) log_text("t ptr is NULL\n"); @@ -228,7 +202,7 @@ JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv */ JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) threads_yield(); #endif } @@ -241,11 +215,8 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz) */ JNIEXPORT s4 JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz) { -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) return threads_check_if_interrupted_and_reset(); -#else - log_text("Java_java_lang_VMThread_interrupted"); - return 0; #endif } @@ -257,12 +228,9 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass cla */ JNIEXPORT s4 JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o) { -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) return lock_does_thread_hold_lock((threadobject*) THREADOBJECT, - (java_objectheader *) o); -#else - /* I don't know how to find out [stefan] */ - return 0; + (java_objectheader *) o); #endif } diff --git a/src/threads/Makefile.am b/src/threads/Makefile.am index 7348124eb..4c618f93a 100644 --- a/src/threads/Makefile.am +++ b/src/threads/Makefile.am @@ -26,17 +26,13 @@ ## ## Changes: ## -## $Id: Makefile.am 4357 2006-01-22 23:33:38Z twisti $ +## $Id: Makefile.am 4921 2006-05-15 14:24:36Z twisti $ ## Process this file with automake to produce Makefile.in -if USE_THREADS -if NATIVE_THREADS +if ENABLE_THREADS SUBDIRS = native else -SUBDIRS = green -endif -else SUBDIRS = endif diff --git a/src/threads/green/.cvsignore b/src/threads/green/.cvsignore deleted file mode 100644 index cfca56233..000000000 --- a/src/threads/green/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -*.a -*.o -*.la -*.lo -.deps -.libs -Makefile -Makefile.in diff --git a/src/threads/green/Makefile.am b/src/threads/green/Makefile.am deleted file mode 100644 index 5cbcdd933..000000000 --- a/src/threads/green/Makefile.am +++ /dev/null @@ -1,54 +0,0 @@ -## src/threads/green/Makefile.am -## -## Copyright (C) 1996-2005, 2006 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 -## -## This file is part of CACAO. -## -## This program is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License as -## published by the Free Software Foundation; either version 2, or (at -## your option) any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. -## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## -## Changes: -## -## $Id: Makefile.am 4357 2006-01-22 23:33:38Z twisti $ - -## Process this file with automake to produce Makefile.in - -INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/@ARCH_DIR@ - -noinst_LTLIBRARIES = libthreads.la - -libthreads_la_SOURCES = \ - locks.c \ - locks.h \ - threads.c \ - threads.h \ - threadio.c \ - threadio.h - - -## Local variables: -## mode: Makefile -## indent-tabs-mode: t -## c-basic-offset: 4 -## tab-width: 8 -## compile-command: "automake --add-missing" -## End: diff --git a/src/threads/green/locks.c b/src/threads/green/locks.c deleted file mode 100644 index e1ff9adbe..000000000 --- a/src/threads/green/locks.c +++ /dev/null @@ -1,578 +0,0 @@ -/* -*- mode: c; tab-width: 4; c-basic-offset: 4 -*- */ -/* - * locks.c - * Manage locking system - * This include the mutex's and cv's. - * - * Copyright (c) 1996 T. J. Wilkinson & Associates, London, UK. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * Written by Tim Wilkinson , 1996. - */ - - -#include -#include - -#include "config.h" -#include "mm/memory.h" -#include "native/native.h" -#include "threads/green/threads.h" -#include "threads/green/locks.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/loader.h" -#include "vm/tables.h" - - -extern thread* currentThread; - -mutexHashEntry *mutexHashTable; -int mutexHashTableSize; -long mutexHashMask; - -mutexHashEntry *mutexOverflowTable; -int mutexOverflowTableSize; -mutexHashEntry *firstFreeOverflowEntry = 0; - -conditionHashEntry *conditionHashTable; -int conditionHashTableSize; -long conditionHashMask; - -/* - * Init the tables. - */ -void -lock_init (void) -{ - int i; - - mutexHashTableSize = MUTEX_HASH_TABLE_SIZE; - mutexHashTable = MNEW(mutexHashEntry, mutexHashTableSize); - mutexHashMask = (mutexHashTableSize - 1) << 3; - - for (i = 0; i < mutexHashTableSize; ++i) - { - mutexHashTable[i].object = 0; - mutexHashTable[i].mutex.holder = 0; - mutexHashTable[i].mutex.count = 0; - mutexHashTable[i].mutex.muxWaiters = 0; - mutexHashTable[i].conditionCount = 0; - mutexHashTable[i].next = 0; - } - - mutexOverflowTableSize = MUTEX_OVERFLOW_TABLE_SIZE; - mutexOverflowTable = MNEW(mutexHashEntry, mutexOverflowTableSize); - - firstFreeOverflowEntry = &mutexOverflowTable[0]; - - for (i = 0; i < mutexOverflowTableSize; ++i) - { - mutexOverflowTable[i].object = 0; - mutexOverflowTable[i].mutex.holder = 0; - mutexOverflowTable[i].mutex.count = 0; - mutexOverflowTable[i].mutex.muxWaiters = 0; - mutexOverflowTable[i].conditionCount = 0; - mutexOverflowTable[i].next = &mutexOverflowTable[i + 1]; - } - mutexOverflowTable[i - 1].next = 0; - - conditionHashTableSize = CONDITION_HASH_TABLE_SIZE; - conditionHashTable = MNEW(conditionHashEntry, conditionHashTableSize); - conditionHashMask = (conditionHashTableSize - 1) << 3; - - for (i = 0; i < conditionHashTableSize; ++i) - { - conditionHashTable[i].object = 0; - conditionHashTable[i].condition.cvWaiters = 0; - conditionHashTable[i].condition.mux = 0; - } -} - - -/* - * Reorders part of the condition hash table. Must be called after an entry has been deleted. - */ -void -reorderConditionHashTable (int begin) -{ - while (conditionHashTable[begin].object != 0) - { - int hashValue = CONDITION_HASH_VALUE(conditionHashTable[begin].object); - - if (hashValue != begin) - { - while (conditionHashTable[hashValue].object != 0) - { - hashValue = CONDITION_HASH_SUCCESSOR(hashValue); - if (hashValue == begin) - break; - } - if (hashValue != begin) - { - conditionHashTable[hashValue] = conditionHashTable[begin]; - conditionHashTable[begin].object = 0; - conditionHashTable[begin].condition.cvWaiters = 0; - conditionHashTable[begin].condition.mux = 0; - } - } - - begin = CONDITION_HASH_SUCCESSOR(begin); - } -} - -/* - * Looks up an entry in the condition hash table. - */ -iCv* -conditionForObject (java_objectheader *object) -{ - int hashValue; - - intsDisable(); - - hashValue = CONDITION_HASH_VALUE(object); - while (conditionHashTable[hashValue].object != object - && conditionHashTable[hashValue].object != 0) - hashValue = CONDITION_HASH_SUCCESSOR(hashValue); - - if (conditionHashTable[hashValue].object == 0) - { - intsRestore(); - return 0; - } - - intsRestore(); - return &conditionHashTable[hashValue].condition; -} - -/* - * Adds a new entry in the condition hash table and returns a pointer to the condition - */ -iCv* -addConditionForObject (java_objectheader *object) -{ - int hashValue; - - intsDisable(); - - hashValue = CONDITION_HASH_VALUE(object); - while (conditionHashTable[hashValue].object != 0) - hashValue = CONDITION_HASH_SUCCESSOR(hashValue); - - conditionHashTable[hashValue].object = object; - - intsRestore(); - - return &conditionHashTable[hashValue].condition; -} - -/* - * Removes an entry from the condition hash table. - */ -void -removeConditionForObject (java_objectheader *object) -{ - int hashValue; - - intsDisable(); - - hashValue = CONDITION_HASH_VALUE(object); - while (conditionHashTable[hashValue].object != object) - hashValue = CONDITION_HASH_SUCCESSOR(hashValue); - - conditionHashTable[hashValue].object = 0; - conditionHashTable[hashValue].condition.cvWaiters = 0; - conditionHashTable[hashValue].condition.mux = 0; - - reorderConditionHashTable(CONDITION_HASH_SUCCESSOR(hashValue)); - - intsRestore(); -} - -/* - * Returns the mutex entry for the specified object and increments its conditionCount. - */ -mutexHashEntry* -conditionLockedMutexForObject (java_objectheader *object) -{ - int hashValue; - mutexHashEntry *entry; - - assert(object != 0); - - intsDisable(); - - hashValue = MUTEX_HASH_VALUE(object); - entry = &mutexHashTable[hashValue]; - - if (entry->object != 0) - { - if (entry->mutex.count == 0 && entry->conditionCount == 0) - { - entry->object = 0; - entry->mutex.holder = 0; - entry->mutex.count = 0; - entry->mutex.muxWaiters = 0; - } - else - { - while (entry->next != 0 && entry->object != object) - entry = entry->next; - - if (entry->object != object) - { - entry->next = firstFreeOverflowEntry; - firstFreeOverflowEntry = firstFreeOverflowEntry->next; - - entry = entry->next; - entry->object = 0; - entry->next = 0; - assert(entry->conditionCount == 0); - } - } - } - - if (entry->object == 0) - entry->object = object; - - ++entry->conditionCount; - - intsRestore(); - - return entry; -} - -/* - * Wait for the condition of an object to be signalled - */ -void -lock_wait_for_object (java_objectheader *obj, s8 time, s4 par3) -{ - iCv *condition; - mutexHashEntry *mutexEntry; - - intsDisable(); - - mutexEntry = conditionLockedMutexForObject(obj); - - condition = conditionForObject(obj); - if (condition == 0) - condition = addConditionForObject(obj); - - DBG( fprintf(stderr, "condition of %p is %p\n", obj, condition); ); - - internal_wait_cond(&mutexEntry->mutex, condition, time); - - if (condition->cvWaiters == 0 && condition->mux == 0) - removeConditionForObject(obj); - --mutexEntry->conditionCount; - - intsRestore(); -} - -/* - * Signal the condition of an object - */ -void -lock_notify_object (java_objectheader *obj) -{ - iCv *condition; - - intsDisable(); - - condition = conditionForObject(obj); - if (condition == 0) - condition = addConditionForObject(obj); - - DBG( fprintf(stderr, "condition of %p is %p\n", obj, condition); ); - - internal_signal_cond(condition); - - if (condition->cvWaiters == 0 && condition->mux == 0) - removeConditionForObject(obj); - - intsRestore(); -} - -/* - * Broadcast the condition of an object. - */ -void -lock_notify_all_object (java_objectheader *obj) -{ - intsDisable(); - internal_lock_notify_all_object(obj); - intsRestore(); -} - -/* - * Internal: Broadcast the condition of an object. - */ -void -internal_lock_notify_all_object (java_objectheader *obj) -{ - iCv *condition; - - condition = conditionForObject(obj); - if (condition == 0) - condition = addConditionForObject(obj); - - internal_broadcast_cond(condition); - - if (condition->cvWaiters == 0 && condition->mux == 0) - removeConditionForObject(obj); -} - -/* - * Lock a mutex. - */ -void -lock_mutex (iMux *mux) -{ - intsDisable(); - internal_lock_mutex(mux); - intsRestore(); -} - -/* - * Lock the mutex for an object. - */ -void -lock_mutex_for_object (java_objectheader *obj) -{ - intsDisable(); - internal_lock_mutex_for_object(obj); - intsRestore(); -} - -/* - * Unlock a mutex. - */ -void -unlock_mutex (iMux *mux) -{ - intsDisable(); - internal_unlock_mutex(mux); - intsRestore(); -} - -/* - * Unlock the mutex for an object. - */ -void -unlock_mutex_for_object (java_objectheader *obj) -{ - intsDisable(); - internal_unlock_mutex_for_object(obj); - intsRestore(); -} - -/* - * Wait on a condition variable. - */ -void -wait_cond (iMux *mux, iCv *cond, s8 timeout) -{ - intsDisable(); - internal_wait_cond(mux, cond, timeout); - intsRestore(); -} - -/* - * Signal a condition variable. - */ -void -signal_cond (iCv *cond) -{ - intsDisable(); - internal_signal_cond(cond); - intsRestore(); -} - -/* - * Broadcast a condition variable. - */ -void -broadcast_cond (iCv *cond) -{ - intsDisable(); - internal_broadcast_cond(cond); - intsRestore(); -} - -/* - * Internal: Lock a mutex. - */ -void -internal_lock_mutex(iMux* mux) -{ - assert(blockInts > 0); - - if (mux->holder == 0) - { - mux->holder = currentThread; - mux->count = 1; - DBG( fprintf(stderr, "set holder of %p to %p\n", mux, mux->holder); ) - } - else if (mux->holder == currentThread) - { - mux->count++; - } - else - { - while (mux->holder != 0) - { - suspendOnQThread(currentThread, &mux->muxWaiters); - } - mux->holder = currentThread; - mux->count = 1; - } -} - -/* - * Internal: Release a mutex. - */ -void -internal_unlock_mutex(iMux* mux) -{ - thread* tid; - - assert(blockInts > 0); - - assert(mux->holder == currentThread); - - mux->count--; - if (mux->count == 0) - { - mux->holder = 0; - if (mux->muxWaiters != 0) - { - tid = mux->muxWaiters; - mux->muxWaiters = tid->vmThread->next; - iresumeThread(tid); - } - } -} - -/* - * Internal: Wait on a conditional variable. - * (timeout currently ignored) - */ -void -internal_wait_cond(iMux* mux, iCv* cv, s8 timeout) -{ - int count; - thread* tid; - - DBG( fprintf(stderr, "waiting on %p\n", cv); ); - - if (mux->holder != currentThread) { - *exceptionptr = new_exception(string_java_lang_IllegalMonitorStateException); - } - - assert(blockInts > 0); - - count = mux->count; - mux->holder = 0; - mux->count = 0; - cv->mux = mux; - - /* If there's anyone waiting here, wake them up */ - if (mux->muxWaiters != 0) { - tid = mux->muxWaiters; - mux->muxWaiters = tid->vmThread->next; - iresumeThread(tid); - } - - /* Suspend, and keep suspended until I re-get the lock */ - suspendOnQThread(currentThread, &cv->cvWaiters); - while (mux->holder != 0) { - DBG( fprintf(stderr, "woke up\n"); ); - suspendOnQThread(currentThread, &mux->muxWaiters); - } - - mux->holder = currentThread; - mux->count = count; -} - -/* - * Internal: Wake one thread on a conditional variable. - */ -void -internal_signal_cond (iCv* cv) -{ - thread* tid; - - DBG( fprintf(stderr, "signalling on %p\n", cv); ); - - /* If 'mux' isn't set then we've never waited on this object. */ - if (cv->mux == 0) { - return; - } - - if (cv->mux->holder != currentThread) { - *exceptionptr = new_exception(string_java_lang_IllegalMonitorStateException); - } - - assert(blockInts > 0); - - /* Remove one thread from cv list */ - if (cv->cvWaiters != 0) { - DBG( fprintf(stderr, "releasing a waiter\n"); ); - - tid = cv->cvWaiters; - cv->cvWaiters = tid->vmThread->next; - - /* Place it on mux list */ - tid->vmThread->next = cv->mux->muxWaiters; - cv->mux->muxWaiters = tid; - } -} - -/* - * Internal: Wake all threads on a conditional variable. - */ -void -internal_broadcast_cond (iCv* cv) -{ - thread** tidp; - - /* If 'mux' isn't set then we've never waited on this object. */ - if (cv->mux == 0) { - return; - } - - if (cv->mux->holder != currentThread) { - *exceptionptr = new_exception(string_java_lang_IllegalMonitorStateException); - } - - assert(blockInts > 0); - - /* Find the end of the cv list */ - if (cv->cvWaiters) { - for (tidp = &cv->cvWaiters; *tidp != 0; tidp = &(*tidp)->vmThread->next) - ; - - /* Place entire cv list on mux list */ - (*tidp) = cv->mux->muxWaiters; - cv->mux->muxWaiters = cv->cvWaiters; - cv->cvWaiters = 0; - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/threads/green/locks.h b/src/threads/green/locks.h deleted file mode 100644 index fbbe0d263..000000000 --- a/src/threads/green/locks.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * locks.h - * Manage locking system - * This include the mutex's and cv's. - * - * Copyright (c) 1996 T. J. Wilkinson & Associates, London, UK. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * Written by Tim Wilkinson , 1996. - */ - -#ifndef __locks_h -#define __locks_h - -#include "vm/global.h" - - -#define WAITFOREVER -1 - -struct _thread; - -typedef struct _iMux { - struct _thread *holder; - int count; - struct _thread *muxWaiters; -} iMux; - -typedef struct _iCv { - struct _thread* cvWaiters; - struct _iMux* mux; -} iCv; - -#define MAX_MUTEXES 256 - -typedef struct _mutexHashEntry -{ - java_objectheader *object; - iMux mutex; - struct _mutexHashEntry *next; - int conditionCount; -} mutexHashEntry; - -#define MUTEX_HASH_TRASH_BITS 3 -#define MUTEX_HASH_SIGN_BITS 10 - -#define MUTEX_HASH_TABLE_SIZE 1024 -#define MUTEX_OVERFLOW_TABLE_SIZE 1024 -/* -#define MAX_MUTEX_HASH_TABLE_SIZE 65536 -*/ - -/* -#define MUTEX_USE_THRESHOLD 1024 -*/ - -extern long mutexHashMask; -extern int mutexHashTableSize; -extern mutexHashEntry *mutexHashTable; - -extern mutexHashEntry *mutexOverflowTable; -extern int mutexOverflowTableSize; -extern mutexHashEntry *firstFreeOverflowEntry; - -#define MUTEX_HASH_MASK ((MUTEX_HASH_TABLE_SIZE - 1) << 3) - -#if 0 -#define MUTEX_HASH_VALUE(a) ((((long)(a)) & MUTEX_HASH_MASK) >> MUTEX_HASH_TRASH_BITS) -#else -#define MUTEX_HASH_VALUE(a) (( (((long)(a)) ^ ((long)(a) >> MUTEX_HASH_SIGN_BITS)) & mutexHashMask) >> MUTEX_HASH_TRASH_BITS) -#endif -#define MUTEX_HASH_SUCCESSOR(h) (((h) + 7) & (mutexHashTableSize - 1)) - -typedef struct _conditionHashEntry -{ - java_objectheader *object; - iCv condition; -} conditionHashEntry; - -#define CONDITION_HASH_TABLE_SIZE 1024 - -#define CONDITION_HASH_VALUE(a) ((((long)(a)) & conditionHashMask) >> 3) -#define CONDITION_HASH_SUCCESSOR(h) (((h) + 7) & (conditionHashTableSize - 1)) - -typedef struct -{ - bool free; - java_objectheader *object; - iMux mutex; - iCv condition; -} object_mutex; - -extern void lock_init (void); - -mutexHashEntry* conditionLockedMutexForObject (java_objectheader *object); - -void reorderConditionHashTable (int begin); -iCv* conditionForObject (java_objectheader *object); -iCv* addConditionForObject (java_objectheader *object); -void removeConditionForObject (java_objectheader *object); - -/* - * use these functions only outside critical sections (intsEnable/intsRestore). - */ - -void lock_notify_object (java_objectheader *obj); -void lock_notify_all_object (java_objectheader *obj); -void lock_wait_for_object (java_objectheader *obj, s8 time, s4); -void lock_mutex_for_object (java_objectheader *obj); -void unlock_mutex_for_object (java_objectheader *obj); - -void lock_mutex (iMux*); -void unlock_mutex (iMux*); -void wait_cond (iMux*, iCv*, s8); -void signal_cond (iCv*); -void broadcast_cond (iCv*); - -/* - * use these internal functions only in critical sections. blockInts must be exactly - * 1. - */ -void internal_lock_mutex (iMux*); -void internal_unlock_mutex (iMux*); -void internal_wait_cond (iMux*, iCv*, s8); -void internal_signal_cond (iCv*); -void internal_broadcast_cond (iCv*); - -void internal_lock_mutex_for_object (java_objectheader *obj); -void internal_unlock_mutex_for_object (java_objectheader *obj); -void internal_lock_notify_all_object (java_objectheader *obj); - -#endif /* __locks_h */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/threads/green/threadio.c b/src/threads/green/threadio.c deleted file mode 100644 index 529580aa1..000000000 --- a/src/threads/green/threadio.c +++ /dev/null @@ -1,492 +0,0 @@ -/* - * threadCalls.c - * Support for threaded ops which may block (read, write, connect, etc.). - * - * Copyright (c) 1996 T. J. Wilkinson & Associates, London, UK. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * Written by Tim Wilkinson , 1996. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config.h" -#include "threads/green/threads.h" - - -#define TH_READ 0 -#define TH_WRITE 1 -#define TH_ACCEPT TH_READ -#define TH_CONNECT TH_WRITE - -static int maxFd; -static fd_set readsPending; -static fd_set writesPending; -static thread* readQ[FD_SETSIZE]; -static thread* writeQ[FD_SETSIZE]; - -void blockOnFile(int, int); -void waitOnEvents(void); - -extern thread* currentThread; - -/* These are undefined because we do not yet support async I/O */ -#undef F_SETOWN -#undef FIOSETOWN -#undef O_ASYNC -#undef FIOASYNC - -/* - * Create a threaded file descriptor. - */ -int -threadedFileDescriptor(int fd) -{ -#if !defined(BLOCKING_CALLS) - int r; -#if defined(HAVE_IOCTL) && defined(FIOASYNC) - int on = 1; -#endif - int pid; - - /* Make non-blocking */ -#if defined(HAVE_FCNTL) && defined(O_NONBLOCK) - r = fcntl(fd, F_GETFL, 0); - r = fcntl(fd, F_SETFL, r|O_NONBLOCK); -#elif defined(HAVE_IOCTL) && defined(FIONBIO) - r = ioctl(fd, FIONBIO, &on); -#else - r = 0; -#endif - if (r < 0) - { - return (r); - } - - /* Allow socket to signal this process when new data is available */ - pid = getpid(); -#if defined(HAVE_FCNTL) && defined(F_SETOWN) - r = fcntl(fd, F_SETOWN, pid); -#elif defined(HAVE_IOCTL) && defined(FIOSETOWN) - r = ioctl(fd, FIOSETOWN, &pid); -#else - r = 0; -#endif - if (r < 0) - { - return (r); - } - -#if defined(HAVE_FCNTL) && defined(O_ASYNC) - r = fcntl(fd, F_GETFL, 0); - r = fcntl(fd, F_SETFL, r|O_ASYNC); -#elif defined(HAVE_IOCTL) && defined(FIOASYNC) - r = ioctl(fd, FIOASYNC, &on); -#else - r = 0; -#endif - if (r < 0) - { - return (r); - } -#endif - return (fd); -} - -void clear_thread_flags(void) -{ -#if !defined(BLOCKING_CALLS) -#if defined(HAVE_FCNTL) && defined(O_NONBLOCK) - int fl, fd; - - fd = fileno(stdin); - fl = fcntl(fd, F_GETFL, 0); - fl = fcntl(fd, F_SETFL, fl & (~O_NONBLOCK)); - - fd = fileno(stdout); - fl = fcntl(fd, F_GETFL, 0); - fl = fcntl(fd, F_SETFL, fl & (~O_NONBLOCK)); - - fd = fileno(stderr); - fl = fcntl(fd, F_GETFL, 0); - fl = fcntl(fd, F_SETFL, fl & (~O_NONBLOCK)); - -#elif defined(HAVE_IOCTL) && defined(FIONBIO) - int fl, fd; - - fl = 0; - fd = fileno(stdin); - (void) ioctl(fd, FIONBIO, &fl); - - fd = fileno(stdout); - (void) ioctl(fd, FIONBIO, &fl); - - fd = fileno(stderr); - (void) ioctl(fd, FIONBIO, &fl); -#endif -#endif - - fflush(stdout); - fflush(stderr); -} - - -/* - * Threaded create socket. - */ -int -threadedSocket(int af, int type, int proto) -{ - int fd; - - fd = socket(af, type, proto); - return (threadedFileDescriptor(fd)); -} - -/* - * Threaded file open. - */ -int -threadedOpen(char* path, int flags, int mode) -{ - int fd; - - fd = open(path, flags, mode); - return (threadedFileDescriptor(fd)); -} - -/* - * Threaded socket connect. - */ -int -threadedConnect(int fd, struct sockaddr* addr, int len) -{ - int r; - - r = connect(fd, addr, len); -#if !defined(BLOCKING_CALLS) - if ((r < 0) - && (errno == EINPROGRESS || errno == EALREADY - || errno == EWOULDBLOCK)) { - blockOnFile(fd, TH_CONNECT); - r = 0; /* Assume it's okay when we get released */ - } -#endif - - return (r); -} - -/* - * Threaded socket accept. - */ -int -threadedAccept(int fd, struct sockaddr* addr, int* len) -{ - int r; - - for (;;) - { -#if defined(BLOCKING_CALLS) - blockOnFile(fd, TH_ACCEPT); -#endif - r = accept(fd, addr, (int*)len); - if (r >= 0 - || !(errno == EINPROGRESS || errno == EALREADY - || errno == EWOULDBLOCK)) - { - break; - } -#if !defined(BLOCKING_CALLS) - blockOnFile(fd, TH_ACCEPT); -#endif - } - return (threadedFileDescriptor(r)); -} - -/* - * Read but only if we can. - */ -int -threadedRead(int fd, char* buf, int len) -{ - int r; - - DBG( printf("threadedRead\n"); ) - -#if defined(BLOCKING_CALLS) - blockOnFile(fd, TH_READ); -#endif - for (;;) - { - r = read(fd, buf, len); - if (r < 0 - && (errno == EAGAIN || errno == EWOULDBLOCK - || errno == EINTR)) - { - blockOnFile(fd, TH_READ); - continue; - } - return (r); - } -} - -/* - * Write but only if we can. - */ -int -threadedWrite(int fd, char* buf, int len) -{ - int r; - char* ptr; - - ptr = buf; - r = 1; - - DBG( printf("threadedWrite %dbytes\n",len); ) - - while (len > 0 && r > 0) - { -#if defined(BLOCKING_CALLS) - blockOnFile(fd, TH_WRITE); -#endif - r = write(fd, ptr, len); - if (r < 0 - && (errno == EAGAIN || errno == EWOULDBLOCK - || errno == EINTR)) - { -#if !defined(BLOCKING_CALLS) - blockOnFile(fd, TH_WRITE); -#endif - r = 1; - } - else - { - ptr += r; - len -= r; - } - } - return (ptr - buf); -} - -/* - * Receive, but only if we can. - */ -int -threadedRecvfrom (int fd, void *buf, size_t len, int flags, struct sockaddr *addr, int *addrlen) -{ - int r; - - DBG( printf("threadedRecvfrom\n"); ) - -#if defined(BLOCKING_CALLS) - blockOnFile(fd, TH_READ); -#endif - for (;;) - { - r = recvfrom(fd, buf, len, flags, addr, addrlen); - if (r < 0 - && (errno == EAGAIN || errno == EWOULDBLOCK - || errno == EINTR)) - { - blockOnFile(fd, TH_READ); - continue; - } - return (r); - } -} - -/* - * Send, but only if we can. - */ -int -threadedSendto (int fd, void *buf, size_t len, int flags, struct sockaddr *addr, int addrlen) -{ - int r; - - DBG( printf("threadedSendto\n"); ) - -#if defined(BLOCKING_CALLS) - blockOnFile(fd, TH_WRITE); -#endif - for (;;) - { - r = sendto(fd, buf, len, flags, addr, addrlen); - if (r < 0 - && (errno == EAGAIN || errno == EWOULDBLOCK - || errno == EINTR)) - { - blockOnFile(fd, TH_WRITE); - continue; - } - return (r); - } -} - -/* - * An attempt to access a file would block, so suspend the thread until - * it will happen. - */ -void -blockOnFile(int fd, int op) -{ -DBG( printf("blockOnFile()\n"); ) - - intsDisable(); - - if (fd > maxFd) - { - maxFd = fd; - } - - if (op == TH_READ) - { - FD_SET(fd, &readsPending); - suspendOnQThread(currentThread, &readQ[fd]); - FD_CLR(fd, &readsPending); - } - else - { - FD_SET(fd, &writesPending); - suspendOnQThread(currentThread, &writeQ[fd]); - FD_CLR(fd, &writesPending); - } - - intsRestore(); -} - -/* - * Check if some file descriptor or other event to become ready. - * Block if required (but make sure we can still take timer interrupts). - */ -void -checkEvents(bool block) -{ - int r; - fd_set rd; - fd_set wr; - thread* tid; - thread* ntid; - int i; - s8 time = -1; - struct timeval tv; - struct timeval *timeout; - - assert(blockInts > 0); - - DBG( printf("checkEvents block:%d\n", block); ) - - if (sleepThreads != 0) - { - time = currentTime(); - while (sleepThreads != 0 && time >= CONTEXT(sleepThreads).time) - { - tid = sleepThreads; - sleepThreads = sleepThreads->vmThread->next; - tid->vmThread->next = 0; - - iresumeThread(tid); - } - } - - if (block) - { - if (sleepThreads != 0) - { - s8 wait_time = CONTEXT(sleepThreads).time - time; - - tv.tv_sec = wait_time / 1000; - tv.tv_usec = (wait_time % 1000) * 1000; - timeout = &tv; - } - else - timeout = 0; - } - else - { - tv.tv_sec = 0; - tv.tv_usec = 0; - timeout = &tv; - } - -#if defined(FD_COPY) - FD_COPY(&readsPending, &rd); - FD_COPY(&writesPending, &wr); -#else - memcpy(&rd, &readsPending, sizeof(rd)); - memcpy(&wr, &writesPending, sizeof(wr)); -#endif - - r = select(maxFd+1, &rd, &wr, 0, timeout); - - /* We must be holding off interrupts before we start playing with - * the read and write queues. This should be already done but a - * quick check never hurt anyone. - */ - assert(blockInts > 0); - - DBG( printf("Select returns %d\n", r); ) - - /* Some threads may have finished sleeping. - */ - if (block && sleepThreads != 0) - { - time = currentTime(); - while (sleepThreads != 0 && time >= CONTEXT(sleepThreads).time) - { - tid = sleepThreads; - sleepThreads = sleepThreads->vmThread->next; - tid->vmThread->next = 0; - - iresumeThread(tid); - } - } - - for (i = 0; r > 0 && i <= maxFd; i++) - { - if (readQ[i] != 0 && FD_ISSET(i, &rd)) - { - for (tid = readQ[i]; tid != 0; tid = ntid) - { - ntid = tid->vmThread->next; - iresumeThread(tid); - } - readQ[i] = 0; - r--; - } - if (writeQ[i] != 0 && FD_ISSET(i, &wr)) - { - for (tid = writeQ[i]; tid != 0; tid = ntid) - { - ntid = tid->vmThread->next; - iresumeThread(tid); - } - writeQ[i] = 0; - r--; - } - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/threads/green/threadio.h b/src/threads/green/threadio.h deleted file mode 100644 index e95dd08e0..000000000 --- a/src/threads/green/threadio.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c -*- */ - -#ifndef __threadio_h_ -#define __threadio_h_ - -#include -#include - -#include "global.h" - -#ifdef USE_THREADS -int threadedFileDescriptor(int fd); -int threadedSocket(int af, int type, int proto); -int threadedOpen(char* path, int flags, int mode); -int threadedConnect(int fd, struct sockaddr* addr, int len); -int threadedAccept(int fd, struct sockaddr* addr, int* len); -int threadedRead(int fd, char* buf, int len); -int threadedWrite(int fd, char* buf, int len); -int threadedRecvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, int *addrlen); -int threadedSendto(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, int addrlen); -#else -#define threadedFileDescriptor(fd) -#define threadedRead(fd,buf,len) read(fd,buf,len) -#define threadedWrite(fd,buf,len) write(fd,buf,len) -#define threadedSocket(af,type,proto) socket(af,type,proto) -#define threadedAccept(fd,addr,len) accept(fd,addr,len) -#define threadedRecvfrom(fd,buf,len,flags,addr,addrlen) recvfrom(fd,buf,len,flags,addr,addrlen) -#define threadedSendto(fd,buf,len,flags,addr,addrlen) sendto(fd,buf,len,flags,addr,addrlen) -#define threadedConnect(fd,addr,len) connect(fd,addr,len) -#endif - - -#endif diff --git a/src/threads/green/threads.c b/src/threads/green/threads.c deleted file mode 100644 index f9e5cf9cd..000000000 --- a/src/threads/green/threads.c +++ /dev/null @@ -1,926 +0,0 @@ -/* -*- mode: c; tab-width: 4; c-basic-offset: 4 -*- */ -/* - * thread.c - * Thread support. - * - * Copyright (c) 1996 T. J. Wilkinson & Associates, London, UK. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * Written by Tim Wilkinson , 1996. - */ - -#include -#include -#include -#include -#include /* for mprotect */ -#include -#include -#include -#include -#include - -#include "config.h" -#include "mm/memory.h" -#include "native/native.h" -#include "threads/green/locks.h" -#include "threads/green/threads.h" -#include "toolbox/avl.h" -#include "toolbox/logging.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/loader.h" -#include "vm/options.h" -#include "vm/tables.h" -#include "vm/jit/asmpart.h" - - -static classinfo *class_java_lang_ThreadDeath; - -thread* currentThread = NULL; -thread* mainThread; -thread* threadQhead[MAX_THREAD_PRIO + 1]; -thread* threadQtail[MAX_THREAD_PRIO + 1]; - -thread* liveThreads = NULL; -thread* sleepThreads = NULL; - -int blockInts; -bool needReschedule; - -vmthread *contexts[MAXTHREADS]; - -/* Number of threads alive, also counting daemons */ -static int talive; - -/* Number of daemon threads alive */ -static int tdaemon; - -static void firstStartThread(void); - -void reschedule(void); - -/* Setup default thread stack size - this can be overwritten if required */ -int threadStackSize = THREADSTACKSIZE; - -/* Pointer to the stack of the last killed thread. The free is delayed. */ -void *stack_to_be_freed = 0; - -static thread* startDaemon(void* func, char* nm, int stackSize); - - - -java_objectheader *init_vmthread(void *thr) -{ - methodinfo *m; - java_objectheader *o; - classinfo *c; - - if (!load_class_bootstrap(utf_new_char("java/lang/VMThread"),&c)) - return *exceptionptr; - - o = builtin_new(c); /* create object */ - - if (!o) - return NULL; - - /* find initializer */ - - m = class_findmethod(c, - utf_new_char(""), - utf_new_char("(Ljava/lang/Thread;)V")); - - if (!m) { /* initializer not found */ - if (opt_verbose) { - char logtext[MAXLOGTEXT]; - sprintf(logtext, "Warning: class has no instance-initializer: "); - utf_sprint_convert_to_latin1_classname(logtext + strlen(logtext), c->name); - log_text(logtext); - } - return o; - } - - /* call initializer */ - - asm_calljavafunction(m, o, thr, NULL, NULL); - return o; -} - - - - -/* - * Allocate the stack for a thread - */ -void -allocThreadStack (thread *tid, int size) -{ - int pageSize = getpagesize(); - unsigned long pageBegin; - - assert(stack_to_be_freed == 0); - - CONTEXT(tid).stackMem = GCNEW_UNCOLLECTABLE(u1, size + 4 * pageSize); - assert(CONTEXT(tid).stackMem != 0); - CONTEXT(tid).stackEnd = CONTEXT(tid).stackMem + size + 2 * pageSize; - - pageBegin = (unsigned long)(CONTEXT(tid).stackMem) + pageSize - 1; - pageBegin = pageBegin - pageBegin % pageSize; - - CONTEXT(tid).stackBase = (u1*)pageBegin + pageSize; -} - -/* - * Mark the stack for a thread to be freed. We cannot free the stack - * immediately because it is still in use! - */ -void -freeThreadStack (vmthread *vmtid) -{ - if (!(vmtid->flags & THREAD_FLAGS_NOSTACKALLOC)) - { - int pageSize = getpagesize(); - unsigned long pageBegin; - - pageBegin = (unsigned long)(vmtid->stackMem) + pageSize - 1; - pageBegin = pageBegin - pageBegin % pageSize; - - assert(stack_to_be_freed == 0); - - stack_to_be_freed = vmtid->stackMem; - } - vmtid->stackMem = 0; - vmtid->stackBase = 0; - vmtid->stackEnd = 0; -} - -/* - * Initialize threads. - */ -void -initThreads(u1 *stackbottom) -{ - classinfo *c; - thread *the_main_thread; - int i; - char mainname[] = "main"; - /*int len = strlen(mainname);*/ - - signal(SIGPIPE, SIG_IGN); - - lock_init(); - - for (i = 0; i < MAXTHREADS; ++i) { - contexts[i]=0; - } - - /* Allocate a thread to be the main thread */ - if (!load_class_bootstrap(utf_new_char("java/lang/Thread"),&c)) { - log_text("Could not load java/lang/Thread"); - assert(0); - } - - liveThreads = the_main_thread = - (thread *) builtin_new(c); - the_main_thread->vmThread=init_vmthread(the_main_thread); - assert(the_main_thread != 0); - -/* the_main_thread->PrivateInfo = 1; - CONTEXT(the_main_thread).free = false;*/ - -#if 0 - { - /* stefan */ - methodinfo *m; - m = class_fetchmethod( - class_java_lang_String, - utf_new_char ("toCharArray"), - utf_new_char ("()[C") - ); -printf("DEADCODE LIVES ?????????\n");fflush(stdout); - the_main_thread->name = asm_calljavafunction (m, javastring_new(utf_new_char("main")), 0, 0, 0); - } -#endif - the_main_thread->name=javastring_new(utf_new_char(mainname)); -/* the_main_thread->name = builtin_newarray_char(len); - { u2 *d = the_main_thread->name->data; - for (i=0; ipriority = NORM_THREAD_PRIO; - CONTEXT(the_main_thread).priority = (u1)the_main_thread->priority; - CONTEXT(the_main_thread).texceptionptr = 0; - the_main_thread->vmThread->next = 0; - CONTEXT(the_main_thread).status = THREAD_SUSPENDED; - CONTEXT(the_main_thread).stackBase = CONTEXT(the_main_thread).stackEnd = stackbottom; - THREADINFO(&CONTEXT(the_main_thread)); - - DBG( printf("main thread %p base %p end %p\n", - the_main_thread, - CONTEXT(the_main_thread).stackBase, - CONTEXT(the_main_thread).stackEnd); ); - - CONTEXT(the_main_thread).flags = THREAD_FLAGS_NOSTACKALLOC; - CONTEXT(the_main_thread).nextlive = 0; - /*CONTEXT(the_main_thread).thread = the_main_thread;*/ - /*the_main_thread->single_step = 0;*/ - the_main_thread->daemon = 0; - /*the_main_thread->stillborn = 0;*/ - /*the_main_thread->target = 0;*/ - - the_main_thread->contextClassLoader = 0; - /*the_main_thread->inheritedAccessControlContext = 0;*/ - /*the_main_thread->values = 0;*/ - - /* Allocate and init ThreadGroup */ - the_main_thread->group = - (threadGroup *) native_new_and_init(class_load(class_new(utf_new_char("java/lang/ThreadGroup")))); - assert(the_main_thread->group != 0); - - talive++; - - /* Load exception classes */ -/* loader_load_sysclass(&class_java_lang_ThreadDeath, */ -/* utf_new_char("java/lang/ThreadDeath")); */ - class_java_lang_ThreadDeath = - class_load(class_new(utf_new_char("java/lang/ThreadDeath"))); - - DBG( fprintf(stderr, "finishing initThreads\n"); ); - - mainThread = currentThread = the_main_thread; - contexts[0]=mainThread->vmThread; - /* Add thread into runQ */ - iresumeThread(mainThread); - - assert(blockInts == 0); -} - -/* - * Start a new thread running. - */ -void -startThread (thread* tid) -{ - int i; - - /* Allocate a stack context */ - for (i = 0; i < MAXTHREADS; ++i) - if (contexts[i]==0) - break; - - if (i == MAXTHREADS) { - log_text("Too many threads"); - assert(0); - } - - assert(tid->priority >= MIN_THREAD_PRIO && tid->priority <= MAX_THREAD_PRIO); - contexts[i]=tid->vmThread; -/* tid->PrivateInfo = i + 1; - CONTEXT(tid).free = false;*/ - if (tid->vmThread==0) { - log_text("vmThread field not set"); - assert(0); -/* tid->vmThread=init_vmthread(tid);*/ - } - -/* CONTEXT(tid).thread = tid;*/ - CONTEXT(tid).nextlive = liveThreads; - liveThreads = tid; - allocThreadStack(tid, threadStackSize); - CONTEXT(tid).usedStackTop = CONTEXT(tid).stackBase; - CONTEXT(tid).flags = THREAD_FLAGS_GENERAL; - CONTEXT(tid).status = THREAD_SUSPENDED; - CONTEXT(tid).priority = (u1)tid->priority; - CONTEXT(tid).texceptionptr = 0; - - /* Construct the initial restore point. */ - THREADINIT((&CONTEXT(tid)), firstStartThread); - - DBG( printf("new thread %p base %p end %p\n", - tid, CONTEXT(tid).stackBase, - CONTEXT(tid).stackEnd); ); - - talive++; - if (tid->daemon) - tdaemon++; - - /* Add thread into runQ */ - iresumeThread(tid); -} - - -/* - * Start a daemon thread. - */ -static thread *startDaemon(void* func, char* nm, int stackSize) -{ - thread* tid; - int i; - - DBG( printf("startDaemon %s\n", nm); ); - - tid = (thread *) builtin_new(class_new(utf_new_char("java/lang/Thread"))); - assert(tid != 0); - -/* for (i = 0; i < MAXTHREADS; ++i) - if (contexts[i]==0) - break; - if (i == MAXTHREADS) - panic("Too many threads");*/ - -/* tid->PrivateInfo = i + 1; - CONTEXT(tid).free = false;*/ - tid->name = 0; /* for the moment */ - tid->priority = MAX_THREAD_PRIO; - CONTEXT(tid).priority = (u1)tid->priority; - tid->vmThread->next = 0; - CONTEXT(tid).status = THREAD_SUSPENDED; - - allocThreadStack(tid, stackSize); - /*tid->single_step = 0;*/ - tid->daemon = 1; - /*tid->stillborn = 0;*/ - /*tid->target = 0;*/ - tid->group = 0; - - /* Construct the initial restore point. */ - THREADINIT((&CONTEXT(tid)), func); - - talive++; - tdaemon++; - - return tid; -} - -/* - * All threads start here. - */ -static void -firstStartThread(void) -{ - methodinfo *method; - - DBG( printf("firstStartThread %p\n", currentThread); ); - - if (stack_to_be_freed != 0) { - stack_to_be_freed = 0; - } - - /* Every thread starts with the interrupts off */ - intsRestore(); - assert(blockInts == 0); - - /* Find the run()V method and call it */ - method = class_findmethod(currentThread->vmThread->header.vftbl->class, - utf_new_char("run"), utf_new_char("()V")); - - if (method == 0) { - log_text("Cannot find method \'void run ()\'"); - assert(0); - } - - asm_calljavafunction(method, currentThread->vmThread, NULL, NULL, NULL); - - if (*exceptionptr) { - utf_display_printable_ascii((*exceptionptr)->vftbl->class->name); - printf("\n"); - } - - killThread(0); - assert("Thread returned from killThread" == 0); -} - -/* - * Resume a thread running. - * This routine has to be called only from locations which ensure - * run / block queue consistency. There is no check for illegal resume - * conditions (like explicitly resuming an IO blocked thread). There also - * is no update of any blocking queue. Both has to be done by the caller - */ -void -iresumeThread(thread* tid) -{ - vmthread *vmctid; - DBG( printf("resumeThread %p\n", tid); ); - - intsDisable(); - if (tid->vmThread==0) { - intsRestore(); - return; - } - - if (currentThread->vmThread==0) { - long i1; - for (i1=0;i1thread==currentThread) { - vmctid=contexts[i1]; - break; - } - } - if (i1==MAXTHREADS) vmctid=0; /*panic("Thread not found in iresumeThread");*/ - - } else { - vmctid=currentThread->vmThread; - } - - if (CONTEXT(tid).status != THREAD_RUNNING) - { - CONTEXT(tid).status = THREAD_RUNNING; - - DBG( fprintf(stderr, "prio is %d\n", CONTEXT(tid).priority); ); - - /* Place thread on the end of its queue */ - if (threadQhead[CONTEXT(tid).priority] == 0) { - threadQhead[CONTEXT(tid).priority] = tid; - threadQtail[CONTEXT(tid).priority] = tid; - - if ((vmctid==0) || (CONTEXT(tid).priority - > vmctid->priority) ) - needReschedule = true; - } - else - { - threadQtail[CONTEXT(tid).priority]->vmThread->next = tid; - threadQtail[CONTEXT(tid).priority] = tid; - } - tid->vmThread->next = 0; - } - SDBG( else { printf("Re-resuming %p\n", tid); } ); - - intsRestore(); -} - -/* - * Yield process to another thread of equal priority. - */ -void -threads_yield() -{ - intsDisable(); - - if (threadQhead[CONTEXT(currentThread).priority] - != threadQtail[CONTEXT(currentThread).priority]) - { - /* Get the next thread and move me to the end */ - threadQhead[CONTEXT(currentThread).priority] = currentThread->vmThread->next; - threadQtail[CONTEXT(currentThread).priority]->vmThread->next = currentThread; - threadQtail[CONTEXT(currentThread).priority] = currentThread; - currentThread->vmThread->next = 0; - needReschedule = true; - } - - intsRestore(); -} - -/* - * Explicit request by user to resume a thread - * The definition says that it is just legal to call this after a preceeding - * suspend (which got through). If the thread was blocked for some other - * reason (either sleep or IO or a muxSem), we simply can't do it - * We use a new thread flag THREAD_FLAGS_USER_SUSPEND for this purpose - * (which is set by suspendThread(.)) - */ -void -resumeThread (thread* tid) -{ - if ((CONTEXT(tid).flags & THREAD_FLAGS_USER_SUSPEND) != 0) - { - intsDisable(); - CONTEXT(tid).flags &= ~THREAD_FLAGS_USER_SUSPEND; - iresumeThread(tid); - intsRestore(); - } -} - -/* - * Suspend a thread. - * This is an explicit user request to suspend the thread - the counterpart - * for resumeThreadRequest(.). It is JUST called by the java method - * Thread.suspend() - * What makes it distinct is the fact that the suspended thread is not contained - * in any block queue. Without a special flag (indicating the user suspend), we - * can't check s suspended thread for this condition afterwards (which is - * required by resumeThreadRequest()). The new thread flag - * THREAD_FLAGS_USER_SUSPEND is used for this purpose. - */ -void -suspendThread(thread* tid) -{ - thread** ntid; - - intsDisable(); - - if (CONTEXT(tid).status != THREAD_SUSPENDED) - { - CONTEXT(tid).status = THREAD_SUSPENDED; - - /* - * This is used to indicate the explicit suspend condition - * required by resumeThreadRequest() - */ - CONTEXT(tid).flags |= THREAD_FLAGS_USER_SUSPEND; - - for (ntid = &threadQhead[CONTEXT(tid).priority]; - *ntid != 0; - ntid = &(*ntid)->vmThread->next) - { - if (*ntid == tid) - { - *ntid = tid->vmThread->next; - tid->vmThread->next = 0; - if (tid == currentThread) - { - reschedule(); - } - break; - } - } - } - SDBG( else { printf("Re-suspending %p\n", tid); } ); - - intsRestore(); -} - -/* - * Suspend a thread on a queue. - */ -void -suspendOnQThread(thread* tid, thread** queue) -{ - thread** ntid; - - DBG( printf("suspendOnQThread %p %p\n", tid, queue); ); - - assert(blockInts > 0); - - if (CONTEXT(tid).status != THREAD_SUSPENDED) - { - CONTEXT(tid).status = THREAD_SUSPENDED; - - for (ntid = &threadQhead[CONTEXT(tid).priority]; - *ntid != 0; - ntid = &(*ntid)->vmThread->next) - { - if (*ntid == tid) - { - *ntid = tid->vmThread->next; - /* Insert onto head of lock wait Q */ - tid->vmThread->next = *queue; - *queue = tid; - if (tid == currentThread) - { - DBG( fprintf(stderr, "suspending %p (cur=%p) with prio %d\n", - tid, currentThread, CONTEXT(tid).priority); ); - reschedule(); - } - break; - } - } - } - SDBG( else { printf("Re-suspending %p on %p\n", tid, *queue); } ); -} - -/* - * Kill thread. - */ -void -killThread(thread* tid) -{ - vmthread *context; - thread** ntid; - - intsDisable(); - - /* A null tid means the current thread */ - if (tid == 0) - { - tid = currentThread; - } - - if (tid->vmThread==0) { - long i1; - for (i1=0;i1thread==tid) { - context=contexts[i1]; - break; - } - } - if (i1==MAXTHREADS) { - log_text("Thread not found in killThread"); - assert(0); - } - - } else context=tid->vmThread; - - DBG( printf("killThread %p\n", tid); ); - - if (context->status != THREAD_DEAD) - { - /* Get thread off runq (if it needs it) */ - if (context->status == THREAD_RUNNING) - { - for (ntid = &threadQhead[context->priority]; - *ntid != 0; - ntid = &(*ntid)->vmThread->next) - { - if (*ntid == tid) - { - *ntid = context->next; - break; - } - } - } - - context->status = THREAD_DEAD; - talive--; - if (tid->daemon) { - tdaemon--; - } - - /* If we only have daemons left, then everyone is dead. */ - if (talive == tdaemon) { - /* atexit functions get called to clean things up */ - intsRestore(); - exit(0); - } - - /* Notify on the object just in case anyone is waiting */ - internal_lock_mutex_for_object(&tid->header); - internal_lock_notify_all_object(&tid->header); - internal_unlock_mutex_for_object(&tid->header); - - /* Remove thread from live list to it can be garbaged */ - for (ntid = &liveThreads; - *ntid != 0; - ntid = &(CONTEXT((*ntid)).nextlive)) - { - if (tid == (*ntid)) - { - (*ntid) = context->nextlive; - break; - } - } - - - /* Free stack */ - freeThreadStack(context); - - /* free context */ - if (tid != mainThread) - { - long i; - for (i=0;inext; - break; - } - } - - intsRestore(); -} - -/* - * Change thread priority. - */ -void -threads_java_lang_Thread_set_priority(thread* tid, int prio) -{ - thread** ntid; - - assert(prio >= MIN_THREAD_PRIO && prio <= MAX_THREAD_PRIO); - -#warning fixme ?? -/* if (tid->PrivateInfo == 0) { - tid->priority = prio; - return; - }*/ - - if (CONTEXT(tid).status == THREAD_SUSPENDED) { - CONTEXT(tid).priority = (u8)prio; - return; - } - - intsDisable(); - - /* Remove from current thread list */ - for (ntid = &threadQhead[CONTEXT(tid).priority]; *ntid != 0; ntid = &(*ntid)->vmThread->next) { - if (*ntid == tid) { - *ntid = tid->vmThread->next; - break; - } - } - - /* Insert onto a new one */ - tid->priority = prio; - CONTEXT(tid).priority = (u8)tid->priority; - if (threadQhead[prio] == 0) { - threadQhead[prio] = tid; - threadQtail[prio] = tid; - if (prio > CONTEXT(currentThread).priority) { - needReschedule = true; - } - } - else { - threadQtail[prio]->vmThread->next = tid; - threadQtail[prio] = tid; - } - tid->vmThread->next = 0; - - intsRestore(); -} - -/* - * Get the current time in milliseconds since 1970-01-01. - */ -s8 -currentTime (void) -{ - struct timeval tv; - s8 time; - - gettimeofday(&tv, 0); - - time = tv.tv_sec; - time *= 1000; - time += tv.tv_usec / 1000; - - return time; -} - -/* - * Put a thread to sleep. - */ -void -sleepThread(s8 time, s4 nanos) -{ - thread** tidp; - - /* Sleep for no time */ - if (time <= 0) { - return; - } - - intsDisable(); - - /* Get absolute time */ - CONTEXT(currentThread).time = time + currentTime(); - - /* Find place in alarm list */ - for (tidp = &sleepThreads; (*tidp) != 0; tidp = &((*tidp)->vmThread->next)) - { - if (CONTEXT((*tidp)).time > CONTEXT(currentThread).time) - break; - } - - /* Suspend thread on it */ - suspendOnQThread(currentThread, tidp); - - intsRestore(); -} - -/* - * Is this thread alive? - */ -bool -aliveThread(thread* tid) -{ - if (tid!=mainThread && CONTEXT(tid).status != THREAD_DEAD) - return (true); - else - return (false); -} - -/* - * Reschedule the thread. - * Called whenever a change in the running thread is required. - */ -void -reschedule(void) -{ - int i; - thread* lastThread; - int b; - /* sigset_t nsig; */ - - /* A reschedule in a non-blocked context is half way to hell */ - assert(blockInts > 0); - b = blockInts; - - /* Check events - we may release a high priority thread */ - /* Just check IO, no need for a reschedule call by checkEvents() */ - needReschedule = false; - checkEvents(false); - - for (;;) - { - for (i = MAX_THREAD_PRIO; i >= MIN_THREAD_PRIO; i--) - { - if (threadQhead[i] != 0) - { - DBG( fprintf(stderr, "found thread %p in head %d\n", threadQhead[i], i); ); - - if (threadQhead[i] != currentThread) - { - /* USEDSTACKTOP((CONTEXT(currentThread).usedStackTop)); */ - - lastThread = currentThread; - currentThread = threadQhead[i]; - - CONTEXT(currentThread).texceptionptr = *exceptionptr; - - DBG( fprintf(stderr, "thread switch from: %p to: %p\n", lastThread, currentThread); ); - { - THREADSWITCH((&CONTEXT(currentThread)), - (&CONTEXT(lastThread))); - } - blockInts = b; - - *exceptionptr = CONTEXT(currentThread).texceptionptr; - - if (stack_to_be_freed != 0) { - stack_to_be_freed = 0; - } - - /* Alarm signal may be blocked - if so - * unblock it. - */ - /* - if (alarmBlocked == true) { - alarmBlocked = false; - sigemptyset(&nsig); - sigaddset(&nsig, SIGALRM); - sigprocmask(SIG_UNBLOCK, &nsig, 0); - } - */ - - /* I might be dying */ - if ((CONTEXT(lastThread).flags & THREAD_FLAGS_KILLED) - != 0) - { - CONTEXT(lastThread).flags &= ~THREAD_FLAGS_KILLED; - *exceptionptr = native_new_and_init(class_java_lang_ThreadDeath); - } - } - /* Now we kill the schedule and turn ints - back on */ - needReschedule = false; - return; - } - } - /* Nothing to run - wait for external event */ - DBG( fprintf(stderr, "nothing more to do\n"); ); - checkEvents(true); - } -} - -void lock_stopworld(int dummy) -{ -} - -void unlock_stopworld() -{ -} - -void cacao_suspendhandler(void *ctx) -{ -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/threads/green/threads.h b/src/threads/green/threads.h deleted file mode 100644 index 5465d6af4..000000000 --- a/src/threads/green/threads.h +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- mode: c; tab-width: 4; c-basic-offset: 4 -*- */ -/* - * thread.h - * Thread support. - * - * Copyright (c) 1996 T. J. Wilkinson & Associates, London, UK. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * Written by Tim Wilkinson , 1996. - */ - - -#ifndef _THREADS_H -#define _THREADS_H - -#include "config.h" -#include "mm/memory.h" -#include "vm/global.h" /* for native includes */ -#include "native/include/java_lang_ClassLoader.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Throwable.h" - - -#define THREADCLASS "java/lang/Thread" -#define THREADGROUPCLASS "java/lang/ThreadGroup" -#define THREADDEATHCLASS "java/lang/ThreadDeath" - -#define MIN_THREAD_PRIO 1 -#define NORM_THREAD_PRIO 5 -#define MAX_THREAD_PRIO 10 - -#define THREAD_SUSPENDED 0 -#define THREAD_RUNNING 1 -#define THREAD_DEAD 2 -#define THREAD_KILL 3 - -#define THREAD_FLAGS_GENERAL 0 -#define THREAD_FLAGS_NOSTACKALLOC 1 -#define THREAD_FLAGS_USER_SUSPEND 2 /* Flag explicit suspend() call */ -#define THREAD_FLAGS_KILLED 4 - -#define THREADSPECIFIC - -#define MAXTHREADS 256 /* schani */ - -#if 1 -#define DBG(s) -#define SDBG(s) -#else -#define DBG(s) s -#define SDBG(s) s -#endif - -struct _thread; - -#if 0 -typedef struct _ctx -{ - struct _thread *thread; - bool free; - u1 status; - u1 priority; - u1* restorePoint; - u1* stackMem; /* includes guard page */ - u1* stackBase; - u1* stackEnd; - u1* usedStackTop; - s8 time; - java_objectheader *texceptionptr; - struct _thread *nextlive; - u1 flags; -} ctx; -#endif - -/* -struct _stringClass; -struct _object; -*/ - -/* This structure mirrors java.lang.ThreadGroup.h */ - -typedef struct _threadGroup { - java_objectheader header; - struct _threadGroup* parent; - struct java_objectheader* name; - struct java_objectheader* threads; - struct java_objectheader* groups; - s4 daemon_flag; - s4 maxpri; -} threadGroup; - - -typedef struct thread thread; -typedef struct vmthread vmthread; - -/* This structure mirrors java.lang.Thread.h */ - -struct thread { - java_objectheader header; - vmthread *vmThread; - threadGroup *group; - struct java_lang_Runnable* runnable; - java_lang_String *name; - s4 daemon; - s4 priority; - s8 stacksize; - java_lang_Throwable *stillborn; - java_lang_ClassLoader *contextClassLoader; -}; - - -/* This structure mirrors java.lang.VMThread.h */ - -struct vmthread { - java_objectheader header; - thread *thread; - s4 running; - s4 status; - s4 priority; - void *restorePoint; - void *stackMem; - void *stackBase; - void *stackEnd; - void *usedStackTop; - s8 time; - java_objectheader *texceptionptr; - struct _thread *nextlive; - struct _thread *next; - s4 flags; - -#if 0 - dumpinfo *dumpinfo; /* dump memory info structure */ -#endif -}; - - -extern int blockInts; -extern bool needReschedule; -extern thread *currentThread; -extern thread *mainThread; -/*extern ctx contexts[];*/ -extern int threadStackSize; - -extern thread *liveThreads; -extern thread *sleepThreads; - -extern thread *threadQhead[MAX_THREAD_PRIO + 1]; - - -/*#define CONTEXT(_t) (contexts[(_t)->PrivateInfo - 1])*/ -#define CONTEXT(_t) (*(_t->vmThread)) - -#define intsDisable() blockInts++ - -#define intsRestore() if (blockInts == 1 && needReschedule) { \ - reschedule(); \ - } \ - blockInts-- - - -/* access macros */ - -#define THREADSTACKSIZE (32 * 1024) - -#define THREADSWITCH(to, from) \ - do { \ - void *from1; \ - void *from2; \ - asm_perform_threadswitch((from?&(from)->restorePoint:&from1),\ - &(to)->restorePoint, (from?&(from)->usedStackTop:&from2)); \ - } while (0) - - -#define THREADINIT(to, func) \ - do { \ - (to)->restorePoint = asm_initialize_thread_stack((u1*)(func), \ - (to)->stackEnd); \ - } while (0) - - -#define THREADINFO(e) \ - do { \ - (e)->restorePoint = 0; \ - (e)->flags = THREAD_FLAGS_NOSTACKALLOC; \ - } while(0) - - -/* function prototypes ********************************************************/ - -void initThreads (u1 *stackbottom); -void clear_thread_flags (void); -void startThread (thread*); -void resumeThread (thread*); -void iresumeThread (thread*); -void suspendThread (thread*); -void suspendOnQThread (thread*, thread**); -void threads_yield (void); -void killThread (thread*); -void threads_java_lang_Thread_set_priority (thread*, int); - -s8 currentTime (void); -void sleepThread(s8 millis, s4 nanos); -bool aliveThread (thread*); -long framesThread (thread*); - -void reschedule (void); - -void checkEvents (bool block); - -#endif /* _THREADS_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/threads/native/threads.c b/src/threads/native/threads.c index ec7c2cd98..c99461725 100644 --- a/src/threads/native/threads.c +++ b/src/threads/native/threads.c @@ -29,7 +29,7 @@ Changes: Christian Thalinger Edwin Steiner - $Id: threads.c 4919 2006-05-15 12:23:13Z twisti $ + $Id: threads.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -724,7 +724,7 @@ void threads_preinit(void) *******************************************************************************/ -bool threads_init(u1 *stackbottom) +bool threads_init(void) { java_lang_String *threadname; java_lang_Thread *mainthread; diff --git a/src/threads/native/threads.h b/src/threads/native/threads.h index 64675696a..a4f0eaf1a 100644 --- a/src/threads/native/threads.h +++ b/src/threads/native/threads.h @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: threads.h 4919 2006-05-15 12:23:13Z twisti $ + $Id: threads.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -188,7 +188,7 @@ void threads_sem_post(sem_t *sem); threadobject *threads_get_current_threadobject(void); void threads_preinit(void); -bool threads_init(u1 *stackbottom); +bool threads_init(void); void threads_init_threadobject(java_lang_VMThread *); diff --git a/src/toolbox/avl.c b/src/toolbox/avl.c index 7933ad2e5..3b5c4678a 100644 --- a/src/toolbox/avl.c +++ b/src/toolbox/avl.c @@ -28,7 +28,7 @@ Changes: - $Id: avl.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: avl.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -42,12 +42,8 @@ #include "mm/memory.h" #include "toolbox/avl.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/builtin.h" @@ -69,14 +65,12 @@ avl_tree *avl_create(avl_comparator *compar) t->comparator = compar; t->entries = 0; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* create lock object for this tree */ t->lock = NEW(java_objectheader); -# if defined(NATIVE_THREADS) lock_init_object_lock(t->lock); -# endif #endif return t; @@ -325,7 +319,7 @@ bool avl_insert(avl_tree *tree, void *data) assert(tree); assert(data); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(tree->lock); #endif @@ -350,7 +344,7 @@ bool avl_insert(avl_tree *tree, void *data) printf("-------------------\n"); #endif -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(tree->lock); #endif @@ -375,7 +369,7 @@ void *avl_find(avl_tree *tree, void *data) assert(tree); assert(data); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(tree->lock); #endif @@ -389,7 +383,7 @@ void *avl_find(avl_tree *tree, void *data) /* was the entry found? return it */ if (res == 0) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(tree->lock); #endif @@ -401,7 +395,7 @@ void *avl_find(avl_tree *tree, void *data) node = node->childs[(res < 0) ? AVL_LEFT : AVL_RIGHT]; } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(tree->lock); #endif diff --git a/src/toolbox/avl.h b/src/toolbox/avl.h index 7bb76458b..b73b9b873 100644 --- a/src/toolbox/avl.h +++ b/src/toolbox/avl.h @@ -28,7 +28,7 @@ Changes: - $Id: avl.h 4357 2006-01-22 23:33:38Z twisti $ + $Id: avl.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -63,12 +63,12 @@ typedef struct avl_node avl_node; /* avl_tree *******************************************************************/ struct avl_tree { +#if defined(ENABLE_THREADS) + java_objectheader *lock; /* threads lock object */ +#endif avl_node *root; /* pointer to root node */ avl_comparator *comparator; /* pointer to comparison function */ s4 entries; /* contains number of entries */ -#if defined(USE_THREADS) - java_objectheader *lock; /* threads lock object */ -#endif }; diff --git a/src/toolbox/logging.c b/src/toolbox/logging.c index 2e1a42c37..6c9b411da 100644 --- a/src/toolbox/logging.c +++ b/src/toolbox/logging.c @@ -29,17 +29,18 @@ Changes: Christian Thalinger Edwin Steiner - $Id: logging.c 4886 2006-05-05 19:22:57Z edwin $ + $Id: logging.c 4921 2006-05-15 14:24:36Z twisti $ */ +#include "config.h" + #include #include #include #include -#include "config.h" #include "vm/types.h" #include "mm/memory.h" @@ -48,10 +49,8 @@ #include "vm/global.h" #include "vm/statistics.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif @@ -82,12 +81,12 @@ void log_init(const char *fname) void log_start(void) { if (logfile) { -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) fprintf(logfile, "[%p] ", (void *) THREADOBJECT); #endif } else { -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) fprintf(stdout, "LOG: [%p] ", (void *) THREADOBJECT); #else fputs("LOG: ", stdout); diff --git a/src/vm/builtin.c b/src/vm/builtin.c index 0da821f73..ae613c834 100644 --- a/src/vm/builtin.c +++ b/src/vm/builtin.c @@ -37,7 +37,7 @@ calls instead of machine instructions, using the C calling convention. - $Id: builtin.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: builtin.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -63,13 +63,8 @@ #include "native/include/java_lang_Object.h" /* required by VMObject */ #include "native/include/java_lang_VMObject.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# include "threads/green/locks.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/logging.h" @@ -793,7 +788,7 @@ java_objectheader *builtin_new(classinfo *c) o->vftbl = c->vftbl; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) lock_init_object_lock(o); #endif @@ -852,7 +847,7 @@ java_arrayheader *builtin_newarray(s4 size, classinfo *arrayclass) a->objheader.vftbl = arrayclass->vftbl; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) lock_init_object_lock(&a->objheader); #endif @@ -1707,94 +1702,6 @@ void builtin_displaymethodstop(methodinfo *m, s8 l, double d, float f) #endif /* !defined(NDEBUG) */ -/**************************************************************************** - SYNCHRONIZATION FUNCTIONS -*****************************************************************************/ - -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) -/* - * Lock the mutex of an object. - */ -void internal_lock_mutex_for_object(java_objectheader *object) -{ - mutexHashEntry *entry; - int hashValue; - - assert(object != 0); - - hashValue = MUTEX_HASH_VALUE(object); - entry = &mutexHashTable[hashValue]; - - if (entry->object != 0) { - if (entry->mutex.count == 0 && entry->conditionCount == 0) { - entry->object = 0; - entry->mutex.holder = 0; - entry->mutex.count = 0; - entry->mutex.muxWaiters = 0; - - } else { - while (entry->next != 0 && entry->object != object) - entry = entry->next; - - if (entry->object != object) { - entry->next = firstFreeOverflowEntry; - firstFreeOverflowEntry = firstFreeOverflowEntry->next; - - entry = entry->next; - entry->object = 0; - entry->next = 0; - assert(entry->conditionCount == 0); - } - } - - } else { - entry->mutex.holder = 0; - entry->mutex.count = 0; - entry->mutex.muxWaiters = 0; - } - - if (entry->object == 0) - entry->object = object; - - internal_lock_mutex(&entry->mutex); -} -#endif - - -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) -/* - * Unlocks the mutex of an object. - */ -void internal_unlock_mutex_for_object (java_objectheader *object) -{ - int hashValue; - mutexHashEntry *entry; - - hashValue = MUTEX_HASH_VALUE(object); - entry = &mutexHashTable[hashValue]; - - if (entry->object == object) { - internal_unlock_mutex(&entry->mutex); - - } else { - while (entry->next != 0 && entry->next->object != object) - entry = entry->next; - - assert(entry->next != 0); - - internal_unlock_mutex(&entry->next->mutex); - - if (entry->next->mutex.count == 0 && entry->conditionCount == 0) { - mutexHashEntry *unlinked = entry->next; - - entry->next = unlinked->next; - unlinked->next = firstFreeOverflowEntry; - firstFreeOverflowEntry = unlinked; - } - } -} -#endif - #if defined(ENABLE_CYCLES_STATS) void builtin_print_cycles_stats(FILE *file) { @@ -1809,27 +1716,13 @@ void builtin_print_cycles_stats(FILE *file) } #endif /* defined(ENABLE_CYCLES_STATS) */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) void builtin_monitorenter(java_objectheader *o) { #if defined(ENABLE_CYCLES_STATS) u8 cycles_start, cycles_overhead, cycles_end; #endif -#if !defined(NATIVE_THREADS) - int hashValue; - - ++blockInts; - - hashValue = MUTEX_HASH_VALUE(o); - if (mutexHashTable[hashValue].object == o - && mutexHashTable[hashValue].mutex.holder == currentThread) - ++mutexHashTable[hashValue].mutex.count; - else - internal_lock_mutex_for_object(o); - - --blockInts; -#else /* defined(NATIVE_THREADS) */ CYCLES_STATS_GET(cycles_start); CYCLES_STATS_GET(cycles_overhead); @@ -1838,12 +1731,11 @@ void builtin_monitorenter(java_objectheader *o) CYCLES_STATS_GET(cycles_end); CYCLES_STATS_COUNT(builtin_monitorenter, cycles_end - cycles_overhead); CYCLES_STATS_COUNT(builtin_overhead , cycles_overhead - cycles_start); -#endif /* defined(NATIVE_THREADS) */ } #endif -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* * Locks the class object - needed for static synchronized methods. */ @@ -1854,38 +1746,19 @@ void builtin_staticmonitorenter(classinfo *c) #endif -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) void builtin_monitorexit(java_objectheader *o) { #if defined(ENABLE_CYCLES_STATS) u8 cycles_start, cycles_end; #endif -#if !defined(NATIVE_THREADS) - int hashValue; - - ++blockInts; - - hashValue = MUTEX_HASH_VALUE(o); - if (mutexHashTable[hashValue].object == o) { - if (mutexHashTable[hashValue].mutex.count == 1 - && mutexHashTable[hashValue].mutex.muxWaiters != 0) - internal_unlock_mutex_for_object(o); - else - --mutexHashTable[hashValue].mutex.count; - - } else - internal_unlock_mutex_for_object(o); - - --blockInts; -#else /* defined(NATIVE_THREADS) */ CYCLES_STATS_GET(cycles_start); lock_monitor_exit((threadobject *) THREADOBJECT, o); CYCLES_STATS_GET(cycles_end); CYCLES_STATS_COUNT(builtin_monitorexit, cycles_end - cycles_start); -#endif /* defined(NATIVE_THREADS) */ } #endif @@ -2705,7 +2578,7 @@ java_arrayheader *builtin_clone_array(void *env, java_arrayheader *o) *******************************************************************************/ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) java_objectheader **builtin_asm_get_exceptionptrptr(void) { return builtin_get_exceptionptrptr(); diff --git a/src/vm/builtin.h b/src/vm/builtin.h index 2cde3bb90..eed044fdb 100644 --- a/src/vm/builtin.h +++ b/src/vm/builtin.h @@ -29,7 +29,7 @@ Changes: Edwin Steiner Christian Thalinger - $Id: builtin.h 4913 2006-05-14 14:02:51Z edwin $ + $Id: builtin.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -42,12 +42,8 @@ #include "arch.h" #include "toolbox/logging.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/jit/stacktrace.h" @@ -192,7 +188,7 @@ void builtin_trace_args(s8 a0, s8 a1, void builtin_displaymethodstop(methodinfo *m, s8 l, double d, float f); /* NOT AN OP */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) void builtin_monitorenter(java_objectheader *o); #define BUILTIN_monitorenter (functionptr) builtin_monitorenter void builtin_staticmonitorenter(classinfo *c); @@ -312,7 +308,7 @@ java_arrayheader *builtin_clone_array(void *env, java_arrayheader *o); /* this is a wrapper for calls from asmpart */ java_objectheader **builtin_asm_get_exceptionptrptr(void); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) static inline java_objectheader **builtin_get_exceptionptrptr(void); inline java_objectheader **builtin_get_exceptionptrptr(void) diff --git a/src/vm/builtintable.inc b/src/vm/builtintable.inc index e6f4ca829..90b095e25 100644 --- a/src/vm/builtintable.inc +++ b/src/vm/builtintable.inc @@ -28,13 +28,15 @@ Changes: - $Id: builtintable.inc 4357 2006-01-22 23:33:38Z twisti $ + $Id: builtintable.inc 4921 2006-05-15 14:24:36Z twisti $ */ #include "config.h" + #include "arch.h" + #include "vm/builtin.h" #include "vm/jit/jit.h" @@ -218,7 +220,7 @@ static builtintable_entry builtintable_internal[] = { NULL }, -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) { ICMD_MONITORENTER, BUILTIN_monitorenter, diff --git a/src/vm/class.c b/src/vm/class.c index 885396b01..cb296a06b 100644 --- a/src/vm/class.c +++ b/src/vm/class.c @@ -31,7 +31,7 @@ Christian Thalinger Edwin Steiner - $Id: class.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: class.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -46,13 +46,8 @@ #include "mm/memory.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# include "threads/green/locks.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/logging.h" @@ -236,7 +231,7 @@ classinfo *class_create_classinfo(utf *classname) if (classname != utf_not_named_yet) class_set_packagename(c); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) lock_init_object_lock(&c->object.header); #endif diff --git a/src/vm/classcache.c b/src/vm/classcache.c index 2af4fdb4f..bf4fb2100 100644 --- a/src/vm/classcache.c +++ b/src/vm/classcache.c @@ -28,7 +28,7 @@ Changes: Christian Thalinger - $Id: classcache.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: classcache.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -212,7 +212,7 @@ void classcache_print_statistics(FILE *file) { /* NOT synchronized! */ /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) # define CLASSCACHE_LOCK() builtin_monitorenter(lock_hashtable_classcache) # define CLASSCACHE_UNLOCK() builtin_monitorexit(lock_hashtable_classcache) #else @@ -226,7 +226,7 @@ void classcache_print_statistics(FILE *file) { hashtable hashtable_classcache; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static java_objectheader *lock_hashtable_classcache; #endif @@ -259,14 +259,12 @@ bool classcache_init(void) hashtable_create(&hashtable_classcache, CLASSCACHE_INIT_SIZE); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* create utf hashtable lock object */ lock_hashtable_classcache = NEW(java_objectheader); -# if defined(NATIVE_THREADS) lock_init_object_lock(lock_hashtable_classcache); -# endif #endif /* everything's ok */ diff --git a/src/vm/exceptions.c b/src/vm/exceptions.c index d2edfd2f4..161879f16 100644 --- a/src/vm/exceptions.c +++ b/src/vm/exceptions.c @@ -28,7 +28,7 @@ Changes: Edwin Steiner - $Id: exceptions.c 4879 2006-05-05 17:34:49Z edwin $ + $Id: exceptions.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -62,7 +62,7 @@ /* for raising exceptions from native methods *********************************/ -#if !defined(USE_THREADS) || !defined(NATIVE_THREADS) +#if !defined(ENABLE_THREADS) java_objectheader *_no_threads_exceptionptr = NULL; #endif @@ -1351,7 +1351,7 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp s4 i; classref_or_classinfo cr; classinfo *c; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) java_objectheader *o; #endif @@ -1439,7 +1439,7 @@ u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp } } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* is this method synchronized? */ if (issync) { diff --git a/src/vm/exceptions.h b/src/vm/exceptions.h index 7c99f4ea1..297408c19 100644 --- a/src/vm/exceptions.h +++ b/src/vm/exceptions.h @@ -28,7 +28,7 @@ Changes: Edwin Steiner - $Id: exceptions.h 4690 2006-03-27 11:37:46Z twisti $ + $Id: exceptions.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -51,13 +51,13 @@ typedef struct exceptionentry exceptionentry; #include "vm/method.h" -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) #define exceptionptr builtin_get_exceptionptrptr() #else #define exceptionptr &_no_threads_exceptionptr #endif -#if !defined(USE_THREADS) || !defined(NATIVE_THREADS) +#if !defined(ENABLE_THREADS) extern java_objectheader *_no_threads_exceptionptr; #endif diff --git a/src/vm/finalizer.c b/src/vm/finalizer.c index 00b0e24ad..00ad2ca20 100644 --- a/src/vm/finalizer.c +++ b/src/vm/finalizer.c @@ -28,7 +28,7 @@ Changes: - $Id: finalizer.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: finalizer.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -54,7 +54,7 @@ /* global variables ***********************************************************/ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static java_lang_VMThread *finalizer_vmthread; static java_objectheader *lock_finalizer_thread; #endif @@ -68,12 +68,10 @@ static java_objectheader *lock_finalizer_thread; bool finalizer_init(void) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) lock_finalizer_thread = NEW(java_objectheader); -# if defined(NATIVE_THREADS) lock_init_object_lock(lock_finalizer_thread); -# endif #endif /* everything's ok */ @@ -90,7 +88,7 @@ bool finalizer_init(void) *******************************************************************************/ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static void finalizer_thread(void) { while (true) { @@ -120,7 +118,7 @@ static void finalizer_thread(void) *******************************************************************************/ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) bool finalizer_start_thread(void) { java_lang_Thread *t; @@ -162,7 +160,7 @@ bool finalizer_start_thread(void) void finalizer_notify(void) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* get the lock on the finalizer lock object, so we can call wait */ builtin_monitorenter(lock_finalizer_thread); diff --git a/src/vm/global.h b/src/vm/global.h index b6acb0eb3..dd6b02d27 100644 --- a/src/vm/global.h +++ b/src/vm/global.h @@ -33,7 +33,7 @@ Joseph Wenninger Christian Thalinger - $Id: global.h 4908 2006-05-12 16:49:50Z edwin $ + $Id: global.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -88,13 +88,6 @@ typedef struct java_objectarray java_objectarray; #define CLASSPATH_LIBRARY_PATH CLASSPATH_LIBDIR "/classpath" -/* if we have threads disabled this one is not defined ************************/ - -#if !defined(USE_THREADS) -#define THREADSPECIFIC -#endif - - #define MAX_ALIGN 8 /* most generic alignment for JavaVM values */ @@ -204,7 +197,7 @@ typedef struct java_objectarray java_objectarray; struct java_objectheader { /* header for all objects */ struct _vftbl *vftbl; /* pointer to virtual function table */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) struct lock_record_t *monitorPtr; #endif }; @@ -295,7 +288,7 @@ struct java_objectarray { /* Synchronization ************************************************************/ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void compiler_lock(); void compiler_unlock(); #endif diff --git a/src/vm/hashtable.c b/src/vm/hashtable.c index aae8ee778..a15d12301 100644 --- a/src/vm/hashtable.c +++ b/src/vm/hashtable.c @@ -30,7 +30,7 @@ Andreas Krall Christian Thalinger - $Id: hashtable.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: hashtable.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -40,10 +40,8 @@ #include "mm/memory.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/hashtable.h" @@ -60,8 +58,7 @@ void hashtable_create(hashtable *hash, u4 size) { /* initialize locking pointer */ -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* We need to seperately allocate a java_objectheader here, as we need to store the lock object in the new hashtable if it's resized. Otherwise we get an IllegalMonitorStateException. */ @@ -69,7 +66,6 @@ void hashtable_create(hashtable *hash, u4 size) hash->header = NEW(java_objectheader); lock_init_object_lock(hash->header); -# endif #endif /* set initial hash values */ @@ -99,7 +95,7 @@ hashtable *hashtable_resize(hashtable *hash, u4 size) hashtable_create(newhash, size); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* We need to store the old lock object in the new hashtable. Otherwise we get an IllegalMonitorStateException. */ @@ -120,6 +116,8 @@ hashtable *hashtable_resize(hashtable *hash, u4 size) Simply frees the hashtable. + ATTENTION: It does NOT free the lock object! + *******************************************************************************/ void hashtable_free(hashtable *hash) diff --git a/src/vm/hashtable.h b/src/vm/hashtable.h index ee66cb9ef..7f718c258 100644 --- a/src/vm/hashtable.h +++ b/src/vm/hashtable.h @@ -28,7 +28,7 @@ Changes: Christian Thalinger - $Id: hashtable.h 4900 2006-05-11 09:18:28Z twisti $ + $Id: hashtable.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -100,7 +100,7 @@ hashtable.ptr-->+-------------------+ /* hashtable ******************************************************************/ struct hashtable { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) java_objectheader *header; /* required for locking */ #endif u4 size; /* current size of the hashtable */ diff --git a/src/vm/initialize.c b/src/vm/initialize.c index ac3bd9d31..1833a459e 100644 --- a/src/vm/initialize.c +++ b/src/vm/initialize.c @@ -30,7 +30,7 @@ Andreas Krall Christian Thalinger - $Id: initialize.c 4559 2006-03-05 23:24:50Z twisti $ + $Id: initialize.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -74,7 +74,7 @@ bool initialize_class(classinfo *c) if (!makeinitializations) return true; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* enter a monitor on the class */ builtin_monitorenter((java_objectheader *) c); @@ -84,7 +84,7 @@ bool initialize_class(classinfo *c) pass the monitor, is currently initalizing this class */ if (CLASS_IS_OR_ALMOST_INITIALIZED(c)) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit((java_objectheader *) c); #endif @@ -97,7 +97,7 @@ bool initialize_class(classinfo *c) if (c->state & CLASS_ERROR) { *exceptionptr = new_noclassdeffounderror(c->name); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit((java_objectheader *) c); #endif @@ -124,7 +124,7 @@ bool initialize_class(classinfo *c) c->state &= ~CLASS_INITIALIZING; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* leave the monitor */ builtin_monitorexit((java_objectheader *) c); @@ -145,9 +145,6 @@ static bool initialize_class_intern(classinfo *c) { methodinfo *m; java_objectheader *xptr; -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - int b; -#endif /* maybe the class is not already linked */ @@ -199,20 +196,10 @@ static bool initialize_class_intern(classinfo *c) log_message_class("Starting static class initializer for class: ", c); #endif -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - b = blockInts; - blockInts = 0; -#endif - /* now call the initializer */ (void) vm_call_method(m, NULL); -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - assert(blockInts == 0); - blockInts = b; -#endif - /* we have an exception or error */ xptr = *exceptionptr; diff --git a/src/vm/jit/allocator/simplereg.c b/src/vm/jit/allocator/simplereg.c index e03bcef07..a814a092a 100644 --- a/src/vm/jit/allocator/simplereg.c +++ b/src/vm/jit/allocator/simplereg.c @@ -32,7 +32,7 @@ Michael Starzinger Edwin Steiner - $Id: simplereg.c 4761 2006-04-12 22:16:59Z edwin $ + $Id: simplereg.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -1341,6 +1341,32 @@ static void allocate_scratch_registers(jitdata *jd) case ICMD_IF_LCMPGT: case ICMD_IF_LCMPLE: + case ICMD_IF_FCMPEQ: + case ICMD_IF_FCMPNE: + + case ICMD_IF_FCMPL_LT: + case ICMD_IF_FCMPL_GE: + case ICMD_IF_FCMPL_GT: + case ICMD_IF_FCMPL_LE: + + case ICMD_IF_FCMPG_LT: + case ICMD_IF_FCMPG_GE: + case ICMD_IF_FCMPG_GT: + case ICMD_IF_FCMPG_LE: + + case ICMD_IF_DCMPEQ: + case ICMD_IF_DCMPNE: + + case ICMD_IF_DCMPL_LT: + case ICMD_IF_DCMPL_GE: + case ICMD_IF_DCMPL_GT: + case ICMD_IF_DCMPL_LE: + + case ICMD_IF_DCMPG_LT: + case ICMD_IF_DCMPG_GE: + case ICMD_IF_DCMPG_GT: + case ICMD_IF_DCMPG_LE: + case ICMD_IF_ACMPEQ: case ICMD_IF_ACMPNE: diff --git a/src/vm/jit/alpha/asmpart.S b/src/vm/jit/alpha/asmpart.S index 8e4234ca1..9ae20fda8 100644 --- a/src/vm/jit/alpha/asmpart.S +++ b/src/vm/jit/alpha/asmpart.S @@ -31,7 +31,7 @@ Christian Thalinger Edwin Steiner - $Id: asmpart.S 4896 2006-05-10 13:12:06Z twisti $ + $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $ */ @@ -243,7 +243,7 @@ asm_call_jit_compiler: /* directly to the caller (ra). */ L_asm_call_jit_compiler_exception: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) subq sp,2*8,sp stq ra,0*8(sp) /* save return address (xpc) */ jsr ra,builtin_asm_get_exceptionptrptr @@ -503,7 +503,7 @@ L_asm_wrapper_patcher_exception: L_asm_wrapper_patcher_exception_load_gp: ldgp gp,0(itmp1) /* itmp3 == gp, load the current gp */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) subq sp,3*8,sp stq xpc,0*8(sp) /* save return address (xpc) */ stq ra,1*8(sp) @@ -883,7 +883,7 @@ _crit_end: .data asm_criticalsections: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) .quad _crit_begin .quad _crit_end .quad _crit_restart diff --git a/src/vm/jit/alpha/codegen.c b/src/vm/jit/alpha/codegen.c index 537d3360f..4e0bb0d85 100644 --- a/src/vm/jit/alpha/codegen.c +++ b/src/vm/jit/alpha/codegen.c @@ -32,7 +32,7 @@ Christian Ullrich Edwin Steiner - $Id: codegen.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: codegen.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -124,7 +124,7 @@ bool codegen(jitdata *jd) stackframesize = rd->memuse + savedregs_num; -#if defined(USE_THREADS) /* space to save argument of monitor_enter */ +#if defined(ENABLE_THREADS) /* space to save argument of monitor_enter */ if (checksync && (m->flags & ACC_SYNCHRONIZED)) stackframesize++; #endif @@ -138,7 +138,7 @@ bool codegen(jitdata *jd) (void) dseg_addaddress(cd, m); /* MethodPointer */ (void) dseg_adds4(cd, stackframesize * 8); /* FrameSize */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* IsSync contains the offset relative to the stack pointer for the argument of monitor_exit used in the exception handler. Since the offset could be zero and give a wrong meaning of the flag it is @@ -241,7 +241,7 @@ bool codegen(jitdata *jd) /* call monitorenter function */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { /* stack offset for monitor argument */ @@ -2952,7 +2952,7 @@ nowperformreturn: } #endif -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { M_ALD(rd->argintregs[0], REG_SP, rd->memuse * 8); @@ -3328,7 +3328,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); @@ -3418,14 +3418,14 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); M_ALD(REG_ITMP3, REG_PV, disp); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); /* if (s1 != REG_ITMP1) { */ /* M_ILD(REG_ITMP1, REG_ITMP3, OFFSET(vftbl_t, baseval)); */ /* M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); */ - /* #if defined(USE_THREADS) && defined(NATIVE_THREADS) */ + /* #if defined(ENABLE_THREADS) */ /* codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase); */ /* #endif */ /* M_ISUB(REG_ITMP2, REG_ITMP1, REG_ITMP2); */ @@ -3435,7 +3435,7 @@ gen_method: M_ISUB(REG_ITMP2, REG_ITMP3, REG_ITMP2); M_ALD(REG_ITMP3, REG_PV, disp); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif /* } */ @@ -3513,7 +3513,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); @@ -3611,13 +3611,13 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); @@ -3850,7 +3850,7 @@ gen_method: /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* create a virtual java_objectheader */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ @@ -4292,7 +4292,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* check for exception */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) disp = dseg_addaddress(cd, builtin_get_exceptionptrptr); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); @@ -4373,7 +4373,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* create a virtual java_objectheader */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ diff --git a/src/vm/jit/alpha/freebsd/md-os.c b/src/vm/jit/alpha/freebsd/md-os.c index 53d5f5fe8..61eebf5f6 100644 --- a/src/vm/jit/alpha/freebsd/md-os.c +++ b/src/vm/jit/alpha/freebsd/md-os.c @@ -28,7 +28,7 @@ Changes: - $Id: md-os.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: md-os.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -97,7 +97,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *_uc) { mcontext_t *_mc; diff --git a/src/vm/jit/alpha/linux/md-os.c b/src/vm/jit/alpha/linux/md-os.c index e1a779445..412ac5430 100644 --- a/src/vm/jit/alpha/linux/md-os.c +++ b/src/vm/jit/alpha/linux/md-os.c @@ -28,7 +28,7 @@ Changes: - $Id: md-os.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: md-os.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -95,7 +95,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *_uc) { mcontext_t *_mc; diff --git a/src/vm/jit/asmpart.h b/src/vm/jit/asmpart.h index 21d8957d8..d23da4b69 100644 --- a/src/vm/jit/asmpart.h +++ b/src/vm/jit/asmpart.h @@ -30,7 +30,7 @@ Changes: Christian Thalinger Edwin Steiner - $Id: asmpart.h 4920 2006-05-15 13:13:22Z twisti $ + $Id: asmpart.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -42,13 +42,9 @@ #include "vm/types.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# include "threads/native/critical.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" +# include "threads/native/critical.h" #endif #include "vm/global.h" @@ -150,7 +146,7 @@ void asm_replacement_in(executionstate *es); void *asm_switchstackandcall(void *stack, void *func, void **stacktopsave, void * p); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) extern critical_section_node_t asm_criticalsections; #endif @@ -163,12 +159,6 @@ void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out); void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out); #endif - -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) -void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop); -u1* asm_initialize_thread_stack(void *func, u1 *stack); -#endif - /* cache flush function */ void asm_cacheflush(u1 *addr, s4 nbytes); diff --git a/src/vm/jit/code.c b/src/vm/jit/code.c index 434188862..6323aeb80 100644 --- a/src/vm/jit/code.c +++ b/src/vm/jit/code.c @@ -91,7 +91,7 @@ codeinfo *code_codeinfo_new(methodinfo *m) int code_get_sync_slot_count(codeinfo *code) { -#ifdef USE_THREADS +#ifdef ENABLE_THREADS int count; assert(code); @@ -117,11 +117,11 @@ int code_get_sync_slot_count(codeinfo *code) return count; -#else /* !USE_THREADS */ +#else /* !ENABLE_THREADS */ return 0; -#endif /* USE_THREADS */ +#endif /* ENABLE_THREADS */ } /* code_get_stack_frame_size *************************************************** diff --git a/src/vm/jit/codegen-common.c b/src/vm/jit/codegen-common.c index 6ef6c3a74..95c0399a5 100644 --- a/src/vm/jit/codegen-common.c +++ b/src/vm/jit/codegen-common.c @@ -48,7 +48,7 @@ memory. All functions writing values into the data area return the offset relative the begin of the code area (start of procedure). - $Id: codegen-common.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: codegen-common.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -76,12 +76,8 @@ #include "native/jni.h" #include "native/native.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/exceptions.h" @@ -215,7 +211,7 @@ void codegen_setup(jitdata *jd) cd->maxstack = m->maxstack; cd->maxlocals = m->maxlocals; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) cd->threadcritcurrent.next = NULL; cd->threadcritcount = 0; #endif @@ -596,7 +592,7 @@ void codegen_finish(jitdata *jd) mcodelen = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) extralen = sizeof(critical_section_node_t) * cd->threadcritcount; #else extralen = 0; @@ -726,7 +722,7 @@ void codegen_finish(jitdata *jd) #endif -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) { critical_section_node_t *n = (critical_section_node_t *) ((ptrint) code->mcode + alignedlen); s4 i; @@ -1113,7 +1109,7 @@ s4 codegen_reg_of_var(registerdata *rd, u2 opcode, stackptr v, s4 tempregnum) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void codegen_threadcritrestart(codegendata *cd, int offset) { cd->threadcritcurrent.mcoderestart = offset; diff --git a/src/vm/jit/codegen-common.h b/src/vm/jit/codegen-common.h index 036219adb..1f851698c 100644 --- a/src/vm/jit/codegen-common.h +++ b/src/vm/jit/codegen-common.h @@ -29,7 +29,7 @@ Changes: Christian Ullrich Edwin Steiner - $Id: codegen-common.h 4908 2006-05-12 16:49:50Z edwin $ + $Id: codegen-common.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -199,7 +199,7 @@ void removenativestub(u1 *stub); s4 codegen_reg_of_var(registerdata *rd, u2 opcode, stackptr v, s4 tempregnum); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void codegen_threadcritrestart(codegendata *cd, int offset); void codegen_threadcritstart(codegendata *cd, int offset); void codegen_threadcritstop(codegendata *cd, int offset); diff --git a/src/vm/jit/i386/asmpart.S b/src/vm/jit/i386/asmpart.S index 7beec1f2d..4abda6356 100644 --- a/src/vm/jit/i386/asmpart.S +++ b/src/vm/jit/i386/asmpart.S @@ -31,7 +31,7 @@ Changes: Joseph Wenninger Edwin Steiner - $Id: asmpart.S 4818 2006-04-24 00:19:06Z edwin $ + $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $ */ @@ -323,7 +323,7 @@ L_call_method: jmp *v0 /* ...and now call the new method */ L_asm_call_jit_compiler_exception: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) call builtin_asm_get_exceptionptrptr mov v0,itmp2 /* v0 == itmp1 */ #else @@ -534,7 +534,7 @@ asm_wrapper_patcher: L_asm_wrapper_patcher_exception: add $((6+2+4)*4+sizestackframeinfo),sp /* remove stack frame, keep ra */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) call builtin_asm_get_exceptionptrptr mov v0,itmp2 #else @@ -809,7 +809,7 @@ _crit_end2: .data asm_criticalsections: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) #if 0 .long _crit_begin1 .long _crit_end1 diff --git a/src/vm/jit/i386/codegen.c b/src/vm/jit/i386/codegen.c index c6f59fd70..9288991f4 100644 --- a/src/vm/jit/i386/codegen.c +++ b/src/vm/jit/i386/codegen.c @@ -31,7 +31,7 @@ Christian Ullrich Edwin Steiner - $Id: codegen.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: codegen.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -131,7 +131,7 @@ bool codegen(jitdata *jd) stackframesize = rd->memuse + savedregs_num; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* space to save argument of monitor_enter */ if (checksync && (m->flags & ACC_SYNCHRONIZED)) { @@ -154,7 +154,7 @@ bool codegen(jitdata *jd) (void) dseg_addaddress(cd, m); /* MethodPointer */ (void) dseg_adds4(cd, stackframesize * 4); /* FrameSize */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* IsSync contains the offset relative to the stack pointer for the argument of monitor_exit used in the exception handler. Since the offset could be zero and give a wrong meaning of the flag it is @@ -327,7 +327,7 @@ bool codegen(jitdata *jd) /* call monitorenter function */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { s1 = rd->memuse; @@ -593,7 +593,7 @@ bool codegen(jitdata *jd) case ICMD_INLINE_START: { insinfo_inline *insinfo = (insinfo_inline *) iptr->target; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (insinfo->synchronize) { /* add monitor enter code */ if (insinfo->method->flags & ACC_STATIC) { @@ -629,7 +629,7 @@ bool codegen(jitdata *jd) dseg_addlinenumber_inline_end(cd, iptr); dseg_addlinenumber(cd, iptr->line); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (insinfo->synchronize) { /* add monitor exit code */ if (insinfo->method->flags & ACC_STATIC) { @@ -4171,7 +4171,7 @@ nowperformreturn: } #endif /* !defined(NDEBUG) */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { M_ALD(REG_ITMP2, REG_SP, rd->memuse * 4); @@ -4581,7 +4581,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); @@ -4710,7 +4710,7 @@ gen_method: } i386_mov_imm_reg(cd, (ptrint) supervftbl, REG_ITMP3); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif i386_mov_membase32_reg(cd, REG_ITMP2, @@ -4720,7 +4720,7 @@ gen_method: /* if (s1 != REG_ITMP1) { */ /* i386_mov_membase_reg(cd, REG_ITMP3, OFFSET(vftbl_t, baseval), REG_ITMP1); */ /* i386_mov_membase_reg(cd, REG_ITMP3, OFFSET(vftbl_t, diffval), REG_ITMP3); */ - /* #if defined(USE_THREADS) && defined(NATIVE_THREADS) */ + /* #if defined(ENABLE_THREADS) */ /* codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); */ /* #endif */ /* i386_alu_reg_reg(cd, ALU_SUB, REG_ITMP1, REG_ITMP2); */ @@ -4734,7 +4734,7 @@ gen_method: i386_mov_membase_reg(cd, REG_ITMP3, OFFSET(vftbl_t, diffval), REG_ITMP3); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif /* } */ @@ -4811,7 +4811,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif @@ -4940,7 +4940,7 @@ gen_method: } i386_mov_imm_reg(cd, (ptrint) supervftbl, REG_ITMP2); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif i386_mov_membase_reg(cd, REG_ITMP1, @@ -4952,7 +4952,7 @@ gen_method: i386_mov_membase_reg(cd, REG_ITMP2, OFFSET(vftbl_t, baseval), REG_ITMP2); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif i386_alu_reg_reg(cd, ALU_SUB, REG_ITMP2, REG_ITMP1); @@ -5199,7 +5199,7 @@ gen_method: /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ off = dseg_addaddress(cd, NULL); /* vftbl */ @@ -5327,7 +5327,7 @@ u1 *createcompilerstub(methodinfo *m) *******************************************************************************/ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* this way we can call the function directly with a memory call */ static java_objectheader **(*callgetexceptionptrptr)() = builtin_get_exceptionptrptr; @@ -5591,7 +5591,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* check for exception */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* i386_call_mem(cd, (ptrint) builtin_get_exceptionptrptr); */ i386_call_mem(cd, (ptrint) &callgetexceptionptrptr); #else @@ -5623,7 +5623,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* handle exception */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) i386_push_reg(cd, REG_ITMP2); /* i386_call_mem(cd, (ptrint) builtin_get_exceptionptrptr); */ i386_call_mem(cd, (ptrint) &callgetexceptionptrptr); @@ -5671,7 +5671,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* create a virtual java_objectheader */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ diff --git a/src/vm/jit/i386/freebsd/md-os.c b/src/vm/jit/i386/freebsd/md-os.c index 583c9a0ed..ccafbff19 100644 --- a/src/vm/jit/i386/freebsd/md-os.c +++ b/src/vm/jit/i386/freebsd/md-os.c @@ -28,7 +28,7 @@ Changes: - $Id: md-os.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: md-os.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -105,7 +105,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *uc) { void *critical; diff --git a/src/vm/jit/i386/linux/md-os.c b/src/vm/jit/i386/linux/md-os.c index 6665ee1bd..8d82836a7 100644 --- a/src/vm/jit/i386/linux/md-os.c +++ b/src/vm/jit/i386/linux/md-os.c @@ -28,7 +28,7 @@ Changes: - $Id: md-os.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: md-os.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -108,7 +108,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *uc) { void *critical; diff --git a/src/vm/jit/inline/inline.c b/src/vm/jit/inline/inline.c index 5bd60fbc8..9d7a9dadf 100644 --- a/src/vm/jit/inline/inline.c +++ b/src/vm/jit/inline/inline.c @@ -28,7 +28,7 @@ Changes: - $Id: inline.c 4897 2006-05-10 15:09:49Z edwin $ + $Id: inline.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -43,6 +43,7 @@ #include "mm/memory.h" #include "toolbox/logging.h" +#include "vm/builtin.h" #include "vm/global.h" #include "vm/options.h" #include "vm/statistics.h" @@ -61,12 +62,8 @@ #include "vm/jit/verify/typecheck.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #ifndef NDEBUG @@ -233,7 +230,7 @@ static bool inline_jit_compile(inline_node *iln) m = iln->m; assert(m); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* enter a monitor on the method */ builtin_monitorenter((java_objectheader *) m); #endif @@ -296,7 +293,7 @@ static bool inline_jit_compile(inline_node *iln) #endif return_r: -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* leave the monitor */ builtin_monitorexit((java_objectheader *) m ); #endif diff --git a/src/vm/jit/intrp/asmpart.c b/src/vm/jit/intrp/asmpart.c index 05ce77d4a..3c0a774c3 100644 --- a/src/vm/jit/intrp/asmpart.c +++ b/src/vm/jit/intrp/asmpart.c @@ -29,7 +29,7 @@ Changes: - $Id: asmpart.c 4856 2006-04-28 00:46:39Z edwin $ + $Id: asmpart.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -234,24 +234,16 @@ void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out { s4 sbv, sdv, sv; -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) compiler_lock(); -#else - intsDisable(); -#endif #endif sbv = super->baseval; sdv = super->diffval; sv = sub->baseval; -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) compiler_unlock(); -#else - intsRestore(); -#endif #endif out->super_baseval = sbv; diff --git a/src/vm/jit/intrp/codegen.c b/src/vm/jit/intrp/codegen.c index b42066fef..65e041734 100644 --- a/src/vm/jit/intrp/codegen.c +++ b/src/vm/jit/intrp/codegen.c @@ -29,7 +29,7 @@ Changes: Edwin Steiner - $Id: codegen.c 4863 2006-04-30 16:17:44Z edwin $ + $Id: codegen.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -239,7 +239,7 @@ struct builtin_gen builtin_gen_table[] = { {BUILTIN_newarray_double, gen_NEWARRAY_DOUBLE, }, {BUILTIN_arrayinstanceof, gen_ARRAYINSTANCEOF, }, -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) {BUILTIN_monitorenter, gen_MONITORENTER, }, {BUILTIN_monitorexit, gen_MONITOREXIT, }, #endif @@ -315,7 +315,7 @@ bool intrp_codegen(jitdata *jd) (void) dseg_addaddress(cd, m); /* MethodPointer */ (void) dseg_adds4(cd, m->maxlocals * SIZEOF_VOID_P); /* FrameSize */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) (void) dseg_adds4(cd, 1); /* IsSync */ else @@ -348,7 +348,7 @@ bool intrp_codegen(jitdata *jd) gen_BBSTART; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { if (m->flags & ACC_STATIC) gen_ACONST(cd, (java_objectheader *) m->class); @@ -1539,7 +1539,7 @@ bool intrp_codegen(jitdata *jd) case ICMD_IRETURN: /* ..., retvalue ==> ... */ case ICMD_FRETURN: /* ..., retvalue ==> ... */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { if (m->flags & ACC_STATIC) { gen_ACONST(cd, (java_objectheader *) m->class); @@ -1558,7 +1558,7 @@ bool intrp_codegen(jitdata *jd) case ICMD_LRETURN: /* ..., retvalue ==> ... */ case ICMD_DRETURN: /* ..., retvalue ==> ... */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { if (m->flags & ACC_STATIC) { gen_ACONST(cd, (java_objectheader *) m->class); @@ -1576,7 +1576,7 @@ bool intrp_codegen(jitdata *jd) case ICMD_RETURN: /* ... ==> ... */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { if (m->flags & ACC_STATIC) { gen_ACONST(cd, (java_objectheader *) m->class); diff --git a/src/vm/jit/intrp/dynamic-super.c b/src/vm/jit/intrp/dynamic-super.c index c54f696ad..d8e80f48f 100644 --- a/src/vm/jit/intrp/dynamic-super.c +++ b/src/vm/jit/intrp/dynamic-super.c @@ -32,7 +32,7 @@ Changes: - $Id: dynamic-super.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: dynamic-super.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -46,12 +46,8 @@ #include "mm/memory.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/hashtable.h" @@ -110,7 +106,7 @@ typedef struct superstart { static hashtable hashtable_patchersupers; #define HASHTABLE_PATCHERSUPERS_BITS 14 -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static java_objectheader *lock_hashtable_patchersupers; #endif @@ -124,7 +120,7 @@ typedef struct superreuse { static hashtable hashtable_superreuse; #define HASHTABLE_SUPERREUSE_BITS 14 -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static java_objectheader *lock_hashtable_superreuse; #endif @@ -373,12 +369,12 @@ static void superreuse_insert(u1 *code, u4 length) superreuse *sr = NEW(superreuse); sr->code = code; sr->length = length; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(lock_hashtable_superreuse); #endif sr->next = *listp; *listp = sr; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(lock_hashtable_superreuse); #endif count_supers_unique++; @@ -411,7 +407,7 @@ void patchersuper_rewrite(Inst *p) superstart **listp = (superstart **)&hashtable_patchersupers.ptr[slot]; superstart *ss; count_patchers_exec++; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(lock_hashtable_patchersupers); #endif for (; ss=*listp, ss!=NULL; listp = &(ss->next)) { @@ -430,7 +426,7 @@ void patchersuper_rewrite(Inst *p) break; } } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(lock_hashtable_patchersupers); #endif } @@ -441,12 +437,12 @@ static void hashtable_patchersupers_insert(superstart *ss) u4 slot = ((key + (key>>HASHTABLE_PATCHERSUPERS_BITS)) & ((1<next = (superstart *)*listp; *listp = (void *)ss; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(lock_hashtable_patchersupers); #endif count_patchers_ins++; @@ -710,15 +706,13 @@ void dynamic_super_init(void) if (opt_no_replication) hashtable_create(&hashtable_superreuse, 1<_global_sp)) -#else /* defined(USE_THREADS) && defined(NATIVE_THREADS) */ +#else /* defined(ENABLE_THREADS) */ #define MAX_STACK_SIZE 128*1024 static char stack[MAX_STACK_SIZE]; @@ -120,7 +120,7 @@ static char stack[MAX_STACK_SIZE]; static Cell *_global_sp = (Cell *)(stack+MAX_STACK_SIZE); #define global_sp _global_sp -#endif /* defined(USE_THREADS) && defined(NATIVE_THREADS) */ +#endif /* defined(ENABLE_THREADS) */ #define CLEAR_global_sp (global_sp=NULL) diff --git a/src/vm/jit/intrp/java.vmg b/src/vm/jit/intrp/java.vmg index d520ad1ff..ca87e61c0 100644 --- a/src/vm/jit/intrp/java.vmg +++ b/src/vm/jit/intrp/java.vmg @@ -1243,7 +1243,7 @@ ARRAYINSTANCEOF ( aRef aClass -- iResult ) MONITORENTER ( aRef -- ) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* CHECK_NULL_PTR(aRef); is now done explicitly */ builtin_monitorenter(aRef); #endif @@ -1251,7 +1251,7 @@ MONITORENTER ( aRef -- ) MONITOREXIT ( aRef -- ) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* CHECK_NULL_PTR(aRef); cannot happen */ builtin_monitorexit(aRef); #endif diff --git a/src/vm/jit/jit.c b/src/vm/jit/jit.c index a2428759f..4fbfca20a 100644 --- a/src/vm/jit/jit.c +++ b/src/vm/jit/jit.c @@ -31,7 +31,7 @@ Christian Thalinger Christian Ullrich - $Id: jit.c 4834 2006-04-25 12:25:43Z edwin $ + $Id: jit.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -78,12 +78,8 @@ #include "vm/jit/verify/typecheck.h" #include "vm/rt-timing.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif @@ -731,10 +727,53 @@ int jcommandsize[256] = { #define ICMD_LMULPOW2 215 1, +#define ICMD_IF_FCMPEQ 216 + 1, +#define ICMD_IF_FCMPNE 217 + +#define ICMD_IF_FCMPL_LT 218 + 1, +#define ICMD_IF_FCMPL_GE 219 + 1, +#define ICMD_IF_FCMPL_GT 220 + 1, +#define ICMD_IF_FCMPL_LE 221 + 1, + +#define ICMD_IF_FCMPG_LT 222 + 1, +#define ICMD_IF_FCMPG_GE 223 + 1, +#define ICMD_IF_FCMPG_GT 224 + 1, +#define ICMD_IF_FCMPG_LE 225 + 1, + +#define ICMD_IF_DCMPEQ 226 + 1, +#define ICMD_IF_DCMPNE 227 + 1, + +#define ICMD_IF_DCMPL_LT 228 + 1, +#define ICMD_IF_DCMPL_GE 229 + 1, +#define ICMD_IF_DCMPL_GT 230 + 1, +#define ICMD_IF_DCMPL_LE 231 + 1, + +#define ICMD_IF_DCMPG_LT 232 + 1, +#define ICMD_IF_DCMPG_GE 233 + 1, +#define ICMD_IF_DCMPG_GT 234 + 1, +#define ICMD_IF_DCMPG_LE 235 + 1, + /* unused */ - 1,1,1,1, - 1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1 }; @@ -958,10 +997,32 @@ char *icmd_names[256] = { "IMULPOW2 ", /* 214 */ "LMULPOW2 ", /* 215 */ - "UNDEF216", "UNDEF217", "UNDEF218", "UNDEF219", "UNDEF220", - "UNDEF221", "UNDEF222", "UNDEF223", "UNDEF224", "UNDEF225", - "UNDEF226", "UNDEF227", "UNDEF228", "UNDEF229", "UNDEF230", - "UNDEF231", "UNDEF232", "UNDEF233", "UNDEF234", "UNDEF235", + "IF_FCMPEQ ", /* 216 */ + "IF_FCMPNE ", /* 217 */ + + "IF_FCMPL_LT ", /* 218 */ + "IF_FCMPL_GE ", /* 219 */ + "IF_FCMPL_GT ", /* 220 */ + "IF_FCMPL_LE ", /* 221 */ + + "IF_FCMPG_LT ", /* 222 */ + "IF_FCMPG_GE ", /* 223 */ + "IF_FCMPG_GT ", /* 224 */ + "IF_FCMPG_LE ", /* 225 */ + + "IF_DCMPEQ ", /* 226 */ + "IF_DCMPNE ", /* 227 */ + + "IF_DCMPL_LT ", /* 228 */ + "IF_DCMPL_GE ", /* 229 */ + "IF_DCMPL_GT ", /* 230 */ + "IF_DCMPL_LE ", /* 231 */ + + "IF_DCMPG_LT ", /* 232 */ + "IF_DCMPG_GE ", /* 233 */ + "IF_DCMPG_GT ", /* 234 */ + "IF_DCMPG_LE ", /* 235 */ + "UNDEF236", "UNDEF237", "UNDEF238", "UNDEF239", "UNDEF240", "UNDEF241", "UNDEF242", "UNDEF243", "UNDEF244", "UNDEF245", "UNDEF246", "UNDEF247", "UNDEF248", "UNDEF249", "UNDEF250", @@ -1353,7 +1414,7 @@ u1 *jit_compile(methodinfo *m) return m->code->entrypoint; } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* enter a monitor on the method */ builtin_monitorenter((java_objectheader *) m); @@ -1362,7 +1423,7 @@ u1 *jit_compile(methodinfo *m) /* if method has been already compiled return immediately */ if (m->code) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit((java_objectheader *) m); #endif @@ -1440,7 +1501,7 @@ u1 *jit_compile(methodinfo *m) #endif -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* leave the monitor */ builtin_monitorexit((java_objectheader *) m); diff --git a/src/vm/jit/jit.h b/src/vm/jit/jit.h index 0430831cc..9f19c47e6 100644 --- a/src/vm/jit/jit.h +++ b/src/vm/jit/jit.h @@ -30,7 +30,7 @@ Changes: Christian Thalinger Edwin Steiner - $Id: jit.h 4863 2006-04-30 16:17:44Z edwin $ + $Id: jit.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -945,29 +945,46 @@ extern int jcommandsize[256]; /* UNDEF203 */ #define ICMD_IASTORECONST 204 - #define ICMD_LASTORECONST 205 - #define ICMD_FASTORECONST 206 - #define ICMD_DASTORECONST 207 - #define ICMD_AASTORECONST 208 - #define ICMD_BASTORECONST 209 - #define ICMD_CASTORECONST 210 - #define ICMD_SASTORECONST 211 #define ICMD_PUTSTATICCONST 212 - #define ICMD_PUTFIELDCONST 213 #define ICMD_IMULPOW2 214 - #define ICMD_LMULPOW2 215 +#define ICMD_IF_FCMPEQ 216 +#define ICMD_IF_FCMPNE 217 + +#define ICMD_IF_FCMPL_LT 218 +#define ICMD_IF_FCMPL_GE 219 +#define ICMD_IF_FCMPL_GT 220 +#define ICMD_IF_FCMPL_LE 221 + +#define ICMD_IF_FCMPG_LT 222 +#define ICMD_IF_FCMPG_GE 223 +#define ICMD_IF_FCMPG_GT 224 +#define ICMD_IF_FCMPG_LE 225 + +#define ICMD_IF_DCMPEQ 226 +#define ICMD_IF_DCMPNE 227 + +#define ICMD_IF_DCMPL_LT 228 +#define ICMD_IF_DCMPL_GE 229 +#define ICMD_IF_DCMPL_GT 230 +#define ICMD_IF_DCMPL_LE 231 + +#define ICMD_IF_DCMPG_LT 232 +#define ICMD_IF_DCMPG_GE 233 +#define ICMD_IF_DCMPG_GT 234 +#define ICMD_IF_DCMPG_LE 235 + #define ICMD_INLINE_START 251 /* instruction before inlined method */ #define ICMD_INLINE_END 252 /* instruction after inlined method */ #define ICMD_INLINE_GOTO 253 /* jump to caller of inlined method */ diff --git a/src/vm/jit/mips/asmpart.S b/src/vm/jit/mips/asmpart.S index 8046b69c8..90300d649 100644 --- a/src/vm/jit/mips/asmpart.S +++ b/src/vm/jit/mips/asmpart.S @@ -29,7 +29,7 @@ Changes: Christian Thalinger Edwin Steiner - $Id: asmpart.S 4904 2006-05-11 13:09:53Z twisti $ + $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $ */ @@ -301,7 +301,7 @@ asm_call_jit_compiler: /* directly to the caller (ra). */ L_asm_call_jit_compiler_exception: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) aaddiu sp,sp,-2*8 ast ra,0*8(sp) jal builtin_asm_get_exceptionptrptr @@ -520,7 +520,7 @@ L_asm_wrapper_patcher_exception: ald xpc,((5+2+16+22+4)*8+sizestackframeinfo)(sp) /* RA to JIT is xpc */ aaddiu sp,sp,((6+2+16+22+4)*8+sizestackframeinfo) /* remove stack frame */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) daddiu sp,sp,-4*8 sd xpc,0*8(sp) sd ra,1*8(sp) @@ -888,7 +888,7 @@ _crit_end: .data asm_criticalsections: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) .dword _crit_begin .dword _crit_end .dword _crit_restart diff --git a/src/vm/jit/mips/codegen.c b/src/vm/jit/mips/codegen.c index 0e3bc80f7..417b66674 100644 --- a/src/vm/jit/mips/codegen.c +++ b/src/vm/jit/mips/codegen.c @@ -35,7 +35,7 @@ This module generates MIPS machine code for a sequence of intermediate code commands (ICMDs). - $Id: codegen.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: codegen.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -118,7 +118,9 @@ bool codegen(jitdata *jd) parentargs_base = rd->memuse + savedregs_num; -#if defined(USE_THREADS) /* space to save argument of monitor_enter */ +#if defined(ENABLE_THREADS) + /* space to save argument of monitor_enter */ + if (checksync && (m->flags & ACC_SYNCHRONIZED)) parentargs_base++; #endif @@ -136,7 +138,7 @@ bool codegen(jitdata *jd) (void) dseg_addaddress(cd, m); /* MethodPointer */ (void) dseg_adds4(cd, parentargs_base * 8); /* FrameSize */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* IsSync contains the offset relative to the stack pointer for the argument of monitor_exit used in the exception handler. Since the offset could be zero and give a wrong meaning of the flag it is @@ -241,7 +243,7 @@ bool codegen(jitdata *jd) /* call monitorenter function */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { /* stack offset for monitor argument */ @@ -2881,7 +2883,7 @@ nowperformreturn: M_LDA(REG_SP, REG_SP, 3 * 8); } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { disp = dseg_addaddress(cd, (void *) builtin_monitorexit); M_ALD(REG_ITMP3, REG_PV, disp); @@ -3285,7 +3287,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif @@ -3385,14 +3387,14 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); M_ALD(REG_ITMP3, REG_PV, disp); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); /* if (s1 != REG_ITMP1) { */ /* M_ILD(REG_ITMP1, REG_ITMP3, OFFSET(vftbl_t, baseval)); */ /* M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); */ - /* #if defined(USE_THREADS) && defined(NATIVE_THREADS) */ + /* #if defined(ENABLE_THREADS) */ /* codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); */ /* #endif */ /* M_ISUB(REG_ITMP2, REG_ITMP1, REG_ITMP2); */ @@ -3401,7 +3403,7 @@ gen_method: M_ISUB(REG_ITMP2, REG_ITMP3, REG_ITMP2); M_ALD(REG_ITMP3, REG_PV, disp); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif /* } */ @@ -3478,7 +3480,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif @@ -3579,13 +3581,13 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); @@ -3845,7 +3847,7 @@ gen_method: /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* create a virtual java_objectheader */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ @@ -4290,7 +4292,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* check for exception */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) disp = dseg_addaddress(cd, builtin_get_exceptionptrptr); M_ALD(REG_ITMP3, REG_PV, disp); M_JSR(REG_RA, REG_ITMP3); @@ -4369,7 +4371,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* order reversed because of data segment layout */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ diff --git a/src/vm/jit/mips/irix/md-os.c b/src/vm/jit/mips/irix/md-os.c index ab9f95d4d..e13b52291 100644 --- a/src/vm/jit/mips/irix/md-os.c +++ b/src/vm/jit/mips/irix/md-os.c @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: md-os.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: md-os.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -124,7 +124,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *uc) { void *critical; diff --git a/src/vm/jit/mips/linux/md-os.c b/src/vm/jit/mips/linux/md-os.c index 3d7d1f913..6f7c99dd5 100644 --- a/src/vm/jit/mips/linux/md-os.c +++ b/src/vm/jit/mips/linux/md-os.c @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: md-os.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: md-os.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -127,7 +127,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *_uc) { mcontext_t *_mc; diff --git a/src/vm/jit/parse.c b/src/vm/jit/parse.c index dc992c8d8..73a3eb98f 100644 --- a/src/vm/jit/parse.c +++ b/src/vm/jit/parse.c @@ -31,7 +31,7 @@ Joseph Wenninger Christian Thalinger - $Id: parse.c 4863 2006-04-30 16:17:44Z edwin $ + $Id: parse.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -217,7 +217,7 @@ bool parse(jitdata *jd) s_count = 1 + m->exceptiontablelength; /* initialize stack element counter */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { m->isleafmethod = false; } @@ -1012,7 +1012,7 @@ invoke_method: break; case JAVA_MONITORENTER: -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync) { OP(ICMD_CHECKNULL); bte = builtintable_get_internal(BUILTIN_monitorenter); @@ -1027,7 +1027,7 @@ invoke_method: break; case JAVA_MONITOREXIT: -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync) { bte = builtintable_get_internal(BUILTIN_monitorexit); BUILTIN(bte, false, NULL, currentline); diff --git a/src/vm/jit/patcher.h b/src/vm/jit/patcher.h index 64cbfe69a..996bda95a 100644 --- a/src/vm/jit/patcher.h +++ b/src/vm/jit/patcher.h @@ -28,7 +28,7 @@ Changes: Edwin Steiner - $Id: patcher.h 4760 2006-04-12 20:06:23Z edwin $ + $Id: patcher.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -44,7 +44,7 @@ /* patcher macros *************************************************************/ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) #define PATCHER_MONITORENTER \ /* enter a monitor on the patching position */ \ @@ -79,7 +79,7 @@ #define PATCHER_MONITOREXIT /* nop */ #define PATCHER_MARK_PATCHED_MONITOREXIT /* nop */ -#endif /* defined(USE_THREADS) */ +#endif /* defined(ENABLE_THREADS) */ /* function prototypes ********************************************************/ diff --git a/src/vm/jit/powerpc/asmpart.S b/src/vm/jit/powerpc/asmpart.S index 6998b7e90..a38e19d43 100644 --- a/src/vm/jit/powerpc/asmpart.S +++ b/src/vm/jit/powerpc/asmpart.S @@ -31,7 +31,7 @@ Changes: Christian Thalinger Edwin Steiner - $Id: asmpart.S 4894 2006-05-08 11:05:48Z twisti $ + $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $ */ @@ -72,9 +72,6 @@ .globl asm_replacement_in .globl asm_cacheflush - .globl asm_initialize_thread_stack - .globl asm_perform_threadswitch - .globl asm_switchstackandcall .globl asm_criticalsections .globl asm_getclassvalues_atomic @@ -714,7 +711,7 @@ L_asm_call_jit_compiler: /* required for PIC code */ bctr /* and call the Java method */ L_asm_call_jit_compiler_exception: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) mflr r0 stw r0,LA_LR_OFFSET(sp) stwu sp,-LA_SIZE_ALIGNED(sp) /* preserve linkage area */ @@ -1076,7 +1073,7 @@ L_asm_wrapper_patcher_exception: lwz xpc,(5+LA_WORD_SIZE+5+58)*4+sizestackframeinfo(sp) addi sp,sp,(8+LA_WORD_SIZE+5+58)*4+sizestackframeinfo -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) mflr r0 stw r0,LA_LR_OFFSET(sp) stwu sp,-(LA_SIZE+1*4)(sp) /* preserve linkage area */ @@ -1343,180 +1340,6 @@ asm_cacheflush: blr - .align 3 -doublezero: - .double 0.0 - -asm_initialize_thread_stack: - addi r4,r4,-256 - stw r3,120(r4) - li r3,0 - stw r3,124(r4) - stw r3,0(r4) - stw r3,4(r4) - stw r3,8(r4) - stw r3,12(r4) - stw r3,16(r4) - stw r3,20(r4) - stw r3,24(r4) - stw r3,28(r4) - stw r3,32(r4) - stw r3,36(r4) - - stw r3,128(r4) - stw r3,132(r4) - stw r3,136(r4) - stw r3,140(r4) - stw r3,144(r4) - stw r3,148(r4) - stw r3,152(r4) - stw r3,156(r4) - - mflr r0 - bl 0f -0: - mflr r3 - mtlr r0 -#if defined(__DARWIN__) - lfd fr0,lo16(doublezero-0b)(r3) -#else - lfd fr0,(doublezero-0b)@l(r3) -#endif - - stfd fr0,40(r4) - stfd fr0,48(r4) - stfd fr0,56(r4) - stfd fr0,64(r4) - stfd fr0,72(r4) - stfd fr0,80(r4) - stfd fr0,88(r4) - stfd fr0,96(r4) - stfd fr0,104(r4) - stfd fr0,112(r4) - - stfd fr0,160(r4) - stfd fr0,168(r4) - stfd fr0,176(r4) - stfd fr0,184(r4) - stfd fr0,192(r4) - stfd fr0,200(r4) - stfd fr0,208(r4) - stfd fr0,216(r4) - - mr r3,r4 - blr - - -asm_perform_threadswitch: - mflr r0 - addi r1,r1,-224 - stw r0,120(r1) - stw pv,124(r1) - stw r14,0(r1) - stw r15,4(r1) - stw r24,8(r1) - stw r25,12(r1) - stw r26,16(r1) - stw r27,20(r1) - stw r28,24(r1) - stw r29,28(r1) - stw r30,32(r1) - stw r31,36(r1) - stfd fr14,40(r1) - stfd fr15,48(r1) - stfd fr24,56(r1) - stfd fr25,64(r1) - stfd fr26,72(r1) - stfd fr27,80(r1) - stfd fr28,88(r1) - stfd fr29,96(r1) - stfd fr30,104(r1) - stfd fr31,112(r1) - - stw r16,128(r1) - stw r17,132(r1) - stw r18,136(r1) - stw r19,140(r1) - stw r20,144(r1) - stw r21,148(r1) - stw r22,152(r1) - stw r23,156(r1) - stfd fr16,160(r1) - stfd fr17,168(r1) - stfd fr18,176(r1) - stfd fr19,184(r1) - stfd fr20,192(r1) - stfd fr21,200(r1) - stfd fr22,208(r1) - stfd fr23,216(r1) - - stw r1,0(r3) - stw r1,0(r5) - lwz r1,0(r4) - - lwz r0,120(r1) - lwz pv,124(r1) - lwz r14,0(r1) - lwz r15,4(r1) - lwz r24,8(r1) - lwz r25,12(r1) - lwz r26,16(r1) - lwz r27,20(r1) - lwz r28,24(r1) - lwz r29,28(r1) - lwz r30,32(r1) - lwz r31,36(r1) - lfd fr14,40(r1) - lfd fr15,48(r1) - lfd fr24,56(r1) - lfd fr25,64(r1) - lfd fr26,72(r1) - lfd fr27,80(r1) - lfd fr28,88(r1) - lfd fr29,96(r1) - lfd fr30,104(r1) - lfd fr31,112(r1) - - lwz r16,128(r1) - lwz r17,132(r1) - lwz r18,136(r1) - lwz r19,140(r1) - lwz r20,144(r1) - lwz r21,148(r1) - lwz r22,152(r1) - lwz r23,156(r1) - lfd fr16,160(r1) - lfd fr17,168(r1) - lfd fr18,176(r1) - lfd fr19,184(r1) - lfd fr20,192(r1) - lfd fr21,200(r1) - lfd fr22,208(r1) - lfd fr23,216(r1) - - mtlr r0 - addi r1,r1,224 - blr - - -asm_switchstackandcall: - mflr r0 - stwu r3,-48(r3) - stw r0,40(r3) - stw r1,44(r3) - stw r1,0(r5) - mr r1,r3 - - mtctr r4 - mr r3,r6 - bctrl - - lwz r0,40(r1) - mtlr r0 - lwz r1,44(r1) - blr - - asm_getclassvalues_atomic: _crit_restart: _crit_begin: @@ -1532,7 +1355,7 @@ _crit_end: .data asm_criticalsections: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) .long _crit_begin .long _crit_end .long _crit_restart diff --git a/src/vm/jit/powerpc/codegen.c b/src/vm/jit/powerpc/codegen.c index dcd4a89ef..d9adfa6da 100644 --- a/src/vm/jit/powerpc/codegen.c +++ b/src/vm/jit/powerpc/codegen.c @@ -31,7 +31,7 @@ Christian Ullrich Edwin Steiner - $Id: codegen.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: codegen.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -125,7 +125,7 @@ bool codegen(jitdata *jd) stackframesize = rd->memuse + savedregs_num; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* space to save argument of monitor_enter and Return Values to survive */ /* monitor_exit. The stack position for the argument can not be shared */ /* with place to save the return register on PPC, since both values */ @@ -148,7 +148,7 @@ bool codegen(jitdata *jd) (void) dseg_addaddress(cd, m); /* MethodPointer */ (void) dseg_adds4(cd, stackframesize * 4); /* FrameSize */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* IsSync contains the offset relative to the stack pointer for the argument of monitor_exit used in the exception handler. Since the offset could be zero and give a wrong meaning of the flag it is @@ -296,7 +296,7 @@ bool codegen(jitdata *jd) /* save monitorenter argument */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { /* stack offset for monitor argument */ @@ -1509,6 +1509,122 @@ bool codegen(jitdata *jd) emit_store(jd, iptr, iptr->dst, d); break; + case ICMD_IF_FCMPEQ: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPEQ: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(1); + M_BEQ(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + case ICMD_IF_FCMPNE: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPNE: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(0); + codegen_addreference(cd, (basicblock *) iptr->target); + M_BNE(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + + case ICMD_IF_FCMPL_LT: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPL_LT: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(0); + codegen_addreference(cd, (basicblock *) iptr->target); + M_BLT(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + case ICMD_IF_FCMPL_GT: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPL_GT: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(1); + M_BGT(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + case ICMD_IF_FCMPL_LE: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPL_LE: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(0); + codegen_addreference(cd, (basicblock *) iptr->target); + M_BLE(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + case ICMD_IF_FCMPL_GE: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPL_GE: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(1); + M_BGE(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + case ICMD_IF_FCMPG_LT: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPG_LT: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(1); + M_BLT(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + case ICMD_IF_FCMPG_GT: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPG_GT: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(0); + codegen_addreference(cd, (basicblock *) iptr->target); + M_BGT(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + case ICMD_IF_FCMPG_LE: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPG_LE: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(1); + M_BLE(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + + case ICMD_IF_FCMPG_GE: /* ..., value, value ==> ... */ + case ICMD_IF_DCMPG_GE: + + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); + M_FCMPU(s1, s2); + M_BNAN(0); + codegen_addreference(cd, (basicblock *) iptr->target); + M_BGE(0); + codegen_addreference(cd, (basicblock *) iptr->target); + break; + /* memory operations **************************************************/ @@ -2069,9 +2185,9 @@ bool codegen(jitdata *jd) /* op1 = target JavaVM pc, val.i = constant */ s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); - if ((iptr->val.i >= -32768) && (iptr->val.i <= 32767)) { + if ((iptr->val.i >= -32768) && (iptr->val.i <= 32767)) M_CMPI(s1, iptr->val.i); - } else { + else { ICONST(REG_ITMP2, iptr->val.i); M_CMP(s1, REG_ITMP2); } @@ -2507,7 +2623,7 @@ nowperformreturn: M_MTLR(REG_ZERO); } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { disp = dseg_addaddress(cd, BUILTIN_monitorexit); M_ALD(REG_ITMP3, REG_PV, disp); @@ -2920,7 +3036,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); @@ -3010,7 +3126,7 @@ gen_method: } M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); @@ -3018,7 +3134,7 @@ gen_method: if (s1 != REG_ITMP1) { M_ILD(REG_ITMP1, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif M_ISUB(REG_ITMP3, REG_ITMP1, REG_ITMP3); @@ -3027,7 +3143,7 @@ gen_method: M_ISUB(REG_ITMP3, REG_ITMP2, REG_ITMP3); M_ALD(REG_ITMP2, REG_PV, disp); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif } @@ -3102,7 +3218,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); @@ -3197,13 +3313,13 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); @@ -3285,7 +3401,8 @@ gen_method: default: *exceptionptr = - new_internalerror("Unknown ICMD %d", iptr->opc); + new_internalerror("Unknown ICMD %d during code generation", + iptr->opc); return false; } /* switch */ @@ -3455,7 +3572,7 @@ gen_method: /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* order reversed because of data segment layout */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ @@ -3917,7 +4034,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* check for exception */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) disp = dseg_addaddress(cd, builtin_get_exceptionptrptr); M_ALD(REG_ITMP1, REG_PV, disp); M_MTCTR(REG_ITMP1); @@ -4007,7 +4124,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* order reversed because of data segment layout */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ diff --git a/src/vm/jit/powerpc/darwin/md-asm.h b/src/vm/jit/powerpc/darwin/md-asm.h index 2e0a2b4bf..45e8da558 100644 --- a/src/vm/jit/powerpc/darwin/md-asm.h +++ b/src/vm/jit/powerpc/darwin/md-asm.h @@ -28,7 +28,7 @@ Changes: - $Id: md-asm.h 4851 2006-04-27 10:32:27Z twisti $ + $Id: md-asm.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -267,7 +267,7 @@ #define stacktrace_remove_stackframeinfo \ L_stacktrace_remove_stackframeinfo$stub -#if !defined(USE_THREADS) || !defined(NATIVE_THREADS) +#if !defined(ENABLE_THREADS) #define _no_threads_exceptionptr __no_threads_exceptionptr #endif diff --git a/src/vm/jit/powerpc/darwin/md-os.c b/src/vm/jit/powerpc/darwin/md-os.c index bd31e9775..b1a243279 100644 --- a/src/vm/jit/powerpc/darwin/md-os.c +++ b/src/vm/jit/powerpc/darwin/md-os.c @@ -28,7 +28,7 @@ Changes: - $Id: md-os.c 4357 2006-01-22 23:33:38Z twisti $ + $Id: md-os.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -103,7 +103,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *uc) { /* XXX set pc to restart address */ diff --git a/src/vm/jit/powerpc/linux/md-os.c b/src/vm/jit/powerpc/linux/md-os.c index 8845fb4ba..16a1d71ba 100644 --- a/src/vm/jit/powerpc/linux/md-os.c +++ b/src/vm/jit/powerpc/linux/md-os.c @@ -28,7 +28,7 @@ Changes: - $Id: md-os.c 4357 2006-01-22 23:33:38Z twisti $ + $Id: md-os.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -94,7 +94,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *uc) { /* XXX set pc to restart address */ diff --git a/src/vm/jit/powerpc/netbsd/md-os.c b/src/vm/jit/powerpc/netbsd/md-os.c index 22ae480db..77b853c67 100644 --- a/src/vm/jit/powerpc/netbsd/md-os.c +++ b/src/vm/jit/powerpc/netbsd/md-os.c @@ -94,7 +94,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *uc) { /* XXX set pc to restart address */ diff --git a/src/vm/jit/profile/profile.c b/src/vm/jit/profile/profile.c index c73bbb50b..dfb82906e 100644 --- a/src/vm/jit/profile/profile.c +++ b/src/vm/jit/profile/profile.c @@ -44,12 +44,8 @@ #include "native/include/java_lang_Thread.h" #include "native/include/java_lang_VMThread.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/builtin.h" @@ -72,7 +68,7 @@ struct list_method_entry { /* global variables ***********************************************************/ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static java_lang_VMThread *profile_vmthread; #endif @@ -97,7 +93,7 @@ bool profile_init(void) *******************************************************************************/ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static void profile_thread(void) { /* s4 i = 0; */ @@ -134,7 +130,7 @@ static void profile_thread(void) *******************************************************************************/ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) bool profile_start_thread(void) { java_lang_Thread *t; diff --git a/src/vm/jit/stack.c b/src/vm/jit/stack.c index aff572e52..ed9a2f40d 100644 --- a/src/vm/jit/stack.c +++ b/src/vm/jit/stack.c @@ -30,7 +30,7 @@ Christian Thalinger Christian Ullrich - $Id: stack.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: stack.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -72,7 +72,7 @@ /* global variables ***********************************************************/ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static java_objectheader *lock_stack_show_icmd; #endif @@ -92,14 +92,12 @@ static java_objectheader *lock_stack_show_icmd; bool stack_init(void) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* initialize the show lock */ lock_stack_show_icmd = NEW(java_objectheader); -# if defined(NATIVE_THREADS) lock_init_object_lock(lock_stack_show_icmd); -# endif #endif /* everything's ok */ @@ -1996,16 +1994,188 @@ bool stack_analyse(jitdata *jd) #endif /* SUPPORT_LONG_CMP_CONST */ OPTT2_1(TYPE_LNG, TYPE_INT); break; + +#if 0 + case ICMD_FCMPL: + COUNT(count_pcmd_op); + if ((len > 0) && (iptr[1].val.i == 0)) { + switch (iptr[1].opc) { + case ICMD_IFEQ: + iptr[0].opc = ICMD_IF_FCMPEQ; + icmd_if_fcmpl_tail: + iptr[0].op1 = iptr[1].op1; + iptr[1].opc = ICMD_NOP; + + OP2_0(TYPE_FLT); + tbptr = m->basicblocks + + m->basicblockindex[iptr[0].op1]; + + iptr[0].target = (void *) tbptr; + + MARKREACHED(tbptr, copy); + COUNT(count_pcmd_bra); + break; + case ICMD_IFNE: + iptr[0].opc = ICMD_IF_FCMPNE; + goto icmd_if_fcmpl_tail; + case ICMD_IFLT: + iptr[0].opc = ICMD_IF_FCMPL_LT; + goto icmd_if_fcmpl_tail; + case ICMD_IFGT: + iptr[0].opc = ICMD_IF_FCMPL_GT; + goto icmd_if_fcmpl_tail; + case ICMD_IFLE: + iptr[0].opc = ICMD_IF_FCMPL_LE; + goto icmd_if_fcmpl_tail; + case ICMD_IFGE: + iptr[0].opc = ICMD_IF_FCMPL_GE; + goto icmd_if_fcmpl_tail; + default: + OPTT2_1(TYPE_FLT, TYPE_INT); + } + } + else + OPTT2_1(TYPE_FLT, TYPE_INT); + break; + + case ICMD_FCMPG: + COUNT(count_pcmd_op); + if ((len > 0) && (iptr[1].val.i == 0)) { + switch (iptr[1].opc) { + case ICMD_IFEQ: + iptr[0].opc = ICMD_IF_FCMPEQ; + icmd_if_fcmpg_tail: + iptr[0].op1 = iptr[1].op1; + iptr[1].opc = ICMD_NOP; + + OP2_0(TYPE_FLT); + tbptr = m->basicblocks + + m->basicblockindex[iptr[0].op1]; + + iptr[0].target = (void *) tbptr; + + MARKREACHED(tbptr, copy); + COUNT(count_pcmd_bra); + break; + case ICMD_IFNE: + iptr[0].opc = ICMD_IF_FCMPNE; + goto icmd_if_fcmpg_tail; + case ICMD_IFLT: + iptr[0].opc = ICMD_IF_FCMPG_LT; + goto icmd_if_fcmpg_tail; + case ICMD_IFGT: + iptr[0].opc = ICMD_IF_FCMPG_GT; + goto icmd_if_fcmpg_tail; + case ICMD_IFLE: + iptr[0].opc = ICMD_IF_FCMPG_LE; + goto icmd_if_fcmpg_tail; + case ICMD_IFGE: + iptr[0].opc = ICMD_IF_FCMPG_GE; + goto icmd_if_fcmpg_tail; + default: + OPTT2_1(TYPE_FLT, TYPE_INT); + } + } + else + OPTT2_1(TYPE_FLT, TYPE_INT); + break; + + case ICMD_DCMPL: + COUNT(count_pcmd_op); + if ((len > 0) && (iptr[1].val.i == 0)) { + switch (iptr[1].opc) { + case ICMD_IFEQ: + iptr[0].opc = ICMD_IF_DCMPEQ; + icmd_if_dcmpl_tail: + iptr[0].op1 = iptr[1].op1; + iptr[1].opc = ICMD_NOP; + + OP2_0(TYPE_DBL); + tbptr = m->basicblocks + + m->basicblockindex[iptr[0].op1]; + + iptr[0].target = (void *) tbptr; + + MARKREACHED(tbptr, copy); + COUNT(count_pcmd_bra); + break; + case ICMD_IFNE: + iptr[0].opc = ICMD_IF_DCMPNE; + goto icmd_if_dcmpl_tail; + case ICMD_IFLT: + iptr[0].opc = ICMD_IF_DCMPL_LT; + goto icmd_if_dcmpl_tail; + case ICMD_IFGT: + iptr[0].opc = ICMD_IF_DCMPL_GT; + goto icmd_if_dcmpl_tail; + case ICMD_IFLE: + iptr[0].opc = ICMD_IF_DCMPL_LE; + goto icmd_if_dcmpl_tail; + case ICMD_IFGE: + iptr[0].opc = ICMD_IF_DCMPL_GE; + goto icmd_if_dcmpl_tail; + default: + OPTT2_1(TYPE_DBL, TYPE_INT); + } + } + else + OPTT2_1(TYPE_DBL, TYPE_INT); + break; + + case ICMD_DCMPG: + COUNT(count_pcmd_op); + if ((len > 0) && (iptr[1].val.i == 0)) { + switch (iptr[1].opc) { + case ICMD_IFEQ: + iptr[0].opc = ICMD_IF_DCMPEQ; + icmd_if_dcmpg_tail: + iptr[0].op1 = iptr[1].op1; + iptr[1].opc = ICMD_NOP; + + OP2_0(TYPE_DBL); + tbptr = m->basicblocks + + m->basicblockindex[iptr[0].op1]; + + iptr[0].target = (void *) tbptr; + + MARKREACHED(tbptr, copy); + COUNT(count_pcmd_bra); + break; + case ICMD_IFNE: + iptr[0].opc = ICMD_IF_DCMPNE; + goto icmd_if_dcmpg_tail; + case ICMD_IFLT: + iptr[0].opc = ICMD_IF_DCMPG_LT; + goto icmd_if_dcmpg_tail; + case ICMD_IFGT: + iptr[0].opc = ICMD_IF_DCMPG_GT; + goto icmd_if_dcmpg_tail; + case ICMD_IFLE: + iptr[0].opc = ICMD_IF_DCMPG_LE; + goto icmd_if_dcmpg_tail; + case ICMD_IFGE: + iptr[0].opc = ICMD_IF_DCMPG_GE; + goto icmd_if_dcmpg_tail; + default: + OPTT2_1(TYPE_DBL, TYPE_INT); + } + } + else + OPTT2_1(TYPE_DBL, TYPE_INT); + break; +#else case ICMD_FCMPL: case ICMD_FCMPG: COUNT(count_pcmd_op); OPTT2_1(TYPE_FLT, TYPE_INT); break; + case ICMD_DCMPL: case ICMD_DCMPG: COUNT(count_pcmd_op); OPTT2_1(TYPE_DBL, TYPE_INT); break; +#endif /* pop 1 push 1 */ @@ -2718,7 +2888,7 @@ void stack_show_method(jitdata *jd) cd = jd->cd; rd = jd->rd; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* We need to enter a lock here, since the binutils disassembler is not reentrant-able and we could not read functions printed at the same time. */ @@ -2915,7 +3085,7 @@ void stack_show_method(jitdata *jd) } #endif -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(lock_stack_show_icmd); #endif @@ -3421,12 +3591,40 @@ void stack_show_icmd(instruction *iptr, bool deadcode) case ICMD_IF_ICMPGE: case ICMD_IF_ICMPGT: case ICMD_IF_ICMPLE: + case ICMD_IF_LCMPEQ: case ICMD_IF_LCMPNE: case ICMD_IF_LCMPLT: case ICMD_IF_LCMPGE: case ICMD_IF_LCMPGT: case ICMD_IF_LCMPLE: + + case ICMD_IF_FCMPEQ: + case ICMD_IF_FCMPNE: + + case ICMD_IF_FCMPL_LT: + case ICMD_IF_FCMPL_GE: + case ICMD_IF_FCMPL_GT: + case ICMD_IF_FCMPL_LE: + + case ICMD_IF_FCMPG_LT: + case ICMD_IF_FCMPG_GE: + case ICMD_IF_FCMPG_GT: + case ICMD_IF_FCMPG_LE: + + case ICMD_IF_DCMPEQ: + case ICMD_IF_DCMPNE: + + case ICMD_IF_DCMPL_LT: + case ICMD_IF_DCMPL_GE: + case ICMD_IF_DCMPL_GT: + case ICMD_IF_DCMPL_LE: + + case ICMD_IF_DCMPG_LT: + case ICMD_IF_DCMPG_GE: + case ICMD_IF_DCMPG_GT: + case ICMD_IF_DCMPG_LE: + case ICMD_IF_ACMPEQ: case ICMD_IF_ACMPNE: if (!(iptr->opc & ICMD_CONDITION_MASK)) { diff --git a/src/vm/jit/stacktrace.c b/src/vm/jit/stacktrace.c index f7f3fb247..63d8d0b12 100644 --- a/src/vm/jit/stacktrace.c +++ b/src/vm/jit/stacktrace.c @@ -29,7 +29,7 @@ Changes: Christian Thalinger Edwin Steiner - $Id: stacktrace.c 4913 2006-05-14 14:02:51Z edwin $ + $Id: stacktrace.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -51,12 +51,8 @@ #include "native/include/java_lang_Throwable.h" #include "native/include/java_lang_VMThrowable.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #else # include "threads/none/threads.h" #endif @@ -89,7 +85,7 @@ struct linenumbertable_entry { /* global variables ***********************************************************/ -#if !defined(USE_THREADS) +#if !defined(ENABLE_THREADS) stackframeinfo *_no_threads_stackframeinfo = NULL; #endif @@ -819,7 +815,10 @@ stacktracebuffer *stacktrace_create(threadobject* thread) native stackframeinfo (VMThrowable.fillInStackTrace is a native function). */ -#if defined(USE_THREADS) + /* We don't use the STACKFRAMEINFO macro here, as we have to use + the passed thread. */ + +#if defined(ENABLE_THREADS) sfi = thread->_stackframeinfo; #else sfi = _no_threads_stackframeinfo; diff --git a/src/vm/jit/stacktrace.h b/src/vm/jit/stacktrace.h index acb898a44..1e83f6989 100644 --- a/src/vm/jit/stacktrace.h +++ b/src/vm/jit/stacktrace.h @@ -28,7 +28,7 @@ Changes: - $Id: stacktrace.h 4913 2006-05-14 14:02:51Z edwin $ + $Id: stacktrace.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -64,7 +64,7 @@ struct stackframeinfo { u1 *xpc; /* XPC (for inline stubs) */ }; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) #define STACKFRAMEINFO (&(THREADOBJECT->_stackframeinfo)) #else extern stackframeinfo *_no_threads_stackframeinfo; diff --git a/src/vm/jit/verify/typecheck.c b/src/vm/jit/verify/typecheck.c index 5db73df1b..9bd558574 100644 --- a/src/vm/jit/verify/typecheck.c +++ b/src/vm/jit/verify/typecheck.c @@ -28,7 +28,7 @@ Changes: Christian Thalinger - $Id: typecheck.c 4863 2006-04-30 16:17:44Z edwin $ + $Id: typecheck.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -2100,18 +2100,46 @@ fieldaccess_tail: case ICMD_IF_ICMPLE: case ICMD_IF_ACMPEQ: case ICMD_IF_ACMPNE: + case ICMD_IF_LEQ: case ICMD_IF_LNE: case ICMD_IF_LLT: case ICMD_IF_LGE: case ICMD_IF_LGT: case ICMD_IF_LLE: + case ICMD_IF_LCMPEQ: case ICMD_IF_LCMPNE: case ICMD_IF_LCMPLT: case ICMD_IF_LCMPGE: case ICMD_IF_LCMPGT: case ICMD_IF_LCMPLE: + + case ICMD_IF_FCMPEQ: + case ICMD_IF_FCMPNE: + + case ICMD_IF_FCMPL_LT: + case ICMD_IF_FCMPL_GE: + case ICMD_IF_FCMPL_GT: + case ICMD_IF_FCMPL_LE: + + case ICMD_IF_FCMPG_LT: + case ICMD_IF_FCMPG_GE: + case ICMD_IF_FCMPG_GT: + case ICMD_IF_FCMPG_LE: + + case ICMD_IF_DCMPEQ: + case ICMD_IF_DCMPNE: + + case ICMD_IF_DCMPL_LT: + case ICMD_IF_DCMPL_GE: + case ICMD_IF_DCMPL_GT: + case ICMD_IF_DCMPL_LE: + + case ICMD_IF_DCMPG_LT: + case ICMD_IF_DCMPG_GE: + case ICMD_IF_DCMPG_GT: + case ICMD_IF_DCMPG_LE: TYPECHECK_COUNT(stat_ins_branch); tbptr = (basicblock *) state->iptr->target; diff --git a/src/vm/jit/x86_64/asmpart.S b/src/vm/jit/x86_64/asmpart.S index c246b932a..aaf2e8a5f 100644 --- a/src/vm/jit/x86_64/asmpart.S +++ b/src/vm/jit/x86_64/asmpart.S @@ -30,7 +30,7 @@ Changes: Edwin Steiner - $Id: asmpart.S 4805 2006-04-21 10:54:24Z twisti $ + $Id: asmpart.S 4921 2006-05-15 14:24:36Z twisti $ */ @@ -345,7 +345,7 @@ L_asm_call_jit_compiler: /* required for PIC code */ jmp *v0 /* ...and now call the new method */ L_asm_call_jit_compiler_exception: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) call builtin_asm_get_exceptionptrptr@PLT mov v0,itmp2 /* v0 == xptr */ #else @@ -564,7 +564,7 @@ asm_wrapper_patcher: ret /* call new patched code */ L_asm_wrapper_patcher_exception: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) call builtin_asm_get_exceptionptrptr@PLT mov v0,itmp2 /* v0 == xptr */ #else @@ -881,7 +881,7 @@ _crit_end: .data asm_criticalsections: -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) .quad _crit_begin .quad _crit_end .quad _crit_restart diff --git a/src/vm/jit/x86_64/codegen.c b/src/vm/jit/x86_64/codegen.c index b61a84689..6d5b11b11 100644 --- a/src/vm/jit/x86_64/codegen.c +++ b/src/vm/jit/x86_64/codegen.c @@ -30,7 +30,7 @@ Changes: Christian Ullrich Edwin Steiner - $Id: codegen.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: codegen.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -126,7 +126,7 @@ bool codegen(jitdata *jd) stackframesize = rd->memuse + savedregs_num; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* space to save argument of monitor_enter */ if (checksync && (m->flags & ACC_SYNCHRONIZED)) @@ -144,7 +144,7 @@ bool codegen(jitdata *jd) (void) dseg_addaddress(cd, m); /* MethodPointer */ (void) dseg_adds4(cd, stackframesize * 8); /* FrameSize */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* IsSync contains the offset relative to the stack pointer for the argument of monitor_exit used in the exception handler. Since the offset could be zero and give a wrong meaning of the flag it is @@ -256,7 +256,7 @@ bool codegen(jitdata *jd) /* save monitorenter argument */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { /* stack offset for monitor argument */ @@ -2992,7 +2992,7 @@ nowperformreturn: } #endif /* !defined(NDEBUG) */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) if (checksync && (m->flags & ACC_SYNCHRONIZED)) { M_ALD(rd->argintregs[0], REG_SP, rd->memuse * 8); @@ -3354,7 +3354,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); @@ -3478,7 +3478,7 @@ gen_method: } M_MOV_IMM(supervftbl, REG_ITMP3); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif emit_movl_membase32_reg(cd, REG_ITMP2, @@ -3491,7 +3491,7 @@ gen_method: /* emit_movl_membase_reg(cd, REG_ITMP3, */ /* OFFSET(vftbl_t, diffval), */ /* REG_ITMP3); */ - /* #if defined(USE_THREADS) && defined(NATIVE_THREADS) */ + /* #if defined(ENABLE_THREADS) */ /* codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); */ /* #endif */ /* emit_alu_reg_reg(cd, ALU_SUB, REG_ITMP1, REG_ITMP2); */ @@ -3504,7 +3504,7 @@ gen_method: M_MOV_IMM(supervftbl, REG_ITMP3); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); /* } */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif M_CMP(REG_ITMP3, REG_ITMP2); @@ -3576,7 +3576,7 @@ gen_method: supervftbl = super->vftbl; } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase); #endif @@ -3698,7 +3698,7 @@ gen_method: } emit_mov_imm_reg(cd, (ptrint) supervftbl, REG_ITMP2); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase); #endif emit_movl_membase_reg(cd, REG_ITMP1, @@ -3710,7 +3710,7 @@ gen_method: emit_movl_membase_reg(cd, REG_ITMP2, OFFSET(vftbl_t, baseval), REG_ITMP2); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase); #endif emit_alu_reg_reg(cd, ALU_SUB, REG_ITMP2, REG_ITMP1); @@ -3923,7 +3923,7 @@ gen_method: /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* create a virtual java_objectheader */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ @@ -4301,7 +4301,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* check for exception */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) M_MOV_IMM(builtin_get_exceptionptrptr, REG_ITMP3); M_CALL(REG_ITMP3); #else @@ -4331,7 +4331,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* handle exception */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) M_LST(REG_ITMP2, REG_SP, 0 * 8); M_MOV_IMM(builtin_get_exceptionptrptr, REG_ITMP3); M_CALL(REG_ITMP3); @@ -4361,7 +4361,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) ptrint mcode; u1 *savedmcodeptr; u1 *tmpmcodeptr; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) s4 disp; #endif @@ -4383,7 +4383,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* move pointer to java_objectheader onto stack */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) /* create a virtual java_objectheader */ (void) dseg_addaddress(cd, lock_get_initial_lock_word()); /* monitorPtr */ diff --git a/src/vm/jit/x86_64/md.c b/src/vm/jit/x86_64/md.c index f3be618c5..c64ef6669 100644 --- a/src/vm/jit/x86_64/md.c +++ b/src/vm/jit/x86_64/md.c @@ -28,7 +28,7 @@ Changes: Edwin Steiner - $Id: md.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: md.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -132,7 +132,7 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void thread_restartcriticalsection(ucontext_t *uc) { void *critical; diff --git a/src/vm/linker.c b/src/vm/linker.c index 041d627bc..97963a555 100644 --- a/src/vm/linker.c +++ b/src/vm/linker.c @@ -32,7 +32,7 @@ Edwin Steiner Christian Thalinger - $Id: linker.c 4834 2006-04-25 12:25:43Z edwin $ + $Id: linker.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -369,7 +369,7 @@ classinfo *link_class(classinfo *c) return NULL; } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* enter a monitor on the class */ builtin_monitorenter((java_objectheader *) c); @@ -378,7 +378,7 @@ classinfo *link_class(classinfo *c) /* maybe the class is already linked */ if (c->state & CLASS_LINKED) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit((java_objectheader *) c); #endif @@ -414,7 +414,7 @@ classinfo *link_class(classinfo *c) compilingtime_start(); #endif -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* leave the monitor */ builtin_monitorexit((java_objectheader *) c); @@ -1074,12 +1074,8 @@ static arraydescriptor *link_array(classinfo *c) static void linker_compute_subclasses(classinfo *c) { -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) compiler_lock(); -#else - intsDisable(); -#endif #endif if (!(c->flags & ACC_INTERFACE)) { @@ -1098,12 +1094,8 @@ static void linker_compute_subclasses(classinfo *c) linker_compute_class_values(class_java_lang_Object); -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) compiler_unlock(); -#else - intsRestore(); -#endif #endif } diff --git a/src/vm/loader.c b/src/vm/loader.c index bec093a19..208754d49 100644 --- a/src/vm/loader.c +++ b/src/vm/loader.c @@ -32,7 +32,7 @@ Edwin Steiner Christian Thalinger - $Id: loader.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: loader.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -49,13 +49,8 @@ #include "native/native.h" #include "native/include/java_lang_Throwable.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# include "threads/green/locks.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "toolbox/logging.h" @@ -102,9 +97,9 @@ *******************************************************************************/ -bool loader_init(u1 *stackbottom) +bool loader_init(void) { -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) list_classpath_entry *lce; /* Initialize the monitor pointer for zip/jar file locking. */ @@ -223,11 +218,6 @@ bool loader_init(u1 *stackbottom) load_class_bootstrap(utf_new_char("[Ljava/lang/Object;")))) return false; -#if defined(USE_THREADS) - if (stackbottom != 0) - lock_init(); /* XXX this should probably be done only for green threads */ -#endif - return true; } @@ -1015,7 +1005,7 @@ static bool load_method(classbuffer *cb, methodinfo *m, descriptor_pool *descpoo c = cb->class; -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) lock_init_object_lock(&m->header); #endif @@ -2488,7 +2478,7 @@ classinfo *load_newly_created_array(classinfo *c, java_objectheader *loader) clone = c->methods; MSET(clone, 0, methodinfo, 1); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) lock_init_object_lock(&clone->header); #endif diff --git a/src/vm/loader.h b/src/vm/loader.h index 412553a53..763cc7c9e 100644 --- a/src/vm/loader.h +++ b/src/vm/loader.h @@ -28,7 +28,7 @@ Changes: Christian Thalinger - $Id: loader.h 4490 2006-02-12 16:02:43Z edwin $ + $Id: loader.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -115,17 +115,10 @@ struct classbuffer { }; -/* export variables ***********************************************************/ - -#if defined(USE_THREADS) -extern int blockInts; -#endif - - /* function prototypes ********************************************************/ /* initialize loader, load important systemclasses */ -bool loader_init(u1 *stackbottom); +bool loader_init(void); void loader_load_all_classes(void); diff --git a/src/vm/signal.c b/src/vm/signal.c index 4529ea386..d4520fcd8 100644 --- a/src/vm/signal.c +++ b/src/vm/signal.c @@ -28,7 +28,7 @@ Changes: - $Id: signal.c 4530 2006-02-21 09:11:53Z twisti $ + $Id: signal.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -40,7 +40,7 @@ #include "vm/types.h" -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) # include "threads/native/threads.h" #endif @@ -115,7 +115,7 @@ void signal_init(void) /* catch SIGQUIT for thread dump */ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) #if !defined(__FREEBSD__) act.sa_sigaction = signal_handler_sigquit; act.sa_flags = SA_SIGINFO; @@ -137,7 +137,7 @@ void signal_init(void) *******************************************************************************/ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void signal_handler_sigquit(int sig, siginfo_t *siginfo, void *_p) { /* do thread dump */ @@ -175,7 +175,7 @@ void signal_handler_sigint(int sig, siginfo_t *siginfo, void *_p) *******************************************************************************/ -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) void signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p) { /* call stacktrace function */ diff --git a/src/vm/string.c b/src/vm/string.c index a0e975559..7259258de 100644 --- a/src/vm/string.c +++ b/src/vm/string.c @@ -31,7 +31,7 @@ Changes: Christian Thalinger Edwin Steiner - $Id: string.c 4908 2006-05-12 16:49:50Z edwin $ + $Id: string.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -61,7 +61,7 @@ hashtable hashtable_string; /* hashtable for javastrings */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) static java_objectheader *lock_hashtable_string; #endif @@ -206,14 +206,12 @@ bool string_init(void) hashtable_create(&hashtable_string, HASHTABLE_STRING_SIZE); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* create string hashtable lock object */ lock_hashtable_string = NEW(java_objectheader); -# if defined(NATIVE_THREADS) lock_init_object_lock(lock_hashtable_string); -# endif #endif /* everything's ok */ @@ -565,7 +563,7 @@ java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, u4 slot; u2 i; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(lock_hashtable_string); #endif @@ -590,7 +588,7 @@ java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, if (!copymode) mem_free(a, sizeof(java_chararray) + sizeof(u2) * (length - 1) + 10); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(lock_hashtable_string); #endif @@ -632,7 +630,7 @@ java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, js = NEW(java_lang_String); -#if defined(USE_THREADS) && defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) lock_init_object_lock(&js->header); #endif @@ -693,7 +691,7 @@ java_objectheader *literalstring_u2(java_chararray *a, u4 length, u4 offset, hashtable_string = newhash; } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(lock_hashtable_string); #endif diff --git a/src/vm/suck.c b/src/vm/suck.c index b8e753c0a..2d6be09b2 100644 --- a/src/vm/suck.c +++ b/src/vm/suck.c @@ -28,7 +28,7 @@ Changes: - $Id: suck.c 4883 2006-05-05 18:58:00Z edwin $ + $Id: suck.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -540,7 +540,7 @@ classbuffer *suck_start(classinfo *c) #if defined(ENABLE_ZLIB) if (lce->type == CLASSPATH_ARCHIVE) { -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* enter a monitor on zip/jar archives */ builtin_monitorenter((java_objectheader *) lce); @@ -550,7 +550,7 @@ classbuffer *suck_start(classinfo *c) cb = zip_get(lce, c); -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* leave the monitor */ builtin_monitorexit((java_objectheader *) lce); diff --git a/src/vm/suck.h b/src/vm/suck.h index 41feb42a2..a8904ea20 100644 --- a/src/vm/suck.h +++ b/src/vm/suck.h @@ -28,7 +28,7 @@ Changes: - $Id: suck.h 4357 2006-01-22 23:33:38Z twisti $ + $Id: suck.h 4921 2006-05-15 14:24:36Z twisti $ */ @@ -54,10 +54,9 @@ enum { typedef struct list_classpath_entry list_classpath_entry; struct list_classpath_entry { -#if defined(USE_THREADS) - /* Required for monitor locking on zip/jar files. */ - java_objectheader header; -#endif +#if defined(ENABLE_THREADS) + java_objectheader header; /* monitor locking on zip/jar files */ +#endif s4 type; char *path; s4 pathlen; diff --git a/src/vm/utf8.c b/src/vm/utf8.c index cd16f8b3f..24dabea1e 100644 --- a/src/vm/utf8.c +++ b/src/vm/utf8.c @@ -31,7 +31,7 @@ Christian Thalinger Edwin Steiner - $Id: utf8.c 4900 2006-05-11 09:18:28Z twisti $ + $Id: utf8.c 4921 2006-05-15 14:24:36Z twisti $ */ @@ -45,12 +45,8 @@ #include "mm/memory.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/builtin.h" @@ -505,7 +501,7 @@ utf *utf_new(const char *text, u2 length) utf *u; /* hashtable element */ u2 i; -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorenter(hashtable_utf->header); #endif @@ -535,7 +531,7 @@ utf *utf_new(const char *text, u2 length) /* symbol found in hashtable */ -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(hashtable_utf->header); #endif @@ -608,7 +604,7 @@ utf *utf_new(const char *text, u2 length) hashtable_utf = newhash; } -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) builtin_monitorexit(hashtable_utf->header); #endif diff --git a/src/vm/vm.c b/src/vm/vm.c index 644c8cd0d..3676003f3 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -45,13 +45,8 @@ #include "native/jni.h" #include "native/native.h" -#if defined(USE_THREADS) -# if defined(NATIVE_THREADS) -# include "threads/native/threads.h" -# else -# include "threads/green/threads.h" -# include "threads/green/locks.h" -# endif +#if defined(ENABLE_THREADS) +# include "threads/native/threads.h" #endif #include "vm/classcache.h" @@ -91,8 +86,6 @@ bool vm_exiting = false; u1 *intrp_main_stack = NULL; #endif -void **stackbottom = NULL; - char *mainstring = NULL; classinfo *mainclass = NULL; @@ -1086,12 +1079,9 @@ bool vm_create(JavaVMInitArgs *vm_args) } #endif -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) threads_preinit(); #endif - lock_init(); -#endif /* initialize the string hashtable stuff: lock (must be done _after_ threads_preinit) */ @@ -1160,7 +1150,7 @@ bool vm_create(JavaVMInitArgs *vm_args) /* initialize the loader subsystems (must be done _after_ classcache_init) */ - if (!loader_init((u1 *) stackbottom)) + if (!loader_init()) throw_main_exception_exit(); if (!linker_init()) @@ -1182,8 +1172,8 @@ bool vm_create(JavaVMInitArgs *vm_args) if (!jni_init()) throw_main_exception_exit(); -#if defined(USE_THREADS) - if (!threads_init((u1 *) stackbottom)) +#if defined(ENABLE_THREADS) + if (!threads_init()) throw_main_exception_exit(); #endif @@ -1202,7 +1192,7 @@ bool vm_create(JavaVMInitArgs *vm_args) throw_main_exception_exit(); #endif -#if defined(USE_THREADS) +#if defined(ENABLE_THREADS) /* finally, start the finalizer thread */ if (!finalizer_start_thread()) @@ -1243,12 +1233,8 @@ bool vm_create(JavaVMInitArgs *vm_args) s4 vm_destroy(JavaVM *vm) { -#if defined(USE_THREADS) -#if defined(NATIVE_THREADS) +#if defined(ENABLE_THREADS) threads_join_all_threads(); -#else - killThread(currentThread); -#endif #endif /* everything's ok */ @@ -1355,11 +1341,6 @@ void vm_exit_handler(void) # endif #endif /* !defined(NDEBUG) */ -#if defined(USE_THREADS) && !defined(NATIVE_THREADS) - clear_thread_flags(); /* restores standard file descriptor - flags */ -#endif - #if defined(ENABLE_RT_TIMING) rt_timing_print_time_stats(stderr); #endif -- 2.25.1