aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.h
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-12-17 15:49:41 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-12-18 12:52:28 +0900
commitf054f11a38f66af17a0aed8e0d2d46731eaab27d (patch)
treed85000f9e73f282d6e79056415e33c99eb6d86a0 /vm_insnhelper.h
parent77e3078ede833e86a1ee0e2ce745b15e892bdbf6 (diff)
downloadruby-f054f11a38f66af17a0aed8e0d2d46731eaab27d.tar.gz
per-method serial number
Methods and their definitions can be allocated/deallocated on-the-fly. One pathological situation is when a method is deallocated then another one is allocated immediately after that. Address of those old/new method entries/definitions can be the same then, depending on underlying malloc/free implementation. So pointer comparison is insufficient. We have to check the contents. To do so we introduce def->method_serial, which is an integer unique to that specific method definition. PS: Note that method_serial being uintptr_t rather than rb_serial_t is intentional. This is because rb_serial_t can be bigger than a pointer on a 32bit system (rb_serial_t is at least 64bit). In order to preserve old packing of struct rb_call_cache, rb_serial_t is inappropriate.
Diffstat (limited to 'vm_insnhelper.h')
-rw-r--r--vm_insnhelper.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index 1a3dbc0326..18a670bf14 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -132,7 +132,7 @@ static inline void
CC_SET_ME(CALL_CACHE cc, const rb_callable_method_entry_t *me)
{
cc->me = me;
- cc->def = me ? me->def : NULL;
+ cc->method_serial = me ? me->def->method_serial : 0;
}
#define GET_BLOCK_HANDLER() (GET_LEP()[VM_ENV_DATA_INDEX_SPECVAL])