diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-03 14:21:54 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-09 09:52:46 +0900 |
commit | 877238f2d3522381f184d44b308f6e3b68367c56 (patch) | |
tree | bf3a5f843d6e18cf5238fbc449e6e75e6fb8ca65 | |
parent | 42a2fa3b175b6420a23f22441179521b4193ddd7 (diff) |
check_cfunc: add assertions
For debug. Must not change generated binary unless VM_ASSERT is on.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3179
-rw-r--r-- | vm_insnhelper.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index f8936b33c5..0774217507 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1653,12 +1653,19 @@ vm_search_method(VALUE cd_owner, struct rb_call_data *cd, VALUE recv) static inline int check_cfunc(const rb_callable_method_entry_t *me, VALUE (*func)()) { - if (me && me->def->type == VM_METHOD_TYPE_CFUNC && - me->def->body.cfunc.func == func) { - return 1; + if (! me) { + return false; } else { - return 0; + VM_ASSERT(IMEMO_TYPE_P(me, imemo_ment)); + VM_ASSERT(callable_method_entry_p(me)); + VM_ASSERT(me->def); + if (me->def->type != VM_METHOD_TYPE_CFUNC) { + return false; + } + else { + return me->def->body.cfunc.func == func; + } } } |