Write barrier for stack updates?
marlowsd at gmail.com
Wed Jul 18 07:52:19 UTC 2018
The write barrier is the function `dirty_STACK()` here:
If you grep for `dirty_STACK` you'll see it being called everywhere we
mutate a STACK, in particular in the scheduler just before running a
We don't call the write barrier in the code generator or from primops,
because at that point the thread is already running and has already been
marked dirty. If we GC and mark the stack clean, then it will be marked
dirty again by the scheduler before we start running it.
On 17 July 2018 at 20:45, Ömer Sinan Ağacan <omeragacan at gmail.com> wrote:
> Hi Simon,
> I'm a bit confused about stack updates in generated code and write
> Because stacks are mutable (we push new stuff or maybe even update existing
> frames?) it seems to me that we need one these two, similar to other
> - Always keep all stacks in mut_lists
> - Add write barriers before updates
> However looking at some of the primops like catch# and the code generator
> generates code that pushes update frames I can't see any write barriers
> and the
> GC doesn't always add stacks to mut_lists (unlike e.g. MUT_ARR_PTRS). I
> thought maybe we add a stack to a mut_list when we switch to the TSO that
> it or we park the TSO, but I don't see anything relevant in Schedule.c or
> ThreadPaused.c. So I'm lost. Could you say a few words about how we deal
> mutated stacks in the GC, so that if an old stack points to a young object
> don't collect the young object in a minor GC?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs