[Haskell-cafe] How does the RTS pin ByteArray# objects during FFI calls?
reiner.pope at gmail.com
Wed Jan 3 02:51:40 UTC 2018
I understand from
it is safe to pass ByteArray# objects to FFI calls, using the
UnliftedFFITypes language extension. As I understand it, the implicit
guarantee is that the RTS will pin the ByteArray#'s address in memory for
the duration of the FFI call -- even if the ByteArray# wasn't allocated
I'm curious: how does the RTS achieve this "retroactive" pinning? The
that *all* ByteArrays are allocated pinned to account for the possibility
that they will in future be passed to the FFI. Is this really the case?
This seems like it forces an unreasonably slow allocator on small (say,
~10-byte) ByteArray allocations where the GC's usual bump-pointer allocator
might otherwise be preferable.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe