diff options
author | 卜部昌平 <[email protected]> | 2019-12-17 15:49:41 +0900 |
---|---|---|
committer | 卜部昌平 <[email protected]> | 2019-12-18 12:52:28 +0900 |
commit | f054f11a38f66af17a0aed8e0d2d46731eaab27d (patch) | |
tree | d85000f9e73f282d6e79056415e33c99eb6d86a0 /internal.h | |
parent | 77e3078ede833e86a1ee0e2ce745b15e892bdbf6 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2759
Diffstat (limited to 'internal.h')
-rw-r--r-- | internal.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/internal.h b/internal.h index fe2b028f47..c35e3bdb6f 100644 --- a/internal.h +++ b/internal.h @@ -2350,7 +2350,7 @@ struct rb_call_cache { (CACHELINE - sizeof(rb_serial_t) /* method_state */ - sizeof(struct rb_callable_method_entry_struct *) /* me */ - - sizeof(struct rb_callable_method_definition_struct *) /* def */ + - sizeof(uintptr_t) /* method_serial */ - sizeof(enum method_missing_reason) /* aux */ - sizeof(VALUE (*)( /* call */ struct rb_execution_context_struct *e, @@ -2362,7 +2362,7 @@ struct rb_call_cache { /* inline cache: values */ const struct rb_callable_method_entry_struct *me; - const struct rb_method_definition_struct *def; + uintptr_t method_serial; /* me->def->method_serial */ VALUE (*call)(struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, |