This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: Remove old ABI mangling
Mark Mitchell <mark@codesourcery.com> writes:
> I knew there would be issues with [Java] layout, so I didn't plan on
> touching those yet, but what's the dependency with mangling?
Libgjc needs to reference to the the Class object for certain types,
i.e. the Java version of the rrti object of a class. Unfortunately,
we don't have any clean way of doing it, so we refer to the mangled
name directly. For example in natObject.cc:
#define CloneableClass _CL_Q34java4lang9Cloneable
extern java::lang::Class CloneableClass;
This is of course really bad, but nobody has gotten around to
implementing a cleaner mechanism. CNI (the Compiled Native Interface)
needs to be extended to provide a standard mechanism to reference
the run-time Class for a given compile-time class. This has been
discussed a few times on the java-discuss mailing list.
The nicest solution would be to merge Java Classes with C++ type_info
objects (basically. make Class be a subtype of type_info). That means
we could use (java::lang::Class*)typeid(java::lang::Cloneable). It
also improves cross-language exception handling. However, it would
be a non-trivial amount of work - and it might break the new C++ ABI.
An easier implementation would be to add a __builtin_java_class
primitive to G++. Even easier might be to add appropriate declarations
to gcjh. If the Class is defined as a static member of its class,
with a conventional name, when we just need to make sure gcjh emits
a declaration for the static member. We are almost there: Gcj does
define such a static member, named "class". This makes sense from
a Java point of view (where 'Xxx.class' is valid syntax that returns
the Class for Xxx), but it would break the C++ parser.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/