Skip sweeping old slots which don't contain any young object.

This commit is contained in:
Narihiro Nakamura
2013-01-07 11:54:23 +09:00
parent 4258d7735b
commit 542eda83ab
+10
View File
@@ -206,6 +206,7 @@ struct heap_page {
struct heap_page *next;
struct heap_page *free_next;
struct heap_page *free_prev;
unsigned int old:1;
RVALUE objects[MRB_HEAP_PAGE_SIZE];
};
@@ -762,6 +763,11 @@ incremental_sweep_phase(mrb_state *mrb, size_t limit)
int dead_slot = 1;
int full = (page->freelist == NULL);
if (is_minor_gc(mrb) && page->old) {
/* skip a slot which doesn't contain any young object */
p = e;
dead_slot = 0;
}
while (p<e) {
if (is_dead(mrb, &p->as.basic)) {
if (p->as.basic.tt != MRB_TT_FREE) {
@@ -792,6 +798,10 @@ incremental_sweep_phase(mrb_state *mrb, size_t limit)
if (full && freed > 0) {
link_free_heap_page(mrb, page);
}
if (page->freelist == NULL && is_minor_gc(mrb))
page->old = TRUE;
else
page->old = FALSE;
page = page->next;
}
tried_sweep += MRB_HEAP_PAGE_SIZE;