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

ruby-changes:36690

From: ko1 <ko1@a...>
Date: Thu, 11 Dec 2014 19:15:49 +0900 (JST)
Subject: [ruby-changes:36690] ko1:r48771 (trunk): * class.c (class_alloc): Strat from age == 2.

ko1	2014-12-11 19:15:30 +0900 (Thu, 11 Dec 2014)

  New Revision: 48771

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

  Log:
    * class.c (class_alloc): Strat from age == 2.
      Class and Module objects can be living long life.
    * iseq.c: Same for ISeq objects.
    * gc.c (RVALUE_AGE_RESET): added.
    * gc.c (newobj_of): allow to generate (age != 0) objects.
    * gc.c (rb_copy_wb_protected_attribute): reset age for wb unprotected
      objects.
    * include/ruby/ruby.h: add RUBY_TYPED_PROMOTED1 as an unrecommended
      flag.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/gc.c
    trunk/include/ruby/ruby.h
    trunk/iseq.c
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 48770)
+++ include/ruby/ruby.h	(revision 48771)
@@ -1019,7 +1019,8 @@ void *rb_check_typeddata(VALUE, const rb https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1019
 
 /* bits for rb_data_type_struct::flags */
 #define RUBY_TYPED_FREE_IMMEDIATELY  1 /* TYPE field */
-#define RUBY_TYPED_WB_PROTECTED      FL_WB_PROTECTED
+#define RUBY_TYPED_WB_PROTECTED      FL_WB_PROTECTED /* THIS FLAG DEPENDS ON Ruby version */
+#define RUBY_TYPED_PROMOTED1         FL_PROMOTED1    /* THIS FLAG DEPENDS ON Ruby version */
 
 #define Data_Wrap_Struct(klass,mark,free,sval)\
     rb_data_object_alloc((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48770)
+++ ChangeLog	(revision 48771)
@@ -1,3 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Dec 11 19:06:01 2014  Koichi Sasada  <ko1@a...>
+
+	* class.c (class_alloc): Strat from age == 2.
+	  Class and Module objects can be living long life.
+
+	* iseq.c: Same for ISeq objects.
+
+	* gc.c (RVALUE_AGE_RESET): added.
+
+	* gc.c (newobj_of): allow to generate (age != 0) objects.
+
+	* gc.c (rb_copy_wb_protected_attribute): reset age for wb unprotected
+	  objects.
+
+	* include/ruby/ruby.h: add RUBY_TYPED_PROMOTED1 as an unrecommended
+	  flag.
+
 Thu Dec 11 05:37:52 2014  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* lib/prime.rb: Remove useless loop and block capture.
Index: iseq.c
===================================================================
--- iseq.c	(revision 48770)
+++ iseq.c	(revision 48771)
@@ -182,7 +182,7 @@ static const rb_data_type_t iseq_data_ty https://github.com/ruby/ruby/blob/trunk/iseq.c#L182
 	iseq_memsize,
     },              /* functions */
     0, 0,
-    RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
+    RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_PROMOTED1 /* start from age == 2 */ | RUBY_TYPED_WB_PROTECTED
 };
 
 static VALUE
Index: gc.c
===================================================================
--- gc.c	(revision 48770)
+++ gc.c	(revision 48771)
@@ -1152,13 +1152,17 @@ RVALUE_DEMOTE(rb_objspace_t *objspace, V https://github.com/ruby/ruby/blob/trunk/gc.c#L1152
 }
 
 static inline void
+RVALUE_AGE_RESET_RAW(VALUE obj)
+{
+    RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, 0);
+}
+
+static inline void
 RVALUE_AGE_RESET(VALUE obj)
 {
     check_rvalue_consistency(obj);
     if (RGENGC_CHECK_MODE) assert(!RVALUE_OLD_P(obj));
-
-    RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, 0);
-
+    RVALUE_AGE_RESET_RAW(obj);
     check_rvalue_consistency(obj);
 }
 
@@ -1653,7 +1657,13 @@ newobj_of(VALUE klass, VALUE flags, VALU https://github.com/ruby/ruby/blob/trunk/gc.c#L1657
     assert(RVALUE_MARKING(obj) == FALSE);
     assert(RVALUE_OLD_P(obj) == FALSE);
     assert(RVALUE_WB_UNPROTECTED(obj) == FALSE);
-    if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj));
+
+    if (flags & FL_PROMOTED1) {
+	if (RVALUE_AGE(obj) != 2) rb_bug("newobj: %s of age (%d) != 2.", obj_info(obj), RVALUE_AGE(obj));
+    }
+    else {
+	if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj));
+    }
     if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj));
 #endif
 
@@ -5556,7 +5566,10 @@ rb_copy_wb_protected_attribute(VALUE des https://github.com/ruby/ruby/blob/trunk/gc.c#L5566
 #if USE_RGENGC
     if (RVALUE_WB_UNPROTECTED(obj)) {
 	MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(dest), dest);
+	RVALUE_AGE_RESET_RAW(dest);
     }
+
+    check_rvalue_consistency(dest);
 #endif
 }
 
Index: class.c
===================================================================
--- class.c	(revision 48770)
+++ class.c	(revision 48771)
@@ -150,7 +150,7 @@ rb_class_detach_module_subclasses(VALUE https://github.com/ruby/ruby/blob/trunk/class.c#L150
 static VALUE
 class_alloc(VALUE flags, VALUE klass)
 {
-    NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0));
+    NEWOBJ_OF(obj, struct RClass, klass, (flags & T_MASK) | FL_PROMOTED1 /* start from age == 2 */ | (RGENGC_WB_PROTECTED_CLASS ? FL_WB_PROTECTED : 0));
     obj->ptr = ALLOC(rb_classext_t);
     RCLASS_IV_TBL(obj) = 0;
     RCLASS_CONST_TBL(obj) = 0;

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

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