From bb66691e7e205c5f04c62741f212db1a94388bb3 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 11 Apr 2017 04:17:45 +0000 Subject: vm_insnhelper.c: CHECK_CFP_CONSISTENCY * vm_insnhelper.c (CHECK_CFP_CONSISTENCY): make [BUG] messages consistent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_eval.c | 8 ++------ vm_insnhelper.c | 12 ++++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/vm_eval.c b/vm_eval.c index d820f628b5..ed9463da79 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -92,9 +92,7 @@ vm_call0_cfunc(rb_thread_t* th, struct rb_calling_info *calling, const struct rb th->passed_ci = 0; } else { - if (reg_cfp != th->cfp + 1) { - rb_bug("vm_call0_cfunc: cfp consistency error"); - } + CHECK_CFP_CONSISTENCY("vm_call0_cfunc"); VM_PROFILE_UP(C2C_POPF); rb_vm_pop_frame(th); } @@ -131,9 +129,7 @@ vm_call0_cfunc_with_frame(rb_thread_t* th, struct rb_calling_info *calling, cons VM_PROFILE_UP(C2C_CALL); val = (*cfunc->invoker)(cfunc->func, recv, argc, argv); - if (UNLIKELY(reg_cfp != th->cfp + 1)) { - rb_bug("vm_call0_cfunc_with_frame: cfp consistency error"); - } + CHECK_CFP_CONSISTENCY("vm_call0_cfunc_with_frame"); VM_PROFILE_UP(C2C_POPF); rb_vm_pop_frame(th); } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 21a358cb30..ae4d1b2a1b 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1715,6 +1715,10 @@ vm_profile_show_result(void) #define VM_PROFILE_ATEXIT() #endif +#define CHECK_CFP_CONSISTENCY(func) \ + LIKELY(reg_cfp == th->cfp + 1) ? (void) 0 : \ + rb_bug(func ": cfp consistency error (%p, %p)", reg_cfp, th->cfp+1) + static inline const rb_method_cfunc_t * vm_method_cfunc_entry(const rb_callable_method_entry_t *me) @@ -1768,9 +1772,7 @@ vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb VM_PROFILE_UP(R2C_CALL); val = (*cfunc->invoker)(cfunc->func, recv, argc, reg_cfp->sp + 1); - if (reg_cfp != th->cfp + 1) { - rb_bug("vm_call_cfunc - cfp consistency error"); - } + CHECK_CFP_CONSISTENCY("vm_call_cfunc"); rb_vm_pop_frame(th); @@ -1804,9 +1806,7 @@ vm_call_cfunc_latter(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_cal th->passed_ci = 0; } else { - 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); - } + CHECK_CFP_CONSISTENCY("vm_call_cfunc_latter"); vm_pop_frame(th, reg_cfp, reg_cfp->ep); VM_PROFILE_UP(R2C_POPF); } -- cgit v1.2.3