This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Java name-mangling


Mark Mitchell <mark@codesourcery.com> writes:

> Yup.  There are other complexities with virtual bases as well (which
> it sound like Java does use for interfaces).

Java does not "use" virtual bases for interfaces.  My point is that
interfaces are essentially *equivalent* to virtual bases.  In terms
of debug information and such like, it may make sense to view
interfaces as virtual bases.  However, it looks like the Java
implementation of interfaces will be disjoint from the C++ 
implementation of virtual bases:  The expectations of programmers
and specifications etc are probably too different.

> There need to be "vcall
> offsets" in the vtables to deal with virtual function calls given a
> pointer to the interface type.  This code, more than the mangling
> code, will be difficult to share; I think the Java folks will most
> likely have to recode it.  However, I don't think it will be too hard
> to get right, especially given the C++ front-end as a model.

One of us is misunderstanding, I think.  What do you think needs
recoding?

I will emphasise more strongly: Any implementation of Java interfaces
that requires adjusting of this pointers is pretty darn close to out
of the question.  So Java cannot share any part of a C++ ABI that
involves adjusting this pointers.  Though *conceptually* interfaces
are the equivalent of no-field virtual abstract bases, it does not
follow they should be implemented the same way.  It would be nice
if they were, but adjusting this pointers is an unacceptable cost
for Java.  It is up to the C++ people:  If they are willing to use
the Java implementation, or come up with a better one, great.  If not,
we'll just have separate ABIs for this.  For the sake of CNI (i.e.
native Java methods written in C++), it would be nice if it were
possible to call Java methods given a pointer to a Java interface
type.  That may require duplicating some of the jc1 code in cc1plus,
which could be a hassle.  (However, we've managed to live without this
feature so far, so it isn't that critical.)

In any case, we still want to share the C++ ABI as much as practical
otherwise.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]