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
|
@ -546,7 +546,7 @@ RCLASS_WRITABLE_ENSURE_FIELDS_OBJ(VALUE obj)
|
|||
RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
|
||||
rb_classext_t *ext = RCLASS_EXT_WRITABLE(obj);
|
||||
if (!ext->fields_obj) {
|
||||
RB_OBJ_WRITE(obj, &ext->fields_obj, rb_imemo_fields_new(rb_singleton_class(obj), 1));
|
||||
RB_OBJ_WRITE(obj, &ext->fields_obj, rb_imemo_fields_new(obj, 1));
|
||||
}
|
||||
return ext->fields_obj;
|
||||
}
|
||||
|
|
|
@ -273,12 +273,18 @@ struct rb_fields {
|
|||
#define OBJ_FIELD_EXTERNAL IMEMO_FL_USER0
|
||||
#define IMEMO_OBJ_FIELDS(fields) ((struct rb_fields *)fields)
|
||||
|
||||
VALUE rb_imemo_fields_new(VALUE klass, size_t capa);
|
||||
VALUE rb_imemo_fields_new_complex(VALUE klass, size_t capa);
|
||||
VALUE rb_imemo_fields_new_complex_tbl(VALUE klass, st_table *tbl);
|
||||
VALUE rb_imemo_fields_new(VALUE owner, size_t capa);
|
||||
VALUE rb_imemo_fields_new_complex(VALUE owner, size_t capa);
|
||||
VALUE rb_imemo_fields_new_complex_tbl(VALUE owner, st_table *tbl);
|
||||
VALUE rb_imemo_fields_clone(VALUE fields_obj);
|
||||
void rb_imemo_fields_clear(VALUE fields_obj);
|
||||
|
||||
static inline VALUE
|
||||
rb_imemo_fields_owner(VALUE fields_obj)
|
||||
{
|
||||
return CLASS_OF(fields_obj);
|
||||
}
|
||||
|
||||
static inline VALUE *
|
||||
rb_imemo_fields_ptr(VALUE obj_fields)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue