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

ruby-changes:35651

From: nobu <ko1@a...>
Date: Mon, 29 Sep 2014 09:49:36 +0900 (JST)
Subject: [ruby-changes:35651] nobu:r47733 (trunk): date_core.c: write-barrier

nobu	2014-09-29 09:49:18 +0900 (Mon, 29 Sep 2014)

  New Revision: 47733

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

  Log:
    date_core.c: write-barrier
    
    * ext/date/date_core.c (d_lite_type): add write-barrier.

  Modified files:
    trunk/ext/date/date_core.c
Index: ext/date/date_core.c
===================================================================
--- ext/date/date_core.c	(revision 47732)
+++ ext/date/date_core.c	(revision 47733)
@@ -313,9 +313,9 @@ canon(VALUE x) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L313
 }
 
 #ifndef USE_PACK
-#define set_to_simple(x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
+#define set_to_simple(obj, x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
 {\
-    (x)->nth = canon(_nth);\
+    RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
     (x)->jd = _jd;\
     (x)->sg = (date_sg_t)(_sg);\
     (x)->year = _year;\
@@ -324,9 +324,9 @@ canon(VALUE x) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L324
     (x)->flags = _flags;\
 }
 #else
-#define set_to_simple(x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
+#define set_to_simple(obj, x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
 {\
-    (x)->nth = canon(_nth);\
+    RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
     (x)->jd = _jd;\
     (x)->sg = (date_sg_t)(_sg);\
     (x)->year = _year;\
@@ -336,13 +336,13 @@ canon(VALUE x) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L336
 #endif
 
 #ifndef USE_PACK
-#define set_to_complex(x, _nth, _jd ,_df, _sf, _of, _sg,\
+#define set_to_complex(obj, x, _nth, _jd ,_df, _sf, _of, _sg,\
 _year, _mon, _mday, _hour, _min, _sec, _flags) \
 {\
-    (x)->nth = canon(_nth);\
+    RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
     (x)->jd = _jd;\
     (x)->df = _df;\
-    (x)->sf = canon(_sf);\
+    RB_OBJ_WRITE((obj), &(x)->sf, canon(_sf));\
     (x)->of = _of;\
     (x)->sg = (date_sg_t)(_sg);\
     (x)->year = _year;\
@@ -354,13 +354,13 @@ _year, _mon, _mday, _hour, _min, _sec, _ https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L354
     (x)->flags = _flags;\
 }
 #else
-#define set_to_complex(x, _nth, _jd ,_df, _sf, _of, _sg,\
+#define set_to_complex(obj, x, _nth, _jd ,_df, _sf, _of, _sg,\
 _year, _mon, _mday, _hour, _min, _sec, _flags) \
 {\
-    (x)->nth = canon(_nth);\
+    RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
     (x)->jd = _jd;\
     (x)->df = _df;\
-    (x)->sf = canon(_sf);\
+    RB_OBJ_WRITE((obj), &(x)->sf, canon(_sf));\
     (x)->of = _of;\
     (x)->sg = (date_sg_t)(_sg);\
     (x)->year = _year;\
@@ -370,9 +370,9 @@ _year, _mon, _mday, _hour, _min, _sec, _ https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L370
 #endif
 
 #ifndef USE_PACK
-#define copy_simple_to_complex(x, y) \
+#define copy_simple_to_complex(obj, x, y) \
 {\
-    (x)->nth = (y)->nth;\
+    RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
     (x)->jd = (y)->jd;\
     (x)->df = 0;\
     (x)->sf = INT2FIX(0);\
@@ -387,9 +387,9 @@ _year, _mon, _mday, _hour, _min, _sec, _ https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L387
     (x)->flags = (y)->flags;\
 }
 #else
-#define copy_simple_to_complex(x, y) \
+#define copy_simple_to_complex(obj, x, y) \
 {\
-    (x)->nth = (y)->nth;\
+    RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
     (x)->jd = (y)->jd;\
     (x)->df = 0;\
     (x)->sf = INT2FIX(0);\
@@ -402,9 +402,9 @@ _year, _mon, _mday, _hour, _min, _sec, _ https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L402
 #endif
 
 #ifndef USE_PACK
-#define copy_complex_to_simple(x, y) \
+#define copy_complex_to_simple(obj, x, y) \
 {\
-    (x)->nth = (y)->nth;\
+    RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
     (x)->jd = (y)->jd;\
     (x)->sg = (date_sg_t)((y)->sg);\
     (x)->year = (y)->year;\
@@ -413,9 +413,9 @@ _year, _mon, _mday, _hour, _min, _sec, _ https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L413
     (x)->flags = (y)->flags;\
 }
 #else
-#define copy_complex_to_simple(x, y) \
+#define copy_complex_to_simple(obj, x, y) \
 {\
-    (x)->nth = (y)->nth;\
+    RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
     (x)->jd = (y)->jd;\
     (x)->sg = (date_sg_t)((y)->sg);\
     (x)->year = (y)->year;\
@@ -2944,7 +2944,7 @@ static const rb_data_type_t d_lite_type https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L2944
     "Date",
     {d_lite_gc_mark, RUBY_TYPED_DEFAULT_FREE, d_lite_memsize,},
     NULL, NULL,
-    RUBY_TYPED_FREE_IMMEDIATELY,
+    RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED,
 };
 
 inline static VALUE
@@ -2959,7 +2959,7 @@ d_simple_new_internal(VALUE klass, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L2959
 
     obj = TypedData_Make_Struct(klass, struct SimpleDateData,
 				&d_lite_type, dat);
-    set_to_simple(dat, nth, jd, sg, y, m, d, flags & ~COMPLEX_DAT);
+    set_to_simple(obj, dat, nth, jd, sg, y, m, d, flags & ~COMPLEX_DAT);
 
     assert(have_jd_p(dat) || have_civil_p(dat));
 
@@ -2980,7 +2980,7 @@ d_complex_new_internal(VALUE klass, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L2980
 
     obj = TypedData_Make_Struct(klass, struct ComplexDateData,
 				&d_lite_type, dat);
-    set_to_complex(dat, nth, jd, df, sf, of, sg,
+    set_to_complex(obj, dat, nth, jd, df, sf, of, sg,
 		   y, m, d, h, min, s, flags | COMPLEX_DAT);
 
     assert(have_jd_p(dat) || have_civil_p(dat));
@@ -4638,6 +4638,7 @@ dup_obj(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L4638
 	{
 	    get_d1b(new);
 	    bdat->s = adat->s;
+	    RB_OBJ_WRITTEN(new, Qundef, bdat->s.nth);
 	    return new;
 	}
     }
@@ -4646,6 +4647,8 @@ dup_obj(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L4647
 	{
 	    get_d1b(new);
 	    bdat->c = adat->c;
+	    RB_OBJ_WRITTEN(new, Qundef, bdat->c.nth);
+	    RB_OBJ_WRITTEN(new, Qundef, bdat->c.sf);
 	    return new;
 	}
     }
@@ -4660,7 +4663,7 @@ dup_obj_as_complex(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L4663
 	VALUE new = d_lite_s_alloc_complex(rb_obj_class(self));
 	{
 	    get_d1b(new);
-	    copy_simple_to_complex(&bdat->c, &adat->s);
+	    copy_simple_to_complex(new, &bdat->c, &adat->s);
 	    bdat->c.flags |= HAVE_DF | COMPLEX_DAT;
 	    return new;
 	}
@@ -4670,6 +4673,8 @@ dup_obj_as_complex(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L4673
 	{
 	    get_d1b(new);
 	    bdat->c = adat->c;
+	    RB_OBJ_WRITTEN(new, Qundef, bdat->c.nth);
+	    RB_OBJ_WRITTEN(new, Qundef, bdat->c.sf);
 	    return new;
 	}
     }
@@ -4728,7 +4733,7 @@ d_lite_initialize(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L4733
 
 	decode_jd(jd, &nth, &rjd);
 	if (!df && f_zero_p(sf) && !of) {
-	    set_to_simple(&dat->s, nth, rjd, sg, 0, 0, 0, HAVE_JD);
+	    set_to_simple(self, &dat->s, nth, rjd, sg, 0, 0, 0, HAVE_JD);
 	}
 	else {
 	    if (!complex_dat_p(dat))
@@ -7091,13 +7096,13 @@ d_lite_marshal_load(VALUE self, VALUE a) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7096
 		       &nth, &jd, &df, &sf, &rof, &rsg);
 
 	    if (!df && f_zero_p(sf) && !rof) {
-		set_to_simple(&dat->s, nth, jd, rsg, 0, 0, 0, HAVE_JD);
+		set_to_simple(self, &dat->s, nth, jd, rsg, 0, 0, 0, HAVE_JD);
 	    } else {
 		if (!complex_dat_p(dat))
 		    rb_raise(rb_eArgError,
 			     "cannot load complex into simple");
 
-		set_to_complex(&dat->c, nth, jd, df, sf, rof, rsg,
+		set_to_complex(self, &dat->c, nth, jd, df, sf, rof, rsg,
 			       0, 0, 0, 0, 0, 0,
 			       HAVE_JD | HAVE_DF | COMPLEX_DAT);
 	    }
@@ -7116,13 +7121,13 @@ d_lite_marshal_load(VALUE self, VALUE a) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7121
 	    of = NUM2INT(RARRAY_PTR(a)[4]);
 	    sg = NUM2DBL(RARRAY_PTR(a)[5]);
 	    if (!df && f_zero_p(sf) && !of) {
-		set_to_simple(&dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD);
+		set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD);
 	    } else {
 		if (!complex_dat_p(dat))
 		    rb_raise(rb_eArgError,
 			     "cannot load complex into simple");
 
-		set_to_complex(&dat->c, nth, jd, df, sf, of, sg,
+		set_to_complex(self, &dat->c, nth, jd, df, sf, of, sg,
 			       0, 0, 0, 0, 0, 0,
 			       HAVE_JD | HAVE_DF | COMPLEX_DAT);
 	    }
@@ -8614,7 +8619,7 @@ datetime_to_date(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L8619
 	VALUE new = d_lite_s_alloc_simple(cDate);
 	{
 	    get_d1b(new);
-	    copy_complex_to_simple(&bdat->s, &adat->c)
+	    copy_complex_to_simple(new, &bdat->s, &adat->c)
 	    bdat->s.jd = m_local_jd(adat);
 	    bdat->s.flags &= ~(HAVE_DF | HAVE_TIME | COMPLEX_DAT);
 	    return new;

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

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