diff options
| Commit | 715632578a616f7a983553c7c6670c785bd41f2c (patch) | |
|---|---|---|
| Author | 2020-12-12 20:44:36 +0200 | |
| Committer | 2020-12-12 20:44:36 +0200 | |
| Files | 8e2701ae4378926adcd858d9aee228a8795c85b3 | |
| IPL-715632578a616f7a983553c7c6670c785bd41f2c.tar IPL-715632578a616f7a983553c7c6670c785bd41f2c.tar.gz IPL-715632578a616f7a983553c7c6670c785bd41f2c.zip | ||
| Parent | e99f1851bcb2536e30bf0c6d17d744d166ce3ba8 (diff) | |
Enhance GC slides
1 files changed, 78 insertions, 0 deletions
| -rw-r--r-- | website/content/slides/10_vm_gc/_index.md | 78 |
diff --git a/website/content/slides/10_vm_gc/_index.md b/website/content/slides/10_vm_gc/_index.md index 09453e9..046467f 100644 --- a/website/content/slides/10_vm_gc/_index.md +++ b/website/content/slides/10_vm_gc/_index.md @@ -16,6 +16,83 @@ outputs: ["Reveal"] 5. Optimizations --- +## Theory reminders + +1. [Theory](https://www.slideshare.net/eelcovisser/garbage-collection-69688448) +0. [Barriers](https://www.cs.kent.ac.uk/pubs/2010/3011/content.pdf) +0. [Lua GC](http://www.inf.puc-rio.br/~roberto/talks/gc-lua.pdf) +0. [V8 GC](http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection) +0. [Generational GC](https://www.ps.uni-saarland.de/courses/gc-ws01/slides/generational_gc.pdf) +0. [Java Z GC](http://cr.openjdk.java.net/~pliden/slides/ZGC-FOSDEM-2018.pdf) +0. [LuaJIT GC](http://wiki.luajit.org/New-Garbage-Collector) + +--- +## Tri-colour marking + +In the core of concurrent and incremental garbage collectors + +- _white_ - not used, _dead_ object +- _black_ - used, _alive_ object, whose references have been marked +- _gray_ - used, _alive_ object, whose references have yet to be marked + +> references are the objects that are referenced by the current object + +--- +### Invariants + +- Weak: + + > All white objects pointed to by a black object are reachable from some grey + > object through a chain of white objects. + +- Strong: + + > There are no pointers from black objects to white objects. + +--- +### Escapes + +In the incremental or concurrent GC, while the marking phase is running, the +mutator can change the references of a black object and break the above +invariants. + +--- +### Barriers + +Barriers are code that gets executed by the mutator every time it mutates the +heap. They will enforce that the invariants are being kept. + +- read +- write + - deletion + +--- +#### Read Barrier + +Ensure the invariants by not allowing getting a _white_ object out of a _gray_ +one + + def read(object, field): + if is_grey(object): + shade(object) + return object[field] + +Not used, since _read_ operations are more than _write_ operations in a program +and having a slower _read_ is worse than having a slower _write_ + +--- +#### Write Barrier + +Ensure the invariants by not allowing to set a _white_ object as a reference +inside a _black_ object + + def write(object, field, value): + object[field] = value + if is_black(object): + shade(value) + + +--- ## Disclaimer > This is how GC can be implemented. Everything is subject to change. @@ -146,5 +223,6 @@ Where to store whether an object is *dead* or *alive* - `bit` per pointer + --- # ? |
