[前][次][番号順一覧][スレッド一覧]

ruby-changes:29381

From: ko1 <ko1@a...>
Date: Wed, 19 Jun 2013 23:34:21 +0900 (JST)
Subject: [ruby-changes:29381] ko1:r41433 (trunk): * gc.c (RVALUE_PROMOTED): check consistency between oldgen flag and

ko1	2013-06-19 23:34:11 +0900 (Wed, 19 Jun 2013)

  New Revision: 41433

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41433

  Log:
    * gc.c (RVALUE_PROMOTED): check consistency between oldgen flag and
      oldgen bitmap if RGENGC_CHECK_MODE > 0.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41432)
+++ ChangeLog	(revision 41433)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jun 19 23:32:23 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (RVALUE_PROMOTED): check consistency between oldgen flag and
+	  oldgen bitmap if RGENGC_CHECK_MODE > 0.
+
 Wed Jun 19 23:29:29 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c (rb_gc_force_recycle): clear oldgen bitmap, too.
Index: gc.c
===================================================================
--- gc.c	(revision 41432)
+++ gc.c	(revision 41433)
@@ -518,9 +518,22 @@ static size_t rgengc_rememberset_mark(rb https://github.com/ruby/ruby/blob/trunk/gc.c#L518
 #define FL_UNSET2(x,f)        do {if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) rb_bug("FL_UNSET2: SPECIAL_CONST"); RBASIC(x)->flags &= ~(f);} while (0)
 
 #define RVALUE_SHADY(x)       (!FL_TEST2((x), FL_WB_PROTECTED))
-#define RVALUE_PROMOTED(x)    FL_TEST2((x), FL_OLDGEN)
 #define RVALUE_PROMOTED_FROM_BITMAP(x) MARKED_IN_BITMAP(GET_HEAP_OLDGEN_BITS(x),x)
 
+static inline int
+RVALUE_PROMOTED(VALUE obj)
+{
+    int result = FL_TEST2((obj), FL_OLDGEN);
+
+    if (RGENGC_CHECK_MODE > 0) {
+	int bitmap_result = RVALUE_PROMOTED_FROM_BITMAP(obj);
+	if (!result != !bitmap_result) rb_bug("RVALUE_PROMOTED: %p (%s) flag %d but bitmap is %d\n",
+					      (void *)obj, obj_type_name(obj), !!result, !!bitmap_result);
+    }
+
+    return result;
+}
+
 static inline void
 RVALUE_PROMOTE(VALUE obj)
 {
@@ -2206,7 +2219,7 @@ slot_sweep_body(rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L2219
 #endif
 			rgengc_report(3, objspace, "slot_sweep_body: free %p (%s)\n", p, obj_type_name((VALUE)p));
 #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((VALUE)p)) rb_bug("slot_sweep_body: %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));
 #endif
 			if ((deferred = obj_free(objspace, (VALUE)p)) || (FL_TEST(p, FL_FINALIZE))) {
@@ -3104,7 +3117,7 @@ gc_mark_children(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L3117
     }
 
 #if USE_RGENGC
-    if (RGENGC_CHECK_MODE && RVALUE_SHADY(obj) && RVALUE_PROMOTED(obj)) {
+    if (RGENGC_CHECK_MODE && RVALUE_SHADY(obj) && RVALUE_PROMOTED((VALUE)obj)) {
 	rb_bug("gc_mark_children: (0) %p (%s) is shady and promoted.\n", (void *)obj, obj_type_name((VALUE)obj));
     }
 #endif /* USE_RGENGC */
@@ -3113,7 +3126,7 @@ gc_mark_children(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L3126
 
 #if USE_RGENGC
     if (LIKELY(objspace->mark_func_data == 0)) {
-	if (RGENGC_CHECK_MODE && RVALUE_SHADY(obj) && RVALUE_PROMOTED(obj)) {
+	if (RGENGC_CHECK_MODE && RVALUE_SHADY(obj) && RVALUE_PROMOTED((VALUE)obj)) {
 	    rb_bug("gc_mark_children: (1) %p (%s) is shady and promoted.\n", (void *)obj, obj_type_name((VALUE)obj));
 	}
 
@@ -3131,7 +3144,7 @@ gc_mark_children(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L3144
 	    objspace->rgengc.parent_object_is_promoted = FALSE;
 	}
 
-	if (RGENGC_CHECK_MODE && RVALUE_SHADY(obj) && RVALUE_PROMOTED(obj)) {
+	if (RGENGC_CHECK_MODE && RVALUE_SHADY(obj) && RVALUE_PROMOTED((VALUE)obj)) {
 	    rb_bug("gc_mark_children: (2) %p (%s) is shady and promoted.\n", (void *)obj, obj_type_name((VALUE)obj));
 	}
     }
@@ -3535,7 +3548,7 @@ gc_marks_test(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L3548
 	while (p < pend) {
 	    if (MARKED_IN_BITMAP(major_mark_bits, p) && /* should be lived */
 		!MARKED_IN_BITMAP(minor_mark_bits, p) &&
-		!RVALUE_PROMOTED(p)) {
+		!RVALUE_PROMOTED((VALUE)p)) {
 
 		fprintf(stderr, "gc_marks_test: %p (%s) is living, but not marked && not promoted.\n", p, obj_type_name((VALUE)p));
 		objspace->rgengc.interesting_object = (VALUE)p;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]