diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-07-23 21:34:06 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-07-23 21:34:06 +0900 |
| commit | 1516822b0503f2ecbd2c408eebfb92d72241ff83 (patch) | |
| tree | 4e7f78ce362e1da7f9193ca393dee2f94f095d35 /src/gc.c | |
| parent | 8d7e71615810b46d82c62bc96fd27aedbbd5ac88 (diff) | |
| parent | 29a3f8b8e3826551daedbc4802a12ae2411a0351 (diff) | |
| download | mruby-1516822b0503f2ecbd2c408eebfb92d72241ff83.tar.gz mruby-1516822b0503f2ecbd2c408eebfb92d72241ff83.zip | |
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'src/gc.c')
| -rw-r--r-- | src/gc.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -38,18 +38,23 @@ * Gray - Marked, But the child objects are unmarked. * Black - Marked, the child objects are also marked. - == Two white part - - The white has a different part of A and B. - In sweep phase, the sweep target white is either A or B. - The sweep target white is switched just before sweep phase. - e.g. A -> B -> A -> B ... - - All objects are painted white when allocated. - This white is another the sweep target white. - For example, if the sweep target white is A, it's B. - So objects when allocated in sweep phase will be next sweep phase target. - Therefore, these objects will not be released accidentally in sweep phase. + == Two White Types + + There're two white color types in a flip-flop fassion: White-A and White-B, + which respectively represent the Current White color (the newly allocated + objects in the current round of GC) and the Sweep Target White color (the + dead objects to be swept). + + A and B will be switched just at the beginning of the next round of GC. At + that time, all the dead objects have been swept, while the newly created + objects in the current round of GC which finally remains White are now + regarded as dead objects. Instead of traversing all the White-A objects and + paint them as White-B, just switch the meaning of White-A and White-B would + be much cheaper. + + As a result, the objects we sweep in the current round of GC are always + left from the previous round of GC. This allows us to sweep objects + incrementally, without the disturbance of the newly created objects. == Execution Timing |
