[foreign] RFR 8219470: Use clang API to parse macros

John Rose john.r.rose at oracle.com
Wed Feb 20 20:28:23 UTC 2019


Very cool use of appropriate technologies. 

I have one suggestion. 

> On Feb 20, 2019, at 10:56 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> Note that, this patch retains the previous optimization for special casing simple numeric #define - where we just try to parse the number in Java. For API such as OpenGL with loads of constants, this is an essential optimization.

Instead of being given to a special case interpreter, those could be handled more uniformly by being handed to the same PCH technique you have created. Because they are unlikely to fail they can be batched, which will probably lead to similar perf as the present technique. Occasional failures can be removed and the remaining batch rerun if needed. The batches can be split at failure points to shake out two-point failures at the cost of a log n multiplier for divide and conquer in the worst case. 

Basic idea: handle safe macros batch style and doubtful ones one at a time. Demote safe to doubtful when they fail. 

This is complicated but leads to a uniform translation. It probably gives batch performance in most cases. And it allows the ad hoc interpreter to be retired. I think this probably works out to a wash in complexity and small improvements in maintainability and bug resistance. 

Sound plausible?  Or is it just the hack of the day?

— John





More information about the panama-dev mailing list