<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="WordSection1">
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">Hi Erik,</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal elementToProof" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">thanks for answering. I </span><span class="SpellE"><span lang="DE" style="font-size:11.0pt">understand</span></span><span style="font-size:11.0pt"> that the nmethod oops are seen by GC as an</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">mere set of weak oops. And that's about it. No need to know anything about</span></p>
<p class="MsoNormal elementToProof" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">@Stable constness and the like. It's just a simple set of weak oops and GC gets</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">notified when it is accessed. This reduces complexity and makes the vm robust,</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">on the other hand doesn't yield optimal performance but that can be tolerated.</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">I needed this explanation because I wasn't sure if I was missing something. And</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">I assumed GC and compilers would be tighter integrated.</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">> Besides, the idea of fixing up the last remaining nmethods that are on-stack</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">> when you get to remark, doesn’t really work for loom. Because some of the</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">> stacks won’t be mounted on carrier threads. Instead, they could reside only in</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">> heap continuations that have been allocated after concurrent marking started, and</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">> hence will never be visited by a GC. This was indeed the original motivation</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">> for adding nmethod entry barriers to G1, before the @Stable stuff appeared.</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">Good point I've missed so far. The comment on select_barrier_set_nmethod()</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">mentions continuations. I'll revisit it in the REDO.</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal elementToProof" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">Thanks indeed,</span></p>
<p class="MsoNormal elementToProof" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt">Richard.</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt"> </span></p>
<div style="border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;margin-bottom:12.0pt">
<a name="_MailOriginal"><b><span style="font-size:12.0pt; color:black">From: </span>
</b></a><span style=""><span style="font-size:12.0pt; color:black">Erik Osterlund <erik.osterlund@oracle.com><br>
<b>Date: </b>Monday, 30. January 2023 at 18:48<br>
<b>To: </b>Reingruber, Richard <richard.reingruber@sap.com><br>
<b>Cc: </b>hotspot-gc-dev@openjdk.org <hotspot-gc-dev@openjdk.org><br>
<b>Subject: </b>Re: G1: Should nmethod entry barriers keep oop constants alive?</span></span></p>
</div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">Hi Richard, </span></span></p>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">I have *always* thought that having nmethod oops be required to be reachable some other way from the object graph or risk breaking SATB is very fragile. That’s part of the reason why ZGC required nmethod entry barriers
from the first release that supported class unloading at all (JDK-12). Meanwhile I have kind of been waiting for a situation in G1 where we would add an oop that ends up not being reachable some other way. I felt pretty certain it would pop up eventually,
I just did not know in which shape or form it would appear in. Indeed, it did materialize with @Stable. It can also materialize with final fields that you modify them with reflection, Unsafe or JNI. Are there other holes? I don’t know. And I’d rather not wait
to find out.</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">I think that nmethod oops should stand on their own feet. If the compiler decides to put them in, we shouldn’t rely on other fragile and hard to reason about properties to not break SATB. So whether this bug would
have presented itself or not, I have always thought the previous mechanism is too fragile.</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">Besides, the idea of fixing up the last remaining nmethods that are on-stack when you get to remark, doesn’t really work for loom. Because some of the stacks won’t be mounted on carrier threads. Instead, they could
reside only in heap continuations that have been allocated concurrent marking started, and hence will never be visited by a GC. This was indeed the original motivation for adding nmethod entry barriers to G1, before the @Stable stuff appeared.</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">In other words, I think you should REDO JDK-8297487, and not consider this as a problem only for @Stable.</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">Thanks,</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">/Erik</span></span></p>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"><br style="">
<br style="">
</span></span></p>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">On 30 Jan 2023, at 17:52, Reingruber, Richard <</span></span><a href="mailto:richard.reingruber@sap.com" data-auth="NotApplicable" data-loopstyle="link"><span style=""><span style="font-size:11.0pt">richard.reingruber@sap.com</span></span><span style=""></span></a><span style=""><span style="font-size:11.0pt">>
wrote:</span></span></p>
</div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
<div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">Hi,</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">the nmethod entry barrier used by G1 keeps oop constants of nmethods alive [1].</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">As I see it this is only needed if actually constant fields (final or @Stable) are changed after initialization (see JDK-8288970).</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">Is this correct or are there other cases? [2]</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">If correct then I'd think it isn't the best solution to the issue. (a) the</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">keep-alive is almost always redundant (b) it is imprecise and can hinder</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">unloading of unreachable code because class loaders of inlined or devirtualized</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">calls are added to the nmethods constants. (c) nmethods with a stale constant</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">value are kept as long as they are called (d) the stale constant value might be</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">persisted somewhere which could cause inconsistency.</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">I'd like to get some feedback on this because I wonder if I should REDO</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">JDK-8297487 at all (</span></span><span style=""><span lang="DE" style="font-size:11.0pt">after<span class="apple-converted-space"> </span></span></span><span style=""><span style="font-size:11.0pt">BACKOUT JDK-8299956).</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">Thanks, Richard.</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">[1] Keepalive of nmethod entry barrier used by G1:</span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> <span class="apple-converted-space"> </span></span></span><a href="https://github.com/openjdk/jdk/blob/08b24ac7aacaff32577dc07e77ed0961dd804904/src/hotspot/share/gc/shared/barrierSetNMethod.cpp#L100-L103" data-auth="NotApplicable"><span style=""><span style="font-size:11.0pt; color:#0563C1">https://github.com/openjdk/jdk/blob/08b24ac7aacaff32577dc07e77ed0961dd804904/src/hotspot/share/gc/shared/barrierSetNMethod.cpp#L100-L103</span></span><span style=""></span></a><span style=""><span style="font-size:11.0pt"></span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style=""><span style="font-size:11.0pt">[2] Could be Loom but I wouldn't see why the keep-alive would be needed there. Otherwise it should be unlikely. After all G1 was working well w/o it.</span></span></p>
</div>
</div>
</blockquote>
</div>
<span style=""></span>
<p class="MsoNormal" style="margin: 0cm; font-size: 10pt; font-family: Calibri, sans-serif;">
<span style="font-size:11.0pt"> </span></p>
</div>
</div>
</body>
</html>