From f054f11a38f66af17a0aed8e0d2d46731eaab27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Tue, 17 Dec 2019 15:49:41 +0900 Subject: 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. --- method.h | 1 + 1 file changed, 1 insertion(+) (limited to 'method.h') diff --git a/method.h b/method.h index 14ffecc398..b26caaa92d 100644 --- a/method.h +++ b/method.h @@ -177,6 +177,7 @@ struct rb_method_definition_struct { } body; ID original_id; + uintptr_t method_serial; }; typedef struct rb_method_definition_struct rb_method_definition_t; -- cgit v1.2.3