mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm_args.c: fix marking symbol ifunc
* vm_args.c (vm_caller_setup_arg_block): store new ifunc for symbol in control frame proc to be marked. * proc.c (proc_new), vm_insnhelper.c (vm_yield_with_cfunc): block->proc may be an ifunc now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
de2c8c9dbc
commit
c90550c251
3 changed files with 22 additions and 10 deletions
7
proc.c
7
proc.c
|
@ -596,6 +596,13 @@ proc_new(VALUE klass, int8_t is_lambda)
|
||||||
procval = block->proc;
|
procval = block->proc;
|
||||||
|
|
||||||
if (procval) {
|
if (procval) {
|
||||||
|
if (RUBY_VM_IFUNC_P(procval)) {
|
||||||
|
VALUE newprocval = rb_proc_alloc(klass);
|
||||||
|
rb_proc_t *proc = RTYPEDDATA_DATA(newprocval);
|
||||||
|
proc->block.iseq = (rb_iseq_t *)procval;
|
||||||
|
proc->block.proc = newprocval;
|
||||||
|
return newprocval;
|
||||||
|
}
|
||||||
if (RBASIC(procval)->klass == klass) {
|
if (RBASIC(procval)->klass == klass) {
|
||||||
return procval;
|
return procval;
|
||||||
}
|
}
|
||||||
|
|
22
vm_args.c
22
vm_args.c
|
@ -776,12 +776,21 @@ vm_caller_setup_arg_block(const rb_thread_t *th, rb_control_frame_t *reg_cfp,
|
||||||
|
|
||||||
proc = *(--reg_cfp->sp);
|
proc = *(--reg_cfp->sp);
|
||||||
|
|
||||||
if (SYMBOL_P(proc) && rb_method_basic_definition_p(rb_cSymbol, idTo_proc)) {
|
if (NIL_P(proc)) {
|
||||||
calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp);
|
calling->blockptr = NULL;
|
||||||
calling->blockptr->iseq = (rb_iseq_t *)IFUNC_NEW(rb_sym_proc_call, SYM2ID(proc), 0);
|
|
||||||
calling->blockptr->proc = 0;
|
|
||||||
}
|
}
|
||||||
else if (!NIL_P(proc)) {
|
else if (SYMBOL_P(proc) && rb_method_basic_definition_p(rb_cSymbol, idTo_proc)) {
|
||||||
|
calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp);
|
||||||
|
blockiseq = (rb_iseq_t *)IFUNC_NEW(rb_sym_proc_call, SYM2ID(proc), 0);
|
||||||
|
calling->blockptr->iseq = blockiseq;
|
||||||
|
calling->blockptr->proc = (VALUE)blockiseq;
|
||||||
|
}
|
||||||
|
else if (RUBY_VM_IFUNC_P(proc)) {
|
||||||
|
calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp);
|
||||||
|
calling->blockptr->iseq = (rb_iseq_t *)proc;
|
||||||
|
calling->blockptr->proc = proc;
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (!rb_obj_is_proc(proc)) {
|
if (!rb_obj_is_proc(proc)) {
|
||||||
VALUE b;
|
VALUE b;
|
||||||
b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
|
b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
|
||||||
|
@ -797,9 +806,6 @@ vm_caller_setup_arg_block(const rb_thread_t *th, rb_control_frame_t *reg_cfp,
|
||||||
calling->blockptr = &po->block;
|
calling->blockptr = &po->block;
|
||||||
RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc;
|
RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
calling->blockptr = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (blockiseq != 0) { /* likely */
|
else if (blockiseq != 0) { /* likely */
|
||||||
rb_block_t *blockptr = calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp);
|
rb_block_t *blockptr = calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp);
|
||||||
|
|
|
@ -2297,11 +2297,10 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block, VALUE self,
|
||||||
{
|
{
|
||||||
const struct vm_ifunc *ifunc = (struct vm_ifunc *)block->iseq;
|
const struct vm_ifunc *ifunc = (struct vm_ifunc *)block->iseq;
|
||||||
VALUE val, arg, blockarg;
|
VALUE val, arg, blockarg;
|
||||||
int lambda = block_proc_is_lambda(block->proc);
|
|
||||||
const rb_callable_method_entry_t *me = th->passed_bmethod_me;
|
const rb_callable_method_entry_t *me = th->passed_bmethod_me;
|
||||||
th->passed_bmethod_me = NULL;
|
th->passed_bmethod_me = NULL;
|
||||||
|
|
||||||
if (lambda) {
|
if (!RUBY_VM_IFUNC_P(block->proc) && block_proc_is_lambda(block->proc)) {
|
||||||
arg = rb_ary_new4(argc, argv);
|
arg = rb_ary_new4(argc, argv);
|
||||||
}
|
}
|
||||||
else if (argc == 0) {
|
else if (argc == 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue