<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)">
<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;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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:1605916574;
        mso-list-type:hybrid;
        mso-list-template-ids:-524383778 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
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="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Regarding Call-site size specification:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">CoreCLR (<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_dotnet_coreclr&d=AwMFAg&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=tivqoQ8PCwy6RXvEMP_xKCln6qCCa_YS5vOE5ysnkU4&s=ucAtdIpwc4EFLCn3boQR7yLnHAOYMcmAlYOMPWSTMls&e=">https://github.com/dotnet/coreclr</a>) requires the size of the Call-instruction to be reported in the GCInfo
 encoding.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">The runtime performs querries for StackMap records using instruction offsets as follows:<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><span style="mso-list:Ignore">1)<span style="font:7.0pt "Times New Roman"">     
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Offset at the end of the call instruction (offset of next instruction-1) if the call instruction occurs in code where GC can only take control at safe-points.<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><span style="mso-list:Ignore">2)<span style="font:7.0pt "Times New Roman"">     
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Offset of the start of the call instruction if the call instruction occurs within a code-range that allows full interruption (that is, all instructions
 in a range are considered safe-points)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">LLVM/statepoint GC does not support option (2), but the CoreCLR’s GC-table Encoding has an interface designed to suite both modes.<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:Consolas;color:blue">void</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> DefineCallSites(</span><span style="font-size:10.0pt;font-family:Consolas;color:#2B91AF">UINT32</span><span style="font-size:10.0pt;font-family:Consolas;color:black">* </span><span style="font-size:10.0pt;font-family:Consolas;color:gray">pCallSites</span><span style="font-size:10.0pt;font-family:Consolas;color:black">, </span><span style="font-size:10.0pt;font-family:Consolas;color:#2B91AF">BYTE</span><span style="font-size:10.0pt;font-family:Consolas;color:black">* </span><span style="font-size:10.0pt;font-family:Consolas;color:gray">pCallSiteSizes</span><span style="font-size:10.0pt;font-family:Consolas;color:black">, </span><span style="font-size:10.0pt;font-family:Consolas;color:#2B91AF">UINT32</span><span style="font-size:10.0pt;font-family:Consolas;color:black"> </span><span style="font-size:10.0pt;font-family:Consolas;color:gray">numCallSites</span><span style="font-size:10.0pt;font-family:Consolas;color:black">)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Therefore, it is helpful to have Call-Site size specified in
</span><span style="font-family:"Courier New"">StackMapRecord</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I agree with Andy, that the call-site size should include all bytes between the start of the call instruction and the start of the next instruction.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Swaroop.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Juergen Ributzka [mailto:juergen@apple.com]
<br>
<b>Sent:</b> Thursday, July 9, 2015 2:04 PM<br>
<b>To:</b> LLVM Dev<br>
<b>Cc:</b> Lang Hames; Andrew Trick; Phil Pizlo; Philip Reames; Sanjoy Das; Swaroop Sridhar; Russell Hadley<br>
<b>Subject:</b> [RFC] New StackMap format proposal (StackMap v2)<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi @ll,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">over the past year we gained more experience with the patchpoint/stackmap/statepoint intrinsics and it exposed limitations in the stackmap format.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">The following proposal includes feedback and request from several interested parties and I would like to hear your feedback.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Missing correlation between functions and stackmap records:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Originally the client had to keep track of the ID to know which stackmap record belongs to which function, but this would stop working once functions are inlined.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">The new format fixes that by adding a direct reference from the function to the stackmap records.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Call Size and Function Size:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">These are additional information that are of interest and have been added to the format.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">@Swaroop: Could you please provide a little more detailed explanation on the "Call Size" field and what exactly is there recorded. Is it just the call instruction<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">or also the materialization code for the address? For what is this used for?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Flat format:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">We think moving to a flat form will make parsing easier, because every record has a fixed size and offsets can be calculated easily. The plan is to also<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">provide parsers for both stackmap versions (there is already one for the first format in tree) and a corresponding C-API to make it easier for clients to<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">adopt the new format. There is no plan to drop the original format and we will continue to support both formats. I will ask for feedback on the C API in a<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">separate RFC. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Another benefit we hope to achieve from this format is to optimize for size by uniquing entries - but that is independent optimization and not required.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">More detailed frame record:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Clients require more information about the function frame, such as spilled registers, etc. The frame base register i.e. might change when dynamic stack<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">realignment is performed on X86.<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">If there is anything missing please let me know.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Juergen<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>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Header v2 {<br>
  uint8  : Stack Map Version (2)<br>
  uint8  : Reserved [3] (0)<br>
  uint32 : Constants Offset (bytes)<br>
  uint32 : Frame Records Offset (bytes)<br>
  uint32 : Frame Registers Offset (bytes)<br>
  uint32 : StackMap Records Offset (bytes)<br>
  uint32 : Locations Offset (bytes)<br>
  uint32 : LiveOuts Offset (bytes)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">}<br>
<br>
align to 8 bytes<br>
Constants[] {<br>
  uint64 : LargeConstant<br>
}<br>
<br>
align to 8 bytes<br>
FrameRecord[] {<br>
  uint64 : Function Address<br>
  uint32 : Function Size<br>
  uint32 : Stack Size<br>
  uint16 : Flags {<br>
    bool : HasFrame<br>
    bool : HasVariableSizeAlloca<br>
    bool : HasStackRealignment<br>
    bool : HasLiveOutInfo<br>
    bool : Reserved [12]<br>
  }<br>
  uint16 : Frame Base Register Dwarf RegNum<br>
  uint16 : Num Frame Registers<br>
  uint16 : Frame Register Index<br>
  uint16 : Num StackMap Records<br>
  uint16 : StackMap Record Index</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">}<br>
<br>
align to 4 bytes<br>
FrameRegister[] {<br>
  uint16 : Dwarf RegNum<br>
  int16  : Offset<br>
  uint8  : Size in Bytes<br>
  uint8  : Flags {<br>
    bool : IsSpilled<br>
    bool : Reserved [7]<br>
  }<br>
}<br>
<br>
align to 8 bytes<br>
StackMapRecord[] {<br>
  uint64 : PatchPoint ID<br>
  uint32 : Instruction Offset<br>
  uint8  : Call size (bytes)<br>
  uint8  : Flags {<br>
    bool : HasLiveOutInfo<br>
    bool : Reserved [7]<br>
  }<br>
  uint16 : Num Locations<br>
  uint16 : Location Index<br>
  uint16 : Num LiveOuts<br>
  uint16 : LiveOut Index<br>
}</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">align to 4 bytes</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">Location[] {<br>
  uint8  : Register | Direct | Indirect | Constant | ConstantIndex<br>
  uint8  : Reserved (location flags)<br>
  uint16 : Dwarf RegNum<br>
  int32  : Offset or SmallConstant<br>
}<br>
<br>
align to 2 bytes<br>
LiveOuts[] {<br>
  uint16 : Dwarf RegNum<br>
  uint8  : Reserved<br>
  uint8  : Size in Bytes<br>
}</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>