<div dir="ltr"><div>Thanks for all the comments on this.</div><div><br></div><div>The concern for not using a trampoline is that it's very likely my language will interpret for a while, then generate code, then generate better code, etc. Much like the WebKit FLT JavaScript project. It seems like they will be using patch points? I should probably use that for my perf use-case as well.</div><div><br></div><div>However, I have an additional case that requires correctness to maintained across threads, i.e. the code may be semantically different. In this case I need either all callsites updated at once, or none. It can't be that half of the </div><div>callsites are calling into a different function because there maybe real differences.</div><div><br></div><div>I suppose an approach I can take is to use patch points for eventual consistency and have an if check that has maintains the correctness and will trampoline or execute code depending on if all call sites are done being patched.</div><div><br></div><div>Or maybe I'm over complicating this for my language :-)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 19, 2015 at 10:55 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"><span>> That all makes sense. What are your thoughts on the trade-offs of this vs<br>
> the patchpoint approach though? If you can modify previously executable<br>
> memory it seems like the patchpoint approach would have lower overhead,<br>
> unless you have a truly huge number of callsites to update?<br>
<br>
</span>You need the hijack-return-pc approach *in addition* to a call-site<br>
patching approach. Modifying the return PC lets you guarantee that<br>
nothing will *return* into the old generated code. To guarantee that<br>
nothing will *call* into it either you could use a double indirection<br>
(all calls go through a trampoline) or patchpoints.<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Sanjoy<br>
</font></span></blockquote></div><br></div>