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

ruby-changes:29320

From: ko1 <ko1@a...>
Date: Tue, 18 Jun 2013 11:18:10 +0900 (JST)
Subject: [ruby-changes:29320] ko1:r41372 (trunk): * gc.c (gc_mark_maybe): check to skip T_NONE.

ko1	2013-06-18 11:17:59 +0900 (Tue, 18 Jun 2013)

  New Revision: 41372

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

  Log:
    * gc.c (gc_mark_maybe): check to skip T_NONE.
    * gc.c (markable_object_p): do not need to check (flags == 0) here.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41371)
+++ ChangeLog	(revision 41372)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jun 18 11:02:18 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_mark_maybe): check to skip T_NONE.
+
+	* gc.c (markable_object_p): do not need to check (flags == 0) here.
+
 Tue Jun 18 10:17:37 2013  Koichi Sasada  <ko1@a...>
 
 	* variable.c (rb_autoload): fix WB miss.
Index: gc.c
===================================================================
--- gc.c	(revision 41371)
+++ gc.c	(revision 41372)
@@ -2916,9 +2916,11 @@ static void https://github.com/ruby/ruby/blob/trunk/gc.c#L2916
 gc_mark_maybe(rb_objspace_t *objspace, VALUE obj)
 {
     (void)VALGRIND_MAKE_MEM_DEFINED(&obj, sizeof(obj));
-    if (is_pointer_to_heap(objspace, (void *)obj) &&
-	BUILTIN_TYPE(obj) != T_ZOMBIE) {
-	gc_mark(objspace, obj);
+    if (is_pointer_to_heap(objspace, (void *)obj)) {
+	int type = BUILTIN_TYPE(obj);
+	if (type != T_ZOMBIE && type != T_NONE) {
+	    gc_mark(objspace, obj);
+	}
     }
 }
 
@@ -2948,17 +2950,21 @@ gc_mark_ptr(rb_objspace_t *objspace, VAL https://github.com/ruby/ruby/blob/trunk/gc.c#L2950
 static int
 markable_object_p(rb_objspace_t *objspace, VALUE obj)
 {
-    if (rb_special_const_p(obj)) return 0; /* special const not marked */
-    if (RBASIC(obj)->flags == 0) return 0; /* free cell */
-    if (RGENGC_CHECK_MODE && BUILTIN_TYPE(obj) == T_ZOMBIE)
-      rb_bug("markable_object_p: %p is T_ZOMBIE", (void *)obj);
+    if (rb_special_const_p(obj)) return 0; /* special const is not markable */
+
+    if (RGENGC_CHECK_MODE) {
+	if (!is_pointer_to_heap(objspace, (void *)obj)) rb_bug("markable_object_p: %p is not pointer to heap", (void *)obj);
+	if (BUILTIN_TYPE(obj) == T_NONE)   rb_bug("markable_object_p: %p is T_NONE", (void *)obj);
+	if (BUILTIN_TYPE(obj) == T_ZOMBIE) rb_bug("markable_object_p: %p is T_ZOMBIE", (void *)obj);
+    }
+
     return 1;
 }
 
 int
 rb_objspace_markable_object_p(VALUE obj)
 {
-    return markable_object_p(/* now it doesn't use &rb_objspace */ 0, obj);
+    return markable_object_p(&rb_objspace, obj);
 }
 
 static const char *

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

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