summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 08:57:21 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 08:57:21 +0000
commite322989bb3ebae6b85327963f91ff112fc37fada (patch)
tree4de1aac8df4352d74851e03e12cdc44b4bed2031 /gc.c
parent4103e718f8209dff7da1e8aa6c140820c18412ef (diff)
merge revision(s) 34719,34720: [Backport #6059]
* gc.c : remove gc_clear_mark_on_sweep_slots() and use rest_sweep() instead of it, because some dead objects might be marked in next the mark phase by false pointers. [ruby-core:42672] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/gc.c b/gc.c
index c53bfd9842..e65d0ec6e6 100644
--- a/gc.c
+++ b/gc.c
@@ -464,13 +464,12 @@ rb_gc_set_params(void)
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
static void gc_sweep(rb_objspace_t *);
static void slot_sweep(rb_objspace_t *, struct heaps_slot *);
-static void gc_clear_mark_on_sweep_slots(rb_objspace_t *);
+static void rest_sweep(rb_objspace_t *);
void
rb_objspace_free(rb_objspace_t *objspace)
{
- gc_clear_mark_on_sweep_slots(objspace);
- gc_sweep(objspace);
+ rest_sweep(objspace);
if (objspace->profile.record) {
free(objspace->profile.record);
objspace->profile.record = 0;
@@ -2430,28 +2429,6 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th)
}
static void
-gc_clear_mark_on_sweep_slots(rb_objspace_t *objspace)
-{
- struct heaps_slot *scan;
- RVALUE *p, *pend;
-
- if (objspace->heap.sweep_slots) {
- while (heaps_increment(objspace));
- while (objspace->heap.sweep_slots) {
- scan = objspace->heap.sweep_slots;
- p = scan->slot; pend = p + scan->limit;
- while (p < pend) {
- if (p->as.free.flags & FL_MARK && BUILTIN_TYPE(p) != T_ZOMBIE) {
- p->as.basic.flags &= ~FL_MARK;
- }
- p++;
- }
- objspace->heap.sweep_slots = objspace->heap.sweep_slots->next;
- }
- }
-}
-
-static void
gc_marks(rb_objspace_t *objspace)
{
struct gc_list *list;
@@ -2462,8 +2439,6 @@ gc_marks(rb_objspace_t *objspace)
objspace->count++;
- gc_clear_mark_on_sweep_slots(objspace);
-
SET_STACK_END;
init_mark_stack(objspace);
@@ -2520,6 +2495,8 @@ garbage_collect(rb_objspace_t *objspace)
GC_PROF_TIMER_START;
+ rest_sweep(objspace);
+
during_gc++;
gc_marks(objspace);
@@ -3025,7 +3002,7 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
size_t i;
/* run finalizers */
- gc_clear_mark_on_sweep_slots(objspace);
+ rest_sweep(objspace);
do {
/* XXX: this loop will make no sense */