From: hboehm Date: Tue, 26 Aug 2008 23:11:47 +0000 (+0000) Subject: 2008-08-26 Hans Boehm (with help from Marco Maggi) X-Git-Tag: gc7_2alpha2~67 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=60e21c3690bf4e30c9e082a887580d603115f7d5;p=gc 2008-08-26 Hans Boehm (with help from Marco Maggi) * configure.ac: Check for gc-debug earlier; replace remaining full-debug tests. * configure: Regenerate. * include/gc.h, ptr_chck.c (GC_pre_incr, GC_post_incr): Use signed offset type. Use ptr_t internally. * doc/gcinterface.html: Update LOCAL_MALLOC description. * doc/README.autoconf, doc/leak.html, doc/README.DGUX386: Fix full-debug reference. * include/gc.h: Rewrite GC_..._INCR and friends. * tests/test.c: Minimally test GC_..._INCR and friends. --- diff --git a/ChangeLog b/ChangeLog index d8a1d766..f6dfcec0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-08-26 Hans Boehm (with help from Marco Maggi) + * configure.ac: Check for gc-debug earlier; replace remaining + full-debug tests. + * configure: Regenerate. + * include/gc.h, ptr_chck.c (GC_pre_incr, GC_post_incr): + Use signed offset type. Use ptr_t internally. + * doc/gcinterface.html: Update LOCAL_MALLOC description. + * doc/README.autoconf, doc/leak.html, doc/README.DGUX386: + Fix full-debug reference. + * include/gc.h: Rewrite GC_..._INCR and friends. + * tests/test.c: Minimally test GC_..._INCR and friends. + 2008-08-21 Hans Boehm * mark.c: (GC_push_next_marked, GC_push_next_marked_dirty, GC_push_next_marked_uncollectable): Never invoke GC_push_marked diff --git a/configure b/configure index 823cf64a..04426cdf 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Revision: 1.38 . +# From configure.ac Revision: 1.39 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for gc 7.2alpha1. # @@ -1527,6 +1527,7 @@ Optional Features: optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-gcj-support Disable support for gcj. + --enable-gc-debug include full support for pointer backtracing etc. --disable-java-finalization Disable support for java finalization. --disable-atomic-uncollectible @@ -1534,7 +1535,6 @@ Optional Features: --enable-redirect-malloc Redirect malloc and friends to GC routines --enable-large-config Optimize for large (> 100 MB) heap or root set - --enable-gc-debug include full support for pointer backtracing etc. --enable-gc-assertions collector-internal assertion checking --enable-munmap=N return page to the os if empty for N collections @@ -21276,6 +21276,7 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool' # # Check for AViiON Machines running DGUX +# FIXME: Should this be moved down to below the gc-debug processing? # ac_is_dgux=no if test "${ac_cv_header_sys_dg_sys_info_h+set}" = set; then @@ -21416,7 +21417,7 @@ fi ## :GOTCHA: we do not check anything but sys/dg_sys_info.h if test $ac_is_dgux = yes; then - if test "$enable_full_debug" = "yes"; then + if test "$enable_gc_debug" = "yes"; then CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2" CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2" else @@ -21511,93 +21512,6 @@ _ACEOF fi -# Check whether --enable-java-finalization was given. -if test "${enable_java_finalization+set}" = set; then - enableval=$enable_java_finalization; -fi - -if test x"$enable_java_finalization" != xno; then - cat >>confdefs.h <<\_ACEOF -#define JAVA_FINALIZATION 1 -_ACEOF - -fi - -# Check whether --enable-atomic-uncollectable was given. -if test "${enable_atomic_uncollectable+set}" = set; then - enableval=$enable_atomic_uncollectable; -fi - -if test x"$enable_atomic_uncollectible" != x"no"; then - -cat >>confdefs.h <<\_ACEOF -#define ATOMIC_UNCOLLECTABLE 1 -_ACEOF - -fi - -# Check whether --enable-redirect-malloc was given. -if test "${enable_redirect_malloc+set}" = set; then - enableval=$enable_redirect_malloc; -fi - - -if test "${enable_redirect_malloc}" = yes; then - if test "${enable_full_debug}" = yes; then - cat >>confdefs.h <<\_ACEOF -#define REDIRECT_MALLOC GC_debug_malloc_replacement -_ACEOF - - cat >>confdefs.h <<\_ACEOF -#define REDIRECT_REALLOC GC_debug_realloc_replacement -_ACEOF - - cat >>confdefs.h <<\_ACEOF -#define REDIRECT_FREE GC_debug_free -_ACEOF - - else - cat >>confdefs.h <<\_ACEOF -#define REDIRECT_MALLOC GC_malloc -_ACEOF - - fi - cat >>confdefs.h <<\_ACEOF -#define GC_USE_DLOPEN_WRAP 1 -_ACEOF - -fi - -# Check whether --enable-large-config was given. -if test "${enable_large_config+set}" = set; then - enableval=$enable_large_config; -fi - - -if test "${enable_large_config}" = yes; then - -cat >>confdefs.h <<\_ACEOF -#define LARGE_CONFIG 1 -_ACEOF - -fi - -if test -n "${with_cross_host}"; then - cat >>confdefs.h <<\_ACEOF -#define NO_CLOCK 1 -_ACEOF - - cat >>confdefs.h <<\_ACEOF -#define SMALL_CONFIG 1 -_ACEOF - - cat >>confdefs.h <<\_ACEOF -#define NO_DEBUGGING 1 -_ACEOF - -fi - - UNWINDLIBS= # Check whether --enable-gc-debug was given. @@ -21720,6 +21634,93 @@ _ACEOF fi +# Check whether --enable-java-finalization was given. +if test "${enable_java_finalization+set}" = set; then + enableval=$enable_java_finalization; +fi + +if test x"$enable_java_finalization" != xno; then + cat >>confdefs.h <<\_ACEOF +#define JAVA_FINALIZATION 1 +_ACEOF + +fi + +# Check whether --enable-atomic-uncollectable was given. +if test "${enable_atomic_uncollectable+set}" = set; then + enableval=$enable_atomic_uncollectable; +fi + +if test x"$enable_atomic_uncollectible" != x"no"; then + +cat >>confdefs.h <<\_ACEOF +#define ATOMIC_UNCOLLECTABLE 1 +_ACEOF + +fi + +# Check whether --enable-redirect-malloc was given. +if test "${enable_redirect_malloc+set}" = set; then + enableval=$enable_redirect_malloc; +fi + + +if test "${enable_redirect_malloc}" = yes; then + if test "${enable_gc_debug}" = yes; then + cat >>confdefs.h <<\_ACEOF +#define REDIRECT_MALLOC GC_debug_malloc_replacement +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define REDIRECT_REALLOC GC_debug_realloc_replacement +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define REDIRECT_FREE GC_debug_free +_ACEOF + + else + cat >>confdefs.h <<\_ACEOF +#define REDIRECT_MALLOC GC_malloc +_ACEOF + + fi + cat >>confdefs.h <<\_ACEOF +#define GC_USE_DLOPEN_WRAP 1 +_ACEOF + +fi + +# Check whether --enable-large-config was given. +if test "${enable_large_config+set}" = set; then + enableval=$enable_large_config; +fi + + +if test "${enable_large_config}" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define LARGE_CONFIG 1 +_ACEOF + +fi + +if test -n "${with_cross_host}"; then + cat >>confdefs.h <<\_ACEOF +#define NO_CLOCK 1 +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define SMALL_CONFIG 1 +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define NO_DEBUGGING 1 +_ACEOF + +fi + + # Check whether --enable-gc-assertions was given. diff --git a/configure.ac b/configure.ac index 3b209457..8dd0ba9a 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_INIT(gc,7.2alpha1,Hans.Boehm@hp.com) AC_CONFIG_SRCDIR(gcj_mlc.c) AC_CANONICAL_TARGET AC_PREREQ(2.53) -AC_REVISION($Revision: 1.39 $) +AC_REVISION($Revision: 1.40 $) GC_SET_VERSION AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects nostdinc]) AM_MAINTAINER_MODE @@ -432,6 +432,7 @@ AC_PROG_LIBTOOL # # Check for AViiON Machines running DGUX +# FIXME: Should this be moved down to below the gc-debug processing? # ac_is_dgux=no AC_CHECK_HEADER(sys/dg_sys_info.h, @@ -439,7 +440,7 @@ AC_CHECK_HEADER(sys/dg_sys_info.h, ## :GOTCHA: we do not check anything but sys/dg_sys_info.h if test $ac_is_dgux = yes; then - if test "$enable_full_debug" = "yes"; then + if test "$enable_gc_debug" = "yes"; then CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2" CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2" else @@ -514,6 +515,38 @@ if test x"$enable_gcj_support" != xno; then AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj]) fi +dnl Debugging +dnl --------- + +UNWINDLIBS= +AC_ARG_ENABLE(gc-debug, +[AC_HELP_STRING([--enable-gc-debug], + [include full support for pointer backtracing etc.])], +[ if test "$enable_gc_debug" = "yes"; then + AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.") + AC_DEFINE(KEEP_BACK_PTRS) + AC_DEFINE(DBG_HDRS_ALL) + case $host in + ia64-*-linux* ) + AC_DEFINE(MAKE_BACK_GRAPH) + AC_DEFINE(SAVE_CALL_COUNT, 8) + AC_CHECK_LIB(unwind, backtrace, [ + AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE) + UNWINDLIBS=-lunwind + AC_MSG_WARN("Client code may need to link against libunwind.") + ]) + ;; + x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* ) + AC_DEFINE(MAKE_BACK_GRAPH) + AC_MSG_WARN("Client must not use -fomit-frame-pointer.") + AC_DEFINE(SAVE_CALL_COUNT, 8) + ;; + i[3456]86-*-dgux*) + AC_DEFINE(MAKE_BACK_GRAPH) + ;; + esac ] + fi) + AC_ARG_ENABLE(java-finalization, [AC_HELP_STRING([--disable-java-finalization], [Disable support for java finalization.])]) @@ -534,7 +567,7 @@ AC_ARG_ENABLE(redirect-malloc, [Redirect malloc and friends to GC routines])]) if test "${enable_redirect_malloc}" = yes; then - if test "${enable_full_debug}" = yes; then + if test "${enable_gc_debug}" = yes; then AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement) AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement) AC_DEFINE(REDIRECT_FREE, GC_debug_free) @@ -562,38 +595,6 @@ if test -n "${with_cross_host}"; then fi -dnl Debugging -dnl --------- - -UNWINDLIBS= -AC_ARG_ENABLE(gc-debug, -[AC_HELP_STRING([--enable-gc-debug], - [include full support for pointer backtracing etc.])], -[ if test "$enable_gc_debug" = "yes"; then - AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.") - AC_DEFINE(KEEP_BACK_PTRS) - AC_DEFINE(DBG_HDRS_ALL) - case $host in - ia64-*-linux* ) - AC_DEFINE(MAKE_BACK_GRAPH) - AC_DEFINE(SAVE_CALL_COUNT, 8) - AC_CHECK_LIB(unwind, backtrace, [ - AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE) - UNWINDLIBS=-lunwind - AC_MSG_WARN("Client code may need to link against libunwind.") - ]) - ;; - x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* ) - AC_DEFINE(MAKE_BACK_GRAPH) - AC_MSG_WARN("Client must not use -fomit-frame-pointer.") - AC_DEFINE(SAVE_CALL_COUNT, 8) - ;; - i[3456]86-*-dgux*) - AC_DEFINE(MAKE_BACK_GRAPH) - ;; - esac ] - fi) - AC_SUBST(UNWINDLIBS) AC_ARG_ENABLE(gc-assertions, diff --git a/doc/README.DGUX386 b/doc/README.DGUX386 index 9d6d8478..0b878517 100644 --- a/doc/README.DGUX386 +++ b/doc/README.DGUX386 @@ -23,7 +23,7 @@ to build only the static version of libgc. To enable debugging messages please do: - 1) Add the "--enable-full-debug" flag during configuration. + 1) Add the "--enable-gc-debug" flag during configuration. 2) Edit the file linux-threads.c and uncommnect the line: /* #define DEBUG_THREADS 1 */ to ---> diff --git a/doc/README.autoconf b/doc/README.autoconf index 53fcf5a5..6c8ba55a 100644 --- a/doc/README.autoconf +++ b/doc/README.autoconf @@ -47,7 +47,9 @@ Important options to configure: [same as prefix] --enable-threads=TYPE choose threading package --enable-parallel-mark parallelize marking and free list construction - --enable-full-debug include full support for pointer backtracing etc. + --enable-gc-debug (--enable-full-debug before about 7.0) + include full support for pointer backtracing etc. + Unless --prefix is set (or --exec-prefix or one of the more obscure options), make install will install libgc.a and libgc.so in /usr/local/bin, which diff --git a/doc/gcinterface.html b/doc/gcinterface.html index 312d37f4..bd7b4a94 100644 --- a/doc/gcinterface.html +++ b/doc/gcinterface.html @@ -152,8 +152,15 @@ for details.

If you are concerned with multiprocessor performance and scalability, -you should consider enabling and using thread local allocation (e.g. -GC_LOCAL_MALLOC, see gc_local_alloc.h. If your platform +you should consider enabling and using thread local allocation. +For GC versions before 7.0, use e.g. +GC_LOCAL_MALLOC and see gc_local_alloc.h; +for later versions enabling thread-local allocations when the collector +library is built changes the +implementation of GC_MALLOC, so the client doesn't need to +change. +

+If your platform supports it, you should build the collector with parallel marking support (-DPARALLEL_MARK, or --enable-parallel-mark).

diff --git a/doc/leak.html b/doc/leak.html index 8f460c9f..fc9c3eb7 100644 --- a/doc/leak.html +++ b/doc/leak.html @@ -173,7 +173,7 @@ no longer necessary to call GC_ routines explicitly, though that can also improve the quality of the leak reports.

  • Build the collector and install it in directory foo as follows:
      -
    • configure --prefix=foo --enable-full-debug --enable-redirect-malloc +
    • configure --prefix=foo --enable-gc-debug --enable-redirect-malloc --disable-threads
    • make
    • make install diff --git a/include/gc.h b/include/gc.h index 31af7914..fcb0f3c5 100644 --- a/include/gc.h +++ b/include/gc.h @@ -927,8 +927,8 @@ GC_API void * GC_same_obj (void * p, void * q); /* the second argument is in units of bytes, not multiples of the */ /* object size. This should either be invoked from a macro, or the */ /* call should be automatically generated. */ -GC_API void * GC_pre_incr (void * *p, size_t how_much); -GC_API void * GC_post_incr (void * *p, size_t how_much); +GC_API void * GC_pre_incr (void * *p, ptrdiff_t how_much); +GC_API void * GC_post_incr (void * *p, ptrdiff_t how_much); /* Check that p is visible */ /* to the collector as a possibly pointer containing location. */ @@ -954,34 +954,36 @@ GC_API void GC_dump(void); /* Safer, but slow, pointer addition. Probably useful mainly with */ /* a preprocessor. Useful only for heap pointers. */ -#ifdef GC_DEBUG +/* Only the macros without trailing digits are meant to be used */ +/* by clients. These are designed to model the available C pointer */ +/* arithmetic expressions. */ +/* Even then, these are probably more useful as */ +/* documentation than as part of the API. */ +/* Note that GC_PTR_ADD evaluates the first argument more than once. */ +#if defined(GC_DEBUG) && defined(__GNUC__) # define GC_PTR_ADD3(x, n, type_of_result) \ ((type_of_result)GC_same_obj((x)+(n), (x))) # define GC_PRE_INCR3(x, n, type_of_result) \ - ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x)) -# define GC_POST_INCR2(x, type_of_result) \ - ((type_of_result)GC_post_incr(&(x), sizeof(*x)) -# ifdef __GNUC__ -# define GC_PTR_ADD(x, n) \ + ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x))) +# define GC_POST_INCR3(x, n, type_of_result) \ + ((type_of_result)GC_post_incr(&(x), (n)*sizeof(*x))) +# define GC_PTR_ADD(x, n) \ GC_PTR_ADD3(x, n, typeof(x)) -# define GC_PRE_INCR(x, n) \ +# define GC_PRE_INCR(x, n) \ GC_PRE_INCR3(x, n, typeof(x)) -# define GC_POST_INCR(x, n) \ - GC_POST_INCR3(x, typeof(x)) -# else +# define GC_POST_INCR(x) \ + GC_POST_INCR3(x, 1, typeof(x)) +# define GC_POST_DECR(x) \ + GC_POST_INCR3(x, -1, typeof(x)) +#else /* !GC_DEBUG || !__GNUC__ */ /* We can't do this right without typeof, which ANSI */ - /* decided was not sufficiently useful. Repeatedly */ - /* mentioning the arguments seems too dangerous to be */ - /* useful. So does not casting the result. */ -# define GC_PTR_ADD(x, n) ((x)+(n)) -# endif -#else /* !GC_DEBUG */ -# define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n)) + /* decided was not sufficiently useful. Without it */ + /* we resort to the non-debug version. */ + /* FIXME: This should eventially support C++0x decltype */ # define GC_PTR_ADD(x, n) ((x)+(n)) -# define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n)) # define GC_PRE_INCR(x, n) ((x) += (n)) -# define GC_POST_INCR2(x, n, type_of_result) ((x)++) -# define GC_POST_INCR(x, n) ((x)++) +# define GC_POST_INCR(x) ((x)++) +# define GC_POST_DECR(x) ((x)--) #endif /* Safer assignment of a pointer to a nonstack location. */ diff --git a/ptr_chck.c b/ptr_chck.c index 6d5637fa..9d8faa00 100644 --- a/ptr_chck.c +++ b/ptr_chck.c @@ -255,10 +255,10 @@ fail: } -GC_API void * GC_pre_incr (void **p, size_t how_much) +GC_API void * GC_pre_incr (void **p, ptrdiff_t how_much) { void * initial = *p; - void * result = GC_same_obj((void *)((word)initial + how_much), initial); + void * result = GC_same_obj((void *)((ptr_t)initial + how_much), initial); if (!GC_all_interior_pointers) { (void) GC_is_valid_displacement(result); @@ -266,10 +266,10 @@ GC_API void * GC_pre_incr (void **p, size_t how_much) return (*p = result); } -GC_API void * GC_post_incr (void **p, size_t how_much) +GC_API void * GC_post_incr (void **p, ptrdiff_t how_much) { void * initial = *p; - void * result = GC_same_obj((void *)((word)initial + how_much), initial); + void * result = GC_same_obj((void *)((ptr_t)initial + how_much), initial); if (!GC_all_interior_pointers) { (void) GC_is_valid_displacement(result); diff --git a/tests/test.c b/tests/test.c index 60335414..f33c9a72 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1069,10 +1069,17 @@ void run_one_test() GC_is_visible_print_proc = fail_proc1; collectable_count += 1; x = GC_malloc(16); - if (GC_base(x + 13) != x) { + if (GC_base(GC_PTR_ADD(x, 13)) != x) { GC_printf("GC_base(heap ptr) produced incorrect result\n"); FAIL; } + GC_PRE_INCR(x, 0); + GC_POST_INCR(x); + GC_POST_DECR(x); + if (GC_base(x) != x) { + GC_printf("Bad INCR/DECR result\n"); + FAIL; + } # ifndef PCR if (GC_base(y) != 0) { GC_printf("GC_base(fn_ptr) produced incorrect result\n");