[project @ 2001-08-08 10:50:36 by simonmar]
authorsimonmar <unknown>
Wed, 8 Aug 2001 10:50:37 +0000 (10:50 +0000)
committersimonmar <unknown>
Wed, 8 Aug 2001 10:50:37 +0000 (10:50 +0000)
commit52c078343e70a170441fed71480ba8569475c4cd
tree1153092a2cbfd5eec41fb74205c97c8c472751df
parent1cc01adad4360ab1014b83ce933aec055d5d0e85
[project @ 2001-08-08 10:50:36 by simonmar]
Had a brainwave on the way to work this morning, and realised that the
garbage collector can handle "pinned objects" as long as they don't
contain any pointers.

This is absolutely ideal for doing temporary allocation in the FFI,
because what we really want to do is allocate a pinned ByteArray and
let the GC clean it up later.  So this set of changes adds the
required framework.

There are two new primops:

 newPinnedByteArray# :: Int# -> State# s -> (# State# s, MutByteArr# s #)
 byteArrayContents#  :: ByteArr# -> Addr#

obviously byteArrayContents# is highly unsafe.

Allocating a pinned ByteArr# isn't the default, because a pinned
ByteArr# will hold an entire block (currently 4k) live until it is
garbage collected (that doesn't mean each pinned ByteArr# requires
4k of storage, just that if a block contains a single live pinned
ByteArray, the whole block must be retained).
ghc/compiler/prelude/primops.txt.pp
ghc/includes/PrimOps.h
ghc/lib/std/PrelGHC.hi-boot.pp
ghc/rts/GC.c
ghc/rts/PrimOps.hc
ghc/rts/Storage.c
ghc/rts/Storage.h
ghc/rts/StoragePriv.h