<html xmlns:v="urn:schemas-microsoft-com:vml" 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=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:917858799;
        mso-list-type:hybrid;
        mso-list-template-ids:-1656354292 1836882286 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:\F0D8;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;
        mso-fareast-font-family:DengXian;
        mso-bidi-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1
        {mso-list-id:2140030125;
        mso-list-type:hybrid;
        mso-list-template-ids:-1548434028 -350476256 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l1:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:\F0D8;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;
        mso-fareast-font-family:DengXian;
        mso-bidi-font-family:"Times New Roman";}
@list l1:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l1:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l1:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l1:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l1:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l1:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Jatin,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks for looking at this issue!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="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?
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="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 ?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Xiaohong<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="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<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Xiaohong, Fred,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="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><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">For a field to be a true constant should we not check for both static and final accesses?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="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 ?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Best Regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Jatin <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div id="mail-editor-reference-message-container">
<p class="MsoNormal"><o:p> </o:p></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="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<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<p class="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>
>><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>