diff options
Diffstat (limited to 'libjava')
| -rw-r--r-- | libjava/ChangeLog | 10 | ||||
| -rw-r--r-- | libjava/boehm.cc | 18 | ||||
| -rw-r--r-- | libjava/include/boehm-gc.h | 4 | ||||
| -rw-r--r-- | libjava/java/lang/natThread.cc | 6 |
4 files changed, 37 insertions, 1 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 1e3680f..8c20e8c 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,13 @@ +2006-08-21 Bryce McKinlay <mckinlay@redhat.com> + + * java/lang/natThread.cc (_Jv_AttachCurrentThread): Attach thread + to GC. + (_Jv_DetachCurrentThread): Detach thread from GC. + * include/boehm-gc.h (_Jv_GCAttachThread, _Jv_GCDetachThread): + Declare. + * boehm.cc (_Jv_GCAttachThread): New function. + (_Jv_GCDetachThread): Likewise. + 2006-08-19 Ranjit Mathew <rmathew@gcc.gnu.org> * sysdep/i386/backtrace.h (fallback_backtrace): Add "0x55 0x8B 0xEC" diff --git a/libjava/boehm.cc b/libjava/boehm.cc index 6a5603d..f96128e 100644 --- a/libjava/boehm.cc +++ b/libjava/boehm.cc @@ -695,3 +695,21 @@ _Jv_ResumeThread (_Jv_Thread_t *thread) GC_resume_thread (_Jv_GetPlatformThreadID (thread)); #endif } + +void +_Jv_GCAttachThread () +{ + // The registration interface is only defined on posixy systems and + // only actually works if pthread_getattr_np is defined. +#ifdef HAVE_PTHREAD_GETATTR_NP + GC_register_my_thread (); +#endif +} + +void +_Jv_GCDetachThread () +{ +#ifdef HAVE_PTHREAD_GETATTR_NP + GC_unregister_my_thread (); +#endif +} diff --git a/libjava/include/boehm-gc.h b/libjava/include/boehm-gc.h index 764b2a1..7e61b8e 100644 --- a/libjava/include/boehm-gc.h +++ b/libjava/include/boehm-gc.h @@ -80,6 +80,10 @@ _Jv_AllocPtrFreeObj (jsize size, jclass klass); #endif /* LIBGCJ_GC_DEBUG */ +void _Jv_GCAttachThread (); + +void _Jv_GCDetachThread (); + // _Jv_AllocBytes (jsize size) should go here, too. But clients don't // usually include this header. diff --git a/libjava/java/lang/natThread.cc b/libjava/java/lang/natThread.cc index f778510..facce30 100644 --- a/libjava/java/lang/natThread.cc +++ b/libjava/java/lang/natThread.cc @@ -410,7 +410,8 @@ _Jv_SetCurrentJNIEnv (JNIEnv *env) } // Attach the current native thread to an existing (but unstarted) Thread -// object. Returns -1 on failure, 0 upon success. +// object. Does not register thread with the garbage collector. +// Returns -1 on failure, 0 upon success. jint _Jv_AttachCurrentThread(java::lang::Thread* thread) { @@ -427,6 +428,8 @@ _Jv_AttachCurrentThread(java::lang::Thread* thread) java::lang::Thread* _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group) { + // Register thread with GC before attempting any allocations. + _Jv_GCAttachThread (); java::lang::Thread *thread = _Jv_ThreadCurrent (); if (thread != NULL) return thread; @@ -461,6 +464,7 @@ _Jv_DetachCurrentThread (void) return -1; _Jv_ThreadUnRegister (); + _Jv_GCDetachThread (); // Release the monitors. t->finish_ (); |
