OSDN Git Service

PR c++/29728
[pf3gnuchains/gcc-fork.git] / libjava / boehm.cc
index d939f41..2e38295 100644 (file)
@@ -167,6 +167,11 @@ _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);
+
+      // 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
     {
@@ -486,7 +491,7 @@ _Jv_InitGC (void)
   // Ignore pointers that do not point to the start of an object.
   GC_all_interior_pointers = 0;
 
-#ifdef HAVE_DLFCN_H
+#if defined (HAVE_DLFCN_H) && defined (HAVE_DLADDR)
   // Tell the collector to ask us before scanning DSOs.
   GC_register_has_static_roots_callback (_Jv_GC_has_static_roots);
 #endif
@@ -581,7 +586,7 @@ _Jv_GCCanReclaimSoftReference (jobject)
 
 \f
 
-#ifdef HAVE_DLFCN_H
+#if defined (HAVE_DLFCN_H) && defined (HAVE_DLADDR)
 
 // We keep a store of the filenames of DSOs that need to be
 // conservatively scanned by the garbage collector.  During collection
@@ -661,7 +666,7 @@ _Jv_GC_has_static_roots (const char *filename, void *, size_t)
 void
 _Jv_RegisterLibForGc (const void *p __attribute__ ((__unused__)))
 {
-#ifdef HAVE_DLFCN_H
+#if defined (HAVE_DLFCN_H) && defined (HAVE_DLADDR)
   Dl_info info;
 
   if (dladdr (const_cast<void *>(p), &info) != 0)
@@ -673,3 +678,39 @@ _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
+}
+
+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
+}