summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-07-23 21:34:06 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-07-23 21:34:06 +0900
commit1516822b0503f2ecbd2c408eebfb92d72241ff83 (patch)
tree4e7f78ce362e1da7f9193ca393dee2f94f095d35 /src
parent8d7e71615810b46d82c62bc96fd27aedbbd5ac88 (diff)
parent29a3f8b8e3826551daedbc4802a12ae2411a0351 (diff)
downloadmruby-1516822b0503f2ecbd2c408eebfb92d72241ff83.tar.gz
mruby-1516822b0503f2ecbd2c408eebfb92d72241ff83.zip
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'src')
-rw-r--r--src/gc.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/gc.c b/src/gc.c
index 37d61ad35..05577f9c7 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -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