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

ruby-changes:29528

From: ko1 <ko1@a...>
Date: Sun, 23 Jun 2013 05:48:48 +0900 (JST)
Subject: [ruby-changes:29528] ko1:r41580 (trunk): * class.c (rb_include_class_new), eval.c (rb_using_refinement):

ko1	2013-06-23 05:48:35 +0900 (Sun, 23 Jun 2013)

  New Revision: 41580

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

  Log:
    * class.c (rb_include_class_new), eval.c (rb_using_refinement):
      make classes/modules (who share method table) shady.
      If module `a' and `b' shares method table m_tbl and new method
      with iseq is added, then write barrier is applied only `a' or `b'.
      To avoid this issue, shade such classes/modules.
    * vm_method.c (rb_method_entry_make): add write barriers.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/eval.c
    trunk/vm_method.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41579)
+++ ChangeLog	(revision 41580)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jun 23 05:41:32 2013  Koichi Sasada  <ko1@a...>
+
+	* class.c (rb_include_class_new), eval.c (rb_using_refinement): 
+	  make classes/modules (who share method table) shady.
+	  If module `a' and `b' shares method table m_tbl and new method
+	  with iseq is added, then write barrier is applied only `a' or `b'.
+	  To avoid this issue, shade such classes/modules.
+
+	* vm_method.c (rb_method_entry_make): add write barriers.
+
 Sun Jun 23 01:27:54 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (bytes_zero_p): Removed.
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 41579)
+++ vm_method.c	(revision 41580)
@@ -317,7 +317,24 @@ rb_method_entry_make(VALUE klass, ID mid https://github.com/ruby/ruby/blob/trunk/vm_method.c#L317
     me->called_id = mid;
     me->klass = klass;
     me->def = def;
-    if (def) def->alias_count++;
+
+    if (def) {
+	def->alias_count++;
+
+	switch(def->type) {
+	  case VM_METHOD_TYPE_ISEQ:
+	    OBJ_WRITTEN(klass, Qundef, def->body.iseq);
+	    break;
+	  case VM_METHOD_TYPE_IVAR:
+	    OBJ_WRITTEN(klass, Qundef, def->body.attr.location);
+	    break;
+	  case VM_METHOD_TYPE_BMETHOD:
+	    OBJ_WRITTEN(klass, Qundef, def->body.proc);
+	    break;
+	  default:;
+	    /* ignore */
+	}
+    }
 
     /* check mid */
     if (klass == rb_cObject && mid == idInitialize) {
Index: eval.c
===================================================================
--- eval.c	(revision 41579)
+++ eval.c	(revision 41580)
@@ -1099,7 +1099,9 @@ rb_using_refinement(NODE *cref, VALUE kl https://github.com/ruby/ruby/blob/trunk/eval.c#L1099
     FL_SET(module, RMODULE_IS_OVERLAID);
     c = iclass = rb_include_class_new(module, superclass);
     RCLASS_REFINED_CLASS(c) = klass;
-    RCLASS_M_TBL(c) = RCLASS_M_TBL(module);
+
+    RCLASS_M_TBL(OBJ_WB_GIVEUP(c)) = RCLASS_M_TBL(OBJ_WB_GIVEUP(module));
+
     module = RCLASS_SUPER(module);
     while (module && module != klass) {
 	FL_SET(module, RMODULE_IS_OVERLAID);
Index: class.c
===================================================================
--- class.c	(revision 41579)
+++ class.c	(revision 41580)
@@ -689,7 +689,9 @@ rb_include_class_new(VALUE module, VALUE https://github.com/ruby/ruby/blob/trunk/class.c#L689
     }
     RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
     RCLASS_CONST_TBL(klass) = RCLASS_CONST_TBL(module);
-    RCLASS_M_TBL(klass) = RCLASS_M_TBL(RCLASS_ORIGIN(module));
+
+    RCLASS_M_TBL(OBJ_WB_GIVEUP(klass)) = RCLASS_M_TBL(OBJ_WB_GIVEUP(RCLASS_ORIGIN(module)));
+
     RCLASS_SET_SUPER(klass, super);
     if (RB_TYPE_P(module, T_ICLASS)) {
 	RBASIC_SET_CLASS(klass, RBASIC(module)->klass);

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

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