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:
nobu 2015-10-01 10:52:52 +00:00
Родитель de2c8c9dbc
Коммит c90550c251
3 изменённых файлов: 22 добавлений и 10 удалений

7
proc.c
Просмотреть файл

@ -596,6 +596,13 @@ proc_new(VALUE klass, int8_t is_lambda)
procval = block->proc;
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) {
return procval;
}

Просмотреть файл

@ -776,12 +776,21 @@ vm_caller_setup_arg_block(const rb_thread_t *th, rb_control_frame_t *reg_cfp,
proc = *(--reg_cfp->sp);
if (SYMBOL_P(proc) && rb_method_basic_definition_p(rb_cSymbol, idTo_proc)) {
calling->blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp);
calling->blockptr->iseq = (rb_iseq_t *)IFUNC_NEW(rb_sym_proc_call, SYM2ID(proc), 0);
calling->blockptr->proc = 0;
if (NIL_P(proc)) {
calling->blockptr = NULL;
}
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)) {
VALUE b;
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;
RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc;
}
else {
calling->blockptr = NULL;
}
}
else if (blockiseq != 0) { /* likely */
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;
VALUE val, arg, blockarg;
int lambda = block_proc_is_lambda(block->proc);
const rb_callable_method_entry_t *me = th->passed_bmethod_me;
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);
}
else if (argc == 0) {