Project

General

Profile

Backport #8531 » fix-ifunc-block.patch

ktsj (Kazuki Tsujimoto), 06/16/2013 03:33 AM

View differences:

include/ruby/ruby.h
#define rb_funcall2 rb_funcallv
#define rb_funcall3 rb_funcallv_public
VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE*, VALUE);
int rb_scan_args(int, const VALUE*, const char*, ...);
VALUE rb_call_super(int, const VALUE*);
string.c
}
static VALUE
sym_call(VALUE args, VALUE sym, int argc, VALUE *argv)
sym_call(VALUE args, VALUE sym, int argc, VALUE *argv, VALUE pass_procval)
{
VALUE obj;
......
rb_raise(rb_eArgError, "no receiver given");
}
obj = argv[0];
return rb_funcall_passing_block(obj, (ID)sym, argc - 1, argv + 1);
return rb_funcall_with_block(obj, (ID)sym, argc - 1, argv + 1, pass_procval);
}
/*
vm_eval.c
return rb_call(recv, mid, argc, argv, CALL_PUBLIC);
}
VALUE
rb_funcall_with_block(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE pass_procval)
{
if (!NIL_P(pass_procval)) {
rb_thread_t *th = GET_THREAD();
rb_block_t *block = 0;
rb_proc_t *pass_proc;
GetProcPtr(pass_procval, pass_proc);
block = &pass_proc->block;
th->passed_block = block;
}
return rb_call(recv, mid, argc, argv, CALL_PUBLIC);
}
static VALUE
send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope)
{
vm_insnhelper.c
NODE *ifunc = (NODE *) block->iseq;
VALUE val, arg, blockarg;
int lambda = block_proc_is_lambda(block->proc);
rb_control_frame_t *cfp;
if (lambda) {
arg = rb_ary_new4(argc, argv);
......
blockarg = Qnil;
}
cfp = vm_push_frame(th, (rb_iseq_t *)ifunc, VM_FRAME_MAGIC_IFUNC, self,
0, VM_ENVVAL_PREV_EP_PTR(block->ep), 0,
th->cfp->sp, 1, 0);
vm_push_frame(th, (rb_iseq_t *)ifunc, VM_FRAME_MAGIC_IFUNC, self,
0, VM_ENVVAL_PREV_EP_PTR(block->ep), 0,
th->cfp->sp, 1, 0);
if (blockargptr) {
VM_CF_LEP(cfp)[0] = VM_ENVVAL_BLOCK_PTR(blockargptr);
}
val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg);
th->cfp++;
    (1-1/1)