<div dir="ltr">This looks great to me. I think the attribute using byte sizes was overly general, but we still want to leave room to implement a few different patching schemes. Other than your scheme, the obvious ones are the MS one and one that leaves space for a long jump in the prologue.<br><div><br></div><div>I'm assuming this attribute won't affect inlining or other IPO in any way, but you should probably mention that in the langref.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 6, 2016 at 12:10 AM, Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[Proposed langref entry]<br>
<br>
The "patchable-prologue" attribute on a function is a general<br>
mechanism to control the form of a function's prologue in ways that<br>
make it easy to patch at runtime.<br>
<br>
Currently only one value is supported:<br>
<br>
# "hotpatch-compact"<br>
<br>
If a function is marked with "patchable-prologue"="hotpatch-compact"<br>
then:<br>
<br>
 1. The first instruction of the function is at least two bytes long.<br>
 2. The first two bytes of the first instruction does not span a cache<br>
    line boundary.<br>
 3. The instruction denoted by (1) is preferably not a no-op, i.e.,<br>
    we'd prefer to "re-use" an instruction already present.  For<br>
    instance, we can emit a two byte form of a "push CSR" instruction<br>
    that we'd have needed anyway.<br>
<br>
"hotpatch-compact" is useful for runtimes that want to thread-safely<br>
overwrite the first instruction of a function with a short branch.<br>
<br>
[End proposed langref entry]<br>
<br>
<br>
We can consider adding more "schemes" in the future, for instance<br>
"hotpatch-ms" for the Microsoft hotpatching scheme.  I was initially<br>
thinking of proposing "num-patchable-bytes"="<count>" as the<br>
fundamental building block, but the more I thought about it the less I<br>
liked it, since a specific patching scheme has several tightly<br>
integrated constraints of which the number of bytes is just one.<br>
<br>
What do you think?<span class="HOEnZb"><font color="#888888"><br>
<br>
-- Sanjoy<br>
</font></span></blockquote></div><br></div>