ruby-changes:24900
From: nobu <ko1@a...>
Date: Wed, 12 Sep 2012 22:59:21 +0900 (JST)
Subject: [ruby-changes:24900] nobu:r36952 (trunk): vm_insnhelper.c: reuse VM stack
nobu 2012-09-12 22:59:10 +0900 (Wed, 12 Sep 2012) New Revision: 36952 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36952 Log: vm_insnhelper.c: reuse VM stack * vm_insnhelper.c (vm_method_missing, vm_call_method): reuse arguments on the VM stack and get rid of ALLOCA. Modified files: trunk/ChangeLog trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 36951) +++ ChangeLog (revision 36952) @@ -1,3 +1,8 @@ +Wed Sep 12 22:59:07 2012 Nobuyoshi Nakada <nobu@r...> + + * vm_insnhelper.c (vm_method_missing, vm_call_method): reuse arguments + on the VM stack and get rid of ALLOCA. + Wed Sep 12 22:45::00 2012 Zachary Scott <zzak@r...> * ext/pathname/lib/pathname.rb: Documentation for Pathname. Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 36951) +++ vm_insnhelper.c (revision 36952) @@ -473,27 +473,21 @@ return val; } -static inline void -vm_method_missing_args(rb_thread_t *th, VALUE *argv, - int num, const rb_block_t *blockptr, int opt) +static inline VALUE +vm_method_missing(rb_thread_t *th, rb_control_frame_t *const reg_cfp, + ID id, VALUE recv, + int num, const rb_block_t *blockptr, int opt) { - rb_control_frame_t * const reg_cfp = th->cfp; - MEMCPY(argv, STACK_ADDR_FROM_TOP(num + 1), VALUE, num + 1); + VALUE ret, *argv = STACK_ADDR_FROM_TOP(num + 1); + th->method_missing_reason = opt; th->passed_block = blockptr; + argv[0] = ID2SYM(id); + ret = rb_funcall2(recv, idMethodMissing, num + 1, argv); POPN(num + 1); + return ret; } -static inline VALUE -vm_method_missing(rb_thread_t *th, ID id, VALUE recv, - int num, const rb_block_t *blockptr, int opt) -{ - VALUE *argv = ALLOCA_N(VALUE, num + 1); - vm_method_missing_args(th, argv, num, blockptr, opt); - argv[0] = ID2SYM(id); - return rb_funcall2(recv, idMethodMissing, num + 1, argv); -} - static inline void vm_setup_method(rb_thread_t *th, rb_control_frame_t *cfp, VALUE recv, int argc, const rb_block_t *blockptr, VALUE flag, @@ -682,11 +676,11 @@ if (flag & VM_CALL_VCALL_BIT) { stat |= NOEX_VCALL; } - val = vm_method_missing(th, id, recv, num, blockptr, stat); + val = vm_method_missing(th, cfp, id, recv, num, blockptr, stat); } else if (!(flag & VM_CALL_OPT_SEND_BIT) && (me->flag & NOEX_MASK) & NOEX_PROTECTED) { if (!rb_obj_is_kind_of(cfp->self, defined_class)) { - val = vm_method_missing(th, id, recv, num, blockptr, NOEX_PROTECTED); + val = vm_method_missing(th, cfp, id, recv, num, blockptr, NOEX_PROTECTED); } else { goto normal_method_dispatch; @@ -711,12 +705,12 @@ stat |= NOEX_SUPER; } if (id == idMethodMissing) { - VALUE *argv = ALLOCA_N(VALUE, num); - vm_method_missing_args(th, argv, num - 1, 0, stat); + rb_control_frame_t *reg_cfp = cfp; + VALUE *argv = STACK_ADDR_FROM_TOP(num); rb_raise_method_missing(th, num, argv, recv, stat); } else { - val = vm_method_missing(th, id, recv, num, blockptr, stat); + val = vm_method_missing(th, cfp, id, recv, num, blockptr, stat); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/