RFR: 8334137: Marlin: replace sun.misc.Unsafe memory access methods with FFM
Phil Race
prr at openjdk.org
Mon Jun 9 21:27:35 UTC 2025
On Mon, 9 Jun 2025 21:15:08 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
> > Multi-threaded access in the sense of the not being used concurrently by different threads ? What FFM means is that the thread that creates the Arena is the only thread ever allowed to use the Arena or any memory allocated by it. I don't quite see how you guarantee a static field of a class is never accessed by another thread. And all it takes is for some other thread to have initialize the class and boom
> > And how in fact is Marlin ensuring only one thread is ever used to run Marlin ? I didn't think it did anything of the kind. Is this just a case of the FX thread always runs it ?
>
> The QuantumRenderer thread uses Marlin during rendering and the JavaFX application thread uses it during picking.
>
> @bourgesl can provide a more complete answer, but from what I see, all accesses to OffHeapArray are done via an instance of the RendererContext class. Marlin ensures that a RendererContext instance is created and accessed on the same thread by using thread local state and using the rendering context for the thread in question (or creating it if it is the first time). See [DMarlinRenderingEngine::getRendererContext](https://github.com/openjdk/jfx/blob/b22ed6d202f7bb3765fa402a748d455f6316f7c9/modules/javafx.graphics/src/main/java/com/sun/marlin/DMarlinRenderingEngine.java#L254).
I'd looked at that but it was not obvious. And it definitely is not obvious that it will be the same thread that initialises the MaskMarlinAlphaConsumer.java class
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1814#issuecomment-2957070973
More information about the openjfx-dev
mailing list