[Haskell-cafe] accessing a ByteArray from FFI

Johan Tibell johan.tibell at gmail.com
Wed Jun 25 13:02:34 UTC 2014

On Wed, Jun 25, 2014 at 2:54 PM, Mihaly Barasz <klao at nilcons.com> wrote:

> Well, I don't know enough about how GC is specified in GHC, but _in
>  practice_ calls to GC could happen only on entry to the exampleFn
> closure.  Not between the address computation and the foreign call. (I
> simply looked at the generated code, I don't know if there is any
> guarantee for that.)

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.

> Thanks, I'll look into that. Are there any pointers/examples?

There's some code out there on the web that uses the extension. Here's an

> I don't know why, but the constructor for Vector is not exported, only
> for the MVector. But, this use of unsafeThaw is completely benign.
> (Actually, it fully disappears in the generated code. :))

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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140625/216b75bd/attachment.html>

More information about the Haskell-Cafe mailing list