| 1 | How to implement GMS in Parrot. |
| 2 | |
| 3 | There is 2 complex things in implementing Generational GC: |
| 4 | * Skip older generations during marking younger. |
| 5 | * Properly handle old-to-young pointers. |
| 6 | |
| 7 | Usually first part implemented with help of Compacting GC when survived {{{young}}} objects |
| 8 | moved into {{{old}}} generation physically. It will require some substantial changes in Parrot's |
| 9 | GC. Instead I'm going to add integer {{{generation}}} field into {{{PObj}}} and skip older objects |
| 10 | during marking young ones. |
| 11 | |
| 12 | Second part can be implemented in various ways - {{{mprotect}}} on old objects, {{{mprotect}}} of whole generations, |
| 13 | manually inserting WriteBarriers, etc. But because we have VTABLEs API and most of access to PMCs go through it we can |
| 14 | use idea from http://research.microsoft.com/en-us/um/people/simonpj/papers/non-stop/index.htm to insert write barriers |
| 15 | automatically. |
| 16 | |
| 17 | * Add {{{VTABLE *write_barrier_variant}}} into {{{VTABLE}}} |
| 18 | * Patch Pmc2c to create new "write barrier" VTABLE. |
| 19 | * Every method marked with :write will have body like this |
| 20 | {{{ |
| 21 | VTABLE_foo() { |
| 22 | Parrot_gc_write_barrier(INTERP, SELF); |
| 23 | SELF->vtable = SELF->vtable->write_barrier_variant; |
| 24 | SELF.foo(); |
| 25 | } |
| 26 | }}} |
| 27 | * {{{Parrot_gc_write_barrier}}} will add PMC into {{{root set}}} |
| 28 | * GMS will have {{{current_generation}}} property during mark. |
| 29 | * {{{Parrot_gc_mark_PMC_alive}}} will skip older objects during marking. |