Allow multiple C finalizers to be attached to a Weak#
authorTakano Akio <aljee@hyper.cx>
Thu, 18 Apr 2013 09:30:23 +0000 (18:30 +0900)
committerIan Lynagh <ian@well-typed.com>
Sat, 15 Jun 2013 15:23:09 +0000 (16:23 +0100)
commitd61c623ed6b2d352474a7497a65015dbf6a72e12
tree13132eb4473fb8594bd72e168f918ea79a0c9da6
parent5d9e686c30a00be08a04d9fd1c860994153a1f7a
Allow multiple C finalizers to be attached to a Weak#

The commit replaces mkWeakForeignEnv# with addCFinalizerToWeak#.
This new primop mutates an existing Weak# object and adds a new
C finalizer to it.

This change removes an invariant in MarkWeak.c, namely that the relative
order of Weak# objects in the list needs to be preserved across GC. This
makes it easier to split the list into per-generation structures.

The patch also removes a race condition between two threads calling
finalizeWeak# on the same WEAK object at that same time.
compiler/prelude/primops.txt.pp
includes/rts/storage/Closures.h
includes/stg/MiscClosures.h
rts/Linker.c
rts/PrimOps.cmm
rts/StgMiscClosures.cmm
rts/Weak.c
rts/Weak.h
rts/sm/Compact.c
rts/sm/MarkWeak.c
utils/deriveConstants/DeriveConstants.hs