From be5564a178ee453b7d6fedc7c312bec01e29dde2 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 26 Jul 2016 10:28:21 +0000 Subject: * vm_insnhelper.c: introduce rb_vm_pop_frame() and use it instead of setting rb_thread_t::cfp directly. * vm_insnhelper.c (vm_pop_frame): return the result of finish frame or not. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 3841801c41..40bc4b228c 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -207,14 +207,26 @@ vm_push_frame(rb_thread_t *th, return cfp; } -static inline void -vm_pop_frame(rb_thread_t *th) +static inline int +vm_pop_frame(rb_thread_t *th, rb_control_frame_t *cfp, const VALUE *ep /* we'll use ep soon */) { - th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); + if (VM_CHECK_MODE >= 4) rb_gc_verify_internal_consistency(); + if (VMDEBUG == 2) SDR(); - if (VMDEBUG == 2) { - SDR(); + th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); + + if (UNLIKELY(VM_FRAME_TYPE_FINISH_P(cfp))) { + return TRUE; } + else { + return FALSE; + } +} + +void +rb_vm_pop_frame(rb_thread_t *th) +{ + vm_pop_frame(th, th->cfp, th->cfp->ep); } /* method dispatch */ @@ -1425,7 +1437,8 @@ vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_ VALUE *sp_orig, *sp; VALUE finish_flag = VM_FRAME_TYPE_FINISH_P(cfp) ? VM_FRAME_FLAG_FINISH : 0; - cfp = th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); /* pop cf */ + vm_pop_frame(th, cfp, cfp->ep); + cfp = th->cfp; RUBY_VM_CHECK_INTS(th); @@ -1644,7 +1657,7 @@ vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb rb_bug("vm_call_cfunc - cfp consistency error"); } - vm_pop_frame(th); + rb_vm_pop_frame(th); EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->called_id, me->owner, val); RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->called_id); @@ -1679,7 +1692,7 @@ vm_call_cfunc_latter(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_cal if (UNLIKELY(reg_cfp != RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp))) { rb_bug("vm_call_cfunc_latter: cfp consistency error (%p, %p)", reg_cfp, th->cfp+1); } - vm_pop_frame(th); + vm_pop_frame(th, reg_cfp, reg_cfp->ep); VM_PROFILE_UP(R2C_POPF); } @@ -2338,8 +2351,8 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block, VALUE self, data = (VALUE)ifunc->data; } val = (*func)(arg, data, argc, argv, blockarg); + rb_vm_pop_frame(th); - th->cfp++; return val; } -- cgit v1.2.3