<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
<div dir="auto"><span dir="auto" style="color:rgb(0, 0, 0);font-size:medium">Hi <span>Xiaohong,</span></span>
<div dir="auto" style="color:rgb(0, 0, 0);font-size:medium"><br>
</div>
<div dir="auto" style="color:rgb(0, 0, 0);font-size:medium"><span>Thanks for your response.</span></div>
<div dir="auto" style="color:rgb(0, 0, 0);font-size:medium"><span><br>
</span></div>
<div dir="auto" style="color:rgb(0, 0, 0);font-size:medium"><span><br>
</span></div>
<div id="mail-editor-reference-message-container" dir="auto" style="color:rgb(0, 0, 0);font-size:medium">
<span style="font-family:Calibri, sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">> I think it’s different. One is the fields in the value/primitive class is immutable (final). Another is the field with the type
of value/primitive class is final. The latter is mutable if no “final” is set</span></div>
<div id="mail-editor-reference-message-container" dir="auto" style="color:rgb(0, 0, 0);font-size:medium">
<font color="#000000" face="Calibri, sans-serif"><span style="font-size:14.6667px"><br>
</span></font></div>
<div id="mail-editor-reference-message-container" dir="auto" style="color:rgb(0, 0, 0);font-size:medium">
<font color="#000000" face="Calibri, sans-serif"><span style="font-size:14.6667px">Yes, this is correct, and my earlier response was in this context. But to make a value object mutable it must transition into larval state. </span></font></div>
<div id="mail-editor-reference-message-container" dir="auto" style="color:rgb(0, 0, 0);font-size:medium">
<font color="#000000" face="Calibri, sans-serif"><span style="font-size:14.6667px"><br>
</span></font></div>
<div id="mail-editor-reference-message-container" dir="auto" style="color:rgb(0, 0, 0);font-size:medium">
<font color="#000000" face="Calibri, sans-serif"><span style="font-size:14.6667px">
<p class="MsoNormal" style="background-color:rgb(255, 255, 255);margin:0in;font-size:11pt">
> This sounds reasonable to me! And I think this is the current behavior. So the final field is always to be flattened even its size is larger than the specified max flat size?</p>
<p class="MsoNormal" style="background-color:rgb(255, 255, 255);margin:0in;font-size:11pt">
<br>
</p>
<p class="MsoNormal" style="background-color:rgb(255, 255, 255);margin:0in;font-size:11pt">
Correct, only query was around usage of final along with static to treat it as a true constant.</p>
<p class="MsoNormal" style="background-color:rgb(255, 255, 255);margin:0in;font-size:11pt">
<br>
</p>
<div class="MsoNormal" dir="auto" style="background-color:rgb(255, 255, 255);margin:0px 0in;font-size:11pt">
<a rel="noreferrer noopener" href="https://github.com/openjdk/valhalla/blob/cabc4d28c5c92f6386252851b0dede1ddde3129c/src/hotspot/share/ci/ciField.hpp#L126" style="color:rgb(0, 120, 212)">https://github.com/openjdk/valhalla/blob/cabc4d28c5c92f6386252851b0dede1ddde3129c/src/hotspot/share/ci/ciField.hpp#L126</a><br>
</div>
<br>
</span></font></div>
<div id="mail-editor-reference-message-container" dir="auto" style="color:rgb(0, 0, 0);font-size:medium">
<font color="#000000" face="Calibri, sans-serif"><span style="font-size:14.6667px">Best Regards,</span></font></div>
<span id="mail-editor-reference-message-container" dir="auto" style="color:rgb(0, 0, 0);font-size:medium"><font color="#000000" face="Calibri, sans-serif"><span style="font-size:14.6667px">Jatin </span></font></span><br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Xiaohong Gong <Xiaohong.Gong@arm.com><br>
<b>Sent:</b> Friday, July 7, 2023 7:31:30 AM<br>
<b>To:</b> Bhateja, Jatin <jatin.bhateja@intel.com>; Frederic Parain <frederic.parain@oracle.com>; valhalla-dev@openjdk.org <valhalla-dev@openjdk.org><br>
<b>Cc:</b> nd <nd@arm.com><br>
<b>Subject:</b> RE: [External] : RE: Question on the inline type flattening decision</font>
<div> </div>
</div>
<style>
<!--
@font-face
{font-family:Wingdings}
@font-face
{font-family:SimSun}
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:DengXian}
@font-face
{font-family:Calibri}
@font-face
{}
@font-face
{}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
{color:blue;
text-decoration:underline}
span.x_EmailStyle20
{font-family:"Calibri",sans-serif;
color:windowtext}
.x_MsoChpDefault
{font-size:10.0pt}
@page WordSection1
{margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
{}
ol
{margin-bottom:0in}
ul
{margin-bottom:0in}
-->
</style>
<div lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi Jatin,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Thanks for looking at this issue!</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">> On final field flatting, it's good to always flatten them to enhance constant folding opportunities for C2 compiler. We may have an InlineTypeNodes with high indegree, but a getfield will always get hold of constant value.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">This sounds reasonable to me! And I think this is the current behavior. So the final field is always to be flattened even its size is larger than the specified max flat size?
</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">> Alternatively, since a primitive/value class objects are immutable with implicit final fields unless object in larval state so we may also relax final access check, WDYT ?</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">I think it’s different. One is the fields in the value/primitive class is immutable (final). Another is the field with the type of value/primitive class is final. The latter is mutable if no “final” is set.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Thanks,</p>
<p class="x_MsoNormal">Xiaohong</p>
<p class="x_MsoNormal"> </p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b>From:</b> Bhateja, Jatin <jatin.bhateja@intel.com> <br>
<b>Sent:</b> Friday, July 7, 2023 12:07 AM<br>
<b>To:</b> Frederic Parain <frederic.parain@oracle.com>; Xiaohong Gong <Xiaohong.Gong@arm.com>; valhalla-dev@openjdk.org<br>
<b>Cc:</b> nd <nd@arm.com><br>
<b>Subject:</b> Re: [External] : RE: Question on the inline type flattening decision</p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div>
<p class="x_MsoNormal">Hi Xiaohong, Fred,</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal"><span style="color:black; background:white">> One is removing the followed "field" access check, which means the fields can be flattened no matter whether the field is "final" or not.</span></p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">On final field flatting, it's good to always flatten them to enhance constant folding opportunities for C2 compiler. We may have an InlineTypeNodes with high indegree, but a
<i>getfield</i> will always get hold of constant value.</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">For a field to be a true constant should we not check for both static and final accesses?</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">Alternatively, since a primitive/value class objects are immutable with implicit final fields unless object in larval state so we may also relax final access check, WDYT ?</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">Best Regards,</p>
</div>
<div>
<p class="x_MsoNormal">Jatin </p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div id="x_mail-editor-reference-message-container">
<p class="x_MsoNormal"> </p>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><strong><span style="font-family:"Calibri",sans-serif">From:</span></strong> valhalla-dev <<a href="mailto:valhalla-dev-retn@openjdk.org">valhalla-dev-retn@openjdk.org</a>> on behalf of Frederic Parain <<a href="mailto:frederic.parain@oracle.com">frederic.parain@oracle.com</a>><br>
<strong><span style="font-family:"Calibri",sans-serif">Sent:</span></strong> Thursday, July 6, 2023 6:28:16 PM<br>
<strong><span style="font-family:"Calibri",sans-serif">To:</span></strong> Xiaohong Gong <<a href="mailto:Xiaohong.Gong@arm.com">Xiaohong.Gong@arm.com</a>>;
<a href="mailto:valhalla-dev@openjdk.org">valhalla-dev@openjdk.org</a> <<a href="mailto:valhalla-dev@openjdk.org">valhalla-dev@openjdk.org</a>><br>
<strong><span style="font-family:"Calibri",sans-serif">Cc:</span></strong> nd <<a href="mailto:nd@arm.com">nd@arm.com</a>><br>
<strong><span style="font-family:"Calibri",sans-serif">Subject:</span></strong> Re: [External] : RE: Question on the inline type flattening decision</p>
</div>
<p class="x_MsoNormal"><br>
<br>
</p>
<div>
<p class="x_MsoNormal">Hi Xiaohong,<br>
<br>
<br>
I would recommend to modify the test driving the flattening decisions <br>
the following way:<br>
<br>
if (InlineFieldMaxFlatSize != 0<br>
<br>
&& (!(too_big_to_flatten | too_atomic_to_flatten | <br>
too_volatile_to_flatten) || fieldinfo.access_flags().is_final()) {<br>
<br>
<br>
By adding the first term "InlineFieldMaxFlatSize != 0 ", it will be <br>
obvious that this is the way to completely disable field flattening.<br>
<br>
The second term would remain the more specific tests on the field's <br>
properties to decide to flatten or not when flattening is enabled.<br>
<br>
<br>
What do you think of this proposal?<br>
<br>
<br>
Best Regards,<br>
<br>
<br>
Fred<br>
<br>
<br>
On 7/2/23 9:23 PM, Xiaohong Gong wrote:<br>
> Hi Frederic,<br>
><br>
> Thanks for looking at this issue. Yes, I was planning to fix this. But I'm not sure how to handle the relationship with "final" fields.<br>
><br>
> One is removing the followed "field" access check, which means the fields can be flattened no matter whether the field is "final" or not.<br>
><br>
> Another is changing the followed "||" to "&&", so that only the "final" fields that match the preconditions can be flattened.<br>
><br>
> So which one do you think is the defined behavior? The first one sounds reasonable to me. WDYT? Thanks a lot!<br>
><br>
> BTW, I'v filed this issue to: <a href="https://bugs.openjdk.org/browse/JDK-8311219">
https://bugs.openjdk.org/browse/JDK-8311219</a><br>
><br>
> Best Regards,<br>
> Xiaohong<br>
><br>
> -----Original Message-----<br>
> From: Frederic Parain <<a href="mailto:frederic.parain@oracle.com">frederic.parain@oracle.com</a>><br>
> Sent: Friday, June 30, 2023 9:28 PM<br>
> To: Xiaohong Gong <<a href="mailto:Xiaohong.Gong@arm.com">Xiaohong.Gong@arm.com</a>>;
<a href="mailto:valhalla-dev@openjdk.org">valhalla-dev@openjdk.org</a><br>
> Cc: nd <<a href="mailto:nd@arm.com">nd@arm.com</a>><br>
> Subject: Re: Question on the inline type flattening decision<br>
><br>
> Hi Xiaohong,<br>
><br>
><br>
> Thank you for reporting this. It looks like a bug to me, specifying<br>
> -XX:InlineFieldMaxFlatSize=0 should disable all field flattening, including final fields.<br>
><br>
> Do you want to fill a bug report or do you want me to take care of it?<br>
><br>
><br>
> Best Regards,<br>
><br>
><br>
> Fred<br>
><br>
><br>
> On 6/30/23 3:04 AM, Xiaohong Gong wrote:<br>
>> Hi,<br>
>><br>
>> I guess this is the right place to ask this question related to the<br>
>> flattening decision on inline type fields?<br>
>><br>
>> I met an issue when I was running the tests under<br>
>> “hotspot/jtreg/compiler/valhalla/inlinetypes” with<br>
>> “-XX:InlineFieldMaxFlatSize=0”. The intention is doing some testing by<br>
>> forcing the inline type fields not be flattened. And I debugged some<br>
>> C2 code in `inlinetypenode.cpp` like `InlineTypeNode::load()`. But I<br>
>> found that the code path has no difference, which means this flag<br>
>> cannot work and the field is flattened as without this flag.<br>
>><br>
>> And then, I checked the relative code<br>
>> <a href="https://urldefense.com/v3/__https:/github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/clas__;!!ACWV5N9M2RV99hQ!J7daZI_Hay5kWckchOY_VRTIwQvkJzF8AtUA0SEbDccLvtWEIcMKpkQY4IFKruqGd1K0_qzZXVvoPrHk3ys7z-iq8Q$">
https://urldefense.com/v3/__https://github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/clas__;!!ACWV5N9M2RV99hQ!J7daZI_Hay5kWckchOY_VRTIwQvkJzF8AtUA0SEbDccLvtWEIcMKpkQY4IFKruqGd1K0_qzZXVvoPrHk3ys7z-iq8Q$</a><br>
>> sfile/fieldLayoutBuilder.cpp#L759 to find out the reason. It checks<br>
>> the three necessary conditions (i.e.<br>
>> “the code size comparison with `InlineFieldMaxSize`”, “atomic” or<br>
>> “volatile” fields) firstly, which is the right behavior I think. But<br>
>> then the result is “||” with the `final` access flag. Which means if<br>
>> the field is `final`, it will be flattened anyway regardless of the<br>
>> necessary three limitations.<br>
>><br>
>> So is this the expected behavior? Does this mean the inline type field<br>
>> can always be flattened if it is declared with `final`? But I didn’t<br>
>> find any descriptions on the flattening decision related to the<br>
>> `final` flag.<br>
>><br>
>> Many thanks if any help on this!<br>
>><br>
>> Best Regards,<br>
>><br>
>> Xiaohong<br>
>></p>
</div>
<p class="x_MsoNormal"> </p>
</div>
</div>
</div>
</body>
</html>