Project

General

Profile

Bug #10368 » 0001-add-blockprocval-to-rb_block_t.patch

ktsj (Kazuki Tsujimoto), 10/11/2014 10:56 AM

View differences:

proc.c
bind = ptr;
RUBY_MARK_UNLESS_NULL(bind->env);
RUBY_MARK_UNLESS_NULL(bind->path);
RUBY_MARK_UNLESS_NULL(bind->blockprocval);
}
RUBY_MARK_LEAVE("binding");
}
......
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
};
static VALUE
binding_alloc(VALUE klass)
VALUE
rb_binding_alloc(VALUE klass)
{
VALUE obj;
rb_binding_t *bind;
......
static VALUE
binding_dup(VALUE self)
{
VALUE bindval = binding_alloc(rb_cBinding);
VALUE bindval = rb_binding_alloc(rb_cBinding);
rb_binding_t *src, *dst;
GetBindingPtr(self, src);
GetBindingPtr(bindval, dst);
dst->env = src->env;
dst->path = src->path;
dst->blockprocval = src->blockprocval;
dst->first_lineno = src->first_lineno;
return bindval;
}
......
VALUE
rb_binding_new_with_cfp(rb_thread_t *th, const rb_control_frame_t *src_cfp)
{
rb_control_frame_t *cfp = rb_vm_get_binding_creatable_next_cfp(th, src_cfp);
rb_control_frame_t *ruby_level_cfp = rb_vm_get_ruby_level_next_cfp(th, src_cfp);
VALUE bindval, envval;
rb_binding_t *bind;
if (cfp == 0 || ruby_level_cfp == 0) {
rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber.");
}
while (1) {
envval = rb_vm_make_env_object(th, cfp);
if (cfp == ruby_level_cfp) {
break;
}
cfp = rb_vm_get_binding_creatable_next_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
}
bindval = binding_alloc(rb_cBinding);
GetBindingPtr(bindval, bind);
bind->env = envval;
bind->path = ruby_level_cfp->iseq->location.path;
bind->first_lineno = rb_vm_get_sourceline(ruby_level_cfp);
return bindval;
return rb_vm_make_binding(th, src_cfp);
}
VALUE
......
}
}
bindval = binding_alloc(rb_cBinding);
bindval = rb_binding_alloc(rb_cBinding);
GetBindingPtr(bindval, bind);
bind->env = proc->envval;
bind->blockprocval = proc->blockprocval;
if (RUBY_VM_NORMAL_ISEQ_P(proc->block.iseq)) {
bind->path = proc->block.iseq->location.path;
bind->first_lineno = FIX2INT(rb_iseq_first_lineno(proc->block.iseq->self));
vm.c
return procval;
}
/* Binding */
VALUE
rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp)
{
rb_control_frame_t *cfp = rb_vm_get_binding_creatable_next_cfp(th, src_cfp);
rb_control_frame_t *ruby_level_cfp = rb_vm_get_ruby_level_next_cfp(th, src_cfp);
VALUE bindval, envval;
rb_binding_t *bind;
VALUE blockprocval = 0;
if (cfp == 0 || ruby_level_cfp == 0) {
rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber.");
}
while (1) {
envval = vm_make_env_object(th, cfp, &blockprocval);
if (cfp == ruby_level_cfp) {
break;
}
cfp = rb_vm_get_binding_creatable_next_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
}
bindval = rb_binding_alloc(rb_cBinding);
GetBindingPtr(bindval, bind);
bind->env = envval;
bind->path = ruby_level_cfp->iseq->location.path;
bind->blockprocval = blockprocval;
bind->first_lineno = rb_vm_get_sourceline(ruby_level_cfp);
return bindval;
}
VALUE *
rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
{
vm_core.h
typedef struct {
VALUE env;
VALUE path;
VALUE blockprocval; /* for GC mark */
unsigned short first_lineno;
} rb_binding_t;
......
/* VM related object allocate functions */
VALUE rb_thread_alloc(VALUE klass);
VALUE rb_proc_wrap(VALUE klass, rb_proc_t *); /* may use with rb_proc_alloc */
VALUE rb_binding_alloc(VALUE klass);
/* for debug */
extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
......
VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc,
int argc, const VALUE *argv, const rb_block_t *blockptr);
VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass);
VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp);
VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
VALUE rb_vm_env_local_variables(VALUE envval);
VALUE rb_binding_new_with_cfp(rb_thread_t *th, const rb_control_frame_t *src_cfp);
(1-1/2)