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

ruby-changes:32102

From: nobu <ko1@a...>
Date: Sat, 14 Dec 2013 00:22:25 +0900 (JST)
Subject: [ruby-changes:32102] nobu:r44181 (trunk): thread.c: reduce tags and stack

nobu	2013-12-14 00:22:18 +0900 (Sat, 14 Dec 2013)

  New Revision: 44181

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

  Log:
    thread.c: reduce tags and stack
    
    * thread.c: (exec_recursive): use rb_catch_protect() instead of
      rb_catch_obj() and PUSH_TAG(), and reduce pushing tags and
      machine stack usage.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44180)
+++ ChangeLog	(revision 44181)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Dec 14 00:22:16 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c: (exec_recursive): use rb_catch_protect() instead of
+	  rb_catch_obj() and PUSH_TAG(), and reduce pushing tags and
+	  machine stack usage.
+
 Sat Dec 14 00:18:08 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* proc.c (mnew_from_me): achieve the original defined_class from
Index: thread.c
===================================================================
--- thread.c	(revision 44180)
+++ thread.c	(revision 44181)
@@ -4880,19 +4880,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L4880
 exec_recursive_i(RB_BLOCK_CALL_FUNC_ARGLIST(tag, data))
 {
     struct exec_recursive_params *p = (void *)data;
-    VALUE result = Qundef;
-    int state;
-
-    recursive_push(p->list, p->objid, p->pairid);
-    PUSH_TAG();
-    if ((state = EXEC_TAG()) == 0) {
-	result = (*p->func)(p->obj, p->arg, FALSE);
-    }
-    POP_TAG();
-    recursive_pop(p->list, p->objid, p->pairid);
-    if (state)
-	JUMP_TAG(state);
-    return result;
+    return (*p->func)(p->obj, p->arg, FALSE);
 }
 
 /*
@@ -4926,18 +4914,30 @@ exec_recursive(VALUE (*func) (VALUE, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L4914
 	return (*func)(obj, arg, TRUE);
     }
     else {
+	int state;
+
 	p.func = func;
 
 	if (outermost) {
 	    recursive_push(p.list, ID2SYM(recursive_key), 0);
-	    result = rb_catch_obj(p.list, exec_recursive_i, (VALUE)&p);
+	    recursive_push(p.list, p.objid, p.pairid);
+	    result = rb_catch_protect(p.list, exec_recursive_i, (VALUE)&p, &state);
+	    recursive_pop(p.list, p.objid, p.pairid);
 	    recursive_pop(p.list, ID2SYM(recursive_key), 0);
+	    if (state) JUMP_TAG(state);
 	    if (result == p.list) {
 		result = (*func)(obj, arg, TRUE);
 	    }
 	}
 	else {
-	    result = exec_recursive_i(0, (VALUE)&p, 0, 0, Qnil);
+	    recursive_push(p.list, p.objid, p.pairid);
+	    PUSH_TAG();
+	    if ((state = EXEC_TAG()) == 0) {
+		result = (*func)(obj, arg, FALSE);
+	    }
+	    POP_TAG();
+	    recursive_pop(p.list, p.objid, p.pairid);
+	    if (state) JUMP_TAG(state);
 	}
     }
     *(volatile struct exec_recursive_params *)&p;

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

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