Skip to content
  • 卜部昌平's avatar
    f054f11a
    per-method serial number · f054f11a
    卜部昌平 authored
    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.
    f054f11a
    per-method serial number
    卜部昌平 authored
    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.
Loading