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

ruby-changes:30586

From: ko1 <ko1@a...>
Date: Fri, 23 Aug 2013 18:42:24 +0900 (JST)
Subject: [ruby-changes:30586] ko1:r42665 (trunk): * array.c (ary_make_shared): shared ary as shady. Need more effort to

ko1	2013-08-23 18:42:18 +0900 (Fri, 23 Aug 2013)

  New Revision: 42665

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

  Log:
    * array.c (ary_make_shared): shared ary as shady. Need more effort to
      make it normal object.
    * array.c (rb_ary_modify): use RARRAY_PTR_USE() without WB because
      there are not new relations.
    * array.c (ary_ensure_room_for_unshift): use RARRAY_RAWPTR() because
      there are not new relations.

  Modified files:
    trunk/ChangeLog
    trunk/array.c
Index: array.c
===================================================================
--- array.c	(revision 42664)
+++ array.c	(revision 42665)
@@ -328,7 +328,9 @@ rb_ary_modify(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L328
 	    FL_UNSET_SHARED(ary);
 	    ARY_SET_PTR(ary, RARRAY_RAWPTR(shared));
 	    ARY_SET_CAPA(ary, RARRAY_LEN(shared));
-	    MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+shift, VALUE, len);
+	    RARRAY_PTR_USE(ary, ptr, {
+		MEMMOVE(ptr, ptr+shift, VALUE, len);
+	    });
 	    FL_SET_EMBED(shared);
 	    rb_ary_decrement_share(shared);
 	}
@@ -571,12 +573,12 @@ ary_make_shared(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L573
 	return ary;
     }
     else {
-	NEWOBJ_OF(shared, struct RArray, 0, T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0));
+	NEWOBJ_OF(shared, struct RArray, 0, T_ARRAY); /* keep shared ary as shady */
         FL_UNSET_EMBED(shared);
 
         ARY_SET_LEN((VALUE)shared, ARY_CAPA(ary));
-	ARY_SET_PTR((VALUE)shared, RARRAY_PTR(ary));
-	rb_mem_clear(RARRAY_PTR(shared) + RARRAY_LEN(ary), ARY_CAPA(ary) - RARRAY_LEN(ary));
+	ARY_SET_PTR((VALUE)shared, RARRAY_RAWPTR(ary));
+	ary_mem_clear((VALUE)shared, RARRAY_LEN(ary), ARY_CAPA(ary) - RARRAY_LEN(ary));
 	FL_SET_SHARED_ROOT(shared);
 	ARY_SET_SHARED_NUM((VALUE)shared, 1);
 	FL_SET_SHARED(ary);
@@ -1073,14 +1075,14 @@ ary_ensure_room_for_unshift(VALUE ary, i https://github.com/ruby/ruby/blob/trunk/array.c#L1075
     long len = RARRAY_LEN(ary);
     long new_len = len + argc;
     long capa;
-    VALUE *head, *sharedp;
+    const VALUE *head, *sharedp;
 
     if (ARY_SHARED_P(ary)) {
 	VALUE shared = ARY_SHARED(ary);
 	capa = RARRAY_LEN(shared);
 	if (ARY_SHARED_OCCUPIED(shared) && capa > new_len) {
-	    head = RARRAY_PTR(ary);
-	    sharedp = RARRAY_PTR(shared);
+	    head = RARRAY_RAWPTR(ary);
+	    sharedp = RARRAY_RAWPTR(shared);
 	    goto makeroom_if_need;
 	}
     }
@@ -1097,7 +1099,7 @@ ary_ensure_room_for_unshift(VALUE ary, i https://github.com/ruby/ruby/blob/trunk/array.c#L1099
 	capa = ARY_CAPA(ary);
 	ary_make_shared(ary);
 
-	head = sharedp = RARRAY_PTR(ary);
+	head = sharedp = RARRAY_RAWPTR(ary);
 	goto makeroom;
       makeroom_if_need:
 	if (head - sharedp < argc) {
@@ -1105,7 +1107,7 @@ ary_ensure_room_for_unshift(VALUE ary, i https://github.com/ruby/ruby/blob/trunk/array.c#L1107
 	  makeroom:
 	    room = capa - new_len;
 	    room -= room >> 4;
-	    MEMMOVE(sharedp + argc + room, head, VALUE, len);
+	    MEMMOVE((VALUE *)sharedp + argc + room, head, VALUE, len);
 	    head = sharedp + argc + room;
 	}
 	ARY_SET_PTR(ary, head - argc);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42664)
+++ ChangeLog	(revision 42665)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Aug 23 18:39:04 2013  Koichi Sasada  <ko1@a...>
+
+	* array.c (ary_make_shared): shared ary as shady. Need more effort to
+	  make it normal object.
+
+	* array.c (rb_ary_modify): use RARRAY_PTR_USE() without WB because
+	  there are not new relations.
+
+	* array.c (ary_ensure_room_for_unshift): use RARRAY_RAWPTR() because
+	  there are not new relations.
+
 Fri Aug 23 11:25:57 2013  Koichi Sasada  <ko1@a...>
 
 	* array.c: introduce ARY_SHARED_OCCUPIED(shared).

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

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