RFR[S] 8005165 Platform-independent C++ vtables for CDS (original) (raw)

Ioi Lam ioi.lam at oracle.com
Mon Mar 6 19:16:41 UTC 2017


Hi Thomas,

On 3/6/17 8:51 AM, Thomas Stüfe wrote:

Hi Coleen and Ioi,

I had to port C++ code to platforms with terrible compilers for a time in my life, that is why I like code to be as portable as possible. That said, you are right in your argumentation, the SafeFetch solution is not terribly elegant and Ioi's original way of determining the vtable size is cleaner. I did some checks on some of our architectures with a test similar to Ioi's and on a first glance it seems to work for simple cases (single and public inheritance) on ppc (AIX) and Linux ia64. Although the vtables seemed to me to contain function descriptors, not real pointers to code, so this is something to keep in mind. But if the live vtable are copied, the function descriptors they contain should point to valid code too, so it should not matter. Just to remember to not expect every slot in the array to be a valid code pointer. I also notice on our current Solaris build the first slot in the vtable is the RTTI pointer, not a function address. This slot is different in the TesterA and TesterB classes, so I had to skip over it. I think this is safe because Metadata has about 10 virtual methods, so skipping over the first one should not cause any harm. So, in short, I remove my objection to Ioi's original solution, as far as that matters. I still think we rely on a lot here: Contiguous vtable containing absolute memory addresses, vtable pointer at start of object and vtable entries to be ordered from base->derived class. So I wonder how much effort it would be (now or in the future as a separate change) to have a fallback where - at loading time - instead of copying vtables the vtable pointers in the objects were fixed up to point to the new live vtables? I know this would be more expensive and potentially defeat the point of shared classes. But maybe not, it depends on how many objects are there, no?

I think for portability, perhaps we can add a porting layer so the vtables can be copied in a different way? I think this is better than patching each object at run time.

Also, I would suggest not adding such a layer now, but do it when such a need actually arises.

Thanks



More information about the hotspot-dev mailing list