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

ruby-changes:25147

From: ko1 <ko1@a...>
Date: Tue, 16 Oct 2012 06:35:53 +0900 (JST)
Subject: [ruby-changes:25147] ko1:r37199 (trunk): * vm_insnhelper.c (vm_call_method): disable CI_SET_FASTPATH() if

ko1	2012-10-16 06:35:29 +0900 (Tue, 16 Oct 2012)

  New Revision: 37199

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

  Log:
    * vm_insnhelper.c (vm_call_method): disable CI_SET_FASTPATH() if
      this method call needs splat argument because cahced functions
      (vm_call_attrset, vm_call_ivar, vm_call_cfunc_fast_(unary|binary))
      do not check an arity.
    * bootstraptest/test_method.rb: add a test to check an above issue.

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_method.rb
    trunk/vm_insnhelper.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37198)
+++ ChangeLog	(revision 37199)
@@ -1,3 +1,12 @@
+Tue Oct 16 06:29:18 2012  Koichi Sasada  <ko1@a...>
+
+	* vm_insnhelper.c (vm_call_method): disable CI_SET_FASTPATH() if
+	  this method call needs splat argument because cahced functions
+	  (vm_call_attrset, vm_call_ivar, vm_call_cfunc_fast_(unary|binary))
+	  do not check an arity.
+
+	* bootstraptest/test_method.rb: add a test to check an above issue.
+
 Tue Oct 16 06:15:44 2012  Koichi Sasada  <ko1@a...>
 
 	* method.h: introduce new method type VM_METHOD_TYPE_CFUNC_FAST.
Index: bootstraptest/test_method.rb
===================================================================
--- bootstraptest/test_method.rb	(revision 37198)
+++ bootstraptest/test_method.rb	(revision 37199)
@@ -1184,3 +1184,23 @@
   'ok'
 }, '[ruby-core:30534]'
 
+# should not cache when splat
+assert_equal 'ok', %q{
+  class C
+    attr_reader :a
+    def initialize
+      @a = 1
+    end
+  end
+
+  def m *args
+    C.new.a(*args)
+  end
+
+  m()
+  begin
+    m(1)
+  rescue ArgumentError
+    'ok'
+  end
+}
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 37198)
+++ vm_insnhelper.c	(revision 37199)
@@ -1523,13 +1523,13 @@
 	      }
 	      case VM_METHOD_TYPE_ATTRSET:{
 		rb_check_arity(ci->argc, 0, 1);
-		CI_SET_FASTPATH(ci, vm_call_attrset, enable_fastpath);
+		CI_SET_FASTPATH(ci, vm_call_attrset, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT));
 		val = vm_call_attrset(th, cfp, ci);
 		break;
 	      }
 	      case VM_METHOD_TYPE_IVAR:{
 		rb_check_arity(ci->argc, 0, 0);
-		CI_SET_FASTPATH(ci, vm_call_ivar, enable_fastpath);
+		CI_SET_FASTPATH(ci, vm_call_ivar, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT));
 		val = vm_call_ivar(th, cfp, ci);
 		break;
 	      }
@@ -1577,12 +1577,12 @@
 		switch (ci->me->def->body.cfunc.argc) {
 		  case 0:
 		    rb_check_arity(ci->argc, 0, 0);
-		    CI_SET_FASTPATH(ci, vm_call_cfunc_fast_unary, enable_fastpath);
+		    CI_SET_FASTPATH(ci, vm_call_cfunc_fast_unary, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT));
 		    val = vm_call_cfunc_fast_unary(th, cfp, ci);
 		    break;
 		  case 1:
 		    rb_check_arity(ci->argc, 0, 1);
-		    CI_SET_FASTPATH(ci, vm_call_cfunc_fast_binary, enable_fastpath);
+		    CI_SET_FASTPATH(ci, vm_call_cfunc_fast_binary, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT));
 		    val = vm_call_cfunc_fast_binary(th, cfp, ci);
 		    break;
 		  default:

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

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