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

ruby-changes:43005

From: nobu <ko1@a...>
Date: Fri, 20 May 2016 19:48:54 +0900 (JST)
Subject: [ruby-changes:43005] nobu:r55079 (trunk): exclude non-VALUE in memo from GC

nobu	2016-05-20 19:48:51 +0900 (Fri, 20 May 2016)

  New Revision: 55079

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

  Log:
    exclude non-VALUE in memo from GC
    
    * internal.h (NEW_PARTIAL_MEMO_FOR): shrink buffer array not to
      mark non-VALUE fields.  fix check_rvalue_consistency abort with
      RGENGC_CHECK_MODE=2.
    * internal.h (NEW_CMP_OPT_MEMO): exclude struct cmp_opt_data from
      the valid array range.
    * enum.c (slicewhen_i): exclude inverted too.

  Modified files:
    trunk/ChangeLog
    trunk/enum.c
    trunk/internal.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55078)
+++ ChangeLog	(revision 55079)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri May 20 19:48:48 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* internal.h (NEW_PARTIAL_MEMO_FOR): shrink buffer array not to
+	  mark non-VALUE fields.  fix check_rvalue_consistency abort with
+	  RGENGC_CHECK_MODE=2.
+
+	* internal.h (NEW_CMP_OPT_MEMO): exclude struct cmp_opt_data from
+	  the valid array range.
+
+	* enum.c (slicewhen_i): exclude inverted too.
+
 Thu May 19 21:21:57 2016  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* re.c (rb_reg_match_m_p): [DOC] fix return value in rdoc.
Index: internal.h
===================================================================
--- internal.h	(revision 55078)
+++ internal.h	(revision 55079)
@@ -773,6 +773,10 @@ struct MEMO { https://github.com/ruby/ruby/blob/trunk/internal.h#L773
 #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
 #define NEW_MEMO_FOR(type, value) \
   ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
+#define NEW_PARTIAL_MEMO_FOR(type, value, member) \
+  ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), \
+   rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
+   MEMO_FOR(type, value))
 
 #define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
 
@@ -787,6 +791,8 @@ struct cmp_opt_data { https://github.com/ruby/ruby/blob/trunk/internal.h#L791
     int opt_inited;
 };
 
+#define NEW_CMP_OPT_MEMO(type, value) \
+    NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)
 #define CMP_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(cmp_opt_,type))
 #define CMP_OPTIMIZABLE(data, type) \
     (((data).opt_inited & CMP_OPTIMIZABLE_BIT(type)) ? \
Index: enum.c
===================================================================
--- enum.c	(revision 55078)
+++ enum.c	(revision 55079)
@@ -1563,7 +1563,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L1563
 enum_min(int argc, VALUE *argv, VALUE obj)
 {
     VALUE memo;
-    struct min_t *m = NEW_MEMO_FOR(struct min_t, memo);
+    struct min_t *m = NEW_CMP_OPT_MEMO(struct min_t, memo);
     VALUE result;
     VALUE num;
 
@@ -1656,7 +1656,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L1656
 enum_max(int argc, VALUE *argv, VALUE obj)
 {
     VALUE memo;
-    struct max_t *m = NEW_MEMO_FOR(struct max_t, memo);
+    struct max_t *m = NEW_CMP_OPT_MEMO(struct max_t, memo);
     VALUE result;
     VALUE num;
 
@@ -1809,7 +1809,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L1809
 enum_minmax(VALUE obj)
 {
     VALUE memo;
-    struct minmax_t *m = NEW_MEMO_FOR(struct minmax_t, memo);
+    struct minmax_t *m = NEW_CMP_OPT_MEMO(struct minmax_t, memo);
 
     m->min = Qundef;
     m->last = Qundef;
@@ -3406,7 +3406,8 @@ slicewhen_i(RB_BLOCK_CALL_FUNC_ARGLIST(y https://github.com/ruby/ruby/blob/trunk/enum.c#L3406
 {
     VALUE enumerable;
     VALUE arg;
-    struct slicewhen_arg *memo = NEW_MEMO_FOR(struct slicewhen_arg, arg);
+    struct slicewhen_arg *memo =
+	NEW_PARTIAL_MEMO_FOR(struct slicewhen_arg, arg, inverted);
 
     enumerable = rb_ivar_get(enumerator, rb_intern("slicewhen_enum"));
     memo->pred = rb_attr_get(enumerator, rb_intern("slicewhen_pred"));

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

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