nmethodBucket in instanceKlass.hpp atomic counters

David Holmes david.holmes at oracle.com
Mon Mar 2 01:28:29 UTC 2015

Hi Staffan,

cc'ing gc group as ...

On 28/02/2015 12:07 PM, Staffan Friberg wrote:
> Hi,
> Was reading through the code for the nmethodBucket in instanceKlass.hpp
> and noticed that when we increase the number we simply do a +1, while
> when we remove the dependency we do a using an atomic.
> Do we have synchronization else where for the increment and decrement,
> and we simply use the atomic in the decrement to ensure visibility to
> non-compiler threads (GC)?

  ... the atomic decrement was added as part of the G1 class unloading code:


The increment is only performed at a safepoint or under the 
CodeCache_lock. However unless there is something else that guarantees 
increments and decrements can not be occurring around the same time, 
then the use of the atomic decrement is not sufficient for thread-safety.


> //Staffan

More information about the hotspot-gc-dev mailing list