[foreign-jextract] RFR: 8249949: jextract libclang Cursor children iteration creates a new up call stub every time

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Jul 23 09:27:17 UTC 2020


On Thu, 23 Jul 2020 07:53:19 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

> Avoiding repeated upcall stub creation by caching. The array list updated is updated in a synchroinzed method.

src/jdk.incubator.jextract/share/classes/jdk/internal/clang/Cursor.java line 338:

> 337:
> 338:     private static class CursorChildren {
> 339:         private static final ArrayList<Cursor> children = new ArrayList<>();

Wrapping the logic in a class is a good idea, but I think we can go further and avoid reusing the same static. E.g. we
could make the list an _instance_ field, and then the static `get` method would create a new instance of
`CursorChildren` (to do the visit) and then return the list attached to that instance.

-------------

PR: https://git.openjdk.java.net/panama-foreign/pull/261


More information about the panama-dev mailing list