On Mon, 5 Jun 2023 21:48:23 GMT, Naoto Sato <na...@openjdk.org> wrote:
>> src/java.base/share/classes/sun/util/locale/BaseLocale.java line 369: >> >>> 367: BaseLocale l = key.holder; >>> 368: BaseLocale locale = new BaseLocale(l.getLanguage(), >>> l.getScript(), l.getRegion(), l.getVariant(), true); >>> 369: return (new Key(locale)).getBaseLocale(); >> >> Perhaps a more rigorous approach would look like this: >> <pre><code class="java"> >> BaseLocale locale = new BaseLocale(l.getLanguage(), l.getScript(), >> l.getRegion(), l.getVariant(), true); >> BaseLocal value = (new Key(locale)).getBaseLocale(); >> Reference.reachabilityFence(locale); >> return value; >> </code></pre> >> But the current patch has passed the tests with >> `-XX:ShenandoahGCHeuristics=aggressive -XX:+ShenandoahOOMDuringEvacALot`, so >> I think the current patch is OK. > > 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)`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14211#discussion_r1218793510