RFR: 8334137: Marlin: replace sun.misc.Unsafe memory access methods with FFM

Kevin Rushforth kcr at openjdk.org
Wed Jun 11 14:18:40 UTC 2025


On Wed, 11 Jun 2025 13:38:36 GMT, Nir Lisker <nlisker at openjdk.org> wrote:

> > > If there is no performance penalty for accessing data from a memory segment created using the global arena, then we could switch to that for JavaFX as well.
> > 
> > 
> > Using memory from the Global arena can actually be _faster_ as we do not have to perform any liveness checks for such segments. So, I think this is a good move. Also, the memory does not have to be acquired/released if the address is conveyed to native code (as the segment's scope never closes).
> 
> In this case, you'll need to change [`free()`](https://github.com/kevinrushforth/jfx/blob/2dd7a35d2eec16b04de1f4cb7aeba31be5d98a55/modules/javafx.graphics/src/main/java/com/sun/marlin/OffHeapArray.java#L126) to remove the closure of the arena, but I think that then you'll have to manually clear the memory segments it allocates. This requires non-trivial modifications with `MarlinUtils`'s cleaner. When @bourgesl and I discussed these changes, we were unsure what the correct arena for this situation is.

The alpha map objects are never freed. They are static arrays that are created and filled once, in the static initializer of the `MaskMarlinAlphaConsumer` class. The change I am thinking to propose is [here](https://github.com/kevinrushforth/jfx/commit/6c38c6040d1abd9b84f3648f892215573a8b1275) if you want to take a look before I push it to this PR branch.

I could still integrate this PR "as is" and file a follow-on for using the global arena for the alpha map arrays depending on what @nlisker and @bourgesl think.

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

PR Comment: https://git.openjdk.org/jfx/pull/1814#issuecomment-2963018875


More information about the openjfx-dev mailing list