Small question about JDK-8253064 and ObjectMonitor allocation

David Holmes david.holmes at oracle.com
Mon Jan 31 05:23:36 UTC 2022


Hi Thomas,

On 31/01/2022 2:32 pm, Thomas Stüfe wrote:
> Hi,
> 
> I have a small question about a detail of JDK-8253064.
> 
> IIUC, before this patch, the VM kept thread-local freelists of
> pre-allocated ObjectMonitors to reduce allocation contention. Now we just
> malloc monitors right away.
> 
> I looked through the issue and the associated PR, but could find no
> information on why this was done. Dan describes what he did very well:
> https://github.com/openjdk/jdk/pull/642#issuecomment-720753946, but not
> why.
> 
> I assume that the complexity and memory overhead of the free lists was not
> worth it? That you found that malloc() is on our platforms "uncontented"
> enough?

The issue was not about freelists and contention it was about requiring 
type-stable-memory: that once a piece of memory was allocated as an 
ObjectMonitor it remained forever after an ObjectMonitor. This allowed 
for various race conditions in the old monitor code maintaining safety. 
Over time that code changed substantially and the need for 
type-stable-memory for ObjectMonitors disappeared, so we finally got rid 
of it and just moved to a direct allocation scheme.

Cheers,
David
-----

> Thank you,
> 
> Thomas


More information about the hotspot-runtime-dev mailing list