<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 25, 2014 at 2:54 PM, Mihaly Barasz <span dir="ltr"><<a href="mailto:klao@nilcons.com" target="_blank">klao@nilcons.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">Well, I don't know enough about how GC is specified in GHC, but _in<br>

</div>
practice_ calls to GC could happen only on entry to the exampleFn<br>
closure.  Not between the address computation and the foreign call. (I<br>
simply looked at the generated code, I don't know if there is any<br>
guarantee for that.)<br></blockquote><div><br></div><div>There can be additional heap checks at the start of any basic block in the generated assembly for the function. Right, in practice there's probably not an issue.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="">Thanks, I'll look into that. Are there any pointers/examples?<br></div></blockquote><div><br></div><div>There's some code out there on the web that uses the extension. Here's an example: <a href="https://github.com/tibbe/hashable/blob/master/Data/Hashable/Class.hs#L470">https://github.com/tibbe/hashable/blob/master/Data/Hashable/Class.hs#L470</a></div>

<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""></div>
<div class="">I don't know why, but the constructor for Vector is not exported, only<br></div>
for the MVector. But, this use of unsafeThaw is completely benign.<br>
(Actually, it fully disappears in the generated code. :))<br></blockquote><div><br></div><div>Probably because it's a ByteArray#, not an Array#. For the latter unsafe thawing results in the object being put on the GC mutable list (in practice that means that the info table ptr changes).</div>

<div><br></div></div></div></div>