ruby-changes:53423
From: ko1 <ko1@a...>
Date: Fri, 9 Nov 2018 10:13:24 +0900 (JST)
Subject: [ruby-changes:53423] ko1:r65639 (trunk): There is a path to use bmethod with ifunc.
ko1 2018-11-09 10:13:20 +0900 (Fri, 09 Nov 2018) New Revision: 65639 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65639 Log: There is a path to use bmethod with ifunc. * vm_insnhelper.c (vm_yield_with_cfunc): use passed me as bmethod. We also need to set `VM_FRAME_FLAG_BMETHOD` if needed. Modified files: trunk/vm.c trunk/vm_insnhelper.c Index: vm.c =================================================================== --- vm.c (revision 65638) +++ vm.c (revision 65639) @@ -1087,7 +1087,7 @@ invoke_block_from_c_bh(rb_execution_cont https://github.com/ruby/ruby/blob/trunk/vm.c#L1087 case block_handler_type_ifunc: return vm_yield_with_cfunc(ec, VM_BH_TO_IFUNC_BLOCK(block_handler), VM_BH_TO_IFUNC_BLOCK(block_handler)->self, - argc, argv, passed_block_handler); + argc, argv, passed_block_handler, NULL); case block_handler_type_symbol: return vm_yield_with_symbol(ec, VM_BH_TO_SYMBOL(block_handler), argc, argv, passed_block_handler); @@ -1164,7 +1164,7 @@ invoke_block_from_c_proc(rb_execution_co https://github.com/ruby/ruby/blob/trunk/vm.c#L1164 case block_type_iseq: return invoke_iseq_block_from_c(ec, &block->as.captured, self, argc, argv, passed_block_handler, NULL, is_lambda, me); case block_type_ifunc: - return vm_yield_with_cfunc(ec, &block->as.captured, self, argc, argv, passed_block_handler); + return vm_yield_with_cfunc(ec, &block->as.captured, self, argc, argv, passed_block_handler, me); case block_type_symbol: return vm_yield_with_symbol(ec, block->as.symbol, argc, argv, passed_block_handler); case block_type_proc: Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 65638) +++ vm_insnhelper.c (revision 65639) @@ -2511,7 +2511,8 @@ block_proc_is_lambda(const VALUE procval https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2511 static VALUE vm_yield_with_cfunc(rb_execution_context_t *ec, const struct rb_captured_block *captured, - VALUE self, int argc, const VALUE *argv, VALUE block_handler) + VALUE self, int argc, const VALUE *argv, VALUE block_handler, + const rb_callable_method_entry_t *me) { int is_lambda = FALSE; /* TODO */ VALUE val, arg, blockarg; @@ -2530,10 +2531,11 @@ vm_yield_with_cfunc(rb_execution_context https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2531 blockarg = rb_vm_bh_to_procval(ec, block_handler); vm_push_frame(ec, (const rb_iseq_t *)captured->code.ifunc, - VM_FRAME_MAGIC_IFUNC | VM_FRAME_FLAG_CFRAME, + VM_FRAME_MAGIC_IFUNC | VM_FRAME_FLAG_CFRAME | + (me ? VM_FRAME_FLAG_BMETHOD : 0), self, VM_GUARDED_PREV_EP(captured->ep), - Qfalse, + (VALUE)me, 0, ec->cfp->sp, 0, 0); val = (*ifunc->func)(arg, ifunc->data, argc, argv, blockarg); rb_vm_pop_frame(ec); @@ -2680,7 +2682,7 @@ vm_invoke_ifunc_block(rb_execution_conte https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2682 int argc; CALLER_SETUP_ARG(ec->cfp, calling, ci); argc = calling->argc; - val = vm_yield_with_cfunc(ec, captured, captured->self, argc, STACK_ADDR_FROM_TOP(argc), calling->block_handler); + val = vm_yield_with_cfunc(ec, captured, captured->self, argc, STACK_ADDR_FROM_TOP(argc), calling->block_handler, NULL); POPN(argc); /* TODO: should put before C/yield? */ return val; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/