diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-09 05:17:19 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-09 05:17:19 +0000 |
commit | f3c33344a4fb559e705d55a4f406d2b59f5d566b (patch) | |
tree | 234d71ba562fa1ec6cdb69bb82ccd845f5a3320d /vm_insnhelper.c | |
parent | c2b4d38165ec2cd7d4946d62dc025cf4c6b78736 (diff) | |
download | ruby-f3c33344a4fb559e705d55a4f406d2b59f5d566b.tar.gz |
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
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 33 |
1 files changed, 30 insertions, 3 deletions
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); |