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)
;;
##
## 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
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 $
*/
#include "native/jvmti/jvmti.h"
#include "native/jvmti/cacaodbg.h"
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
#include <pthread.h>
#endif
#endif
int main(int argc, char **argv)
{
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
- void *dummy;
-#endif
s4 i;
/* local variables ********************************************************/
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");
/* 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);
##
## 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
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 $
*/
#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"
s4 opt;
classinfo *c;
char *opt_directory;
- void *dummy;
/********** internal (only used by main) *****************************/
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) */
/* initialize the loader subsystems (must be done _after_
classcache_init) */
- if (!loader_init((u1 *) &dummy))
+ if (!loader_init())
throw_main_exception_exit();
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 <assert.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include "config.h"
#include "vm/types.h"
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
# if defined(__DARWIN__)
# include <signal.h>
# endif
/* for raising exceptions from native methods *********************************/
-#if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
+#if !defined(ENABLE_THREADS)
java_objectheader *_no_threads_exceptionptr = NULL;
#endif
/* 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
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"
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 $
*/
#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
#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"
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);
{
}
-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);
}
-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 */
{
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;
void heap_free(void *p)
{
- void *result;
-
- MAINTHREADCALL(result, stackcall_free, p, 0);
+ GC_FREE(p);
}
void gc_call(void)
Changes:
- $Id: boehm.h 4357 2006-01-22 23:33:38Z twisti $
+ $Id: boehm.h 4921 2006-05-15 14:24:36Z twisti $
*/
#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);
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 $
*/
#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"
*******************************************************************************/
-#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
#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;
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 */
void *p;
int pagesize;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(codememlock);
#endif
codememptr = (void *) ((ptrint) codememptr + size);
codememsize -= size;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(codememlock);
#endif
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 $
*/
# 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"
/* local reference table ******************************************************/
-#if !defined(USE_THREADS)
+#if !defined(ENABLE_THREADS)
localref_table *_no_threads_localref_table;
#endif
return JNI_ERR;
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(obj);
#endif
return JNI_ERR;
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(obj);
#endif
STATISTICS(jniinvokation());
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(hashtable_global_ref->header);
#endif
gre->refs++;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(hashtable_global_ref->header);
#endif
hashtable_global_ref->entries++;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(hashtable_global_ref->header);
#endif
STATISTICS(jniinvokation());
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(hashtable_global_ref->header);
#endif
FREE(gre, hashtable_global_ref_entry);
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(hashtable_global_ref->header);
#endif
log_println("JNI-DeleteGlobalRef: global reference not found");
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(hashtable_global_ref->header);
#endif
}
{
STATISTICS(jniinvokation());
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
if (threads_get_current_threadobject() == NULL) {
*env = NULL;
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 $
*/
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;
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;
-/* 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,
cacaodbgcommunication *dbgcom;
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
struct _jrawMonitorID {
java_lang_String *name;
};
Samuel Vinson
- $Id: jvmti.c 4913 2006-05-14 14:02:51Z edwin $
+ $Id: jvmti.c 4921 2006-05-15 14:24:36Z twisti $
*/
#include <unistd.h>
#include <sched.h>
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
#include "threads/native/threads.h"
#include <sched.h>
#include <pthread.h>
CHECK_THREAD_IS_ALIVE(thread);
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
om=MNEW(java_objectheader*,size);
CHECK_THREAD_IS_ALIVE(thread);
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
pthread_mutex_lock(&lock_global_pool_lock);
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) {
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))
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)
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");
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;
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");
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;
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;
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;
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;
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
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 $
*/
u4 key; /* hashkey */
u4 slot; /* slot in hashtable */
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(hashtable_library->header);
#endif
while (ne) {
if (ne->name == filename) {
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(hashtable_library->header);
#endif
ne->hashlink = le->namelink;
le->namelink = ne;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(hashtable_library->header);
#endif
}
##
## 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
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
Changes:
- $Id: gennativetable.c 4908 2006-05-12 16:49:50Z edwin $
+ $Id: gennativetable.c 4921 2006-05-15 14:24:36Z twisti $
*/
#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"
methodinfo *m2;
bool nativelyoverloaded;
- void *dummy;
-
#if defined(DISABLE_GC)
nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
#endif
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) */
/* initialize the loader subsystems (must be done _after_
classcache_init) */
- if (!loader_init((u1 *) &dummy))
+ if (!loader_init())
throw_main_exception_exit();
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 <stdlib.h>
#include <string.h>
+#include "vm/types.h"
+
#include "mm/boehm.h"
#include "mm/memory.h"
#include "toolbox/logging.h"
#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"
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
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
*/
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
}
*/
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
}
*/
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
}
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 $
*/
#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"
*/
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 */
*/
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
}
*/
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
}
*/
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
}
*/
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
}
*/
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
}
*/
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
}
{
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");
*/
JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz)
{
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
threads_yield();
#endif
}
*/
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
}
*/
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
}
##
## 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
+++ /dev/null
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
+++ /dev/null
-## 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:
+++ /dev/null
-/* -*- 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 <tim@tjwassoc.demon.co.uk>, 1996.
- */
-
-
-#include <assert.h>
-#include <stdio.h>
-
-#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:
- */
+++ /dev/null
-/*
- * 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 <tim@tjwassoc.demon.co.uk>, 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:
- */
+++ /dev/null
-/*
- * 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 <tim@tjwassoc.demon.co.uk>, 1996.
- */
-
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <assert.h>
-#include <unistd.h>
-#include <string.h>
-
-#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:
- */
+++ /dev/null
-/* -*- c -*- */
-
-#ifndef __threadio_h_
-#define __threadio_h_
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#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
+++ /dev/null
-/* -*- 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 <tim@tjwassoc.demon.co.uk>, 1996.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/mman.h> /* for mprotect */
-#include <unistd.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <time.h>
-#include <errno.h>
-
-#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("<init>"),
- 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; i<len; i++)
- d[i] = mainname[i];
- }*/
-
- the_main_thread->priority = 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;i1<MAXTHREADS;i1++) {
- if (!contexts[i1]) continue;
- if (contexts[i1]->thread==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;i1<MAXTHREADS;i1++) {
- if (!contexts[i1]) continue;
- if (contexts[i1]->thread==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;i<MAXTHREADS;i++) {
- if (!contexts[i]) continue;
- if (contexts[i]==context) {
- contexts[i]=0;
- break;
- }
- }
- }
-/* if (tid != mainThread) {
- CONTEXT(tid).free = true;
- CONTEXT(tid).thread = NULL;
- }*/
-
- /* Run something else */
- needReschedule = true;
- }
- for (ntid = &sleepThreads;
- *ntid != 0;
- ntid = &(CONTEXT((*ntid)).next))
- {
- if (tid == (*ntid))
- {
- (*ntid) = context->next;
- 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:
- */
+++ /dev/null
-/* -*- 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 <tim@tjwassoc.demon.co.uk>, 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:
- */
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 $
*/
*******************************************************************************/
-bool threads_init(u1 *stackbottom)
+bool threads_init(void)
{
java_lang_String *threadname;
java_lang_Thread *mainthread;
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 $
*/
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 *);
Changes:
- $Id: avl.c 4908 2006-05-12 16:49:50Z edwin $
+ $Id: avl.c 4921 2006-05-15 14:24:36Z twisti $
*/
#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"
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;
assert(tree);
assert(data);
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(tree->lock);
#endif
printf("-------------------\n");
#endif
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(tree->lock);
#endif
assert(tree);
assert(data);
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(tree->lock);
#endif
/* was the entry found? return it */
if (res == 0) {
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(tree->lock);
#endif
node = node->childs[(res < 0) ? AVL_LEFT : AVL_RIGHT];
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(tree->lock);
#endif
Changes:
- $Id: avl.h 4357 2006-01-22 23:33:38Z twisti $
+ $Id: avl.h 4921 2006-05-15 14:24:36Z twisti $
*/
/* 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
};
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 <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include "config.h"
#include "vm/types.h"
#include "mm/memory.h"
#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
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);
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 $
*/
#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"
o->vftbl = c->vftbl;
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
lock_init_object_lock(o);
#endif
a->objheader.vftbl = arrayclass->vftbl;
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
lock_init_object_lock(&a->objheader);
#endif
#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)
{
}
#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);
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.
*/
#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
*******************************************************************************/
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
java_objectheader **builtin_asm_get_exceptionptrptr(void)
{
return builtin_get_exceptionptrptr();
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 $
*/
#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"
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);
/* 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)
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"
NULL
},
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
{
ICMD_MONITORENTER,
BUILTIN_monitorenter,
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 $
*/
#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"
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
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 $
*/
/* 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
hashtable hashtable_classcache;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static java_objectheader *lock_hashtable_classcache;
#endif
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 */
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 $
*/
/* for raising exceptions from native methods *********************************/
-#if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
+#if !defined(ENABLE_THREADS)
java_objectheader *_no_threads_exceptionptr = NULL;
#endif
s4 i;
classref_or_classinfo cr;
classinfo *c;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
java_objectheader *o;
#endif
}
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* is this method synchronized? */
if (issync) {
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 $
*/
#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
Changes:
- $Id: finalizer.c 4908 2006-05-12 16:49:50Z edwin $
+ $Id: finalizer.c 4921 2006-05-15 14:24:36Z twisti $
*/
/* global variables ***********************************************************/
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static java_lang_VMThread *finalizer_vmthread;
static java_objectheader *lock_finalizer_thread;
#endif
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 */
*******************************************************************************/
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static void finalizer_thread(void)
{
while (true) {
*******************************************************************************/
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
bool finalizer_start_thread(void)
{
java_lang_Thread *t;
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);
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 $
*/
#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 */
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
};
/* Synchronization ************************************************************/
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void compiler_lock();
void compiler_unlock();
#endif
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 $
*/
#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"
{
/* 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. */
hash->header = NEW(java_objectheader);
lock_init_object_lock(hash->header);
-# endif
#endif
/* set initial hash values */
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. */
Simply frees the hashtable.
+ ATTENTION: It does NOT free the lock object!
+
*******************************************************************************/
void hashtable_free(hashtable *hash)
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 $
*/
/* 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 */
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 $
*/
if (!makeinitializations)
return true;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* enter a monitor on the class */
builtin_monitorenter((java_objectheader *) 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
if (c->state & CLASS_ERROR) {
*exceptionptr = new_noclassdeffounderror(c->name);
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit((java_objectheader *) c);
#endif
c->state &= ~CLASS_INITIALIZING;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) c);
{
methodinfo *m;
java_objectheader *xptr;
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
- int b;
-#endif
/* maybe the class is not already linked */
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;
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 $
*/
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:
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 $
*/
/* 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
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)
.data
asm_criticalsections:
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
.quad _crit_begin
.quad _crit_end
.quad _crit_restart
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 $
*/
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
(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
/* call monitorenter function */
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
/* stack offset for monitor argument */
}
#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);
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);
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); */
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
/* } */
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);
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);
/* 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 */
/* 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);
/* 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 */
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *_uc)
{
mcontext_t *_mc;
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *_uc)
{
mcontext_t *_mc;
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 $
*/
#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"
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
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);
int code_get_sync_slot_count(codeinfo *code)
{
-#ifdef USE_THREADS
+#ifdef ENABLE_THREADS
int count;
assert(code);
return count;
-#else /* !USE_THREADS */
+#else /* !ENABLE_THREADS */
return 0;
-#endif /* USE_THREADS */
+#endif /* ENABLE_THREADS */
}
/* code_get_stack_frame_size ***************************************************
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 $
*/
#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"
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
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;
#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;
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void codegen_threadcritrestart(codegendata *cd, int offset)
{
cd->threadcritcurrent.mcoderestart = offset;
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 $
*/
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);
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 $
*/
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
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
.data
asm_criticalsections:
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
#if 0
.long _crit_begin1
.long _crit_end1
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 $
*/
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)) {
(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
/* call monitorenter function */
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
s1 = rd->memuse;
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) {
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) {
}
#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);
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);
}
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,
/* 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); */
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
/* } */
supervftbl = super->vftbl;
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
#endif
}
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,
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);
/* 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 */
*******************************************************************************/
-#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;
/* 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
/* 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);
/* 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 */
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *uc)
{
void *critical;
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *uc)
{
void *critical;
Changes:
- $Id: inline.c 4897 2006-05-10 15:09:49Z edwin $
+ $Id: inline.c 4921 2006-05-15 14:24:36Z twisti $
*/
#include "mm/memory.h"
#include "toolbox/logging.h"
+#include "vm/builtin.h"
#include "vm/global.h"
#include "vm/options.h"
#include "vm/statistics.h"
#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
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
#endif
return_r:
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) m );
#endif
Changes:
- $Id: asmpart.c 4856 2006-04-28 00:46:39Z edwin $
+ $Id: asmpart.c 4921 2006-05-15 14:24:36Z twisti $
*/
{
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;
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 $
*/
{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
(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
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);
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);
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);
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);
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 $
*/
#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"
static hashtable hashtable_patchersupers;
#define HASHTABLE_PATCHERSUPERS_BITS 14
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static java_objectheader *lock_hashtable_patchersupers;
#endif
static hashtable hashtable_superreuse;
#define HASHTABLE_SUPERREUSE_BITS 14
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static java_objectheader *lock_hashtable_superreuse;
#endif
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++;
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)) {
break;
}
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(lock_hashtable_patchersupers);
#endif
}
u4 slot = ((key + (key>>HASHTABLE_PATCHERSUPERS_BITS)) &
((1<<HASHTABLE_PATCHERSUPERS_BITS)-1));
void **listp = &hashtable_patchersupers.ptr[slot];
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(lock_hashtable_patchersupers);
#endif
ss->next = (superstart *)*listp;
*listp = (void *)ss;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(lock_hashtable_patchersupers);
#endif
count_patchers_ins++;
if (opt_no_replication)
hashtable_create(&hashtable_superreuse, 1<<HASHTABLE_SUPERREUSE_BITS);
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* create patchersupers hashtable lock object */
lock_hashtable_patchersupers = NEW(java_objectheader);
lock_hashtable_superreuse = NEW(java_objectheader);
-# if defined(NATIVE_THREADS)
lock_init_object_lock(lock_hashtable_patchersupers);
lock_init_object_lock(lock_hashtable_superreuse);
-# endif
#endif
}
Changes:
- $Id: engine.c 4912 2006-05-14 12:22:25Z edwin $
+ $Id: engine.c 4921 2006-05-15 14:24:36Z twisti $
*/
#include "vm/jit/methodheader.h"
#include "vm/jit/patcher.h"
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
# ifndef USE_FAKE_ATOMIC_INSTRUCTIONS
# include "machine-instr.h"
# else
# endif
#endif
-#if !defined(STORE_ORDER_BARRIER) && !defined(USE_THREADS)
+#if !defined(STORE_ORDER_BARRIER) && !defined(ENABLE_THREADS)
#define STORE_ORDER_BARRIER() /* nothing */
#endif
Changes: Edwin Steiner
- $Id: intrp.h 4913 2006-05-14 14:02:51Z edwin $
+ $Id: intrp.h 4921 2006-05-15 14:24:36Z twisti $
*/
#endif /* SIZEOF_VOID_P == 4 */
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
#define global_sp (*(Cell **)&(THREADOBJECT->_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];
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)
MONITORENTER ( aRef -- )
{
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* CHECK_NULL_PTR(aRef); is now done explicitly */
builtin_monitorenter(aRef);
#endif
MONITOREXIT ( aRef -- )
{
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* CHECK_NULL_PTR(aRef); cannot happen */
builtin_monitorexit(aRef);
#endif
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 $
*/
#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
#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
};
"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",
return m->code->entrypoint;
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* enter a monitor on the method */
builtin_monitorenter((java_objectheader *) 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
#endif
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) m);
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 $
*/
/* 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 */
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 $
*/
/* 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
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)
.data
asm_criticalsections:
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
.dword _crit_begin
.dword _crit_end
.dword _crit_restart
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 $
*/
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
(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
/* call monitorenter function */
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
/* stack offset for monitor argument */
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);
supervftbl = super->vftbl;
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
#endif
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); */
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
/* } */
supervftbl = super->vftbl;
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
#endif
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);
/* 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 */
/* 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);
/* 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 */
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *uc)
{
void *critical;
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *_uc)
{
mcontext_t *_mc;
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 $
*/
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;
}
break;
case JAVA_MONITORENTER:
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
if (checksync) {
OP(ICMD_CHECKNULL);
bte = builtintable_get_internal(BUILTIN_monitorenter);
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);
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 $
*/
/* patcher macros *************************************************************/
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
#define PATCHER_MONITORENTER \
/* enter a monitor on the patching position */ \
#define PATCHER_MONITOREXIT /* nop */
#define PATCHER_MARK_PATCHED_MONITOREXIT /* nop */
-#endif /* defined(USE_THREADS) */
+#endif /* defined(ENABLE_THREADS) */
/* function prototypes ********************************************************/
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 $
*/
.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
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 */
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 */
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:
.data
asm_criticalsections:
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
.long _crit_begin
.long _crit_end
.long _crit_restart
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 $
*/
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 */
(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
/* save monitorenter argument */
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
/* stack offset for monitor argument */
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 **************************************************/
/* 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);
}
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);
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);
}
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));
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);
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
}
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);
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);
default:
*exceptionptr =
- new_internalerror("Unknown ICMD %d", iptr->opc);
+ new_internalerror("Unknown ICMD %d during code generation",
+ iptr->opc);
return false;
} /* switch */
/* 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 */
/* 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);
/* 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 */
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 $
*/
#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
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *uc)
{
/* XXX set pc to restart address */
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *uc)
{
/* XXX set pc to restart address */
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *uc)
{
/* XXX set pc to restart address */
#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"
/* global variables ***********************************************************/
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static java_lang_VMThread *profile_vmthread;
#endif
*******************************************************************************/
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static void profile_thread(void)
{
/* s4 i = 0; */
*******************************************************************************/
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
bool profile_start_thread(void)
{
java_lang_Thread *t;
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 $
*/
/* global variables ***********************************************************/
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static java_objectheader *lock_stack_show_icmd;
#endif
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 */
#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 */
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. */
}
#endif
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(lock_stack_show_icmd);
#endif
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)) {
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 $
*/
#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
/* global variables ***********************************************************/
-#if !defined(USE_THREADS)
+#if !defined(ENABLE_THREADS)
stackframeinfo *_no_threads_stackframeinfo = NULL;
#endif
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;
Changes:
- $Id: stacktrace.h 4913 2006-05-14 14:02:51Z edwin $
+ $Id: stacktrace.h 4921 2006-05-15 14:24:36Z twisti $
*/
u1 *xpc; /* XPC (for inline stubs) */
};
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
#define STACKFRAMEINFO (&(THREADOBJECT->_stackframeinfo))
#else
extern stackframeinfo *_no_threads_stackframeinfo;
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 $
*/
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;
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 $
*/
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
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
.data
asm_criticalsections:
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
.quad _crit_begin
.quad _crit_end
.quad _crit_restart
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 $
*/
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))
(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
/* save monitorenter argument */
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
/* stack offset for monitor argument */
}
#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);
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);
}
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,
/* 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); */
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);
supervftbl = super->vftbl;
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
#endif
}
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,
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);
/* 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 */
/* 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
/* 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);
ptrint mcode;
u1 *savedmcodeptr;
u1 *tmpmcodeptr;
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
s4 disp;
#endif
/* 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 */
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 $
*/
}
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
void thread_restartcriticalsection(ucontext_t *uc)
{
void *critical;
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 $
*/
return NULL;
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* enter a monitor on the class */
builtin_monitorenter((java_objectheader *) 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
compilingtime_start();
#endif
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) 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)) {
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
}
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 $
*/
#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"
*******************************************************************************/
-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. */
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;
}
c = cb->class;
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
lock_init_object_lock(&m->header);
#endif
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
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 $
*/
};
-/* 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);
Changes:
- $Id: signal.c 4530 2006-02-21 09:11:53Z twisti $
+ $Id: signal.c 4921 2006-05-15 14:24:36Z twisti $
*/
#include "vm/types.h"
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
# include "threads/native/threads.h"
#endif
/* 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;
*******************************************************************************/
-#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 */
*******************************************************************************/
-#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 */
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 $
*/
hashtable hashtable_string; /* hashtable for javastrings */
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
static java_objectheader *lock_hashtable_string;
#endif
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 */
u4 slot;
u2 i;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(lock_hashtable_string);
#endif
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
js = NEW(java_lang_String);
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
lock_init_object_lock(&js->header);
#endif
hashtable_string = newhash;
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(lock_hashtable_string);
#endif
Changes:
- $Id: suck.c 4883 2006-05-05 18:58:00Z edwin $
+ $Id: suck.c 4921 2006-05-15 14:24:36Z twisti $
*/
#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);
cb = zip_get(lce, c);
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* leave the monitor */
builtin_monitorexit((java_objectheader *) lce);
Changes:
- $Id: suck.h 4357 2006-01-22 23:33:38Z twisti $
+ $Id: suck.h 4921 2006-05-15 14:24:36Z twisti $
*/
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;
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 $
*/
#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"
utf *u; /* hashtable element */
u2 i;
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorenter(hashtable_utf->header);
#endif
/* symbol found in hashtable */
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(hashtable_utf->header);
#endif
hashtable_utf = newhash;
}
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
builtin_monitorexit(hashtable_utf->header);
#endif
#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"
u1 *intrp_main_stack = NULL;
#endif
-void **stackbottom = NULL;
-
char *mainstring = NULL;
classinfo *mainclass = NULL;
}
#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) */
/* 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())
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
throw_main_exception_exit();
#endif
-#if defined(USE_THREADS)
+#if defined(ENABLE_THREADS)
/* finally, start the finalizer thread */
if (!finalizer_start_thread())
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 */
# 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