summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-30 09:08:10 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-30 09:08:10 +0000
commitba6b0acdb6c371f9f7150bed6f555c7f34fe3781 (patch)
tree026b57bb537b2eeb5fbe3ae6786cf6988df3d4e3 /vm.c
parent9873f990ae3ffcd722f82ca19bdbab8f10a375aa (diff)
* vm.c (invoke_block_from_c): add VM_FRAME_FLAG_BMETHOD to record
it is bmethod frame. * vm.c (vm_exec): invoke RUBY_EVENT_RETURN event if rollbacked frame is VM_FRAME_FLAG_BMETHOD. [Bug #9759] * test/ruby/test_settracefunc.rb: add a test for TracePoint/set_trace_func. * vm_core.h: renmae rb_thread_t::passed_me to rb_thread_t::passed_bmethod_me to clarify the usage. * vm_insnhelper.c (vm_call_bmethod_body): use renamed member. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/vm.c b/vm.c
index 1742cc5..82bf75b 100644
--- a/vm.c
+++ b/vm.c
@@ -737,13 +737,24 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
opt_pc = vm_yield_setup_args(th, iseq, argc, cfp->sp, blockptr,
(type == VM_FRAME_MAGIC_LAMBDA) ? splattable+1 : 0);
- vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH,
- self, defined_class,
- VM_ENVVAL_PREV_EP_PTR(block->ep),
- iseq->iseq_encoded + opt_pc,
- cfp->sp + arg_size, iseq->local_size - arg_size,
- th->passed_me, iseq->stack_max);
- th->passed_me = 0;
+ if (th->passed_bmethod_me != 0) {
+ /* bmethod */
+ vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_BMETHOD,
+ self, defined_class,
+ VM_ENVVAL_PREV_EP_PTR(block->ep),
+ iseq->iseq_encoded + opt_pc,
+ cfp->sp + arg_size, iseq->local_size - arg_size,
+ th->passed_bmethod_me, iseq->stack_max);
+ th->passed_bmethod_me = 0;
+ }
+ else {
+ vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH,
+ self, defined_class,
+ VM_ENVVAL_PREV_EP_PTR(block->ep),
+ iseq->iseq_encoded + opt_pc,
+ cfp->sp + arg_size, iseq->local_size - arg_size,
+ 0, iseq->stack_max);
+ }
if (cref) {
th->cfp->ep[-1] = (VALUE)cref;
@@ -1536,7 +1547,13 @@ vm_exec(rb_thread_t *th)
break;
case VM_FRAME_MAGIC_BLOCK:
case VM_FRAME_MAGIC_LAMBDA:
- EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
+ if (VM_FRAME_TYPE_BMETHOD_P(th->cfp)) {
+ EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
+ EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, th->cfp->me->called_id, th->cfp->me->klass, Qnil);
+ }
+ else {
+ EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
+ }
break;
case VM_FRAME_MAGIC_CLASS:
EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0, Qnil);