-
Notifications
You must be signed in to change notification settings - Fork 32
LarcenyGcDesign
Felix S. Klock II edited this page Jul 28, 2013
·
1 revision
The garbage collection code is pretty much isolated to Rts/Sys
, which is good. However, even the the "few" files that are there have a pretty convoluted control structure, which makes them difficult to understand.
PnkFelix is going to take notes here to remind himself of things he learned along the way.
-
semispace.c
contains a core ADT that the rest of the collector is built upon.- Its important to understand this ADT at times, because our semispaces are not atomic entities.
- They are made out of chunks of contiguous memory (not one big chunk, but a collection of such chunks).
- There are times when this design component leaks out into the client code.
-
cheney.c
has the core functionality for most of the copying garbage collectors, in terms of scanning and copying objects using a standard (but very heavily bummed) algorithm.- The algorithm is standard but that doesn't mean the implementation is simple.
- PnkFelix spent Fall semester 2005 struggling to translate
cheney.c
into a simpler (and less efficient) recursive version. - The number of strange dependencies and invariants that bit him over the course of the semester was quite remarkable; see the conspiracy branch of the source tree if you dare.
- There are different "objects" floating around that represent different kinds of heaps. In particular, some of these heap objects has a
collect
"method" that takes one arguments (beyond self), and other heap objects have acollect
method that takes three arguments (beyond self).- This is actually not total insanity
- the three arg versions have options for indicating which generation is targetted, how many free bytes are required for the client to proceed, and the "type" of collection (whatever that means)
- The one arg versions are for old heap areas, where we never directly allocate storage, and therefore a collection never needs to indicate how many bytes are needed (I believe).
- Not clear on why we have a generation argument in the first variant though, when it seems like that should be built into the receiver of the message. But perhaps Lars intended to layer these objects so that one heap object could represent a collection of other heap objects.
- PnkFelix thinks this sort of structure is usually a mistake (these sorts of containment hierarchies often introduce more confusion than flexibilty), but sometimes it can work.