Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Recording mutated closures #454

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Recording mutated closures #454

wants to merge 1 commit into from

Conversation

acondolu
Copy link
Contributor

@acondolu acondolu commented Feb 13, 2020

Why

This PR is a prerequisite for implementing generational garbage collection (PR #455). In fact, generational GC requires to keep track of all the closures in the older generation that contain a pointer to a closure in the younger generation. This means that whenever a closure in the older generation is mutated, we need to record it in a set which is usually called remembered set or mut_list.

What

The types of the closures that can mutated at runtime are: Thread State Objects (TSO), STACK, synchronising variables (MVAR), mutable variables (MUT_VAR), arrays with pointers (MUT_ARR_PTRS, SMALL_MUT_ARR_PTRS), CAFs, and of course THUNKs. For each of these closure types, we need to ensure that the PrimOps functions and and the builtin ones manipulating them record correctly their mutation.
We provide stub recordMutable and recordMutableCap builtin methods, which will enqueue mutated closures in a mut_list in a future PR. Note that in all cases recordMutable is called only if the mutated closure is clean, and after setting it as dirty.

How

The main changes are in the Cmm.h file (restored the recordMutable Cmm macro) and in the Builtins.hs file, where various calls to a stub recordMutable builtin functions are added.

@acondolu acondolu mentioned this pull request Feb 14, 2020
4 tasks
@acondolu acondolu force-pushed the wip-record-mutated branch 2 times, most recently from 852ca27 to 8e3be63 Compare February 27, 2020 12:37
@acondolu acondolu requested a review from TerrorJack February 27, 2020 12:57
@acondolu acondolu mentioned this pull request Feb 28, 2020
@acondolu acondolu force-pushed the wip-record-mutated branch 10 times, most recently from 2f00fd0 to f8213c7 Compare March 6, 2020 16:38
@acondolu acondolu force-pushed the wip-record-mutated branch from f8213c7 to f783cae Compare March 28, 2020 17:09
@acondolu
Copy link
Contributor Author

Before merging, we should ensure that updateThunk (and probably also messageBlackHole, but I'm not very familiar with that that function does) call recordMutable when blackholing. The problem is that Blackhole.hs is imported in Builtins.hs, so we need some refactoring before, to avoid the cyclic dependency.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant