From f3c33344a4fb559e705d55a4f406d2b59f5d566b Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 9 Sep 2013 05:17:19 +0000 Subject: vm_insnhelper.c: debugging * vm_insnhelper.c (vm_method_cfunc_entry): check method type if debugging. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 5bcc8ed03f..7037111bdc 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1478,12 +1478,39 @@ vm_profile_show_result(void) #define VM_PROFILE_ATEXIT() #endif +static inline +const rb_method_cfunc_t * +vm_method_cfunc_entry(const rb_method_entry_t *me) +{ +#if VM_DEBUG_VERIFY_METHOD_CACHE + switch (me->def->type) { + case VM_METHOD_TYPE_CFUNC: + case VM_METHOD_TYPE_NOTIMPLEMENTED: + break; +# define METHOD_BUG(t) case VM_METHOD_TYPE_##t: rb_bug("wrong method type: " #t) + METHOD_BUG(ISEQ); + METHOD_BUG(ATTRSET); + METHOD_BUG(IVAR); + METHOD_BUG(BMETHOD); + METHOD_BUG(ZSUPER); + METHOD_BUG(UNDEF); + METHOD_BUG(OPTIMIZED); + METHOD_BUG(MISSING); + METHOD_BUG(REFINED); +# undef METHOD_BUG + default: + rb_bug("wrong method type: %d", me->def->type); + } +#endif + return &me->def->body.cfunc; +} + static VALUE vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci) { VALUE val; const rb_method_entry_t *me = ci->me; - const rb_method_cfunc_t *cfunc = &me->def->body.cfunc; + const rb_method_cfunc_t *cfunc = vm_method_cfunc_entry(me); int len = cfunc->argc; /* don't use `ci' after EXEC_EVENT_HOOK because ci can be override */ @@ -1523,7 +1550,7 @@ vm_call_cfunc_latter(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_ VALUE val; int argc = ci->argc; VALUE *argv = STACK_ADDR_FROM_TOP(argc); - const rb_method_cfunc_t *cfunc = &ci->me->def->body.cfunc; + const rb_method_cfunc_t *cfunc = vm_method_cfunc_entry(ci->me); th->passed_ci = ci; reg_cfp->sp -= argc + 1; @@ -1554,7 +1581,7 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci) { VALUE val; const rb_method_entry_t *me = ci->me; - int len = me->def->body.cfunc.argc; + int len = vm_method_cfunc_entry(me)->argc; VALUE recv = ci->recv; if (len >= 0) rb_check_arity(ci->argc, len, len); -- cgit v1.2.3