mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
imemo_fields: store owner object in RBasic.klass
It is much more convenient than storing the klass, especially when dealing with `object_id` as it allows to update the id2ref table without having to dereference the owner, which may be garbage at that point.
This commit is contained in:
parent
ad12db4b3d
commit
10aa4134d4
7 changed files with 62 additions and 38 deletions
13
shape.c
13
shape.c
|
@ -877,8 +877,17 @@ shape_get_next(rb_shape_t *shape, VALUE obj, ID id, bool emit_warnings)
|
|||
#endif
|
||||
|
||||
VALUE klass;
|
||||
if (IMEMO_TYPE_P(obj, imemo_fields)) { // HACK
|
||||
klass = CLASS_OF(obj);
|
||||
if (IMEMO_TYPE_P(obj, imemo_fields)) {
|
||||
VALUE owner = rb_imemo_fields_owner(obj);
|
||||
switch (BUILTIN_TYPE(owner)) {
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
klass = rb_singleton_class(owner);
|
||||
break;
|
||||
default:
|
||||
klass = rb_obj_class(owner);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
klass = rb_obj_class(obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue