On Thu, 25 Jul 2024 22:53:36 GMT, Phil Race <p...@openjdk.org> wrote:
> Migrate from using Unsafe to FFM's MemorySegment API for allocating and > setting native memory. > This code is used by Metal, OpenGL and D3D, so I manually tested SwingSet2 > and J2Demo as well as running all the usual tests. > I also did some micro-benchmarking on the performance of Unsafe vs > MemorySegment. > The performance of either is more than sufficient for us .. ie they could be > 10x slower and we wouldn't even notice. > But they are in the same ballpark, and if one or the other is clearly faster > it is the new FFM code. src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java line 144: > 142: int offsetInBytes = offset * SIZEOF_BYTE; > 143: int lengthInBytes = length * SIZEOF_BYTE; > 144: MemorySegment.copy(x, offsetInBytes, segment, JAVA_BYTE, > curOffset, length); This needs to be fixed too (similar comment as the one @JornVernee left below). src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java line 274: > 272: int offsetInBytes = offset * SIZEOF_LONG; > 273: int lengthInBytes = length * SIZEOF_LONG; > 274: MemorySegment.copy(x, offsetInBytes, segment, JAVA_LONG, > curOffset, length); This needs fixing too. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20339#discussion_r1692713777 PR Review Comment: https://git.openjdk.org/jdk/pull/20339#discussion_r1692715958