cross-module inlining (was Re: using gcj for a different language - is it possible?)

Andrew Haley aph@redhat.com
Tue Feb 10 17:35:00 GMT 2004


Adam Megacz writes:
 > 
 > Cool.  BTW, Andrew, are you sort of the indirect-dispatch guru

Well, I'm doing most of the work at the moment.  

Your plan for --gc-sections doesn't immediately strike me as being
connected with indirect dispatch.  However, I'll respond to it here.

Please let me apologize in advance for not understanding this stuff.

> 1. Break up otable_syms[] into a seperate symbol-and-section for each
>    entry.  Each otable_sym will be a pointer to the corresponding
>    _Jv_Method rather than a trio of utf8consts.  

I don't get this.  An otable symbol is a symbolic reference to a
method that gets resolved at runtime.  If you're compiling statically
(and AFAIAA --gc-sections implies that) you know the vtable offset of
a method at compile time.  So what is the otable symbol for?

>    All the otable_sym's
>    for a given class all have the same section name, so they get
>    merged during linking.  _Jv_InitClass() writes the appropriate
>    offsets *over* the _Jv_Method*'s in the otable.

This seems problematic, because class names in a running Java program
aren't unique: the same class can be loaded many times by different
class loaders.

> 2. Every _Jv_Method gets its own symbol and section.  All the section
>    names for the methods of a given class are the same, so the section
>    is merged during linkage.  Class->methods is a pointer to the symbol
>    MD_<classname>_BEGIN (see diagram below).
> 
> 3. Every _Jv_Method gets one additional entry, "overrides", which is a
>    pointer into an empty section,
>    ".overrides_<classname>_<methodname>".  Every class which overrides
>    the method includes a section with the same name which includes a
>    single relocation pointing at the *overriding* _Jv_Method.
> 
> 4. We modify the linker in one small way: all section names beginning
>    with ".overrides" are merged BEFORE section_gc.  All other sections
>    are merged after section_gc, as usual.

This doesn't sound unreasonable...

Andrew.



More information about the Java mailing list