Changes between Version 1 and Version 2 of GMPMemoryManagement
- Apr 2, 2007 9:50:39 PM (7 years ago)
v1 v2 4 4 GMP expects a storage model where pointers (newtyped as mpz_t) are explicitly allocated and freed. 5 5 However, Haskell requires Integers to be garbage collected. 6 This could be done with ForeignPtrs, however (presumably for performance reasons?) GHC usesByteArray#s from the heap instead. 6 This could be done with ByteArray#s from the heap instead. 7 7 rts/sm/Storage.c `initStorage` sets three override functions to do this: `stgAllocForGMP`, `stgReallocForGMP`, and `stgDeallocForGMP`. 8 8 9 9 This requires a fairly subtle interaction in order to work safely, 10 because heap ByteArray#s are normal objects and can be moved by garbage collection. 10 because heap ByteArray#s are normal objects and can be moved by garbage collection. 11 11 The important thing to note is that the GHC garbage collector is of the stop-the-world variety. 12 12 This means that all threads must reach a synchronization point before garbage collection can actually begin.