Project

General

Profile

Bug #11954 » invoke_bmethod.diff

shugo (Shugo Maeda), 01/08/2016 01:46 AM

View differences:

test/ruby/test_objectspace.rb
}
end
def test_finalizer_with_super
assert_in_out_err(["-e", <<-END], "", %w(:ok), [])
class A
def foo
end
end
class B < A
def foo
1.times { super }
end
end
class C
module M
end
FINALIZER = proc do
M.module_eval do
end
end
def define_finalizer
ObjectSpace.define_finalizer(self, FINALIZER)
end
end
class D
def foo
B.new.foo
end
end
C::M.singleton_class.send :define_method, :module_eval do |src, id, line|
end
GC.stress = true
10.times do
C.new.define_finalizer
D.new.foo
end
p :ok
END
end
def test_each_object
klass = Class.new
new_obj = klass.new
vm.c
}
static VALUE
invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const rb_block_t *block, int type, int opt_pc)
invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const rb_block_t *block, const rb_callable_method_entry_t *me, int type, int opt_pc)
{
/* bmethod */
int arg_size = iseq->body->param.size;
const rb_callable_method_entry_t *me = th->passed_bmethod_me;
VALUE ret;
th->passed_bmethod_me = NULL;
vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_BMETHOD, self,
VM_ENVVAL_PREV_EP_PTR(block->ep),
(VALUE)me, /* cref or method (TODO: can we ignore cref?) */
......
int i, opt_pc;
int type = block_proc_is_lambda(block->proc) ? VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK;
VALUE *sp = th->cfp->sp;
const rb_callable_method_entry_t *me = th->passed_bmethod_me;
th->passed_bmethod_me = NULL;
for (i=0; i<argc; i++) {
sp[i] = argv[i];
......
opt_pc = vm_yield_setup_args(th, iseq, argc, sp, blockptr,
(type == VM_FRAME_MAGIC_LAMBDA ? (splattable ? arg_setup_lambda : arg_setup_method) : arg_setup_block));
if (th->passed_bmethod_me == NULL) {
if (me == NULL) {
return invoke_block(th, iseq, self, block, cref, type, opt_pc);
}
else {
return invoke_bmethod(th, iseq, self, block, type, opt_pc);
return invoke_bmethod(th, iseq, self, block, me, type, opt_pc);
}
}
(2-2/2)