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

ruby-changes:37930

From: ko1 <ko1@a...>
Date: Thu, 19 Mar 2015 03:46:36 +0900 (JST)
Subject: [ruby-changes:37930] ko1:r50011 (trunk): * gc.c (check_rvalue_consistency): refactoring.

ko1	2015-03-19 03:46:10 +0900 (Thu, 19 Mar 2015)

  New Revision: 50011

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

  Log:
    * gc.c (check_rvalue_consistency): refactoring.
      * not inline on RGENGC_CHECK_MODE > 0.
      * check SPECIAL_CONST_P(obj) first.
      * add a check that remembered_bit is only TRUE when old (age == 3).
    * gc.c (RVALUE_DEMOTE): should clear RVALUE_REMEMBERED bit.
      remembered_bit should be TRUE only for old (age == 3) objects.
      Actually there are no effect because demoted objects will be
      uncollectible WB unprotected objects (marked at the begginig of
      every minor GC).

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50010)
+++ ChangeLog	(revision 50011)
@@ -1,3 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar 19 03:37:52 2015  Koichi Sasada  <ko1@a...>
+
+	* gc.c (check_rvalue_consistency): refactoring.
+	  * not inline on RGENGC_CHECK_MODE > 0.
+	  * check SPECIAL_CONST_P(obj) first.
+	  * add a check that remembered_bit is only TRUE when old (age == 3).
+
+	* gc.c (RVALUE_DEMOTE): should clear RVALUE_REMEMBERED bit.
+
+	  remembered_bit should be TRUE only for old (age == 3) objects.
+
+	  Actually there are no effect because demoted objects will be
+	  uncollectible WB unprotected objects (marked at the begginig of
+	  every minor GC).
+
 Thu Mar 19 02:52:48 2015  Koichi Sasada  <ko1@a...>
 
 	* gc.c: rename terminologies.
Index: gc.c
===================================================================
--- gc.c	(revision 50010)
+++ gc.c	(revision 50011)
@@ -961,22 +961,31 @@ RVALUE_FLAGS_AGE(VALUE flags) https://github.com/ruby/ruby/blob/trunk/gc.c#L961
 
 #endif /* USE_RGENGC */
 
+
+#if RGENGC_CHECK_MODE == 0
 static inline VALUE
 check_rvalue_consistency(const VALUE obj)
 {
-#if RGENGC_CHECK_MODE > 0
+    return obj;
+}
+#else
+static VALUE
+check_rvalue_consistency(const VALUE obj)
+{
     rb_objspace_t *objspace = &rb_objspace;
 
-    if (!is_pointer_to_heap(objspace, (void *)obj)) {
-	rb_bug("check_rvalue_consistency: %p is not a Ruby object.", (void *)obj);
-    }
-    else if (SPECIAL_CONST_P(obj)) {
+    if (SPECIAL_CONST_P(obj)) {
 	rb_bug("check_rvalue_consistency: %p is a special const.", (void *)obj);
     }
+    else if (!is_pointer_to_heap(objspace, (void *)obj)) {
+	rb_bug("check_rvalue_consistency: %p is not a Ruby object.", (void *)obj);
+    }
     else {
-	int wb_unprotected_bit = RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
-	int uncollectible_bit = RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
-	int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
+	const int wb_unprotected_bit = RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
+	const int uncollectible_bit = RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
+	const int mark_bit = RVALUE_MARK_BITMAP(obj) != 0;
+	const int marking_bit = RVALUE_MARKING_BITMAP(obj) != 0, remembered_bit = marking_bit;
+	const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
 
 	if (BUILTIN_TYPE(obj) == T_NONE)   rb_bug("check_rvalue_consistency: %p is T_NONE", obj_info(obj));
 	if (BUILTIN_TYPE(obj) == T_ZOMBIE) rb_bug("check_rvalue_consistency: %p is T_ZOMBIE", obj_info(obj));
@@ -989,13 +998,20 @@ check_rvalue_consistency(const VALUE obj https://github.com/ruby/ruby/blob/trunk/gc.c#L998
 	if (age > 0 && wb_unprotected_bit) {
 	    rb_bug("check_rvalue_consistency: %s is not WB protected, but age is %d > 0.", obj_info(obj), age);
 	}
-	if (!is_full_marking(objspace) && uncollectible_bit && age != RVALUE_OLD_AGE && !wb_unprotected_bit) {
-	    rb_bug("check_rvalue_consistency: %s is uncollectible, but not old (age: %d) and not WB unprotected.\n", obj_info(obj), age);
-	}
-	if (!is_marking(objspace) && uncollectible_bit && RVALUE_MARK_BITMAP(obj) == 0) {
+
+	if (!is_marking(objspace) && uncollectible_bit && !mark_bit) {
 	    rb_bug("check_rvalue_consistency: %s is uncollectible, but is not marked while !gc.", obj_info(obj));
 	}
 
+	if (!is_full_marking(objspace)) {
+	    if (uncollectible_bit && age != RVALUE_OLD_AGE && !wb_unprotected_bit) {
+		rb_bug("check_rvalue_consistency: %s is uncollectible, but not old (age: %d) and not WB unprotected.", obj_info(obj), age);
+	    }
+	    if (remembered_bit && age != RVALUE_OLD_AGE) {
+		rb_bug("check_rvalue_consistency: %s is rememberd, but not old (age: %d).", obj_info(obj), age);
+	    }
+	}
+
 	/*
 	 * check coloring
 	 *
@@ -1003,13 +1019,13 @@ check_rvalue_consistency(const VALUE obj https://github.com/ruby/ruby/blob/trunk/gc.c#L1019
 	 * marked:false  white         *invalid*
 	 * marked:true   black         grey
 	 */
-	if (RVALUE_MARKING_BITMAP(obj)) {
-	    if (!is_marking(objspace) && !RVALUE_MARK_BITMAP(obj)) rb_bug("check_rvalue_consistency: %s is marking, but not marked.", obj_info(obj));
+	if (is_incremental_marking(objspace) && marking_bit) {
+	    if (!is_marking(objspace) && !mark_bit) rb_bug("check_rvalue_consistency: %s is marking, but not marked.", obj_info(obj));
 	}
     }
-#endif
     return obj;
 }
+#endif
 
 static inline int
 RVALUE_MARKED(VALUE obj)
@@ -1154,6 +1170,10 @@ RVALUE_DEMOTE(rb_objspace_t *objspace, V https://github.com/ruby/ruby/blob/trunk/gc.c#L1170
     check_rvalue_consistency(obj);
     if (RGENGC_CHECK_MODE) assert(RVALUE_OLD_P(obj));
 
+    if (!is_incremental_marking(objspace) && RVALUE_REMEMBERED(obj)) {
+	CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj);
+    }
+
     RVALUE_DEMOTE_RAW(objspace, obj);
 
     if (RVALUE_MARKED(obj)) {

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

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