<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: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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi, Graal community,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In section 2 of CGO14 “Partial Escape Analysis and Scalar Replacement for Java”, there’s a sentence:<o:p></o:p></p>
<p class="MsoNormal">“The Graal IR keeps the frame states not at the points where the actual deoptimizations take place, but at the points where side effects may occur.”
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The paper is great, but I can’t find the explanation of this design decision.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My intuitive idea is that we generate FrameState at the point where the deoptimization arises. This is the most accurate, isn’t it?
<o:p></o:p></p>
<p class="MsoNormal">I believe this is also how C2 IR does. Recently, I reckon many macro nodes are affected by C2’s decision. C2 collapses a linked-list of FrameStates on a function call.
<o:p></o:p></p>
<p class="MsoNormal">AllocationNode is a CallNode, so new_instance does this to AllocationNode too. That is to say, an allocation node and all FrameStates bundle. C2 can’t move the allocation
<o:p></o:p></p>
<p class="MsoNormal">node to another place because FrameStates are position-dependent. In C2, many other macro nodes such as LockNode, ArrayCopyNode fall into the same awkward situation. <o:p></o:p></p>
<p class="MsoNormal">Even compiler knows how, it can’t move them.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Obviously, Graal JIT manages to solve this problem. The PEA phrase can move allocations whatever it wants. So far, my understanding is that Graal IR hides those deoptimization nodes in high-tier. <o:p></o:p></p>
<p class="MsoNormal">My revelation is that an AllocationNode itself doesn’t mean deoptimization. It’s a slowpath led by typecheck failure triggers deoptmization. This slowpath won’t emerge until low-level expansion. <o:p></o:p></p>
<p class="MsoNormal">At high-tier, Graal optimizations can move the high-level nodes freely because low-level nodes that cause deoptimization haven’t been there yet. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Simply put, allocation node is floating in Graal high-tier whereas it’s a fixed node in C2. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If I am still on track, the problem boils down to how to generate the correct FrameState for those low-level deoptimization nodes. I guess this is why Graal IR designers save FrameStates “at the points where side-effect may occur”. The
late nodes need anchor points. Either Graal generates a new deoptimization node or move someone to this point, it is easy to find the closest ‘FrameState” in reverse control flows, Like magnet.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">All above is my conjunction. Could Graal experts confirm my understanding? Or could someone point me a literature which describes the rationale of FrameState design?
<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">--lx<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
</div>
</body>
</html>