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

ruby-changes:37861

From: ko1 <ko1@a...>
Date: Thu, 12 Mar 2015 08:13:27 +0900 (JST)
Subject: [ruby-changes:37861] ko1:r49942 (trunk): * internal.h: use T_IMEMO to represent `struct MEMO' value.

ko1	2015-03-12 08:13:01 +0900 (Thu, 12 Mar 2015)

  New Revision: 49942

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

  Log:
    * internal.h: use T_IMEMO to represent `struct MEMO' value.
      memo->v1 and memo->v2 is WB protected values.
      So use MEMO_V1/V2_SET() macros to set these values.
      memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer
      value), so use gc_mark_maybe() in gc.c to mark it.
      Rename NEW_MEMO() to MEMO_NEW().
      Move MEMO_FOR and NEW_MEMO_FOF macros from node.h.
      Export a rb_imemo_new() function for ext/ripper.
    * node.h: remove NODE_MEMO.
    * enum.c: catch up these change.
    * enumerator.c: ditto.
    * load.c: ditto.
    * ext/objspace/objspace.c (count_nodes): ditto.
    * gc.c (gc_mark_children): mark imemo_memo type.
    * parse.y (new_args_gen): use T_IMEMO.
      (I'm not sure it is working correctly...)

  Modified files:
    trunk/ChangeLog
    trunk/enum.c
    trunk/enumerator.c
    trunk/ext/objspace/objspace.c
    trunk/gc.c
    trunk/internal.h
    trunk/load.c
    trunk/node.h
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49941)
+++ ChangeLog	(revision 49942)
@@ -1,3 +1,32 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar 12 07:44:17 2015  Koichi Sasada  <ko1@a...>
+
+	* internal.h: use T_IMEMO to represent `struct MEMO' value.
+	  memo->v1 and memo->v2 is WB protected values.
+	  So use MEMO_V1/V2_SET() macros to set these values.
+	  memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer
+	  value), so use gc_mark_maybe() in gc.c to mark it.
+
+	  Rename NEW_MEMO() to MEMO_NEW().
+
+	  Move MEMO_FOR and NEW_MEMO_FOF macros from node.h.
+
+	  Export a rb_imemo_new() function for ext/ripper.
+
+	* node.h: remove NODE_MEMO.
+
+	* enum.c: catch up these change.
+
+	* enumerator.c: ditto.
+
+	* load.c: ditto.
+
+	* ext/objspace/objspace.c (count_nodes): ditto.
+
+	* gc.c (gc_mark_children): mark imemo_memo type.
+
+	* parse.y (new_args_gen): use T_IMEMO.
+	  (I'm not sure it is working correctly...)
+
 Wed Mar 11 22:36:34 2015  Koichi Sasada  <ko1@a...>
 
 	* eval.c (frame_called_id): it should use vm_ifunc type.
Index: enumerator.c
===================================================================
--- enumerator.c	(revision 49941)
+++ enumerator.c	(revision 49942)
@@ -13,7 +13,6 @@ https://github.com/ruby/ruby/blob/trunk/enumerator.c#L13
 ************************************************/
 
 #include "internal.h"
-#include "node.h"
 
 /*
  * Document-class: Enumerator
@@ -496,7 +495,7 @@ enumerator_with_index_i(RB_BLOCK_CALL_FU https://github.com/ruby/ruby/blob/trunk/enumerator.c#L495
 {
     struct MEMO *memo = (struct MEMO *)m;
     VALUE idx = memo->v1;
-    memo->v1 = rb_int_succ(idx);
+    MEMO_V1_SET(memo, rb_int_succ(idx));
 
     if (argc <= 1)
 	return rb_yield_values(2, val, idx);
@@ -536,7 +535,7 @@ enumerator_with_index(int argc, VALUE *a https://github.com/ruby/ruby/blob/trunk/enumerator.c#L535
 	memo = INT2FIX(0);
     else
 	memo = rb_to_int(memo);
-    return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)NEW_MEMO(memo, 0, 0));
+    return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)MEMO_NEW(memo, 0, 0));
 }
 
 /*
Index: enum.c
===================================================================
--- enum.c	(revision 49941)
+++ enum.c	(revision 49942)
@@ -11,7 +11,6 @@ https://github.com/ruby/ruby/blob/trunk/enum.c#L11
 
 #include "internal.h"
 #include "ruby/util.h"
-#include "node.h"
 #include "id.h"
 
 VALUE rb_mEnumerable;
@@ -86,7 +85,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L85
 enum_grep(VALUE obj, VALUE pat)
 {
     VALUE ary = rb_ary_new();
-    struct MEMO *memo = NEW_MEMO(pat, ary, 0);
+    struct MEMO *memo = MEMO_NEW(pat, ary, 0);
 
     rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)memo);
 
@@ -167,7 +166,7 @@ enum_count(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L166
         func = count_i;
     }
 
-    memo = NEW_MEMO(item, 0, 0);
+    memo = MEMO_NEW(item, 0, 0);
     rb_block_call(obj, id_each, 0, 0, func, (VALUE)memo);
     return INT2NUM(memo->u3.cnt);
 }
@@ -179,7 +178,7 @@ find_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, mem https://github.com/ruby/ruby/blob/trunk/enum.c#L178
 
     if (RTEST(rb_yield(i))) {
 	struct MEMO *memo = MEMO_CAST(memop);
-	memo->v1 = i;
+	MEMO_V1_SET(memo, i);
 	memo->u3.cnt = 1;
 	rb_iter_break();
     }
@@ -213,7 +212,7 @@ enum_find(int argc, VALUE *argv, VALUE o https://github.com/ruby/ruby/blob/trunk/enum.c#L212
 
     rb_scan_args(argc, argv, "01", &if_none);
     RETURN_ENUMERATOR(obj, argc, argv);
-    memo = NEW_MEMO(Qundef, 0, 0);
+    memo = MEMO_NEW(Qundef, 0, 0);
     rb_block_call(obj, id_each, 0, 0, find_i, (VALUE)memo);
     if (memo->u3.cnt) {
 	return memo->v1;
@@ -232,7 +231,7 @@ find_index_i(RB_BLOCK_CALL_FUNC_ARGLIST( https://github.com/ruby/ruby/blob/trunk/enum.c#L231
     ENUM_WANT_SVALUE();
 
     if (rb_equal(i, memo->v2)) {
-	memo->v1 = UINT2NUM(memo->u3.cnt);
+	MEMO_V1_SET(memo, UINT2NUM(memo->u3.cnt));
 	rb_iter_break();
     }
     memo->u3.cnt++;
@@ -245,7 +244,7 @@ find_index_iter_i(RB_BLOCK_CALL_FUNC_ARG https://github.com/ruby/ruby/blob/trunk/enum.c#L244
     struct MEMO *memo = MEMO_CAST(memop);
 
     if (RTEST(enum_yield(argc, argv))) {
-	memo->v1 = UINT2NUM(memo->u3.cnt);
+	MEMO_V1_SET(memo, UINT2NUM(memo->u3.cnt));
 	rb_iter_break();
     }
     memo->u3.cnt++;
@@ -290,7 +289,7 @@ enum_find_index(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/enum.c#L289
         func = find_index_i;
     }
 
-    memo = NEW_MEMO(Qnil, condition_value, 0);
+    memo = MEMO_NEW(Qnil, condition_value, 0);
     rb_block_call(obj, id_each, 0, 0, func, (VALUE)memo);
     return memo->v1;
 }
@@ -571,10 +570,10 @@ inject_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, p https://github.com/ruby/ruby/blob/trunk/enum.c#L570
     ENUM_WANT_SVALUE();
 
     if (memo->v1 == Qundef) {
-	memo->v1 = i;
+	MEMO_V1_SET(memo, i);
     }
     else {
-	memo->v1 = rb_yield_values(2, memo->v1, i);
+	MEMO_V1_SET(memo, rb_yield_values(2, memo->v1, i));
     }
     return Qnil;
 }
@@ -588,17 +587,17 @@ inject_op_i(RB_BLOCK_CALL_FUNC_ARGLIST(i https://github.com/ruby/ruby/blob/trunk/enum.c#L587
     ENUM_WANT_SVALUE();
 
     if (memo->v1 == Qundef) {
-	memo->v1 = i;
+	MEMO_V1_SET(memo, i);
     }
     else if (SYMBOL_P(name = memo->u3.value)) {
 	const ID mid = SYM2ID(name);
-	memo->v1 = rb_funcall(memo->v1, mid, 1, i);
+	MEMO_V1_SET(memo, rb_funcall(memo->v1, mid, 1, i));
     }
     else {
 	VALUE args[2];
 	args[0] = name;
 	args[1] = i;
-	memo->v1 = rb_f_send(numberof(args), args, memo->v1);
+	MEMO_V1_SET(memo, rb_f_send(numberof(args), args, memo->v1));
     }
     return Qnil;
 }
@@ -676,7 +675,7 @@ enum_inject(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L675
 	iter = inject_op_i;
 	break;
     }
-    memo = NEW_MEMO(init, Qnil, op);
+    memo = MEMO_NEW(init, Qnil, op);
     rb_block_call(obj, id_each, 0, 0, iter, (VALUE)memo);
     if (memo->v1 == Qundef) return Qnil;
     return memo->v1;
@@ -721,7 +720,7 @@ enum_partition(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enum.c#L720
 
     RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
 
-    memo = NEW_MEMO(rb_ary_new(), rb_ary_new(), 0);
+    memo = MEMO_NEW(rb_ary_new(), rb_ary_new(), 0);
     rb_block_call(obj, id_each, 0, 0, partition_i, (VALUE)memo);
 
     return rb_assoc_new(memo->v1, memo->v2);
@@ -782,7 +781,7 @@ first_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, pa https://github.com/ruby/ruby/blob/trunk/enum.c#L781
     struct MEMO *memo = MEMO_CAST(params);
     ENUM_WANT_SVALUE();
 
-    memo->v1 = i;
+    MEMO_V1_SET(memo, i);
     rb_iter_break();
 
     UNREACHABLE;
@@ -815,7 +814,7 @@ enum_first(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L814
 	return enum_take(obj, argv[0]);
     }
     else {
-	memo = NEW_MEMO(Qnil, 0, 0);
+	memo = MEMO_NEW(Qnil, 0, 0);
 	rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)memo);
 	return memo->v1;
     }
@@ -987,7 +986,7 @@ enum_sort_by(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enum.c#L986
     RBASIC_CLEAR_CLASS(ary);
     buf = rb_ary_tmp_new(SORT_BY_BUFSIZE*2);
     rb_ary_store(buf, SORT_BY_BUFSIZE*2-1, Qnil);
-    memo = NEW_MEMO(0, 0, 0);
+    memo = MEMO_NEW(0, 0, 0);
     OBJ_INFECT(memo, obj);
     data = (struct sort_by_data *)&memo->v1;
     data->ary = ary;
@@ -1041,7 +1040,7 @@ enum_##name##_func(VALUE result, struct https://github.com/ruby/ruby/blob/trunk/enum.c#L1040
 DEFINE_ENUMFUNCS(all)
 {
     if (!RTEST(result)) {
-	memo->v1 = Qfalse;
+	MEMO_V1_SET(memo, Qfalse);
 	rb_iter_break();
     }
     return Qnil;
@@ -1067,7 +1066,7 @@ DEFINE_ENUMFUNCS(all) https://github.com/ruby/ruby/blob/trunk/enum.c#L1066
 static VALUE
 enum_all(VALUE obj)
 {
-    struct MEMO *memo = NEW_MEMO(Qtrue, 0, 0);
+    struct MEMO *memo = MEMO_NEW(Qtrue, 0, 0);
     rb_block_call(obj, id_each, 0, 0, ENUMFUNC(all), (VALUE)memo);
     return memo->v1;
 }
@@ -1075,7 +1074,7 @@ enum_all(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enum.c#L1074
 DEFINE_ENUMFUNCS(any)
 {
     if (RTEST(result)) {
-	memo->v1 = Qtrue;
+	MEMO_V1_SET(memo, Qtrue);
 	rb_iter_break();
     }
     return Qnil;
@@ -1101,7 +1100,7 @@ DEFINE_ENUMFUNCS(any) https://github.com/ruby/ruby/blob/trunk/enum.c#L1100
 static VALUE
 enum_any(VALUE obj)
 {
-    struct MEMO *memo = NEW_MEMO(Qfalse, 0, 0);
+    struct MEMO *memo = MEMO_NEW(Qfalse, 0, 0);
     rb_block_call(obj, id_each, 0, 0, ENUMFUNC(any), (VALUE)memo);
     return memo->v1;
 }
@@ -1110,10 +1109,10 @@ DEFINE_ENUMFUNCS(one) https://github.com/ruby/ruby/blob/trunk/enum.c#L1109
 {
     if (RTEST(result)) {
 	if (memo->v1 == Qundef) {
-	    memo->v1 = Qtrue;
+	    MEMO_V1_SET(memo, Qtrue);
 	}
 	else if (memo->v1 == Qtrue) {
-	    memo->v1 = Qfalse;
+	    MEMO_V1_SET(memo, Qfalse);
 	    rb_iter_break();
 	}
     }
@@ -1344,7 +1343,7 @@ nmin_run(VALUE obj, VALUE num, int by, i https://github.com/ruby/ruby/blob/trunk/enum.c#L1343
 static VALUE
 enum_one(VALUE obj)
 {
-    struct MEMO *memo = NEW_MEMO(Qundef, 0, 0);
+    struct MEMO *memo = MEMO_NEW(Qundef, 0, 0);
     VALUE result;
 
     rb_block_call(obj, id_each, 0, 0, ENUMFUNC(one), (VALUE)memo);
@@ -1356,7 +1355,7 @@ enum_one(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enum.c#L1355
 DEFINE_ENUMFUNCS(none)
 {
     if (RTEST(result)) {
-	memo->v1 = Qfalse;
+	MEMO_V1_SET(memo, Qfalse);
 	rb_iter_break();
     }
     return Qnil;
@@ -1380,7 +1379,7 @@ DEFINE_ENUMFUNCS(none) https://github.com/ruby/ruby/blob/trunk/enum.c#L1379
 static VALUE
 enum_none(VALUE obj)
 {
-    struct MEMO *memo = NEW_MEMO(Qtrue, 0, 0);
+    struct MEMO *memo = MEMO_NEW(Qtrue, 0, 0);
     rb_block_call(obj, id_each, 0, 0, ENUMFUNC(none), (VALUE)memo);
     return memo->v1;
 }
@@ -1394,12 +1393,12 @@ min_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args https://github.com/ruby/ruby/blob/trunk/enum.c#L1393
     ENUM_WANT_SVALUE();
 
     if (memo->v1 == Qundef) {
-	memo->v1 = i;
+	MEMO_V1_SET(memo, i);
     }
     else {
 	cmp = rb_funcall(i, id_cmp, 1, memo->v1);
 	if (rb_cmpint(cmp, i, memo->v1) < 0) {
-	    memo->v1 = i;
+	    MEMO_V1_SET(memo, i);
 	}
     }
     return Qnil;
@@ -1414,12 +1413,12 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg https://github.com/ruby/ruby/blob/trunk/enum.c#L1413
     ENUM_WANT_SVALUE();
 
     if (memo->v1 == Qundef) {
-	memo->v1 = i;
+	MEMO_V1_SET(memo, i);
     }
     else {
 	cmp = rb_yield_values(2, i, memo->v1);
 	if (rb_cmpint(cmp, i, memo->v1) < 0) {
-	    memo->v1 = i;
+	    MEMO_V1_SET(memo, i);
 	}
     }
     return Qnil;
@@ -1452,7 +1451,7 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg https://github.com/ruby/ruby/blob/trunk/enum.c#L1451
 static VALUE
 enum_min(int argc, VALUE *argv, VALUE obj)
 {
-    struct MEMO *memo = NEW_MEMO(Qundef, 0, 0);
+    struct MEMO *memo = MEMO_NEW(Qundef, 0, 0);
     VALUE result;
     VALUE num;
 
@@ -1481,12 +1480,12 @@ max_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args https://github.com/ruby/ruby/blob/trunk/enum.c#L1480
     ENUM_WANT_SVALUE();
 
     if (memo->v1 == Qundef) {
-	memo->v1 = i;
+	MEMO_V1_SET(memo, i);
     }
     else {
 	cmp = rb_funcall(i, id_cmp, 1, memo->v1);
 	if (rb_cmpint(cmp, i, memo->v1) > 0) {
-	    memo->v1 = i;
+	    MEMO_V1_SET(memo, i);
 	}
     }
     return Qnil;
@@ -1501,12 +1500,12 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg https://github.com/ruby/ruby/blob/trunk/enum.c#L1500
     ENUM_WANT_SVALUE();
 
     if (memo->v1 == Qundef) {
-	memo->v1 = i;
+	MEMO_V1_SET(memo, i);
     }
     else {
 	cmp = rb_yield_values(2, i, memo->v1);
 	if (rb_cmpint(cmp, i, memo->v1) > 0) {
-	    memo->v1 = i;
+	    MEMO_V1_SET(memo, i);
 	}
     }
     return Qnil;
@@ -1538,7 +1537,7 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg https://github.com/ruby/ruby/blob/trunk/enum.c#L1537
 static VALUE
 enum_max(int argc, VALUE *argv, VALUE obj)
 {
-    struct MEMO *memo = NEW_MEMO(Qundef, 0, 0);
+    struct MEMO *memo = MEMO_NEW(Qundef, 0, 0);
     VALUE result;
     VALUE num;
 
@@ -1564,7 +1563,7 @@ struct minmax_t { https://github.com/ruby/ruby/blob/trunk/enum.c#L1563
     VALUE last;
 };
 
-STATIC_ASSERT(minmax_t, sizeof(struct minmax_t) <= sizeof(NODE) - offsetof(NODE, u1));
+STATIC_ASSERT(minmax_t, sizeof(struct minmax_t) <= sizeof(struct MEMO) - offsetof(struct MEMO, v1));
 
 static void
 minmax_i_update(VALUE i, VALUE j, struct minmax_t *memo)
@@ -1688,7 +1687,7 @@ minmax_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, https://github.com/ruby/ruby/blob/trunk/enum.c#L1687
 static VALUE
 enum_minmax(VALUE obj)
 {
-    struct MEMO *memo = NEW_MEMO(Qundef, Qundef, Qundef);
+    struct MEMO *memo = MEMO_NEW(Qundef, Qundef, Qundef);
     struct minmax_t *m = (struct minmax_t *)&memo->v1;
     VALUE ary = rb_ary_new3(2, Qnil, Qnil);
 
@@ -1721,12 +1720,12 @@ min_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, a https://github.com/ruby/ruby/blob/trunk/enum.c#L1720
 
     v = rb_yield(i);
     if (memo->v1 == Qundef) {
-	memo->v1 = v;
-	memo->v2 = i;
+	MEMO_V1_SET(memo, v);
+	MEMO_V2_SET(memo, i);
     }
     else if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo->v1), v, memo->v1) < 0) {
-	memo->v1 = v;
-	memo->v2 = i;
+	MEMO_V1_SET(memo, v);
+	MEMO_V2_SET(memo, i);
     }
     return Qnil;
 }
@@ -1766,7 +1765,7 @@ enum_min_by(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L1765
     if (!NIL_P(num))
         return nmin_run(obj, num, 1, 0);
 
-    memo = NEW_MEMO(Qundef, Qnil, 0);
+    memo = MEMO_NEW(Qundef, Qnil, 0);
     rb_block_call(obj, id_each, 0, 0, min_by_i, (VALUE)memo);
     return memo->v2;
 }
@@ -1781,12 +1780,12 @@ max_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, a https://github.com/ruby/ruby/blob/trunk/enum.c#L1780
 
     v = rb_yield(i);
     if (memo->v1 == Qundef) {
-	memo->v1 = v;
-	memo->v2 = i;
+	MEMO_V1_SET(memo, v);
+	MEMO_V2_SET(memo, i);
     }
     else if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo->v1), v, memo->v1) > 0) {
-	memo->v1 = v;
-	memo->v2 = i;
+	MEMO_V1_SET(memo, v);
+	MEMO_V2_SET(memo, i);
     }
     return Qnil;
 }
@@ -1871,7 +1870,7 @@ enum_max_by(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L1870
     if (!NIL_P(num))
         return nmin_run(obj, num, 1, 1);
 
-    memo = NEW_MEMO(Qundef, Qnil, 0);
+    memo = MEMO_NEW(Qundef, Qnil, 0);
     rb_block_call(obj, id_each, 0, 0, max_by_i, (VALUE)memo);
     return memo->v2;
 }
@@ -1988,7 +1987,7 @@ member_i(RB_BLOCK_CALL_FUNC_ARGLIST(iter https://github.com/ruby/ruby/blob/trunk/enum.c#L1987
     struct MEMO *memo = MEMO_CAST(args);
 
     if (rb_equal(rb_enum_values_pack(argc, argv), memo->v1)) {
-	memo->v2 = Qtrue;
+	MEMO_V2_SET(memo, Qtrue);
 	rb_iter_break();
     }
     return Qnil;
@@ -2010,7 +2009,7 @@ member_i(RB_BLOCK_CALL_FUNC_ARGLIST(iter https://github.com/ruby/ruby/blob/trunk/enum.c#L2009
 static VALUE
 enum_member(VALUE obj, VALUE val)
 {
-    struct MEMO *memo = NEW_MEMO(val, Qfalse, 0);
+    struct MEMO *memo = MEMO_NEW(val, Qfalse, 0);
 
     rb_block_call(obj, id_each, 0, 0, member_i, (VALUE)memo);
     return memo->v2;
@@ -2050,7 +2049,7 @@ enum_each_with_index(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/enum.c#L2049
 
     RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size);
 
-    memo = NEW_MEMO(0, 0, 0);
+    memo = MEMO_NEW(0, 0, 0);
     rb_block_call(obj, id_each, argc, argv, each_with_index_i, (VALUE)memo);
     return obj;
 }
@@ -2154,7 +2153,7 @@ each_slice_i(RB_BLOCK_CALL_FUNC_ARGLIST( https://github.com/ruby/ruby/blob/trunk/enum.c#L2153
 	v = rb_yield(ary);
 
 	if (memo->v2) {
-	    memo->v1 = rb_ary_new2(size);
+	    MEMO_V1_SET(memo, rb_ary_new2(size));
 	}
 	else {
 	    rb_ary_clear(ary);
@@ -2207,7 +2206,7 @@ enum_each_slice(VALUE obj, VALUE n) https://github.com/ruby/ruby/blob/trunk/enum.c#L2206
     size = limit_by_enum_size(obj, size);
     ary = rb_ary_new2(size);
     arity = rb_block_arity();
-    memo = NEW_MEMO(ary, dont_recycle_block_arg(arity), size);
+    memo = MEMO_NEW(ary, dont_recycle_block_arg(arity), size);
     rb_block_call(obj, id_each, 0, 0, each_slice_i, (VALUE)memo);
     ary = memo->v1;
     if (RARRAY_LEN(ary) > 0) rb_yield(ary);
@@ -2283,7 +2282,7 @@ enum_each_cons(VALUE obj, VALUE n) https://github.com/ruby/ruby/blob/trunk/enum.c#L2282
     RETURN_SIZED_ENUMERATOR(obj, 1, &n, enum_each_cons_size);
     arity = rb_block_arity();
     if (enum_size_over_p(obj, size)) return Qnil;
-    memo = NEW_MEMO(rb_ary_new2(size), dont_recycle_block_arg(arity), size);
+    memo = MEMO_NEW(rb_ary_new2(size), dont_recycle_block_arg(arity), size);
     rb_block_call(obj, id_each, 0, 0, each_cons_i, (VALUE)memo);
 
     return Qnil;
@@ -2457,7 +2456,7 @@ enum_zip(int argc, VALUE *argv, VALUE ob https://github.com/ruby/ruby/blob/trunk/enum.c#L2456
     }
 
     /* TODO: use NODE_DOT2 as memo(v, v, -) */
-    memo = NEW_MEMO(result, args, 0);
+    memo = MEMO_NEW(result, args, 0);
     rb_block_call(obj, id_each, 0, 0, allary ? zip_ary : zip_i, (VALUE)memo);
 
     return result;
@@ -2497,7 +2496,7 @@ enum_take(VALUE obj, VALUE n) https://github.com/ruby/ruby/blob/trunk/enum.c#L2496
 
     if (len == 0) return rb_ary_new2(0);
     result = rb_ary_new2(len);
-    memo = NEW_MEMO(result, 0, len);
+    memo = MEMO_NEW(result, 0, len);
     rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)memo);
     return result;
 }
@@ -2574,7 +2573,7 @@ enum_drop(VALUE obj, VALUE n) https://github.com/ruby/ruby/blob/trunk/enum.c#L2573
     }
 
     result = rb_ary_new();
-    memo = NEW_MEMO(result, 0, len);
+    memo = MEMO_NEW(result, 0, len);
     rb_block_call(obj, id_each, 0, 0, drop_i, (VALUE)memo);
     return result;
 }
@@ -2619,7 +2618,7 @@ enum_drop_while(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enum.c#L2618
 
     RETURN_ENUMERATOR(obj, 0, 0);
     result = rb_ary_new();
-    memo = NEW_MEMO(result, 0, FALSE);
+    memo = MEMO_NEW(result, 0, FALSE);
     rb_block_call(obj, id_each, 0, 0, drop_while_i, (VALUE)memo);
     return result;
 }
Index: load.c
===================================================================
--- load.c	(revision 49941)
+++ load.c	(revision 49942)
@@ -728,7 +728,7 @@ load_lock(const char *ftptr) https://github.com/ruby/ruby/blob/trunk/load.c#L728
 	st_insert(loading_tbl, (st_data_t)ftptr, data);
 	return (char *)ftptr;
     }
-    else if (RB_TYPE_P((VALUE)data, T_NODE) && nd_type((VALUE)data) == NODE_MEMO) {
+    else if (RB_TYPE_P((VALUE)data, T_IMEMO) && imemo_type((VALUE)data) == imemo_memo) {
 	struct MEMO *memo = MEMO_CAST(data);
 	void (*init)(void) = (void (*)(void))memo->u3.func;
 	data = (st_data_t)rb_thread_shield_new();
@@ -1078,7 +1078,7 @@ register_init_ext(st_data_t *key, st_dat https://github.com/ruby/ruby/blob/trunk/load.c#L1078
 	rb_warn("%s is already registered", name);
     }
     else {
-	*value = (st_data_t)NEW_MEMO(0, 0, init);
+	*value = (st_data_t)MEMO_NEW(0, 0, init);
 	*key = (st_data_t)ruby_strdup(name);
     }
     return ST_CONTINUE;
Index: gc.c
===================================================================
--- gc.c	(revision 49941)
+++ gc.c	(revision 49942)
@@ -217,7 +217,7 @@ static ruby_gc_params_t gc_params = { https://github.com/ruby/ruby/blob/trunk/gc.c#L217
  * 5: show all references
  */
 #ifndef RGENGC_CHECK_MODE
-#define RGENGC_CHECK_MODE  0
+#define RGENGC_CHECK_MODE  2
 #endif
 
 /* RGENGC_PROFILE
@@ -385,6 +385,7 @@ typedef struct RVALUE { https://github.com/ruby/ruby/blob/trunk/gc.c#L385
 	    struct vm_svar svar;
 	    struct vm_throw_data throw_data;
 	    struct vm_ifunc ifunc;
+	    struct MEMO memo;
 	} imemo;
 	struct {
 	    struct RBasic basic;
@@ -4171,6 +4172,11 @@ gc_mark_children(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L4172
 	  case imemo_ifunc:
 	    gc_mark_maybe(objspace, (VALUE)RANY(obj)->as.imemo.ifunc.data);
 	    return;
+	  case imemo_memo:
+	    gc_mark(objspace, RANY(obj)->as.imemo.memo.v1);
+	    gc_mark(objspace, RANY(obj)->as.imemo.memo.v2);
+	    gc_mark (... truncated)

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

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