* 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:
parent
6572bd3ce9
commit
ac6ad66d0b
@ -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>
|
Thu Sep 8 07:44:25 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* transcode.c (rb_declare_transcoder, load_transcoder_entry): no
|
* transcode.c (rb_declare_transcoder, load_transcoder_entry): no
|
||||||
|
24
gc.c
24
gc.c
@ -2140,10 +2140,10 @@ static void
|
|||||||
rest_sweep(rb_objspace_t *objspace)
|
rest_sweep(rb_objspace_t *objspace)
|
||||||
{
|
{
|
||||||
if (objspace->heap.sweep_slots) {
|
if (objspace->heap.sweep_slots) {
|
||||||
while (objspace->heap.sweep_slots) {
|
while (objspace->heap.sweep_slots) {
|
||||||
lazy_sweep(objspace);
|
lazy_sweep(objspace);
|
||||||
}
|
}
|
||||||
after_gc_sweep(objspace);
|
after_gc_sweep(objspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3086,6 +3086,20 @@ rb_gc(void)
|
|||||||
free_unused_heaps(objspace);
|
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:
|
* call-seq:
|
||||||
* ObjectSpace._id2ref(object_id) -> an_object
|
* 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);
|
rb_raise(rb_eRangeError, "%p is not id value", p0);
|
||||||
}
|
}
|
||||||
if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0 ||
|
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);
|
rb_raise(rb_eRangeError, "%p is recycled object", p0);
|
||||||
}
|
}
|
||||||
return (VALUE)ptr;
|
return (VALUE)ptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user