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

ruby-changes:18899

From: nobu <ko1@a...>
Date: Sun, 20 Feb 2011 16:26:55 +0900 (JST)
Subject: [ruby-changes:18899] Ruby:r30924 (trunk): * thread.c (exec_recursive): prevent temporary objects from GC.

nobu	2011-02-20 16:26:48 +0900 (Sun, 20 Feb 2011)

  New Revision: 30924

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

  Log:
    * thread.c (exec_recursive): prevent temporary objects from GC.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30923)
+++ ChangeLog	(revision 30924)
@@ -1,5 +1,7 @@
-Sun Feb 20 16:23:52 2011  Nobuyoshi Nakada  <nobu@r...>
+Sun Feb 20 16:26:45 2011  Nobuyoshi Nakada  <nobu@r...>
 
+	* thread.c (exec_recursive): prevent temporary objects from GC.
+
 	* prevent temporary objects from GC, and should not use
 	  RSTRING_PTR() for function calls since it evaluates the argument
 	  a couple of times.
Index: thread.c
===================================================================
--- thread.c	(revision 30923)
+++ thread.c	(revision 30924)
@@ -3701,10 +3701,14 @@
 static VALUE
 exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE arg, int outer)
 {
+    VALUE result = Qundef;
     struct exec_recursive_params p;
     int outermost;
     p.list = recursive_list_access();
     p.objid = rb_obj_id(obj);
+    p.obj = obj;
+    p.pairid = pairid;
+    p.arg = arg;
     outermost = outer && !recursive_check(p.list, ID2SYM(recursive_key), 0);
 
     if (recursive_check(p.list, p.objid, pairid)) {
@@ -3714,11 +3718,7 @@
 	return (*func)(obj, arg, TRUE);
     }
     else {
-	VALUE result = Qundef;
 	p.func = func;
-	p.obj = obj;
-	p.pairid = pairid;
-	p.arg = arg;
 
 	if (outermost) {
 	    recursive_push(p.list, ID2SYM(recursive_key), 0);
@@ -3731,8 +3731,9 @@
 	else {
 	    result = exec_recursive_i(0, &p);
 	}
-	return result;
     }
+    *(volatile struct exec_recursive_params *)&p;
+    return result;
 }
 
 /*

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

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