Correction to last message, GC status
Boehm, Hans
hans_boehm@hp.com
Tue Jun 19 09:47:00 GMT 2001
Sorry- It was Bryce who imported the recent GC.
On a related subject:
I integrated 6.0alpha8+ into my workarea. My plan is to turn 6.0alpha8 +
small bug fixes into 6.0 shortly.
I would like to check the 6.0alpha8 changes and the attached patch into the
trunk early next week, after I
return from a conference. Does this look OK? (It needs the (much bigger)
6.0alpha8 changes to work. I can mail a complete patch if someone wants it.
We're still testing, but help is appreciated.)
The following patch enables thread local allocation on Linux by default,
provided threads are enabled.
It supports --enable-parallel-mark to turn on parallel marking. That's not
on by default, since it
involves a small performance hit on uniprocessors. On X86 it requires that
mark bits be updated
with an atomic compare-and-exchange. On multiprocessors, it's potentially a
big performance win. (I included the HP/UX changes, since they're in the GC
distribution. Unfortunately, AFAIK the libffi port for HP/UX still doesn't
exist.)
The patch also includes a couple of other minor bug fixes which appear to
have fallen through the cracks. Boehm.cc needs to support thread local
allocation. The MAYBE_MARK call needed to be cleaned up to no longer call
GC internal macros, since they changed. GC_debug_generic_malloc is gone.
There were always problems with it, and for a while there hasn't been any
configuration in which it could have been invoked.
Hans
------------------------------
Index: libjava/boehm.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/boehm.cc,v
retrieving revision 1.25
diff -u -r1.25 boehm.cc
--- boehm.cc 2001/05/24 05:40:35 1.25
+++ boehm.cc 2001/06/18 23:23:40
@@ -30,24 +30,24 @@
#include <private/gc_pmark.h>
#include <gc_gcj.h>
+#ifdef THREAD_LOCAL_ALLOC
+# define GC_REDIRECT_TO_LOCAL
+# include <gc_local_alloc.h>
+#endif
+
// These aren't declared in any Boehm GC header.
void GC_finalize_all (void);
ptr_t GC_debug_generic_malloc (size_t size, int k, GC_EXTRA_PARAMS);
};
-// FIXME: this should probably be defined in some GC header.
-#ifdef GC_DEBUG
-# define GC_GENERIC_MALLOC(Size, Type) \
- GC_debug_generic_malloc (Size, Type, GC_EXTRAS)
-#else
-# define GC_GENERIC_MALLOC(Size, Type) GC_generic_malloc (Size, Type)
-#endif
-
// We must check for plausibility ourselves.
#define MAYBE_MARK(Obj, Top, Limit, Source, Exit) \
+ Top=GC_MARK_AND_PUSH((GC_PTR)Obj, Top, Limit, (GC_PTR *)Source)
+#if 0
if ((ptr_t) (Obj) >= GC_least_plausible_heap_addr \
&& (ptr_t) (Obj) <= GC_greatest_plausible_heap_addr) \
PUSH_CONTENTS (Obj, Top, Limit, Source, Exit)
+#endif
@@ -312,7 +312,7 @@
# endif
// Mark the object's class.
p = (ptr_t) klass;
- MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, obj, o2label);
+ MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, &(dt -> clas), o2label);
for (int i = 0; i < JvGetArrayLength (array); ++i)
{
@@ -374,7 +374,7 @@
if (size < min_heap_addr)
obj = GC_MALLOC(size);
else
- obj = GC_GENERIC_MALLOC (size, array_kind_x);
+ obj = GC_generic_malloc (size, array_kind_x);
#endif
*((_Jv_VTable **) obj) = klass->vtable;
return obj;
@@ -463,6 +463,8 @@
static void * handle_out_of_memory(size_t)
{
_Jv_ThrowNoMemory();
+ /* NOT REACHED */
+ return 0;
}
void
Index: libjava/prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.53
diff -u -r1.53 prims.cc
--- prims.cc 2001/06/02 08:34:33 1.53
+++ prims.cc 2001/06/18 23:23:40
@@ -255,8 +255,6 @@
if (len < 0)
len = strlen (s);
Utf8Const* m = (Utf8Const*) _Jv_AllocBytes (sizeof(Utf8Const) + len + 1);
- if (! m)
- throw no_memory;
memcpy (m->data, s, len);
m->data[len] = 0;
m->length = len;
@@ -335,7 +333,7 @@
// The collector calls this when it encounters an out-of-memory condition.
void _Jv_ThrowNoMemory()
{
- _Jv_Throw (no_memory);
+ throw no_memory;
}
// Allocate a new object of class KLASS. SIZE is the size of the object
Index: libjava/include/boehm-gc.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/boehm-gc.h,v
retrieving revision 1.4
diff -u -r1.4 boehm-gc.h
--- boehm-gc.h 2001/05/24 05:40:36 1.4
+++ boehm-gc.h 2001/06/18 23:23:41
@@ -28,23 +28,39 @@
extern "C" void * GC_gcj_malloc(size_t, void *);
extern "C" void * GC_malloc_atomic(size_t);
+#ifdef THREAD_LOCAL_ALLOC
+extern "C" void * GC_local_gcj_malloc(size_t, void *);
+extern "C" void * GC_local_malloc_atomic(size_t);
+#endif
inline void *
_Jv_AllocObj (jsize size, jclass klass)
{
// This should call GC_GCJ_MALLOC, but that would involve
// including gc.h.
+#ifdef THREAD_LOCAL_ALLOC
+ return GC_local_gcj_malloc (size, klass->vtable);
+#else
return GC_gcj_malloc (size, klass->vtable);
+#endif
}
inline void *
_Jv_AllocPtrFreeObj (jsize size, jclass klass)
{
#ifdef JV_HASH_SYNCHRONIZATION
- void * obj = GC_malloc_atomic(size);
+# ifdef THREAD_LOCAL_ALLOC
+ void * obj = GC_local_malloc_atomic(size);
+# else
+ void * obj = GC_malloc_atomic(size);
+# endif
*((_Jv_VTable **) obj) = klass->vtable;
#else
- void * obj = GC_gcj_malloc(size, klass->vtable);
+# ifdef THREAD_LOCAL_ALLOC
+ void * obj = GC_local_gcj_malloc(size);
+# else
+ void * obj = GC_gcj_malloc(size, klass->vtable);
+# endif
#endif
return obj;
}
Index: boehm-gc/configure.in
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/configure.in,v
retrieving revision 1.26
diff -u -r1.26 configure.in
--- configure.in 2001/06/09 20:31:13 1.26
+++ configure.in 2001/06/18 23:23:27
@@ -29,6 +29,15 @@
THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
AC_MSG_RESULT([$THREADS])
+AC_ARG_ENABLE(parallel-mark,
+[ --enable-parallel-mark parallelize marking and free list
construction],
+ [case "$THREADS" in
+ no | none | single)
+ AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
+ ;;
+ esac]
+)
+
INCLUDES=-I${srcdir}/include
THREADLIBS=
case "$THREADS" in
@@ -39,9 +48,27 @@
THREADS=posix
THREADLIBS=-lpthread
case "$host" in
+ x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux*)
+ AC_DEFINE(GC_LINUX_THREADS)
+ AC_DEFINE(_REENTRANT)
+ if test "${enable_parallel_mark}"; then
+ AC_DEFINE(PARALLEL_MARK)
+ fi
+ AC_DEFINE(THREAD_LOCAL_ALLOC)
+ ;;
*-*-linux*)
- AC_DEFINE(LINUX_THREADS)
+ AC_DEFINE(GC_LINUX_THREADS)
AC_DEFINE(_REENTRANT)
+ ;;
+ *-*-hpux*)
+ AC_MSG_WARN("Only HP/UX 11 threads are supported.")
+ AC_DEFINE(GC_HPUX_THREADS)
+ AC_DEFINE(_POSIX_C_SOURCE,199506L)
+ if test "${enable_parallel_mark}" = yes; then
+ AC_DEFINE(PARALLEL_MARK)
+ fi
+ AC_DEFINE(THREAD_LOCAL_ALLOC)
+ THREADLIBS="-lpthread -lrt"
;;
*-*-freebsd*)
AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm
GC.")
More information about the Java
mailing list