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

ruby-changes:39969

From: ko1 <ko1@a...>
Date: Tue, 6 Oct 2015 06:34:49 +0900 (JST)
Subject: [ruby-changes:39969] ko1:r52050 (trunk): * proc.c: enable optimization of Proc#call.

ko1	2015-10-06 06:34:24 +0900 (Tue, 06 Oct 2015)

  New Revision: 52050

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

  Log:
    * proc.c: enable optimization of Proc#call.
      [Feature #11569]
    * NEWS: write about this optimization and incompatibilities.
    * test/ruby/test_backtrace.rb: catch up this fix.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/proc.c
    trunk/test/ruby/test_backtrace.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52049)
+++ ChangeLog	(revision 52050)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct  6 06:32:52 2015  Koichi Sasada  <ko1@a...>
+
+	* proc.c: enable optimization of Proc#call.
+	  [Feature #11569]
+
+	* NEWS: write about this optimization and incompatibilities.
+
+	* test/ruby/test_backtrace.rb: catch up this fix.
+
 Tue Oct  6 04:41:03 2015  Koichi Sasada  <ko1@a...>
 
 	* vm_insnhelper.c: solve goto spaghetti.
Index: proc.c
===================================================================
--- proc.c	(revision 52049)
+++ proc.c	(revision 52050)
@@ -733,7 +733,7 @@ rb_block_clear_env_self(VALUE proc) https://github.com/ruby/ruby/blob/trunk/proc.c#L733
  *     	from prog.rb:5:in `<main>'
  *
  */
-
+#if 0
 static VALUE
 proc_call(int argc, VALUE *argv, VALUE procval)
 {
@@ -759,6 +759,7 @@ proc_call(int argc, VALUE *argv, VALUE p https://github.com/ruby/ruby/blob/trunk/proc.c#L759
     RB_GC_GUARD(passed_procval);
     return vret;
 }
+#endif
 
 #if SIZEOF_LONG > SIZEOF_INT
 static inline int
@@ -2803,7 +2804,6 @@ Init_Proc(void) https://github.com/ruby/ruby/blob/trunk/proc.c#L2804
     rb_undef_alloc_func(rb_cProc);
     rb_define_singleton_method(rb_cProc, "new", rb_proc_s_new, -1);
 
-#if 0 /* incomplete. */
     rb_add_method(rb_cProc, rb_intern("call"), VM_METHOD_TYPE_OPTIMIZED,
 		  (void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
     rb_add_method(rb_cProc, rb_intern("[]"), VM_METHOD_TYPE_OPTIMIZED,
@@ -2812,12 +2812,7 @@ Init_Proc(void) https://github.com/ruby/ruby/blob/trunk/proc.c#L2812
 		  (void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
     rb_add_method(rb_cProc, rb_intern("yield"), VM_METHOD_TYPE_OPTIMIZED,
 		  (void *)OPTIMIZED_METHOD_TYPE_CALL, 0);
-#else
-    rb_define_method(rb_cProc, "call", proc_call, -1);
-    rb_define_method(rb_cProc, "[]", proc_call, -1);
-    rb_define_method(rb_cProc, "===", proc_call, -1);
-    rb_define_method(rb_cProc, "yield", proc_call, -1);
-#endif
+
     rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0);
     rb_define_method(rb_cProc, "arity", proc_arity, 0);
     rb_define_method(rb_cProc, "clone", proc_clone, 0);
Index: NEWS
===================================================================
--- NEWS	(revision 52049)
+++ NEWS	(revision 52050)
@@ -65,6 +65,12 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L65
     true when the receiver is positive and negative respectively.
     [Feature #11151]
 
+* Proc
+
+  * Proc#call (and also #[], #===, #yield) are optimized.
+    Backtrace doesn't show each methods (show block lines directly).
+    TracePoint also ignore these calls. [Feature #11569]
+
 * Thread
   * Thread#name, Thread#name= are added to handle thread names [Feature #11251]
 
Index: test/ruby/test_backtrace.rb
===================================================================
--- test/ruby/test_backtrace.rb	(revision 52049)
+++ test/ruby/test_backtrace.rb	(revision 52050)
@@ -79,10 +79,10 @@ class TestBacktrace < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_backtrace.rb#L79
         cs << caller(5)
       }.call
     }.resume
-    assert_equal(3, cs[0].size)
-    assert_equal(2, cs[1].size)
-    assert_equal(1, cs[2].size)
-    assert_equal(0, cs[3].size)
+    assert_equal(2, cs[0].size)
+    assert_equal(1, cs[1].size)
+    assert_equal(0, cs[2].size)
+    assert_equal(nil, cs[3])
     assert_equal(nil, cs[4])
 
     #

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

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