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

ruby-changes:14303

From: mame <ko1@a...>
Date: Sun, 20 Dec 2009 21:31:42 +0900 (JST)
Subject: [ruby-changes:14303] Ruby:r26128 (trunk): * vm_eval.c (rb_iterate): pass current block when the argument bl_proc

mame	2009-12-20 21:31:26 +0900 (Sun, 20 Dec 2009)

  New Revision: 26128

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

  Log:
    * vm_eval.c (rb_iterate): pass current block when the argument bl_proc
      is NULL.  This behavior can be used to make enumerator faster
      [ruby-dev:39874]
    
    * enumerator.c (enumerator_each): pass current block directly instead
      of trampoline block (enumerator_each_i).
    
    * io.c (argf_each_line, argf_each_byte, argf_each_char): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/enumerator.c
    trunk/io.c
    trunk/vm_eval.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26127)
+++ ChangeLog	(revision 26128)
@@ -1,3 +1,14 @@
+Sun Dec 20 21:26:05 2009  Yusuke Endoh  <mame@t...>
+
+	* vm_eval.c (rb_iterate): pass current block when the argument bl_proc
+	  is NULL.  This behavior can be used to make enumerator faster
+	  [ruby-dev:39874]
+
+	* enumerator.c (enumerator_each): pass current block directly instead
+	  of trampoline block (enumerator_each_i).
+
+	* io.c (argf_each_line, argf_each_byte, argf_each_char): ditto.
+
 Sat Dec 19 14:59:30 2009  Yukihiro Matsumoto  <matz@r...>
 
 	* gem_prelude.rb (Kernel#gem): should make gem private.  a patch
Index: enumerator.c
===================================================================
--- enumerator.c	(revision 26127)
+++ enumerator.c	(revision 26128)
@@ -330,12 +330,6 @@
 }
 
 static VALUE
-enumerator_each_i(VALUE v, VALUE enum_obj, int argc, VALUE *argv)
-{
-    return rb_yield_values2(argc, argv);
-}
-
-static VALUE
 enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
 {
     struct enumerator *ptr;
@@ -473,7 +467,7 @@
 enumerator_each(VALUE obj)
 {
     if (!rb_block_given_p()) return obj;
-    return enumerator_block_call(obj, enumerator_each_i, obj);
+    return enumerator_block_call(obj, 0, obj);
 }
 
 static VALUE
Index: io.c
===================================================================
--- io.c	(revision 26127)
+++ io.c	(revision 26128)
@@ -9148,7 +9148,7 @@
     RETURN_ENUMERATOR(argf, argc, argv);
     for (;;) {
 	if (!next_argv()) return argf;
-	rb_block_call(ARGF.current_file, rb_intern("each_line"), argc, argv, rb_yield, 0);
+	rb_block_call(ARGF.current_file, rb_intern("each_line"), argc, argv, 0, 0);
 	ARGF.next_p = 1;
     }
 }
@@ -9182,7 +9182,7 @@
     RETURN_ENUMERATOR(argf, 0, 0);
     for (;;) {
 	if (!next_argv()) return argf;
-	rb_block_call(ARGF.current_file, rb_intern("each_byte"), 0, 0, rb_yield, 0);
+	rb_block_call(ARGF.current_file, rb_intern("each_byte"), 0, 0, 0, 0);
 	ARGF.next_p = 1;
     }
 }
@@ -9212,7 +9212,7 @@
     RETURN_ENUMERATOR(argf, 0, 0);
     for (;;) {
 	if (!next_argv()) return argf;
-	rb_block_call(ARGF.current_file, rb_intern("each_char"), 0, 0, rb_yield, 0);
+	rb_block_call(ARGF.current_file, rb_intern("each_char"), 0, 0, 0, 0);
 	ARGF.next_p = 1;
     }
 }
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 26127)
+++ vm_eval.c	(revision 26128)
@@ -820,20 +820,24 @@
 {
     int state;
     volatile VALUE retval = Qnil;
-    NODE *node = NEW_IFUNC(bl_proc, data2);
     rb_thread_t *th = GET_THREAD();
     rb_control_frame_t *volatile cfp = th->cfp;
+    rb_block_t *blockptr;
 
+    if (bl_proc) {
+	blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
+	blockptr->iseq = (void *)NEW_IFUNC(bl_proc, data2);
+	blockptr->proc = 0;
+    }
+    else {
+	blockptr = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
+    }
+    *(rb_block_t *volatile *)&blockptr = blockptr;
     TH_PUSH_TAG(th);
     state = TH_EXEC_TAG();
     if (state == 0) {
       iter_retry:
-	{
-	    rb_block_t *blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
-	    blockptr->iseq = (void *)node;
-	    blockptr->proc = 0;
-	    th->passed_block = blockptr;
-	}
+	th->passed_block = *(rb_block_t *volatile *)&blockptr;
 	retval = (*it_proc) (data1);
     }
     else {

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

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