diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-12-17 22:42:28 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-12-17 22:42:28 +0000 |
commit | 0417404f5d1230c9d291ea9f73e2831121c8ec99 (patch) | |
tree | 609f1be77f63606772e71ad84c7a92b205baaa9e /rts/Weak.c | |
parent | fb783aeaa5bc1cc60e6bb551c1cd01a097b84fad (diff) | |
download | haskell-0417404f5d1230c9d291ea9f73e2831121c8ec99.tar.gz |
Fix #650: use a card table to mark dirty sections of mutable arrays
The card table is an array of bytes, placed directly following the
actual array data. This means that array reading is unaffected, but
array writing needs to read the array size from the header in order to
find the card table.
We use a bytemap rather than a bitmap, because updating the card table
must be multi-thread safe. Each byte refers to 128 entries of the
array, but this is tunable by changing the constant
MUT_ARR_PTRS_CARD_BITS in includes/Constants.h.
Diffstat (limited to 'rts/Weak.c')
-rw-r--r-- | rts/Weak.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/rts/Weak.c b/rts/Weak.c index f5e918a921..94bead3752 100644 --- a/rts/Weak.c +++ b/rts/Weak.c @@ -76,7 +76,8 @@ scheduleFinalizers(Capability *cap, StgWeak *list) StgWeak *w; StgTSO *t; StgMutArrPtrs *arr; - nat n; + StgWord size; + nat n, i; running_finalizers = rtsTrue; @@ -120,10 +121,12 @@ scheduleFinalizers(Capability *cap, StgWeak *list) debugTrace(DEBUG_weak, "weak: batching %d finalizers", n); - arr = (StgMutArrPtrs *)allocate(cap, sizeofW(StgMutArrPtrs) + n); + size = n + mutArrPtrsCardTableSize(n); + arr = (StgMutArrPtrs *)allocate(cap, sizeofW(StgMutArrPtrs) + size); TICK_ALLOC_PRIM(sizeofW(StgMutArrPtrs), n, 0); SET_HDR(arr, &stg_MUT_ARR_PTRS_FROZEN_info, CCS_SYSTEM); arr->ptrs = n; + arr->size = size; n = 0; for (w = list; w; w = w->link) { @@ -132,6 +135,10 @@ scheduleFinalizers(Capability *cap, StgWeak *list) n++; } } + // set all the cards to 1 + for (i = n; i < size; i++) { + arr->payload[i] = (StgClosure *)(W_)(-1); + } t = createIOThread(cap, RtsFlags.GcFlags.initialStkSize, |