ruby-changes:21173
From: nobu <ko1@a...>
Date: Thu, 8 Sep 2011 09:03:07 +0900 (JST)
Subject: [ruby-changes:21173] nobu:r33222 (trunk): * gc.c (id2ref): objects which are unmarked but not in sweep_slots
nobu 2011-09-08 09:02:55 +0900 (Thu, 08 Sep 2011) New Revision: 33222 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33222 Log: * gc.c (id2ref): objects which are unmarked but not in sweep_slots are not dead. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33221) +++ ChangeLog (revision 33222) @@ -1,3 +1,8 @@ +Thu Sep 8 09:02:53 2011 Nobuyoshi Nakada <nobu@r...> + + * gc.c (id2ref): objects which are unmarked but not in sweep_slots + are not dead. + Thu Sep 8 07:44:25 2011 Nobuyoshi Nakada <nobu@r...> * transcode.c (rb_declare_transcoder, load_transcoder_entry): no Index: gc.c =================================================================== --- gc.c (revision 33221) +++ gc.c (revision 33222) @@ -2140,10 +2140,10 @@ rest_sweep(rb_objspace_t *objspace) { if (objspace->heap.sweep_slots) { - while (objspace->heap.sweep_slots) { - lazy_sweep(objspace); - } - after_gc_sweep(objspace); + while (objspace->heap.sweep_slots) { + lazy_sweep(objspace); + } + after_gc_sweep(objspace); } } @@ -3086,6 +3086,20 @@ free_unused_heaps(objspace); } +static inline int +is_dead_object(rb_objspace_t *objspace, VALUE ptr) +{ + struct heaps_slot *slot = objspace->heap.sweep_slots; + if (!is_lazy_sweeping(objspace) || (RBASIC(ptr)->flags & FL_MARK)) + return FALSE; + while (slot) { + if ((VALUE)slot->slot <= ptr && ptr < (VALUE)(slot->slot + slot->limit)) + return TRUE; + slot = slot->next; + } + return FALSE; +} + /* * call-seq: * ObjectSpace._id2ref(object_id) -> an_object @@ -3133,7 +3147,7 @@ rb_raise(rb_eRangeError, "%p is not id value", p0); } if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0 || - (is_lazy_sweeping(objspace) && !(RBASIC(ptr)->flags & FL_MARK))) { + is_dead_object(objspace, ptr)) { rb_raise(rb_eRangeError, "%p is recycled object", p0); } return (VALUE)ptr; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/