[kaffe] CVS kaffe (doogie): Implement macro wrappers around methods implemented by the threading
Kaffe CVS
cvs-commits at kaffe.org
Wed Dec 15 22:18:10 PST 2004
PatchSet 5647
Date: 2004/12/16 06:13:46
Author: doogie
Branch: HEAD
Tag: (none)
Log:
Implement macro wrappers around methods implemented by the threading
subsystem: KTHREAD, KSIGNAL, KSEM, KMUTEX, KCONDVAR.
Members:
ChangeLog:1.3192->1.3193
config/alpha/alpha.c:1.6->1.7
config/mips/common.h:1.10->1.11
config/mips/mips.c:1.13->1.14
config/parisc/common.h:1.4->1.5
config/sh/common.h:1.1->1.2
kaffe/jvmpi/jvmpi_kaffe.c:1.6->1.7
kaffe/kaffevm/classMethod.c:1.125->1.126
kaffe/kaffevm/classPool.c:1.28->1.29
kaffe/kaffevm/exception.c:1.88->1.89
kaffe/kaffevm/ksem.c:1.9->1.10
kaffe/kaffevm/ksem.h:1.9->1.10
kaffe/kaffevm/locks.c:1.51->1.52
kaffe/kaffevm/locks.h:1.25->1.26
kaffe/kaffevm/soft.c:1.69->1.70
kaffe/kaffevm/stackTrace.c:1.41->1.42
kaffe/kaffevm/support.c:1.78->1.79
kaffe/kaffevm/support.h:1.36->1.37
kaffe/kaffevm/thread.c:1.83->1.84
kaffe/kaffevm/thread.h:1.24->1.25
kaffe/kaffevm/utf8const.c:1.41->1.42
kaffe/kaffevm/boehm-gc/gc2.c:1.6->1.7
kaffe/kaffevm/intrp/machine.c:1.42->1.43
kaffe/kaffevm/intrp/stackTrace-impl.h:1.4->1.5
kaffe/kaffevm/jit/machine.c:1.69->1.70
kaffe/kaffevm/jni/jni.c:1.11->1.12
kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.12->1.13
kaffe/kaffevm/kaffe-gc/gc-incremental.h:1.4->1.5
kaffe/kaffevm/kaffe-gc/gc-mem.c:1.17->1.18
kaffe/kaffevm/kaffe-gc/gc-refs.c:1.4->1.5
kaffe/kaffevm/systems/beos-native/lock-impl.h:1.1->1.2
kaffe/xprof/xprofiler.c:1.7->1.8
libraries/clib/native/Object.c:1.10->1.11
libraries/clib/native/Thread.c:1.19->1.20
libraries/clib/net/InetAddressImpl.c:1.26->1.27
libraries/clib/net/PlainSocketImpl.c:1.48->1.49
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3192 kaffe/ChangeLog:1.3193
--- kaffe/ChangeLog:1.3192 Thu Dec 16 00:09:54 2004
+++ kaffe/ChangeLog Thu Dec 16 06:13:46 2004
@@ -1,3 +1,30 @@
+2004-12-16 Adam Heath <doogieg at brainfood.com>
+
+ * config/alpha/alpha.c, config/mips/common.h, config/mips/mips.c
+ config/parisc/common.h, config/sh/common.h,
+ kaffe/jvmpi/jvmpi_kaffe.c, kaffe/kaffevm/classMethod.c,
+ kaffe/kaffevm/classPool.c, kaffe/kaffevm/exception.c,
+ kaffe/kaffevm/ksem.c, kaffe/kaffevm/ksem.h,
+ kaffe/kaffevm/locks.c, kaffe/kaffevm/locks.h,
+ kaffe/kaffevm/soft.c, kaffe/kaffevm/stackTrace.c,
+ kaffe/kaffevm/support.c, kaffe/kaffevm/support.h,
+ kaffe/kaffevm/thread.c, kaffe/kaffevm/thread.h,
+ kaffe/kaffevm/utf8const.c, kaffe/kaffevm/boehm-gc/gc2.c,
+ kaffe/kaffevm/intrp/machine.c,
+ kaffe/kaffevm/intrp/stackTrace-impl.h,
+ kaffe/kaffevm/jit/machine.c, kaffe/kaffevm/jni/jni.c,
+ kaffe/kaffevm/kaffe-gc/gc-incremental.c,
+ kaffe/kaffevm/kaffe-gc/gc-incremental.h,
+ kaffe/kaffevm/kaffe-gc/gc-mem.c,
+ kaffe/kaffevm/kaffe-gc/gc-refs.c,
+ kaffe/kaffevm/systems/beos-native/lock-impl.h,
+ kaffe/xprof/xprofiler.c, libraries/clib/native/Object.c,
+ libraries/clib/native/Thread.c,
+ libraries/clib/net/InetAddressImpl.c,
+ libraries/clib/net/PlainSocketImpl.c:
+ Implement macro wrappers around methods implemented by the
+ threading subsystem: KTHREAD, KSIGNAL, KSEM, KMUTEX, KCONDVAR.
+
2004-12-16 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/org/xml/sax/AttributeList.java,
Index: kaffe/config/alpha/alpha.c
diff -u kaffe/config/alpha/alpha.c:1.6 kaffe/config/alpha/alpha.c:1.7
--- kaffe/config/alpha/alpha.c:1.6 Wed Jun 23 16:35:28 2004
+++ kaffe/config/alpha/alpha.c Thu Dec 16 06:13:48 2004
@@ -84,7 +84,7 @@
dprintf ("nextFrame pc %p sp %p fp %p\n", pc, (int *) sp, (int *) fp); );
}
- if (!jthread_on_current_stack((void*)sp)) {
+ if (!KTHREAD(on_current_stack)((void*)sp)) {
return NULL;
}
Index: kaffe/config/mips/common.h
diff -u kaffe/config/mips/common.h:1.10 kaffe/config/mips/common.h:1.11
--- kaffe/config/mips/common.h:1.10 Wed Jul 7 22:15:08 2004
+++ kaffe/config/mips/common.h Thu Dec 16 06:13:49 2004
@@ -53,13 +53,13 @@
#define COMPARE_AND_EXCHANGE(A,O,N) \
({ \
int ret = 0; \
- jthread_suspendall(); \
+ KTHREAD(suspendall)(); \
\
if (*(A) == (O)) { \
*(A) = (N); \
ret = 1; \
} \
- jthread_unsuspendall(); \
+ KTHREAD(unsuspendall)(); \
ret; \
})
Index: kaffe/config/mips/mips.c
diff -u kaffe/config/mips/mips.c:1.13 kaffe/config/mips/mips.c:1.14
--- kaffe/config/mips/mips.c:1.13 Sun Jul 11 19:03:03 2004
+++ kaffe/config/mips/mips.c Thu Dec 16 06:13:49 2004
@@ -89,7 +89,7 @@
}
#endif
- if (!jthread_on_current_stack(fp)) {
+ if (!KTHREAD(on_current_stack)(fp)) {
pfp = 0;
ppc = 0;
goto end;
Index: kaffe/config/parisc/common.h
diff -u kaffe/config/parisc/common.h:1.4 kaffe/config/parisc/common.h:1.5
--- kaffe/config/parisc/common.h:1.4 Fri Dec 12 17:27:51 2003
+++ kaffe/config/parisc/common.h Thu Dec 16 06:13:49 2004
@@ -31,13 +31,13 @@
#define COMPARE_AND_EXCHANGE(A,O,N) \
({ \
int ret = 0; \
- jthread_suspendall(); \
+ KTHREAD(suspendall)(); \
\
if (*(A) == (O)) { \
*(A) = (N); \
ret = 1; \
} \
- jthread_unsuspendall(); \
+ KTHREAD(unsuspendall)(); \
ret; \
})
Index: kaffe/config/sh/common.h
diff -u kaffe/config/sh/common.h:1.1 kaffe/config/sh/common.h:1.2
--- kaffe/config/sh/common.h:1.1 Wed Jul 14 14:37:34 2004
+++ kaffe/config/sh/common.h Thu Dec 16 06:13:49 2004
@@ -30,13 +30,13 @@
#define COMPARE_AND_EXCHANGE(A,O,N) \
({ \
int ret = 0; \
- jthread_suspendall(); \
+ KTHREAD(suspendall)(); \
\
if (*(A) == (O)) { \
*(A) = (N); \
ret = 1; \
} \
- jthread_unsuspendall(); \
+ KTHREAD(unsuspendall)(); \
ret; \
})
Index: kaffe/kaffe/jvmpi/jvmpi_kaffe.c
diff -u kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.6 kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.7
--- kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.6 Tue Oct 12 02:00:23 2004
+++ kaffe/kaffe/jvmpi/jvmpi_kaffe.c Thu Dec 16 06:13:49 2004
@@ -195,7 +195,7 @@
ev->u.thread_start.parent_name = NULL;
ev->u.thread_start.thread_id = tid;
ev->u.thread_start.thread_env_id =
- &jthread_get_data((jthread_t)tid->PrivateInfo)->jniEnv;
+ &KTHREAD(get_data)((jthread_t)tid->PrivateInfo)->jniEnv;
}
void jvmpiFillClassLoad(JVMPI_Event *ev, struct Hjava_lang_Class *cl)
@@ -345,14 +345,14 @@
assert(depth > 0);
trace->num_frames = 0;
- if( (jt = jthread_from_data((threadData *)trace->env_id,
+ if( (jt = KTHREAD(from_data)((threadData *)trace->env_id,
&jvmpi_data)) != NULL )
{
sti = (stackTraceInfo *)
- buildStackTrace(jt == jthread_current() ?
+ buildStackTrace(jt == KTHREAD(current)() ?
NULL :
- &jthread_get_data(jt)->topFrame);
- jthread_resume(jt, &jvmpi_data);
+ &KTHREAD(get_data)(jt)->topFrame);
+ KTHREAD(resume)(jt, &jvmpi_data);
}
if( sti != NULL )
{
@@ -404,7 +404,7 @@
{
jlong retval;
- retval = jthread_get_usage(jthread_current());
+ retval = KTHREAD(get_usage)(KTHREAD(current)());
return( retval );
}
@@ -425,11 +425,11 @@
assert(env_id != NULL);
- if( (jt = jthread_from_data((threadData *)env_id,
+ if( (jt = KTHREAD(from_data)((threadData *)env_id,
&jvmpi_data)) != NULL )
{
- retval = jthread_get_data(jt)->jvmpiData;
- jthread_resume(jt, &jvmpi_data);
+ retval = KTHREAD(get_data)(jt)->jvmpiData;
+ KTHREAD(resume)(jt, &jvmpi_data);
}
return( retval );
}
@@ -441,11 +441,11 @@
assert(env_id != NULL);
- if( (jt = jthread_from_data((threadData *)env_id,
+ if( (jt = KTHREAD(from_data)((threadData *)env_id,
&jvmpi_data)) != NULL )
{
- retval = jthread_get_data(jt)->jlThread;
- jthread_resume(jt, &jvmpi_data);
+ retval = KTHREAD(get_data)(jt)->jlThread;
+ KTHREAD(resume)(jt, &jvmpi_data);
}
return( retval );
}
@@ -457,20 +457,20 @@
assert(env_id != NULL);
- if( (jt = jthread_from_data((threadData *)env_id,
+ if( (jt = KTHREAD(from_data)((threadData *)env_id,
&jvmpi_data)) != NULL )
{
- if( jthread_on_mutex(jt) )
+ if( KTHREAD(on_mutex)(jt) )
{
retval = JVMPI_THREAD_MONITOR_WAIT;
}
- else if( jthread_on_condvar(jt) )
+ else if( KTHREAD(on_condvar)(jt) )
{
retval = JVMPI_THREAD_CONDVAR_WAIT;
}
else
{
- switch( jthread_get_status(jt) )
+ switch( KTHREAD(get_status)(jt) )
{
case THREAD_RUNNING:
retval = JVMPI_THREAD_RUNNABLE;
@@ -481,11 +481,11 @@
break;
}
}
- if( jthread_is_interrupted(jt) )
+ if( KTHREAD(is_interrupted)(jt) )
{
retval |= JVMPI_THREAD_INTERRUPTED;
}
- jthread_resume(jt, &jvmpi_data);
+ KTHREAD(resume)(jt, &jvmpi_data);
}
else
{
@@ -516,8 +516,8 @@
{
if( lock_id != NULL )
{
- jmutex_destroy(&lock_id->mux);
- jcondvar_destroy(&lock_id->cv);
+ KMUTEX(destroy)(&lock_id->mux);
+ KCONDVAR(destroy)(&lock_id->cv);
jfree(lock_id);
}
}
@@ -526,28 +526,28 @@
{
assert(lock_id != NULL);
- jmutex_lock(&lock_id->mux);
+ KMUTEX(lock)(&lock_id->mux);
}
static void jvmpiRawMonitorExit(JVMPI_RawMonitor lock_id)
{
assert(lock_id != NULL);
- jmutex_unlock(&lock_id->mux);
+ KMUTEX(unlock)(&lock_id->mux);
}
static void jvmpiRawMonitorNotifyAll(JVMPI_RawMonitor lock_id)
{
assert(lock_id != NULL);
- jcondvar_broadcast(&lock_id->cv, &lock_id->mux);
+ KCONDVAR(broadcast)(&lock_id->cv, &lock_id->mux);
}
static void jvmpiRawMonitorWait(JVMPI_RawMonitor lock_id, jlong ms)
{
assert(lock_id != NULL);
- jcondvar_wait(&lock_id->cv, &lock_id->mux, ms);
+ KCONDVAR(wait)(&lock_id->cv, &lock_id->mux, ms);
}
static jint jvmpiRequestEvent(jint event_type, void *arg)
@@ -619,10 +619,10 @@
assert(env != NULL);
- if( (jt = jthread_from_data((threadData *)env, &jvmpi_data)) != NULL )
+ if( (jt = KTHREAD(from_data)((threadData *)env, &jvmpi_data)) != NULL )
{
- jthread_resume(jt, &jvmpi_data);
- jthread_resume(jt, &jvmpi_data);
+ KTHREAD(resume)(jt, &jvmpi_data);
+ KTHREAD(resume)(jt, &jvmpi_data);
}
}
@@ -649,11 +649,11 @@
assert(env_id != NULL);
- if( (jt = jthread_from_data((threadData *)env_id,
+ if( (jt = KTHREAD(from_data)((threadData *)env_id,
&jvmpi_data)) != NULL )
{
- jthread_get_data(jt)->jvmpiData = ptr;
- jthread_resume(jt, &jvmpi_data);
+ KTHREAD(get_data)(jt)->jvmpiData = ptr;
+ KTHREAD(resume)(jt, &jvmpi_data);
}
}
@@ -661,8 +661,8 @@
{
jthread_t jt;
- jt = jthread_from_data((threadData *)env_id, &jvmpi_data);
- jthread_clear_run(jt);
+ jt = KTHREAD(from_data)((threadData *)env_id, &jvmpi_data);
+ KTHREAD(clear_run)(jt);
}
static void jvmpiSuspendThreadList(jint reqCount, JNIEnv **reqList, jint *results)
@@ -686,10 +686,10 @@
jboolean retval = JNI_FALSE;
jthread_t jt;
- if( (jt = jthread_from_data((threadData *)env, &jvmpi_data)) != NULL )
+ if( (jt = KTHREAD(from_data)((threadData *)env, &jvmpi_data)) != NULL )
{
- retval = jthread_has_run(jt);
- jthread_resume(jt, &jvmpi_data);
+ retval = KTHREAD(has_run)(jt);
+ KTHREAD(resume)(jt, &jvmpi_data);
}
return( retval );
}
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.125 kaffe/kaffe/kaffevm/classMethod.c:1.126
--- kaffe/kaffe/kaffevm/classMethod.c:1.125 Sat Dec 11 07:00:50 2004
+++ kaffe/kaffe/kaffevm/classMethod.c Thu Dec 16 06:13:50 2004
@@ -147,7 +147,7 @@
depth++;
for (i = 0; i < depth; dprintf(" "), i++);
dprintf("%p entering process class %s %d->%d\n",
- jthread_current(), class->name->data,
+ KTHREAD(current)(), class->name->data,
class->state, tostate);
)
@@ -651,7 +651,7 @@
for (i = 0; i < depth; dprintf(" "), i++);
depth--;
dprintf("%p leaving process class %s -> %s\n",
- jthread_current(), class->name->data,
+ KTHREAD(current)(), class->name->data,
success ? "success" : "failure");
)
return (success);
Index: kaffe/kaffe/kaffevm/classPool.c
diff -u kaffe/kaffe/kaffevm/classPool.c:1.28 kaffe/kaffe/kaffevm/classPool.c:1.29
--- kaffe/kaffe/kaffevm/classPool.c:1.28 Mon Aug 2 10:44:56 2004
+++ kaffe/kaffe/kaffevm/classPool.c Thu Dec 16 06:13:50 2004
@@ -331,7 +331,7 @@
jthread_t jt;
int iLockRoot;
- jt = jthread_current();
+ jt = KTHREAD(current)();
while( !done )
{
lockMutex(ce);
@@ -404,7 +404,7 @@
int iLockRoot;
*out_cl = 0;
- jt = jthread_current();
+ jt = KTHREAD(current)();
while( !done )
{
lockMutex(ce);
Index: kaffe/kaffe/kaffevm/exception.c
diff -u kaffe/kaffe/kaffevm/exception.c:1.88 kaffe/kaffe/kaffevm/exception.c:1.89
--- kaffe/kaffe/kaffevm/exception.c:1.88 Sat Dec 11 07:00:50 2004
+++ kaffe/kaffe/kaffevm/exception.c Thu Dec 16 06:13:50 2004
@@ -457,7 +457,7 @@
dprintf("initExceptions()\n");
)
/* Catch signals we need to convert to exceptions */
- jthread_initexceptions(nullException, floatingException, stackOverflowException);
+ KTHREAD(initexceptions)(nullException, floatingException, stackOverflowException);
}
/*
Index: kaffe/kaffe/kaffevm/ksem.c
diff -u kaffe/kaffe/kaffevm/ksem.c:1.9 kaffe/kaffe/kaffevm/ksem.c:1.10
--- kaffe/kaffe/kaffevm/ksem.c:1.9 Wed Oct 20 16:47:13 2004
+++ kaffe/kaffe/kaffevm/ksem.c Thu Dec 16 06:13:50 2004
@@ -9,6 +9,7 @@
*/
#include "ksem.h"
+#include "support.h"
#ifndef THREAD_SYSTEM_HAS_KSEM
@@ -17,7 +18,7 @@
* by the threading system when a new thread is allocated.
*/
void
-ksemInit(Ksem* sem)
+ksem_init(Ksem* sem)
{
assert(sem != NULL);
@@ -39,7 +40,7 @@
* we timed-out in wait and semaphore still wasn't available.
*/
jboolean
-ksemGet(Ksem* volatile sem, jlong timeout)
+ksem_get(Ksem* volatile sem, jlong timeout)
{
jboolean r;
@@ -50,10 +51,10 @@
if (timeout == 0)
timeout = NOTIMEOUT;
- jmutex_lock(&sem->mux);
+ KMUTEX(lock)(&sem->mux);
/* If no stored wakeups, then sleep. */
if (sem->count == 0) {
- (void)jcondvar_wait(&sem->cv, &sem->mux, timeout);
+ (void)KCONDVAR(wait)(&sem->cv, &sem->mux, timeout);
}
/* Use a stored wakeup if available. */
@@ -66,7 +67,7 @@
r = false;
}
assert(sem->count == 0);
- jmutex_unlock(&sem->mux);
+ KMUTEX(unlock)(&sem->mux);
return (r);
}
@@ -75,21 +76,21 @@
* on the cv (if any).
*/
void
-ksemPut(Ksem* volatile sem)
+ksem_put(Ksem* volatile sem)
{
assert(sem != NULL);
- jmutex_lock(&sem->mux);
+ KMUTEX(lock)(&sem->mux);
sem->count = 1;
- jcondvar_signal(&sem->cv, &sem->mux);
- jmutex_unlock(&sem->mux);
+ KCONDVAR(signal)(&sem->cv, &sem->mux);
+ KMUTEX(unlock)(&sem->mux);
}
void
-ksemDestroy(Ksem* sem)
+ksem_destroy(Ksem* sem)
{
assert(sem != NULL);
- jmutex_destroy(&(sem->mux));
- jcondvar_destroy(&(sem->cv));
+ KMUTEX(destroy)(&(sem->mux));
+ KCONDVAR(destroy)(&(sem->cv));
}
#endif
Index: kaffe/kaffe/kaffevm/ksem.h
diff -u kaffe/kaffe/kaffevm/ksem.h:1.9 kaffe/kaffe/kaffevm/ksem.h:1.10
--- kaffe/kaffe/kaffevm/ksem.h:1.9 Wed Sep 29 19:35:43 2004
+++ kaffe/kaffe/kaffevm/ksem.h Thu Dec 16 06:13:50 2004
@@ -39,10 +39,10 @@
*/
#ifndef THREAD_SYSTEM_HAS_KSEM
- extern void ksemInit(struct Ksem* sem);
- extern void ksemPut(struct Ksem* sem);
- extern jboolean ksemGet(struct Ksem* sem, jlong timeout);
- extern void ksemDestroy(struct Ksem* sem);
+ extern void ksem_init(struct Ksem* sem);
+ extern void ksem_put(struct Ksem* sem);
+ extern jboolean ksem_get(struct Ksem* sem, jlong timeout);
+ extern void ksem_destroy(struct Ksem* sem);
/*
* Present POSIX mutex+condvar as a binary semaphore.
Index: kaffe/kaffe/kaffevm/locks.c
diff -u kaffe/kaffe/kaffevm/locks.c:1.51 kaffe/kaffe/kaffevm/locks.c:1.52
--- kaffe/kaffe/kaffevm/locks.c:1.51 Tue Aug 31 15:24:42 2004
+++ kaffe/kaffe/kaffevm/locks.c Thu Dec 16 06:13:50 2004
@@ -82,7 +82,7 @@
DBG(SLOWLOCKS,
dprintf(" getHeavyLock(**lkp=%p, *lk=%p, th=%p)\n",
- lkp, *lkp, jthread_current());
+ lkp, *lkp, KTHREAD(current)());
)
lk = heavyLock;
@@ -95,7 +95,7 @@
if (old == LOCKINPROGRESS || !COMPARE_AND_EXCHANGE(lkp, old, LOCKINPROGRESS)) {
/* Someone else put the lock in LOCKINPROGRESS state */
backoffcount++;
- ksemGet(&THREAD_DATA()->sem, timeout);
+ KSEM(get)(&THREAD_DATA()->sem, timeout);
/* Back off */
timeout = (timeout << 1)|timeout;
continue;
@@ -148,7 +148,7 @@
DBG(SLOWLOCKS,
dprintf(" putHeavyLock(**lkp=%p, *lk=%p, th=%p)\n",
- lkp, lk, jthread_current());
+ lkp, lk, KTHREAD(current)());
)
if (lk == LOCKFREE) {
@@ -167,21 +167,21 @@
slowLockMutex(iLock** lkp, void* where, iLock *heavyLock)
{
iLock* lk;
- jthread_t cur = jthread_current ();
+ jthread_t cur = KTHREAD(current) ();
DBG(SLOWLOCKS,
dprintf("slowLockMutex(**lkp=%p, where=%p, th=%p)\n",
- lkp, where, jthread_current());
+ lkp, where, KTHREAD(current)());
)
- jthread_disable_stop(); /* protect the heavy lock, and its queues */
+ KTHREAD(disable_stop)(); /* protect the heavy lock, and its queues */
for (;;) {
lk = getHeavyLock(lkp, heavyLock);
/* If I hold the heavy lock then just keep on going */
- if (jthread_on_current_stack(lk->holder)) {
+ if (KTHREAD(on_current_stack)(lk->holder)) {
putHeavyLock(lkp, lk);
- jthread_enable_stop();
+ KTHREAD(enable_stop)();
return;
}
@@ -189,15 +189,15 @@
if (lk->holder == 0) {
lk->holder = where;
putHeavyLock(lkp, lk);
- jthread_enable_stop();
+ KTHREAD(enable_stop)();
return;
}
/* Otherwise wait for holder to release it */
- jthread_get_data(cur)->nextlk = lk->mux;
+ KTHREAD(get_data)(cur)->nextlk = lk->mux;
lk->mux = cur;
putHeavyLock(lkp, lk);
- ksemGet(&jthread_get_data(cur)->sem, (jlong)0);
+ KSEM(get)(&KTHREAD(get_data)(cur)->sem, (jlong)0);
}
}
@@ -214,15 +214,15 @@
DBG(SLOWLOCKS,
dprintf("slowUnlockMutex(**lkp=%p, where=%p, th=%p)\n",
- lkp, where, jthread_current());
+ lkp, where, KTHREAD(current)());
)
- jthread_disable_stop(); /* protect the heavy lock, and its queues */
+ KTHREAD(disable_stop)(); /* protect the heavy lock, and its queues */
lk = getHeavyLock(lkp, heavyLock);
/* Only the lock holder can be doing an unlock */
- if (!jthread_on_current_stack(lk->holder)) {
+ if (!KTHREAD(on_current_stack)(lk->holder)) {
putHeavyLock(lkp, lk);
- jthread_enable_stop();
+ KTHREAD(enable_stop)();
throwException(IllegalMonitorStateException);
}
@@ -233,7 +233,7 @@
if (lk->holder > where) {
#endif
putHeavyLock(lkp, lk);
- jthread_enable_stop();
+ KTHREAD(enable_stop)();
return;
}
@@ -242,11 +242,11 @@
*/
if (lk->mux != 0) {
tid = lk->mux;
- lk->mux = jthread_get_data(tid)->nextlk;
- jthread_get_data(tid)->nextlk = 0;
+ lk->mux = KTHREAD(get_data)(tid)->nextlk;
+ KTHREAD(get_data)(tid)->nextlk = 0;
lk->holder = 0;
putHeavyLock(lkp, lk);
- ksemPut(&jthread_get_data(tid)->sem);
+ KSEM(put)(&KTHREAD(get_data)(tid)->sem);
}
/* If someone's waiting to be signaled keep the heavy in place */
else if (lk->cv != 0) {
@@ -259,7 +259,7 @@
}
putHeavyLock(lkp, LOCKFREE);
}
- jthread_enable_stop();
+ KTHREAD(enable_stop)();
}
void
@@ -270,7 +270,7 @@
DBG(SLOWLOCKS,
dprintf("slowUnlockMutexIfHeld(**lkp=%p, where=%p, th=%p)\n",
- lkp, where, jthread_current());
+ lkp, where, KTHREAD(current)());
)
holder = *lkp;
@@ -282,7 +282,7 @@
/* if it's a thin lock and this thread owns it,
* try to free it the easy way
*/
- if (jthread_on_current_stack(holder) &&
+ if (KTHREAD(on_current_stack)(holder) &&
COMPARE_AND_EXCHANGE(lkp, holder, LOCKFREE)) {
return;
}
@@ -292,7 +292,7 @@
holder = lk->holder;
putHeavyLock(lkp, lk);
- if (jthread_on_current_stack(holder)) {
+ if (KTHREAD(on_current_stack)(holder)) {
slowUnlockMutex(lkp, where, heavyLock);
}
}
@@ -302,29 +302,29 @@
{
iLock* lk;
void* holder;
- jthread_t cur = jthread_current();
+ jthread_t cur = KTHREAD(current)();
jthread_t *ptr;
jboolean r;
DBG(SLOWLOCKS,
dprintf("_waitCond(**lkp=%p, timeout=%ld, th=%p)\n",
- lkp, (long)timeout, jthread_current());
+ lkp, (long)timeout, KTHREAD(current)());
)
lk = getHeavyLock(lkp, heavyLock);
holder = lk->holder;
/* I must be holding the damn thing */
- if (!jthread_on_current_stack(holder)) {
+ if (!KTHREAD(on_current_stack)(holder)) {
putHeavyLock(lkp, holder);
throwException(IllegalMonitorStateException);
}
- jthread_get_data(cur)->nextlk = lk->cv;
+ KTHREAD(get_data)(cur)->nextlk = lk->cv;
lk->cv = cur;
putHeavyLock(lkp, lk);
slowUnlockMutex(lkp, holder, heavyLock);
- r = ksemGet(&jthread_get_data(cur)->sem, timeout);
+ r = KSEM(get)(&KTHREAD(get_data)(cur)->sem, timeout);
/* Timeout */
if (r == false) {
@@ -332,22 +332,22 @@
/* Remove myself from CV or MUX queue - if I'm * not on either
* then I should wait on myself to remove any pending signal.
*/
- for (ptr = &lk->cv; *ptr != 0; ptr = &jthread_get_data(*ptr)->nextlk) {
+ for (ptr = &lk->cv; *ptr != 0; ptr = &KTHREAD(get_data)(*ptr)->nextlk) {
if ((*ptr) == cur) {
- *ptr = jthread_get_data(cur)->nextlk;
+ *ptr = KTHREAD(get_data)(cur)->nextlk;
goto found;
}
}
- for (ptr = &lk->mux; *ptr != 0; ptr = &jthread_get_data(*ptr)->nextlk) {
+ for (ptr = &lk->mux; *ptr != 0; ptr = &KTHREAD(get_data)(*ptr)->nextlk) {
if ((*ptr) == cur) {
- *ptr = jthread_get_data(cur)->nextlk;
+ *ptr = KTHREAD(get_data)(cur)->nextlk;
goto found;
}
}
/* Not on list - so must have been signalled after all -
* decrease the semaphore to avoid problems.
*/
- ksemGet(&jthread_get_data(cur)->sem, (jlong)0);
+ KSEM(get)(&KTHREAD(get_data)(cur)->sem, (jlong)0);
found:;
putHeavyLock(lkp, lk);
@@ -366,12 +366,12 @@
DBG(SLOWLOCKS,
dprintf("_signalCond(**lkp=%p, th=%p)\n",
- lkp, jthread_current());
+ lkp, KTHREAD(current)());
)
lk = getHeavyLock(lkp, heavyLock);
- if (!jthread_on_current_stack(lk->holder)) {
+ if (!KTHREAD(on_current_stack)(lk->holder)) {
putHeavyLock(lkp, lk);
throwException(IllegalMonitorStateException);
}
@@ -379,8 +379,8 @@
/* Move one CV's onto the MUX */
tid = lk->cv;
if (tid != 0) {
- lk->cv = jthread_get_data(tid)->nextlk;
- jthread_get_data(tid)->nextlk = lk->mux;
+ lk->cv = KTHREAD(get_data)(tid)->nextlk;
+ KTHREAD(get_data)(tid)->nextlk = lk->mux;
lk->mux = tid;
}
@@ -395,12 +395,12 @@
DBG(SLOWLOCKS,
dprintf("_broadcastCond(**lkp=%p, th=%p)\n",
- lkp, jthread_current());
+ lkp, KTHREAD(current)());
)
lk = getHeavyLock(lkp, heavyLock);
- if (!jthread_on_current_stack(lk->holder)) {
+ if (!KTHREAD(on_current_stack)(lk->holder)) {
putHeavyLock(lkp, lk);
throwException(IllegalMonitorStateException);
}
@@ -408,8 +408,8 @@
/* Move all the CV's onto the MUX */
while (lk->cv != 0) {
tid = lk->cv;
- lk->cv = jthread_get_data(tid)->nextlk;
- jthread_get_data(tid)->nextlk = lk->mux;
+ lk->cv = KTHREAD(get_data)(tid)->nextlk;
+ KTHREAD(get_data)(tid)->nextlk = lk->mux;
lk->mux = tid;
}
@@ -433,7 +433,7 @@
slowLockMutex(lkp, where, heavyLock);
}
}
- else if (!jthread_on_current_stack((void *)val)) {
+ else if (!KTHREAD(on_current_stack)((void *)val)) {
/* XXX count this in the stats area */
slowLockMutex(lkp, where, heavyLock);
}
Index: kaffe/kaffe/kaffevm/locks.h
diff -u kaffe/kaffe/kaffevm/locks.h:1.25 kaffe/kaffe/kaffevm/locks.h:1.26
--- kaffe/kaffe/kaffevm/locks.h:1.25 Thu Jul 29 14:24:50 2004
+++ kaffe/kaffe/kaffevm/locks.h Thu Dec 16 06:13:50 2004
@@ -16,18 +16,19 @@
#include "thread-impl.h"
#include "md.h"
+#include "support.h"
struct _iLock;
#define LOCKOBJECT struct _iLock**
-#define lockMutex(O) (jthread_disable_stop(), locks_internal_lockMutex(&(O)->lock, &iLockRoot, 0))
-#define unlockMutex(O) do { locks_internal_unlockMutex(&(O)->lock, &iLockRoot, 0); jthread_enable_stop(); } while (0)
+#define lockMutex(O) (KTHREAD(disable_stop)(), locks_internal_lockMutex(&(O)->lock, &iLockRoot, 0))
+#define unlockMutex(O) do { locks_internal_unlockMutex(&(O)->lock, &iLockRoot, 0); KTHREAD(enable_stop)(); } while (0)
#define waitCond(O,T) locks_internal_waitCond(&(O)->lock, (T), 0)
#define signalCond(O) locks_internal_signalCond(&(O)->lock, 0)
#define broadcastCond(O) locks_internal_broadcastCond(&(O)->lock, 0)
-#define lockStaticMutex(THING) (jthread_disable_stop(), locks_internal_lockMutex(&(THING)->lock, &iLockRoot, &(THING)->heavyLock))
-#define unlockStaticMutex(THING) do { locks_internal_unlockMutex(&(THING)->lock, &iLockRoot, &(THING)->heavyLock); jthread_enable_stop(); } while(0)
+#define lockStaticMutex(THING) (KTHREAD(disable_stop)(), locks_internal_lockMutex(&(THING)->lock, &iLockRoot, &(THING)->heavyLock))
+#define unlockStaticMutex(THING) do { locks_internal_unlockMutex(&(THING)->lock, &iLockRoot, &(THING)->heavyLock); KTHREAD(enable_stop)(); } while(0)
#define waitStaticCond(THING, TIME) locks_internal_waitCond(&(THING)->lock, (TIME), &(THING)->heavyLock)
#define signalStaticCond(THING) locks_internal_signalCond(&(THING)->lock, &(THING)->heavyLock)
#define broadcastStaticCond(THING) locks_internal_broadcastCond(&(THING)->lock, &(THING)->heavyLock)
Index: kaffe/kaffe/kaffevm/soft.c
diff -u kaffe/kaffe/kaffevm/soft.c:1.69 kaffe/kaffe/kaffevm/soft.c:1.70
--- kaffe/kaffe/kaffevm/soft.c:1.69 Sat Dec 11 20:49:39 2004
+++ kaffe/kaffe/kaffevm/soft.c Thu Dec 16 06:13:50 2004
@@ -476,10 +476,10 @@
errorInfo einfo;
/* XXX Dear lord this sucks! */
- jthread_relaxstack(1);
+ KTHREAD(relaxstack)(1);
th = (Hjava_lang_Throwable *)
newObjectChecked(javaLangStackOverflowError, &einfo);
- jthread_relaxstack(0);
+ KTHREAD(relaxstack)(0);
throwException(th);
}
Index: kaffe/kaffe/kaffevm/stackTrace.c
diff -u kaffe/kaffe/kaffevm/stackTrace.c:1.41 kaffe/kaffe/kaffevm/stackTrace.c:1.42
--- kaffe/kaffe/kaffevm/stackTrace.c:1.41 Sat Dec 11 20:49:39 2004
+++ kaffe/kaffe/kaffevm/stackTrace.c Thu Dec 16 06:13:52 2004
@@ -58,7 +58,7 @@
dprintf("STACKTRACEINIT(trace, %p, %p, orig);\n", base, base); );
STACKTRACEINIT(trace, base, base, orig);
cnt = 0;
- while(STACKTRACEFRAME(trace) && jthread_on_current_stack ((void *)STACKTRACEFP(trace))) {
+ while(STACKTRACEFRAME(trace) && KTHREAD(on_current_stack) ((void *)STACKTRACEFP(trace))) {
cnt++;
STACKTRACESTEP(trace);
}
@@ -77,7 +77,7 @@
dprintf("STACKTRACEINIT(trace, &orig, %p, orig);\n", base); );
STACKTRACEINIT(trace, &orig, base, orig);
- while (STACKTRACEFRAME(trace) && jthread_on_current_stack ((void *)STACKTRACEFP(trace))) {
+ while (STACKTRACEFRAME(trace) && KTHREAD(on_current_stack) ((void *)STACKTRACEFP(trace))) {
info[cnt].pc = STACKTRACEPC(trace);
info[cnt].fp = STACKTRACEFP(trace);
info[cnt].meth = stacktraceFindMethod (info[cnt].fp, info[cnt].pc);
Index: kaffe/kaffe/kaffevm/support.c
diff -u kaffe/kaffe/kaffevm/support.c:1.78 kaffe/kaffe/kaffevm/support.c:1.79
--- kaffe/kaffe/kaffevm/support.c:1.78 Sat Dec 11 20:49:40 2004
+++ kaffe/kaffe/kaffevm/support.c Thu Dec 16 06:13:52 2004
@@ -466,7 +466,7 @@
#if defined(STACK_LIMIT)
call.calltype[i] = 'L';
call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
- call.args[i].l = jthread_stacklimit();
+ call.args[i].l = KTHREAD(stacklimit)();
s += PTR_TYPE_SIZE / SIZEOF_INT;
i++;
#endif
@@ -597,7 +597,7 @@
#if defined(STACK_LIMIT)
call.calltype[i] = 'L';
call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
- call.args[i].l = jthread_stacklimit();
+ call.args[i].l = KTHREAD(stacklimit)();
s += PTR_TYPE_SIZE / SIZEOF_INT;
i++;
#endif
@@ -904,13 +904,13 @@
void
enterUnsafeRegion(void)
{
- jthread_spinon(0);
+ KTHREAD(spinon)(0);
}
void
leaveUnsafeRegion(void)
{
- jthread_spinoff(0);
+ KTHREAD(spinoff)(0);
}
/* XXX Ick */
Index: kaffe/kaffe/kaffevm/support.h
diff -u kaffe/kaffe/kaffevm/support.h:1.36 kaffe/kaffe/kaffevm/support.h:1.37
--- kaffe/kaffe/kaffevm/support.h:1.36 Fri Dec 10 00:37:23 2004
+++ kaffe/kaffe/kaffevm/support.h Thu Dec 16 06:13:52 2004
@@ -16,6 +16,12 @@
#include "gtypes.h"
#include <stdarg.h>
+#define KTHREAD(function) jthread_ ## function
+#define KSIGNAL(function) jsignal_ ## function
+#define KSEM(function) ksem_ ## function
+#define KMUTEX(function) jmutex_ ## function
+#define KCONDVAR(function) jcondvar_ ## function
+
/* For user defined properties */
typedef struct _userProperty {
char* key;
Index: kaffe/kaffe/kaffevm/thread.c
diff -u kaffe/kaffe/kaffevm/thread.c:1.83 kaffe/kaffe/kaffevm/thread.c:1.84
--- kaffe/kaffe/kaffevm/thread.c:1.83 Sun Dec 12 07:57:00 2004
+++ kaffe/kaffe/kaffevm/thread.c Thu Dec 16 06:13:52 2004
@@ -64,7 +64,7 @@
static void
linkNativeAndJavaThread(jthread_t thread, Hjava_lang_VMThread *jlThread)
{
- threadData *thread_data = jthread_get_data(thread);
+ threadData *thread_data = KTHREAD(get_data)(thread);
thread_data->jlThread = jlThread;
unhand (jlThread)->jthreadID = (struct Hkaffe_util_Ptr *)thread;
@@ -81,12 +81,12 @@
void
KaffeVM_unlinkNativeAndJavaThread()
{
- jthread_t thread = jthread_current();
- threadData *thread_data = jthread_get_data(thread);
+ jthread_t thread = KTHREAD(current)();
+ threadData *thread_data = KTHREAD(get_data)(thread);
thread_data->jniEnv = 0;
- ksemDestroy (&thread_data->sem);
+ KSEM(destroy) (&thread_data->sem);
}
/*
@@ -123,7 +123,7 @@
Hjava_lang_Thread* tid = unhand(vmtid)->thread;
nativeThread =
- jthread_create(((unsigned char)unhand(tid)->priority),
+ KTHREAD(create)(((unsigned char)unhand(tid)->priority),
func,
unhand(tid)->daemon,
arg,
@@ -146,7 +146,7 @@
jthread_t nativeTid;
struct _errorInfo info;
-DBG(VMTHREAD, dprintf ("%p starting thread %p (vmthread %p)\n\n", jthread_current(), unhand(tid)->thread, tid); )
+DBG(VMTHREAD, dprintf ("%p starting thread %p (vmthread %p)\n\n", KTHREAD(current)(), unhand(tid)->thread, tid); )
/* Hold the start lock while the thread is created.
* This lock prevents the new thread from running until we're
@@ -154,16 +154,16 @@
* See also firstStartThread.
*/
nativeTid = createThread(tid, &firstStartThread,
- jthread_current(),
+ KTHREAD(current)(),
threadStackSize, &info);
if (nativeTid == NULL) {
throwError(&info);
}
- ksemGet(&THREAD_DATA()->sem, (jlong)0);
+ KSEM(get)(&THREAD_DATA()->sem, (jlong)0);
linkNativeAndJavaThread (nativeTid, tid);
- ksemPut(&jthread_get_data(nativeTid)->sem);
+ KSEM(put)(&KTHREAD(get_data)(nativeTid)->sem);
*** Patch too long, truncated ***
More information about the kaffe
mailing list