On Mon, 24 Jun 2024 18:07:11 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> wrote:
>> src/java.desktop/share/classes/sun/font/StrikeCache.java line 151: >> >>> 149: >>> 150: @SuppressWarnings("restricted") >>> 151: static final float getGlyphXAdvance(long ptr) { >> >> now, I'm not an expert of this code, but I notice that you have accessors >> that seem to take a bare `long` instead of `MemorySegment`. Have you tried >> pushing segments deeper in the implementation? That way I think you could >> completely auto-generate this code using jextract. (of course what you have >> is not bad - I'm mostly trying to see if there's a way to get there w/o all >> these calls to `MemorySegment::reinterpret`). > > To be clear - I'm assuming the `ptr` parameter comes from a single native > call. That call returns a pointer to a struct, or maybe an array of structs. > If so, we could reinterpret right after the native call, with the right size > (the number of structs returned by the native call), and then all the > accessors will be just "plain" memory segment accessors, no need to > reinterpret (as the segment will already have the correct size). Each pointer refers to a single struct, not an array. In this fix I am focused on not using Unsafe. I don't want the change to go further than that. The 'long's are retrieved/ passed around/ back down to native in lots of places so it would turn a focused change into a much bigger change. grep in java.desktop for "getGlyphImage" to see the tip of the iceberg. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/19777#discussion_r1651455679