[RFA] boehm-gc for AIX

Jeff Sturm jsturm@one-point.com
Sun Jan 27 08:00:00 GMT 2002


(I'm replying to a thread on gcc-patches that is probably more on topic
here... the original message from David Edelsohn explained the need for
GC_INIT on AIX to register the main program's static data segment.)

On 26 Jan 2002, Tom Tromey wrote:
> The hard part is programs that use the JNI invocation API.  These are
> C programs, with a C main(), which link against libgcj and make calls
> into it.  I don't see how we could handle these programs.

I've thought about this a bit.  I'm not convinced finding the main roots
in that case is necessary or even desirable, at least for use with gcj.
Consider:

a) The canonical example of JNI invocation consists of a C/C++ program
dynamically loading the Java runtime.  The main program contains no static
roots pertinent to Java.

b) The main program could statically link JNI extension code (i.e. by
using RegisterNatives to find the native functions).  Any static roots are
explicitly named with NewGlobalRef.

c) The main program could contain Java classes compiled by gcj, but
dynamically link the Java runtime (libgcj).  The compiled Java classes
don't actually contain roots.  All static fields are reachable from the
class object, which is in turn reachable from the class loader.  (I do
realize boehm-gc won't traverse these class objects since they aren't heap
allocated.)

d) The main program could static-link CNI extension code.  In this case
the roots become important.

e) The whole program is static linked, which can be handled as a special
case (i.e. the usual AIX symbols to find the beginning/end of the data
segment).

So a and b don't require that we know about static roots in the main
executable.  Although c,d,e are rather unusual for JNI, at least c and e
present another solution.

Of course scanning the main program's roots works (on platforms where we
know how) but considering that the main program may be quite large and
unrelated to Java, this action may be unproductive and even contribute to
leakage (pointer misidentification).

CNI invocation is another problem... it's unfortunate that the CNI spec
says nothing about static roots, so it seems to imply the existence of a
conservative GC.

Jeff



More information about the Java mailing list