ruby-changes:38487
From: nobu <ko1@a...>
Date: Thu, 21 May 2015 07:04:20 +0900 (JST)
Subject: [ruby-changes:38487] nobu:r50568 (trunk): vm.c: vm_invoke_bmethod
nobu 2015-05-21 07:03:06 +0900 (Thu, 21 May 2015) New Revision: 50568 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50568 Log: vm.c: vm_invoke_bmethod * vm.c (vm_invoke_bmethod): bmethod does not need EXEC_TAG as it does not set safe level. Modified files: trunk/vm.c trunk/vm_insnhelper.c Index: vm.c =================================================================== --- vm.c (revision 50567) +++ vm.c (revision 50568) @@ -116,6 +116,9 @@ static void vm_collect_usage_register(in https://github.com/ruby/ruby/blob/trunk/vm.c#L116 #endif static VALUE +vm_invoke_bmethod(rb_thread_t *th, rb_proc_t *proc, VALUE self, VALUE defined_class, + int argc, const VALUE *argv, const rb_block_t *blockptr); +static VALUE vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, VALUE defined_class, int argc, const VALUE *argv, const rb_block_t *blockptr); @@ -896,17 +899,13 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_ https://github.com/ruby/ruby/blob/trunk/vm.c#L899 TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { - if (!proc->is_from_method) { - th->safe_level = proc->safe_level; - } + th->safe_level = proc->safe_level; val = invoke_block_from_c(th, &proc->block, self, argc, argv, blockptr, 0, defined_class, 0); } TH_POP_TAG(); - if (!proc->is_from_method) { - th->safe_level = stored_safe; - } + th->safe_level = stored_safe; if (state) { JUMP_TAG(state); @@ -914,12 +913,26 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_ https://github.com/ruby/ruby/blob/trunk/vm.c#L913 return val; } +static VALUE +vm_invoke_bmethod(rb_thread_t *th, rb_proc_t *proc, VALUE self, VALUE defined_class, + int argc, const VALUE *argv, const rb_block_t *blockptr) +{ + return invoke_block_from_c(th, &proc->block, self, argc, argv, blockptr, 0, + defined_class, 0); +} + VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, int argc, const VALUE *argv, const rb_block_t *blockptr) { - return vm_invoke_proc(th, proc, proc->block.self, proc->block.klass, - argc, argv, blockptr); + VALUE self = proc->block.self; + VALUE defined_class = proc->block.klass; + if (proc->is_from_method) { + return vm_invoke_bmethod(th, proc, self, defined_class, argc, argv, blockptr); + } + else { + return vm_invoke_proc(th, proc, self, defined_class, argc, argv, blockptr); + } } /* special variable */ Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 50567) +++ vm_insnhelper.c (revision 50568) @@ -1539,7 +1539,7 @@ vm_call_bmethod_body(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1539 /* control block frame */ th->passed_bmethod_me = ci->me; GetProcPtr(ci->me->def->body.proc, proc); - val = vm_invoke_proc(th, proc, ci->recv, ci->defined_class, ci->argc, argv, ci->blockptr); + val = vm_invoke_bmethod(th, proc, ci->recv, ci->defined_class, ci->argc, argv, ci->blockptr); return val; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/