Card marking for newly allocated arrays

Johan Tibell johan.tibell at
Mon Mar 10 08:22:00 UTC 2014


For MutableArray#s, a card is supposed to be marked if the array is
pointing to an object in a younger generation than itself resides in. Since
the array always points to elements in the same or an older generation when
it gets allocated, we should be fine with marking the array as clean upon
allocation and setting all the cards to zero. Right now it's marked as
*dirty* and all cards are (modulo a bug) marked as zero.

I think we should mark these arrays as clean to avoid some GC costs later.
We could avoid writing the card table on allocation as well, as it's always
safe to default to dirty. However, this will incur extra GC costs later
(after the first write to the array) as the whole array will appear as
dirty (due to garbage values in the card table as it wasn't initialized)
even if only a single element was written.

I'm leaning towards 1) marking arrays as clean and 2) zeroing out the card
table when the array is created. Thoughts?

-- Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list