From f46b5bcfaf2c7a905f2e625bd9c44b391b5b40ef Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 31 Mar 2016 06:51:27 +0000 Subject: [PATCH] * gc.c (gc_page_sweep): return free slots count. * gc.c (gc_sweep_step): use returned free slots count. * gc.c (gc_sweep_step): change variable name `next' to `next_sweep_page'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ gc.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index dab32c34d2..c092ea43d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Mar 31 15:48:18 2016 Koichi Sasada + + * gc.c (gc_page_sweep): return free slots count. + + * gc.c (gc_sweep_step): use returned free slots count. + + * gc.c (gc_sweep_step): change variable name `next' + to `next_sweep_page'. + Thu Mar 31 11:33:49 2016 Nobuyoshi Nakada * ext/date/date_core.c (d_lite_strftime, dt_lite_strftime): [DOC] diff --git a/gc.c b/gc.c index 6df91df532..d8f2adb831 100644 --- a/gc.c +++ b/gc.c @@ -3367,9 +3367,7 @@ gc_setup_mark_bits(struct heap_page *page) #endif } -/* TRUE : has empty slots */ -/* FALSE: no empty slots (or move to tomb heap because no live slots) */ -static inline void +static inline int gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_page) { int i; @@ -3458,6 +3456,8 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_ } gc_report(2, objspace, "page_sweep: end.\n"); + + return freed_slots + empty_slots; } /* allocate additional minimum page to work */ @@ -3577,7 +3577,7 @@ gc_sweep_finish(rb_objspace_t *objspace) static int gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap) { - struct heap_page *sweep_page = heap->sweep_pages, *next; + struct heap_page *sweep_page = heap->sweep_pages; int unlink_limit = 3; #if GC_ENABLE_INCREMENTAL_MARK int need_pool = will_be_incremental_marking(objspace) ? TRUE : FALSE; @@ -3594,17 +3594,17 @@ gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap) #endif while (sweep_page) { - heap->sweep_pages = next = sweep_page->next; - gc_page_sweep(objspace, heap, sweep_page); + struct heap_page *next_sweep_page = heap->sweep_pages = sweep_page->next; + int free_slots = gc_page_sweep(objspace, heap, sweep_page); - if (sweep_page->final_slots + sweep_page->free_slots == sweep_page->total_slots && + if (sweep_page->final_slots + free_slots == sweep_page->total_slots && unlink_limit > 0) { unlink_limit--; /* there are no living objects -> move this page to tomb heap */ heap_unlink_page(objspace, heap, sweep_page); heap_add_page(objspace, heap_tomb, sweep_page); } - else if (sweep_page->free_slots > 0) { + else if (free_slots > 0) { #if GC_ENABLE_INCREMENTAL_MARK if (need_pool) { if (heap_add_poolpage(objspace, heap, sweep_page)) { @@ -3624,7 +3624,7 @@ gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap) sweep_page->free_next = NULL; } - sweep_page = next; + sweep_page = next_sweep_page; } if (heap->sweep_pages == NULL) {