From 2cf2416ea09ca63efb8469650809bd5fd1707460 Mon Sep 17 00:00:00 2001 From: nari Date: Mon, 9 Jan 2012 06:02:01 +0000 Subject: [PATCH] * gc.c: free_slots is changed Singly linked list. clear free_slots before sweep. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ gc.c | 22 +++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9812e25232..bae66616bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jan 9 14:42:41 2012 Narihiro Nakamura + + * gc.c: free_slots is changed Singly linked list. clear + free_slots before sweep. + Mon Jan 9 07:46:17 2012 NARUSE, Yui * gc.c: i686-linux needs to define _XOPEN_SOURCE 600 for posix_memalign. diff --git a/gc.c b/gc.c index af4f4cc5f7..aa9976f715 100644 --- a/gc.c +++ b/gc.c @@ -320,7 +320,6 @@ struct heaps_slot { struct heaps_slot *next; struct heaps_slot *prev; struct heaps_slot *free_next; - struct heaps_slot *free_prev; }; struct sorted_heaps_slot { @@ -1097,22 +1096,13 @@ static void link_free_heap_slot(rb_objspace_t *objspace, struct heaps_slot *slot) { slot->free_next = objspace->heap.free_slots; - if (objspace->heap.free_slots) { - objspace->heap.free_slots->free_prev = slot; - } objspace->heap.free_slots = slot; } static void unlink_free_heap_slot(rb_objspace_t *objspace, struct heaps_slot *slot) { - if (slot->free_prev) - slot->free_prev->free_next = slot->free_next; - if (slot->free_next) - slot->free_next->free_prev = slot->free_prev; - if (objspace->heap.free_slots == slot) - objspace->heap.free_slots = slot->free_next; - slot->free_prev = NULL; + objspace->heap.free_slots = slot->free_next; slot->free_next = NULL; } @@ -2209,13 +2199,14 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot) } sweep_slot->limit = final_num; unlink_heap_slot(objspace, sweep_slot); - unlink_free_heap_slot(objspace, sweep_slot); } else { - if (free_num > 0 && sweep_slot->free_next == NULL && - sweep_slot->free_prev == NULL) { + if (free_num > 0) { link_free_heap_slot(objspace, sweep_slot); } + else if (sweep_slot->free_next != NULL) { + sweep_slot->free_next = NULL; + } objspace->heap.free_num += free_num; } objspace->heap.final_num += final_num; @@ -2254,6 +2245,7 @@ before_gc_sweep(rb_objspace_t *objspace) } objspace->heap.sweep_slots = heaps; objspace->heap.free_num = 0; + objspace->heap.free_slots = NULL; /* sweep unlinked method entries */ if (GET_VM()->unlinked_method_entry_list) { @@ -2395,7 +2387,7 @@ rb_gc_force_recycle(VALUE p) else { GC_PROF_DEC_LIVE_NUM; slot = add_slot_local_freelist(objspace, (RVALUE *)p); - if (slot->free_next == NULL && slot->free_prev == NULL) { + if (slot->free_next == NULL) { link_free_heap_slot(objspace, slot); } }