<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=DE link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>In a related matter, are the existing tests reliable to detect the Situation (at least for the Default runtime/compiler behavior). i.e. are the testcases covering stack Evaluation in a compiled context where EA would elimiiminate it?</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Gruss</p><p class=MsoNormal>Bernd</p><p class=MsoNormal>-- <br>http://bernd.eckenfels.net</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='border:none;padding:0cm'><b>Von: </b><a href="mailto:dean.long@oracle.com">dean.long@oracle.com</a><br><b>Gesendet: </b>Montag, 17. Dezember 2018 05:56<br><b>An: </b><a href="mailto:claes.redestad@oracle.com">Claes Redestad</a>; <a href="mailto:security-dev@openjdk.java.net">security-dev@openjdk.java.net</a>; <a href="mailto:hotspot-dev@openjdk.java.net">hotspot-dev developers</a><br><b>Betreff: </b>Re: 12 RFR(M) 8214583: AccessController.getContext may return wrongvalue after JDK-8212605</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Unfortunately, I don't think @DontInline on an empty method is sufficient</p><p class=MsoNormal>here. If other code is relying on @DontInline for the same purpose then</p><p class=MsoNormal>we might need to reexamine that code. My understanding from discussing</p><p class=MsoNormal>with other compiler engineers is that using a native method is the safest</p><p class=MsoNormal>technique that the compilers can't see through. The problem with</p><p class=MsoNormal>@DontInline is that C2 looks at the bytecodes of the target method, even</p><p class=MsoNormal>if it isn't inlined (see BCEscapeAnalyzer and the EstimateArgEscape flag).</p><p class=MsoNormal>There may be a way to make it work, but that would require more</p><p class=MsoNormal>investigation, and I'm not sure the benefit outweighs the risk.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>dl</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On 12/15/18 6:48 AM, Claes Redestad wrote:</p><p class=MsoNormal>> Hi Dean,</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> to avoid escape analysis-eliminated allocations in the past @DontInline</p><p class=MsoNormal>> has been sufficient. This means a simpler patch (no changes to native</p><p class=MsoNormal>> code needed - added assertions notwithstanding) and passes your tests</p><p class=MsoNormal>> with C2 (it'd concern me if Graal's EA sees through this trick, as it</p><p class=MsoNormal>> might break some existing places where DontInline is used to this</p><p class=MsoNormal>> effect):</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> /**</p><p class=MsoNormal>> * The value needs to be physically located in the frame, so that it</p><p class=MsoNormal>> * can be found by a stack walk.</p><p class=MsoNormal>> */</p><p class=MsoNormal>> @Hidden</p><p class=MsoNormal>> @DontInline</p><p class=MsoNormal>> private static void ensureMaterializedForStackWalk(Object o) {}</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> Thanks!</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> /Claes</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> On 2018-12-15 01:59, dean.long@oracle.com wrote:</p><p class=MsoNormal>>> https://bugs.openjdk.java.net/browse/JDK-8214583</p><p class=MsoNormal>>> http://cr.openjdk.java.net/~dlong/8214583/webrev</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> This change includes two new regression test that demonstrate the </p><p class=MsoNormal>>> problem, and a fix that allows the tests</p><p class=MsoNormal>>> to pass.</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> The problem happens when the JIT compiler's escape analysis </p><p class=MsoNormal>>> eliminates the allocation of the AccessControlContext object passed </p><p class=MsoNormal>>> to doPrivileged. The compiler thinks this is safe because it does </p><p class=MsoNormal>>> not see that the object "escapes". However, getContext needs to be </p><p class=MsoNormal>>> able to find the object using a stack walk, so we need a way to tell </p><p class=MsoNormal>>> the compiler that it does indeed escape. To do this we pass the </p><p class=MsoNormal>>> value to a native method that does nothing.</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> Microbenchmark results:</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> jdk12-b18:</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> Benchmark Mode Cnt Score Error Units</p><p class=MsoNormal>>> DoPrivileged.test avgt 25 255.626 ± 6.446 ns/op</p><p class=MsoNormal>>> DoPrivileged.testInline avgt 25 250.968 ± 4.975 ns/op</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> jdk12-b19:</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> Benchmark Mode Cnt Score Error Units</p><p class=MsoNormal>>> DoPrivileged.test avgt 25 5.689 ± 0.001 ns/op</p><p class=MsoNormal>>> DoPrivileged.testInline avgt 25 2.765 ± 0.001 ns/op</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> this fix:</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> Benchmark Mode Cnt Score Error Units</p><p class=MsoNormal>>> DoPrivileged.test avgt 25 5.020 ± 0.001 ns/op</p><p class=MsoNormal>>> DoPrivileged.testInline avgt 25 2.774 ± 0.025 ns/op</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> dl</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>