summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-05 07:14:53 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-05 07:14:53 +0000
commit72a77c25e5f9837539d7af523971f0a2ef35d66f (patch)
tree79ac6a1f28e7a26458d41f44198a06040cd29276
parenta4d7e42888b0c7f39d7a0aa94c80c4c44d48c32e (diff)
* gc.c (gc_page_sweep): refactoring.
* gc.c (gc_page_sweep): should not set, but add final_slots into sweep_page->final_slots. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--gc.c46
2 files changed, 34 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 4ef1d71605..ca26052bb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jun 5 16:08:39 2014 Koichi Sasada <ko1@atdot.net>
+
+ * gc.c (gc_page_sweep): refactoring.
+
+ * gc.c (gc_page_sweep): should not set, but add final_slots into
+ sweep_page->final_slots.
+
Thu Jun 5 14:36:24 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (jemalloc): check for the header regardless drop-in
diff --git a/gc.c b/gc.c
index 18984fd036..7e373a5d04 100644
--- a/gc.c
+++ b/gc.c
@@ -2810,25 +2810,33 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
if (bitset) {
p = offset + i * BITS_BITLENGTH;
do {
- if ((bitset & 1) && BUILTIN_TYPE(p) != T_ZOMBIE) {
- if (p->as.basic.flags) {
- rgengc_report(3, objspace, "page_sweep: free %p (%s)\n", p, obj_type_name((VALUE)p));
+ if (bitset & 1) {
+ switch (BUILTIN_TYPE(p)) {
+ default: { /* majority case */
+ rgengc_report(3, objspace, "page_sweep: free %p (%s)\n", p, obj_type_name((VALUE)p));
#if USE_RGENGC && RGENGC_CHECK_MODE
- if (objspace->rgengc.during_minor_gc && RVALUE_OLD_P((VALUE)p)) rb_bug("page_sweep: %p (%s) is old while minor GC.", p, obj_type_name((VALUE)p));
- if (rgengc_remembered(objspace, (VALUE)p)) rb_bug("page_sweep: %p (%s) is remembered.", p, obj_type_name((VALUE)p));
-#endif
- if (obj_free(objspace, (VALUE)p)) {
- final_slots++;
- }
- else {
- (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
- heap_page_add_freeobj(objspace, sweep_page, (VALUE)p);
- rgengc_report(3, objspace, "page_sweep: %p (%s) is added to freelist\n", p, obj_type_name((VALUE)p));
- freed_slots++;
- }
- }
- else {
- empty_slots++;
+ if (objspace->rgengc.during_minor_gc && RVALUE_OLD_P((VALUE)p)) rb_bug("page_sweep: %p (%s) is old while minor GC.", p, obj_type_name((VALUE)p));
+ if (rgengc_remembered(objspace, (VALUE)p)) rb_bug("page_sweep: %p (%s) is remembered.", p, obj_type_name((VALUE)p));
+#endif
+ if (obj_free(objspace, (VALUE)p)) {
+ final_slots++;
+ }
+ else {
+ (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
+ heap_page_add_freeobj(objspace, sweep_page, (VALUE)p);
+ rgengc_report(3, objspace, "page_sweep: %p (%s) is added to freelist\n", p, obj_type_name((VALUE)p));
+ freed_slots++;
+ }
+ break;
+ }
+
+ /* minor cases */
+ case T_ZOMBIE:
+ /* already counted */
+ break;
+ case T_NONE:
+ empty_slots++; /* already freed */
+ break;
}
}
p++;
@@ -2864,7 +2872,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
heap_pages_swept_slots += freed_slots + empty_slots;
objspace->profile.total_freed_object_num += freed_slots;
heap_pages_final_slots += final_slots;
- sweep_page->final_slots = final_slots;
+ sweep_page->final_slots += final_slots;
if (0) fprintf(stderr, "gc_page_sweep(%d): freed?: %d, limt: %d, freed_slots: %d, empty_slots: %d, final_slots: %d\n",
(int)rb_gc_count(),