* gc.c (id2ref): objects which are unmarked but not in sweep_slots

are not dead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-09-08 00:02:55 +00:00
parent 6572bd3ce9
commit ac6ad66d0b
2 changed files with 24 additions and 5 deletions

View File

@ -1,3 +1,8 @@
Thu Sep 8 09:02:53 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@ruby-lang.org>
* transcode.c (rb_declare_transcoder, load_transcoder_entry): no

24
gc.c
View File

@ -2140,10 +2140,10 @@ static void
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 @@ rb_gc(void)
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 @@ id2ref(VALUE obj, VALUE objid)
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;