1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* gc.c (slot_sweep_body): rename to slot_sweep().

No need to separate major/minor GC.
* gc.c (gc_setup_mark_bits): remove gc_clear_mark_bits() and unify to
  this function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-06-21 19:42:04 +00:00
parent a27c48f69e
commit 671c196384
2 changed files with 21 additions and 53 deletions

View file

@ -1,3 +1,11 @@
Sat Jun 22 04:37:08 2013 Koichi Sasada <ko1@atdot.net>
* gc.c (slot_sweep_body): rename to slot_sweep().
No need to separate major/minor GC.
* gc.c (gc_setup_mark_bits): remove gc_clear_mark_bits() and unify to
this function.
Sat Jun 22 04:20:21 2013 Koichi Sasada <ko1@atdot.net> Sat Jun 22 04:20:21 2013 Koichi Sasada <ko1@atdot.net>
* gc.c (check_bitmap_consistency): add to check flag and bitmap consistency. * gc.c (check_bitmap_consistency): add to check flag and bitmap consistency.

66
gc.c
View file

@ -2157,19 +2157,17 @@ lazy_sweep_enable(void)
return Qnil; return Qnil;
} }
#if !USE_RGENGC
static void
gc_clear_slot_bits(struct heaps_slot *slot)
{
memset(&slot->mark_bits[0], 0, HEAP_BITMAP_SIZE);
}
#else
static void static void
gc_setup_mark_bits(struct heaps_slot *slot) gc_setup_mark_bits(struct heaps_slot *slot)
{ {
#if USE_RGENGC
/* copy oldgen bitmap to mark bitmap */
memcpy(&slot->mark_bits[0], &slot->oldgen_bits[0], HEAP_BITMAP_SIZE); memcpy(&slot->mark_bits[0], &slot->oldgen_bits[0], HEAP_BITMAP_SIZE);
} #else
/* clear mark bitmap */
memset(&slot->mark_bits[0], 0, HEAP_BITMAP_SIZE);
#endif #endif
}
static size_t static size_t
objspace_live_num(rb_objspace_t *objspace) objspace_live_num(rb_objspace_t *objspace)
@ -2178,7 +2176,7 @@ objspace_live_num(rb_objspace_t *objspace)
} }
static inline void static inline void
slot_sweep_body(rb_objspace_t *objspace, struct heaps_slot *sweep_slot, const int during_minor_gc) slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
{ {
int i; int i;
size_t empty_num = 0, freed_num = 0, final_num = 0; size_t empty_num = 0, freed_num = 0, final_num = 0;
@ -2187,7 +2185,7 @@ slot_sweep_body(rb_objspace_t *objspace, struct heaps_slot *sweep_slot, const in
int deferred; int deferred;
bits_t *bits, bitset; bits_t *bits, bitset;
rgengc_report(3, objspace, "slot_sweep_body: start.\n"); rgengc_report(1, objspace, "slot_sweep: start.\n");
p = sweep_slot->header->start; pend = p + sweep_slot->header->limit; p = sweep_slot->header->start; pend = p + sweep_slot->header->limit;
offset = p - NUM_IN_SLOT(p); offset = p - NUM_IN_SLOT(p);
@ -2204,10 +2202,10 @@ slot_sweep_body(rb_objspace_t *objspace, struct heaps_slot *sweep_slot, const in
do { do {
if ((bitset & 1) && BUILTIN_TYPE(p) != T_ZOMBIE) { if ((bitset & 1) && BUILTIN_TYPE(p) != T_ZOMBIE) {
if (p->as.basic.flags) { if (p->as.basic.flags) {
rgengc_report(3, objspace, "slot_sweep_body: free %p (%s)\n", p, obj_type_name((VALUE)p)); rgengc_report(3, objspace, "slot_sweep: free %p (%s)\n", p, obj_type_name((VALUE)p));
#if USE_RGENGC && RGENGC_CHECK_MODE #if USE_RGENGC && RGENGC_CHECK_MODE
if (objspace->rgengc.during_minor_gc && RVALUE_PROMOTED(p)) rb_bug("slot_sweep_body: %p (%s) is promoted.\n", p, obj_type_name((VALUE)p)); if (objspace->rgengc.during_minor_gc && RVALUE_PROMOTED(p)) rb_bug("slot_sweep: %p (%s) is promoted.\n", p, obj_type_name((VALUE)p));
if (rgengc_remembered(objspace, (VALUE)p)) rb_bug("slot_sweep_body: %p (%s) is remembered.\n", p, obj_type_name((VALUE)p)); if (rgengc_remembered(objspace, (VALUE)p)) rb_bug("slot_sweep: %p (%s) is remembered.\n", p, obj_type_name((VALUE)p));
#endif #endif
if ((deferred = obj_free(objspace, (VALUE)p)) || (FL_TEST(p, FL_FINALIZE))) { if ((deferred = obj_free(objspace, (VALUE)p)) || (FL_TEST(p, FL_FINALIZE))) {
if (!deferred) { if (!deferred) {
@ -2224,7 +2222,7 @@ slot_sweep_body(rb_objspace_t *objspace, struct heaps_slot *sweep_slot, const in
p->as.free.flags = 0; p->as.free.flags = 0;
p->as.free.next = sweep_slot->freelist; p->as.free.next = sweep_slot->freelist;
sweep_slot->freelist = p; sweep_slot->freelist = p;
rgengc_report(3, objspace, "slot_sweep_body: %p (%s) is added to freelist\n", p, obj_type_name((VALUE)p)); rgengc_report(3, objspace, "slot_sweep: %p (%s) is added to freelist\n", p, obj_type_name((VALUE)p));
freed_num++; freed_num++;
} }
} }
@ -2238,11 +2236,7 @@ slot_sweep_body(rb_objspace_t *objspace, struct heaps_slot *sweep_slot, const in
} }
} }
#if USE_RGENGC
gc_setup_mark_bits(sweep_slot); gc_setup_mark_bits(sweep_slot);
#else
gc_clear_slot_bits(sweep_slot);
#endif
#if GC_PROFILE_MORE_DETAIL #if GC_PROFILE_MORE_DETAIL
if (objspace->profile.run) { if (objspace->profile.run) {
@ -2252,7 +2246,6 @@ slot_sweep_body(rb_objspace_t *objspace, struct heaps_slot *sweep_slot, const in
} }
#endif #endif
if (final_num + freed_num + empty_num == sweep_slot->header->limit && if (final_num + freed_num + empty_num == sweep_slot->header->limit &&
objspace->heap.free_num > objspace->heap.do_heap_free) { objspace->heap.free_num > objspace->heap.do_heap_free) {
RVALUE *pp; RVALUE *pp;
@ -2283,40 +2276,7 @@ slot_sweep_body(rb_objspace_t *objspace, struct heaps_slot *sweep_slot, const in
} }
} }
rgengc_report(3, objspace, "slot_sweep_body: end.\n"); rgengc_report(1, objspace, "slot_sweep: end.\n");
}
#if USE_RGENGC
static void
slot_sweep_minor(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
{
slot_sweep_body(objspace, sweep_slot, TRUE);
}
static void
slot_sweep_major(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
{
slot_sweep_body(objspace, sweep_slot, FALSE);
}
#endif
static void
slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
{
rgengc_report(1, objspace, "slot_sweep: start\n");
{
#if USE_RGENGC
if (objspace->rgengc.during_minor_gc) {
slot_sweep_minor(objspace, sweep_slot);
}
else {
slot_sweep_major(objspace, sweep_slot);
}
#else
slot_sweep_body(objspace, sweep_slot, FALSE);
#endif
}
rgengc_report(1, objspace, "slot_sweep: end\n");
} }
static int static int