This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Interface between gc and clients to control conservative scan
- From: Andrew Haley <aph at redhat dot com>
- To: Hans Boehm <Hans dot Boehm at hp dot com>
- Cc: java at gcc dot gnu dot org, gc at napali dot hpl dot hp dot com
- Date: Thu, 6 Apr 2006 11:23:49 +0100
- Subject: Interface between gc and clients to control conservative scan
Hans,
I need a way to control which shared libraries are conservatively
scanned. This is because the version of gcj I'm working on does not
require conservative scanning of shared libraries, whereas old
gcj-compiled libraries do. We need to be able to interwork with these
old libraries.
In my current work I'm using a version of GC_register_dynlib_callback
like this:
int (*GC_has_static_roots)(struct dl_phdr_info * info, size_t size, void *ptr)
__attribute__((weak));
static int GC_register_dynlib_callback(info, size, ptr)
struct dl_phdr_info * info;
size_t size;
void * ptr;
{
const ElfW(Phdr) * p;
...
p = info->dlpi_phdr;
for( i = 0; i < (int)(info->dlpi_phnum); ((i++),(p++)) ) {
switch( p->p_type ) {
case PT_LOAD:
{
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, size, start))
break;
GC_add_roots_inner(start, start + p->p_memsz, TRUE);
}
break;
default:
break;
}
}
... and a corresponding function in gcj which looks like this:
int (*GC_has_static_roots)(struct dl_phdr_info * info, size_t size, void *ptr)
= _Jv_GC_has_static_roots;
static int
_Jv_GC_has_static_roots (struct dl_phdr_info * info, size_t, void *)
{
So, this implementation depends on weak sysmbols, which in turn depend
on ELF. For a more generic implementation, it would be better to have
a registration function in the gc with an interface like this:
static int GC_register_shlib_conservative_scan_callback
(int (*GC_has_static_roots)(struct dl_phdr_info *, size_t, void *));
Would such an interface be acceptable?
Thanks,
Andrew.