RFR: 8274286: Skip null for make_referent_alive in referenceProcessor

Kim Barrett kbarrett at openjdk.java.net
Sat Sep 25 20:49:56 UTC 2021


On Sat, 25 Sep 2021 19:28:18 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Simple change of avoiding a virtual call for null referent. With this change, two methods of processing the discovered list, `process_discovered_list_work` and `preclean_discovered_reflist`, share the same structure.
>> 
>> Test: hotspot_gc
>
> src/hotspot/share/gc/shared/referenceProcessor.cpp line 267:
> 
>> 265: 
>> 266: void DiscoveredListIterator::make_referent_alive() {
>> 267:   assert(referent() != nullptr, "precondition");
> 
> This assert is not correct.  Preclean runs concurrently with the mutator.  The mutator could clear the reference between the time it is accessed by the list iterator and the call to make_referent_alive.  Looking at this also makes me wonder if the keep-alive function is safe against a racing clear by the mutator.

Answering my own question. Only G1 currently uses precleaning, and it looks fine wrto a concurrent clear. Indeed, I think it's an expensive nop. I suspect (though haven't thought about it carefully yet) that any GC that uses ReferenceProcessor would do nothing there, and I'm not sure preclean actually needs the keep-alive and complete-gc closures.

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

PR: https://git.openjdk.java.net/jdk/pull/5682



More information about the hotspot-gc-dev mailing list