ruby-changes:57581
From: Yusuke <ko1@a...>
Date: Fri, 6 Sep 2019 10:00:09 +0900 (JST)
Subject: [ruby-changes:57581] 030b8e5edf (master): Set calling->kw_splat = 1 in vm_caller_setup_arg_kw
https://git.ruby-lang.org/ruby.git/commit/?id=030b8e5edf From 030b8e5edf1056e59c37bc52ed6f4deca7e8ac41 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Thu, 5 Sep 2019 12:28:36 +0900 Subject: Set calling->kw_splat = 1 in vm_caller_setup_arg_kw There are two styles that argv contains keyword arguments: one is VM_CALL_KWARG which contains value elements in argv (to avoid a hash object creation if possible), and the other is VM_CALL_KW_SPLAT which contains one last hash in argv. vm_caller_setup_arg_kw translates argv from the VM_CALL_KWARG style to the VM_CALL_KW_SPLAT style. `calling->kw_splat` means that argv is the VM_CALL_KW_SPLAT style. So, instead of setting `calling->kw_splat` at many places, it would be better to do so when vm_caller_setup_arg_kw is called. diff --git a/vm_args.c b/vm_args.c index a80100e..add5dd5 100644 --- a/vm_args.c +++ b/vm_args.c @@ -985,6 +985,7 @@ vm_caller_setup_arg_kw(rb_control_frame_t *cfp, struct rb_calling_info *calling, https://github.com/ruby/ruby/blob/trunk/vm_args.c#L985 cfp->sp -= kw_len - 1; calling->argc -= kw_len - 1; + calling->kw_splat = 1; } static VALUE diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 593804b..5730007 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2255,7 +2255,7 @@ vm_call_bmethod_body(rb_execution_context_t *ec, struct rb_calling_info *calling https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2255 /* control block frame */ GetProcPtr(cc->me->def->body.bmethod.proc, proc); - val = rb_vm_invoke_bmethod(ec, proc, calling->recv, calling->argc, argv, calling->kw_splat || (ci->flag & (VM_CALL_KWARG | VM_CALL_KW_SPLAT)), calling->block_handler, cc->me); + val = rb_vm_invoke_bmethod(ec, proc, calling->recv, calling->argc, argv, calling->kw_splat, calling->block_handler, cc->me); return val; } @@ -2412,8 +2412,7 @@ vm_call_method_missing(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2412 CALLER_SETUP_ARG(reg_cfp, calling, orig_ci, 0); argc = calling->argc+1; - ci_entry.flag = VM_CALL_FCALL | VM_CALL_OPT_SEND | - (orig_ci->flag & (VM_CALL_KW_SPLAT |VM_CALL_KWARG) ? VM_CALL_KW_SPLAT : 0); + ci_entry.flag = VM_CALL_FCALL | VM_CALL_OPT_SEND | (orig_ci->flag & VM_CALL_KW_SPLAT); ci_entry.mid = idMethodMissing; ci_entry.orig_argc = argc; ci = &ci_entry; @@ -3016,7 +3015,7 @@ vm_invoke_symbol_block(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3015 int argc; CALLER_SETUP_ARG(ec->cfp, calling, ci, 0); argc = calling->argc; - val = vm_yield_with_symbol(ec, symbol, argc, STACK_ADDR_FROM_TOP(argc), calling->kw_splat || (ci->flag & (VM_CALL_KWARG | VM_CALL_KW_SPLAT)), calling->block_handler); + val = vm_yield_with_symbol(ec, symbol, argc, STACK_ADDR_FROM_TOP(argc), calling->kw_splat, calling->block_handler); POPN(argc); return val; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/