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

ruby-changes:31639

From: ko1 <ko1@a...>
Date: Tue, 19 Nov 2013 18:48:55 +0900 (JST)
Subject: [ruby-changes:31639] ko1:r43718 (trunk): * gc.c (rb_gc_resurrect): added.

ko1	2013-11-19 18:48:47 +0900 (Tue, 19 Nov 2013)

  New Revision: 43718

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

  Log:
    * gc.c (rb_gc_resurrect): added.
      rb_fstring() used rb_gc_mark() to avoid freeing used string.
      However, rb_gc_mark() set mark bit *and* pushes mark_stack.
      rb_gc_resurrect() does only set mark bit if it is before sweeping.
    * string.c (rb_fstring): use rb_gc_resurrect.
    * internal.h: add decl.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/internal.h
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43717)
+++ ChangeLog	(revision 43718)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Nov 19 18:45:40 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (rb_gc_resurrect): added.
+	  rb_fstring() used rb_gc_mark() to avoid freeing used string.
+	  However, rb_gc_mark() set mark bit *and* pushes mark_stack.
+	  rb_gc_resurrect() does only set mark bit if it is before sweeping.
+
+	* string.c (rb_fstring): use rb_gc_resurrect.
+
+	* internal.h: add decl.
+
 Tue Nov 19 09:47:02 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/rdoc:  Update to RDoc master a1195ce.  Changes include:
Index: string.c
===================================================================
--- string.c	(revision 43717)
+++ string.c	(revision 43718)
@@ -140,7 +140,7 @@ rb_fstring(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L140
 	str = (VALUE)fstr;
 	/* because of lazy sweep, str may be unmaked already and swept
 	 * at next time */
-	rb_gc_mark(str);
+	rb_gc_resurrect(str);
     }
     else {
 	str = rb_str_new_frozen(str);
Index: gc.c
===================================================================
--- gc.c	(revision 43717)
+++ gc.c	(revision 43718)
@@ -3571,6 +3571,20 @@ rb_gc_mark(VALUE ptr) https://github.com/ruby/ruby/blob/trunk/gc.c#L3571
     gc_mark(&rb_objspace, ptr);
 }
 
+/* resurrect non-marked `obj' if obj is before swept */
+
+void
+rb_gc_resurrect(VALUE obj)
+{
+    rb_objspace_t *objspace = &rb_objspace;
+
+    if (is_lazy_sweeping(heap_eden) &&
+	!gc_marked(objspace, obj) &&
+	!is_swept_object(objspace, obj)) {
+	gc_mark_ptr(objspace, obj);
+    }
+}
+
 static void
 gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
 {
Index: internal.h
===================================================================
--- internal.h	(revision 43717)
+++ internal.h	(revision 43718)
@@ -435,6 +435,8 @@ void *ruby_sized_xrealloc(void *ptr, siz https://github.com/ruby/ruby/blob/trunk/internal.h#L435
 void ruby_sized_xfree(void *x, size_t size);
 #define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
 
+void rb_gc_resurrect(VALUE ptr);
+
 /* hash.c */
 struct st_table *rb_hash_tbl_raw(VALUE hash);
 #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)

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

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