Interface between gc and clients to control conservative scan
Hans Boehm
Hans.Boehm@hp.com
Sun Apr 23 18:18:00 GMT 2006
Thanks.
That looks good to me. I'll merge it into at least my 7.0 tree.
Hans
On Fri, 21 Apr 2006, Andrew Haley wrote:
> Here's what I've been using.
>
> Is this OK?
>
> Thanks,
> Andrew.
>
>
> 2006-04-21 Andrew Haley <aph@redhat.com>
>
> * include/gc.h (GC_register_has_static_roots_callback): Declare.
> * dyn_load.c (GC_has_static_roots): Declare.
> (GC_register_dynlib_callback): Call GC_has_static_roots.
>
> Index: boehm-gc/include/gc.h
> ===================================================================
> --- boehm-gc/include/gc.h (revision 113114)
> +++ boehm-gc/include/gc.h (working copy)
> @@ -925,6 +925,15 @@
>
> #endif /* THREADS && !SRC_M3 */
>
> +/* Register a callback to control the scanning of dynamic libraries.
> + When the GC scans the static data of a dynamic library, it will
> + first call a user-supplied routine with filename of the library and
> + the address and length of the memory region. This routine should
> + return nonzero if that region should be scanned. */
> +GC_API void GC_register_has_static_roots_callback
> + (int (*callback)(const char *, void *, size_t));
> +
> +
> #if defined(GC_WIN32_THREADS) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
> # include <windows.h>
>
> Index: boehm-gc/dyn_load.c
> ===================================================================
> --- boehm-gc/dyn_load.c (revision 113114)
> +++ boehm-gc/dyn_load.c (working copy)
> @@ -119,6 +119,17 @@
> # endif
> # endif
>
> +/* An user-supplied routine that is called to dtermine if a DSO must
> + be scanned by the gc. */
> +static int (*GC_has_static_roots)(const char *, void *, size_t);
> +/* Register the routine. */
> +void
> +GC_register_has_static_roots_callback
> + (int (*callback)(const char *, void *, size_t))
> +{
> + GC_has_static_roots = callback;
> +}
> +
> #if defined(SUNOS5DL) && !defined(USE_PROC_FOR_LIBRARIES)
>
> #ifdef LINT
> @@ -371,7 +382,7 @@
> {
> return FALSE;
> }
> -
> +
> # define HAVE_REGISTER_MAIN_STATIC_DATA
>
> #endif /* USE_PROC_FOR_LIBRARIES */
> @@ -411,6 +422,11 @@
> {
> if( !(p->p_flags & PF_W) ) break;
> start = ((char *)(p->p_vaddr)) + info->dlpi_addr;
> +
> + if (GC_has_static_roots
> + && !GC_has_static_roots(info->dlpi_name, start, p->p_memsz))
> + break;
> +
> GC_add_roots_inner(start, start + p->p_memsz, TRUE);
> }
> break;
>
More information about the Java
mailing list