On Tue, 6 Jun 2023 18:45:50 GMT, Erik Österlund <eosterl...@openjdk.org> wrote:

>> 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.

Thanks @fisk @rose00 for the explanation. This patch is indeed based on the 
idea that small functions are inlined, cause `-Xcomp` be used, and I have seen 
with parameter `-XX:+PrintCompilation -XX:+PrintInlining` that functions 
`Key::<init>` and `getBaseLocale` are inlined. 
But as @rose00  say, it's not safe, so reachabilityFence should be used. please 
review again.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14211#discussion_r1220780841

Reply via email to