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

ruby-changes:33667

From: usa <ko1@a...>
Date: Wed, 30 Apr 2014 16:10:02 +0900 (JST)
Subject: [ruby-changes:33667] usa:r45748 (ruby_2_0_0): merge revision(s) 45320, 45321: [Backport #9622]

usa	2014-04-30 16:09:56 +0900 (Wed, 30 Apr 2014)

  New Revision: 45748

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

  Log:
    merge revision(s) 45320,45321: [Backport #9622]
    
    * vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an
      inline function.
    
    * vm_insnhelper.c (vm_callee_setup_arg): disable fastpath if splat
      argument, since argc may differ for each calls.
      [ruby-core:61422] [Bug #9622]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/test/ruby/test_call.rb
    branches/ruby_2_0_0/version.h
    branches/ruby_2_0_0/vm_insnhelper.c
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 45747)
+++ ruby_2_0_0/ChangeLog	(revision 45748)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Wed Apr 30 16:09:18 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an
+	  inline function.
+
 Wed Apr 30 15:20:44 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/delegate.rb (SimpleDelegator#__getobj__): target object must be set.
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 45747)
+++ ruby_2_0_0/version.h	(revision 45748)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-04-30"
-#define RUBY_PATCHLEVEL 468
+#define RUBY_PATCHLEVEL 469
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 4
Index: ruby_2_0_0/vm_insnhelper.c
===================================================================
--- ruby_2_0_0/vm_insnhelper.c	(revision 45747)
+++ ruby_2_0_0/vm_insnhelper.c	(revision 45748)
@@ -1231,23 +1231,33 @@ static VALUE vm_call_iseq_setup_2(rb_thr https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_insnhelper.c#L1231
 static inline VALUE vm_call_iseq_setup_normal(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci);
 static inline VALUE vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci);
 
-#define VM_CALLEE_SETUP_ARG(th, ci, iseq, argv, is_lambda) \
-    if (LIKELY((iseq)->arg_simple & 0x01)) { \
-	/* simple check */ \
-	if ((ci)->argc != (iseq)->argc) { \
-	    argument_error((iseq), ((ci)->argc), (iseq)->argc, (iseq)->argc); \
-	} \
-	(ci)->aux.opt_pc = 0; \
-	CI_SET_FASTPATH((ci), UNLIKELY((ci)->flag & VM_CALL_TAILCALL) ? vm_call_iseq_setup_tailcall : vm_call_iseq_setup_normal, !(is_lambda) && !((ci)->me->flag & NOEX_PROTECTED)); \
-    } \
-    else { \
-	(ci)->aux.opt_pc = vm_callee_setup_arg_complex((th), (ci), (iseq), (argv)); \
+static inline void
+vm_callee_setup_arg(rb_thread_t *th, rb_call_info_t *ci, const rb_iseq_t *iseq,
+		    VALUE *argv, int is_lambda)
+{
+    if (LIKELY(iseq->arg_simple & 0x01)) {
+	/* simple check */
+	if (ci->argc != iseq->argc) {
+	    argument_error(iseq, ci->argc, iseq->argc, iseq->argc);
+	}
+	ci->aux.opt_pc = 0;
+	CI_SET_FASTPATH(ci,
+			(UNLIKELY(ci->flag & VM_CALL_TAILCALL) ?
+			 vm_call_iseq_setup_tailcall :
+			 vm_call_iseq_setup_normal),
+			(!is_lambda &&
+			 !(ci->flag & VM_CALL_ARGS_SPLAT) && /* argc may differ for each calls */
+			 !(ci->me->flag & NOEX_PROTECTED)));
+    }
+    else {
+	ci->aux.opt_pc = vm_callee_setup_arg_complex(th, ci, iseq, argv);
     }
+}
 
 static VALUE
 vm_call_iseq_setup(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
 {
-    VM_CALLEE_SETUP_ARG(th, ci, ci->me->def->body.iseq, cfp->sp - ci->argc, 0);
+    vm_callee_setup_arg(th, ci, ci->me->def->body.iseq, cfp->sp - ci->argc, 0);
     return vm_call_iseq_setup_2(th, cfp, ci);
 }
 
@@ -2303,7 +2313,7 @@ vm_yield_setup_args(rb_thread_t * const https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_insnhelper.c#L2313
 	ci_entry.flag = 0;
 	ci_entry.argc = argc;
 	ci_entry.blockptr = (rb_block_t *)blockptr;
-	VM_CALLEE_SETUP_ARG(th, &ci_entry, iseq, argv, 1);
+	vm_callee_setup_arg(th, &ci_entry, iseq, argv, 1);
 	return ci_entry.aux.opt_pc;
     }
     else {
Index: ruby_2_0_0/test/ruby/test_call.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_call.rb	(revision 45747)
+++ ruby_2_0_0/test/ruby/test_call.rb	(revision 45748)
@@ -16,4 +16,19 @@ class TestCall < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_call.rb#L16
     assert_equal([1, 2, 3, 4], aaa(1, 2, 3, 4))
     assert_equal([1, 2, 3, 4], aaa(1, *[2, 3, 4]))
   end
+
+  def test_callinfo
+    bug9622 = '[ruby-core:61422] [Bug #9622]'
+    o = Class.new do
+      def foo(*args)
+        bar(:foo, *args)
+      end
+      def bar(name)
+        name
+      end
+    end.new
+    e = assert_raise(ArgumentError) {o.foo(100)}
+    assert_nothing_raised(ArgumentError) {o.foo}
+    assert_raise_with_message(ArgumentError, e.message, bug9622) {o.foo(100)}
+  end
 end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45320-45321


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

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