On Tue, 6 Jun 2023 02:31:19 GMT, SUN Guoyun <d...@openjdk.org> wrote:
>> I still don't see a clear explanation of how the proposed patch fixes the >> problem. Also, I would appreciate the reasoning in the comments. > > For hotspot, when GC occurs, it causes all threads to run to the nearest > safepoint and then freeze. Generally, safepoints are generated at branch > jumps, method ends(ret instructions), loops instructions, and so on. > Therefore, the purpose of this patch is to make the creation and use of a > softReferences in the same method without branch, jumps and loops in between, > that is ensure that GC will not occur in the process of the sofeReferences be > created and used. > > That's why I didn't use `Reference.reachabilityFence(locale)`. This reasoning seems invalid. There are method calls in there, and you rely on inlining heuristics for this not to break. Please use reachabilityFence instead. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14211#discussion_r1220145376