X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libjava%2Fboehm.cc;h=855d23cb024a83180e289c3a9e104a35b42be351;hb=6026d749aa74ba4a3dbf40ddfecdd16cb0fd968d;hp=a6f7fdf482604b76896fa3b491141bd294f12673;hpb=55c1bfb1a91171e5e94d9d6009e5225a3cea4079;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libjava/boehm.cc b/libjava/boehm.cc index a6f7fdf4826..855d23cb024 100644 --- a/libjava/boehm.cc +++ b/libjava/boehm.cc @@ -1,6 +1,6 @@ // boehm.cc - interface between libjava and Boehm GC. -/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation This file is part of libgcj. @@ -167,6 +167,14 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void *env) MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c); p = (GC_PTR) c->aux_info; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c); + + p = (GC_PTR) c->reflection_data; + MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c); + + // The class chain must be marked for runtime-allocated Classes + // loaded by the bootstrap ClassLoader. + p = (GC_PTR) c->next_or_version; + MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c); } else { @@ -372,6 +380,31 @@ _Jv_AllocRawObj (jsize size) return (void *) GC_MALLOC (size ? size : 1); } +#ifdef INTERPRETER +typedef _Jv_ClosureList *closure_list_pointer; + +/* Release closures in a _Jv_ClosureList. */ +static void +finalize_closure_list (GC_PTR obj, GC_PTR) +{ + _Jv_ClosureList **clpp = (_Jv_ClosureList **)obj; + _Jv_ClosureList::releaseClosures (clpp); +} + +/* Allocate a double-indirect pointer to a _Jv_ClosureList that will + get garbage-collected after this double-indirect pointer becomes + unreachable by any other objects, including finalizable ones. */ +_Jv_ClosureList ** +_Jv_ClosureListFinalizer () +{ + _Jv_ClosureList **clpp; + clpp = (_Jv_ClosureList **)_Jv_AllocBytes (sizeof (*clpp)); + GC_REGISTER_FINALIZER_UNREACHABLE (clpp, finalize_closure_list, + NULL, NULL, NULL); + return clpp; +} +#endif // INTERPRETER + static void call_finalizer (GC_PTR obj, GC_PTR client_data) { @@ -432,6 +465,12 @@ _Jv_GCSetMaximumHeapSize (size_t size) GC_set_max_heap_size ((GC_word) size); } +int +_Jv_SetGCFreeSpaceDivisor (int div) +{ + return (int)GC_set_free_space_divisor ((GC_word)div); +} + void _Jv_DisableGC (void) { @@ -673,3 +712,50 @@ _Jv_RegisterLibForGc (const void *p __attribute__ ((__unused__))) #endif } +void +_Jv_SuspendThread (_Jv_Thread_t *thread) +{ +#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \ + && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS) + GC_suspend_thread (_Jv_GetPlatformThreadID (thread)); +#endif +} + +void +_Jv_ResumeThread (_Jv_Thread_t *thread) +{ +#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \ + && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS) + GC_resume_thread (_Jv_GetPlatformThreadID (thread)); +#endif +} + +int +_Jv_IsThreadSuspended (_Jv_Thread_t *thread) +{ +#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \ + && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS) + return GC_is_thread_suspended (_Jv_GetPlatformThreadID (thread)); +#else + return 0; +#endif +} + +void +_Jv_GCAttachThread () +{ + // The registration interface is only defined on posixy systems and + // only actually works if pthread_getattr_np is defined. + // FIXME: until gc7 it is simpler to disable this on solaris. +#if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(GC_SOLARIS_THREADS) + GC_register_my_thread (); +#endif +} + +void +_Jv_GCDetachThread () +{ +#if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(GC_SOLARIS_THREADS) + GC_unregister_my_thread (); +#endif +}