On Tue, 25 Jan 2022 16:12:11 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:
> > This looks good, although I don't know whether the additional check for > > strongReferent != null is needed in clearStrong(). This is all racy code > > and you have already got a non-null return from getStrong() in case you are > > calling clearStrong()... > > This seems like a standard thing to do to avoid multi-threaded write > contention under the race. By the time one thread calls `clearStrong`, some > other thread might have already cleared it, and we don't have to clear again. > Granted, that is a micro-optimization, but I'd like to avoid surprises on > this path :) Actually, the window after the first `strongVal != null` check is not that large that a second null check would matter. Dropped the null check in `clearStrong` for simplicity. (IIRC, it mattered a bit in prior internal iterations of my patch). ------------- PR: https://git.openjdk.java.net/jdk/pull/7092