mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Rename imemo_class_fields
-> imemo_fields
This commit is contained in:
parent
4cb0205f51
commit
fb68721f63
Notes:
git
2025-06-17 13:28:18 +00:00
12 changed files with 73 additions and 73 deletions
2
class.c
2
class.c
|
@ -298,7 +298,7 @@ rb_class_duplicate_classext(rb_classext_t *orig, VALUE klass, const rb_namespace
|
|||
RCLASSEXT_M_TBL(ext) = duplicate_classext_m_tbl(RCLASSEXT_M_TBL(orig), klass, dup_iclass);
|
||||
|
||||
if (orig->fields_obj) {
|
||||
RB_OBJ_WRITE(klass, &ext->fields_obj, rb_imemo_class_fields_clone(orig->fields_obj));
|
||||
RB_OBJ_WRITE(klass, &ext->fields_obj, rb_imemo_fields_clone(orig->fields_obj));
|
||||
}
|
||||
|
||||
if (RCLASSEXT_SHARED_CONST_TBL(orig)) {
|
||||
|
|
|
@ -315,7 +315,7 @@ RB_DEBUG_COUNTER(obj_imemo_parser_strterm)
|
|||
RB_DEBUG_COUNTER(obj_imemo_callinfo)
|
||||
RB_DEBUG_COUNTER(obj_imemo_callcache)
|
||||
RB_DEBUG_COUNTER(obj_imemo_constcache)
|
||||
RB_DEBUG_COUNTER(obj_imemo_class_fields)
|
||||
RB_DEBUG_COUNTER(obj_imemo_fields)
|
||||
|
||||
RB_DEBUG_COUNTER(opt_new_hit)
|
||||
RB_DEBUG_COUNTER(opt_new_miss)
|
||||
|
|
|
@ -504,7 +504,7 @@ count_imemo_objects(int argc, VALUE *argv, VALUE self)
|
|||
INIT_IMEMO_TYPE_ID(imemo_callinfo);
|
||||
INIT_IMEMO_TYPE_ID(imemo_callcache);
|
||||
INIT_IMEMO_TYPE_ID(imemo_constcache);
|
||||
INIT_IMEMO_TYPE_ID(imemo_class_fields);
|
||||
INIT_IMEMO_TYPE_ID(imemo_fields);
|
||||
#undef INIT_IMEMO_TYPE_ID
|
||||
}
|
||||
|
||||
|
|
52
imemo.c
52
imemo.c
|
@ -30,7 +30,7 @@ rb_imemo_name(enum imemo_type type)
|
|||
IMEMO_NAME(svar);
|
||||
IMEMO_NAME(throw_data);
|
||||
IMEMO_NAME(tmpbuf);
|
||||
IMEMO_NAME(class_fields);
|
||||
IMEMO_NAME(fields);
|
||||
#undef IMEMO_NAME
|
||||
}
|
||||
rb_bug("unreachable");
|
||||
|
@ -111,16 +111,16 @@ rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
imemo_class_fields_new(VALUE klass, size_t capa)
|
||||
imemo_fields_new(VALUE klass, size_t capa)
|
||||
{
|
||||
size_t embedded_size = offsetof(struct rb_class_fields, as.embed) + capa * sizeof(VALUE);
|
||||
size_t embedded_size = offsetof(struct rb_fields, as.embed) + capa * sizeof(VALUE);
|
||||
if (rb_gc_size_allocatable_p(embedded_size)) {
|
||||
VALUE fields = rb_imemo_new(imemo_class_fields, klass, embedded_size);
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(fields, imemo_class_fields));
|
||||
VALUE fields = rb_imemo_new(imemo_fields, klass, embedded_size);
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(fields, imemo_fields));
|
||||
return fields;
|
||||
}
|
||||
else {
|
||||
VALUE fields = rb_imemo_new(imemo_class_fields, klass, sizeof(struct rb_class_fields));
|
||||
VALUE fields = rb_imemo_new(imemo_fields, klass, sizeof(struct rb_fields));
|
||||
FL_SET_RAW(fields, OBJ_FIELD_EXTERNAL);
|
||||
IMEMO_OBJ_FIELDS(fields)->as.external.ptr = ALLOC_N(VALUE, capa);
|
||||
return fields;
|
||||
|
@ -128,41 +128,41 @@ imemo_class_fields_new(VALUE klass, size_t capa)
|
|||
}
|
||||
|
||||
VALUE
|
||||
rb_imemo_class_fields_new(VALUE klass, size_t capa)
|
||||
rb_imemo_fields_new(VALUE klass, size_t capa)
|
||||
{
|
||||
return imemo_class_fields_new(rb_singleton_class(klass), capa);
|
||||
return imemo_fields_new(rb_singleton_class(klass), capa);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
imemo_class_fields_new_complex(VALUE klass, size_t capa)
|
||||
imemo_fields_new_complex(VALUE klass, size_t capa)
|
||||
{
|
||||
VALUE fields = imemo_class_fields_new(klass, sizeof(struct rb_class_fields));
|
||||
VALUE fields = imemo_fields_new(klass, sizeof(struct rb_fields));
|
||||
IMEMO_OBJ_FIELDS(fields)->as.complex.table = st_init_numtable_with_size(capa);
|
||||
return fields;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_imemo_class_fields_new_complex(VALUE klass, size_t capa)
|
||||
rb_imemo_fields_new_complex(VALUE klass, size_t capa)
|
||||
{
|
||||
return imemo_class_fields_new_complex(rb_singleton_class(klass), capa);
|
||||
return imemo_fields_new_complex(rb_singleton_class(klass), capa);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_imemo_class_fields_clone(VALUE fields_obj)
|
||||
rb_imemo_fields_clone(VALUE fields_obj)
|
||||
{
|
||||
shape_id_t shape_id = RBASIC_SHAPE_ID(fields_obj);
|
||||
VALUE clone;
|
||||
|
||||
if (rb_shape_too_complex_p(shape_id)) {
|
||||
clone = rb_imemo_class_fields_new_complex(CLASS_OF(fields_obj), 0);
|
||||
clone = rb_imemo_fields_new_complex(CLASS_OF(fields_obj), 0);
|
||||
RBASIC_SET_SHAPE_ID(clone, shape_id);
|
||||
st_table *src_table = rb_imemo_class_fields_complex_tbl(fields_obj);
|
||||
st_replace(rb_imemo_class_fields_complex_tbl(clone), src_table);
|
||||
st_table *src_table = rb_imemo_fields_complex_tbl(fields_obj);
|
||||
st_replace(rb_imemo_fields_complex_tbl(clone), src_table);
|
||||
}
|
||||
else {
|
||||
clone = imemo_class_fields_new(CLASS_OF(fields_obj), RSHAPE_CAPACITY(shape_id));
|
||||
clone = imemo_fields_new(CLASS_OF(fields_obj), RSHAPE_CAPACITY(shape_id));
|
||||
RBASIC_SET_SHAPE_ID(clone, shape_id);
|
||||
MEMCPY(rb_imemo_class_fields_ptr(clone), rb_imemo_class_fields_ptr(fields_obj), VALUE, RSHAPE_LEN(shape_id));
|
||||
MEMCPY(rb_imemo_fields_ptr(clone), rb_imemo_fields_ptr(fields_obj), VALUE, RSHAPE_LEN(shape_id));
|
||||
}
|
||||
|
||||
return clone;
|
||||
|
@ -215,7 +215,7 @@ rb_imemo_memsize(VALUE obj)
|
|||
size += ((rb_imemo_tmpbuf_t *)obj)->cnt * sizeof(VALUE);
|
||||
|
||||
break;
|
||||
case imemo_class_fields:
|
||||
case imemo_fields:
|
||||
if (rb_shape_obj_too_complex_p(obj)) {
|
||||
size += st_memsize(IMEMO_OBJ_FIELDS(obj)->as.complex.table);
|
||||
}
|
||||
|
@ -487,11 +487,11 @@ rb_imemo_mark_and_move(VALUE obj, bool reference_updating)
|
|||
|
||||
break;
|
||||
}
|
||||
case imemo_class_fields: {
|
||||
case imemo_fields: {
|
||||
rb_gc_mark_and_move((VALUE *)&RBASIC(obj)->klass);
|
||||
|
||||
if (rb_shape_obj_too_complex_p(obj)) {
|
||||
st_table *tbl = rb_imemo_class_fields_complex_tbl(obj);
|
||||
st_table *tbl = rb_imemo_fields_complex_tbl(obj);
|
||||
if (reference_updating) {
|
||||
rb_gc_ref_update_table_values_only(tbl);
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ rb_imemo_mark_and_move(VALUE obj, bool reference_updating)
|
|||
}
|
||||
}
|
||||
else {
|
||||
VALUE *fields = rb_imemo_class_fields_ptr(obj);
|
||||
VALUE *fields = rb_imemo_fields_ptr(obj);
|
||||
attr_index_t len = RSHAPE_LEN(RBASIC_SHAPE_ID(obj));
|
||||
for (attr_index_t i = 0; i < len; i++) {
|
||||
rb_gc_mark_and_move(&fields[i]);
|
||||
|
@ -602,7 +602,7 @@ rb_cc_tbl_free(struct rb_id_table *cc_tbl, VALUE klass)
|
|||
}
|
||||
|
||||
static inline void
|
||||
imemo_class_fields_free(struct rb_class_fields *fields)
|
||||
imemo_fields_free(struct rb_fields *fields)
|
||||
{
|
||||
if (rb_shape_obj_too_complex_p((VALUE)fields)) {
|
||||
st_free_table(fields->as.complex.table);
|
||||
|
@ -686,9 +686,9 @@ rb_imemo_free(VALUE obj)
|
|||
RB_DEBUG_COUNTER_INC(obj_imemo_tmpbuf);
|
||||
|
||||
break;
|
||||
case imemo_class_fields:
|
||||
imemo_class_fields_free(IMEMO_OBJ_FIELDS(obj));
|
||||
RB_DEBUG_COUNTER_INC(obj_imemo_class_fields);
|
||||
case imemo_fields:
|
||||
imemo_fields_free(IMEMO_OBJ_FIELDS(obj));
|
||||
RB_DEBUG_COUNTER_INC(obj_imemo_fields);
|
||||
break;
|
||||
default:
|
||||
rb_bug("unreachable");
|
||||
|
|
|
@ -526,7 +526,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_class_fields_new(obj, 1));
|
||||
RB_OBJ_WRITE(obj, &ext->fields_obj, rb_imemo_fields_new(obj, 1));
|
||||
}
|
||||
return ext->fields_obj;
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ RCLASS_FIELDS_COUNT(VALUE obj)
|
|||
VALUE fields_obj = RCLASS_WRITABLE_FIELDS_OBJ(obj);
|
||||
if (fields_obj) {
|
||||
if (rb_shape_obj_too_complex_p(fields_obj)) {
|
||||
return (uint32_t)rb_st_table_size(rb_imemo_class_fields_complex_tbl(fields_obj));
|
||||
return (uint32_t)rb_st_table_size(rb_imemo_fields_complex_tbl(fields_obj));
|
||||
}
|
||||
else {
|
||||
return RSHAPE_LEN(RBASIC_SHAPE_ID(fields_obj));
|
||||
|
|
|
@ -42,7 +42,7 @@ enum imemo_type {
|
|||
imemo_callinfo = 11,
|
||||
imemo_callcache = 12,
|
||||
imemo_constcache = 13,
|
||||
imemo_class_fields = 14,
|
||||
imemo_fields = 14,
|
||||
};
|
||||
|
||||
/* CREF (Class REFerence) is defined in method.h */
|
||||
|
@ -258,7 +258,7 @@ MEMO_V2_SET(struct MEMO *m, VALUE v)
|
|||
RB_OBJ_WRITE(m, &m->v2, v);
|
||||
}
|
||||
|
||||
struct rb_class_fields {
|
||||
struct rb_fields {
|
||||
struct RBasic basic;
|
||||
union {
|
||||
struct {
|
||||
|
@ -276,20 +276,20 @@ struct rb_class_fields {
|
|||
};
|
||||
|
||||
#define OBJ_FIELD_EXTERNAL IMEMO_FL_USER0
|
||||
#define IMEMO_OBJ_FIELDS(fields) ((struct rb_class_fields *)fields)
|
||||
#define IMEMO_OBJ_FIELDS(fields) ((struct rb_fields *)fields)
|
||||
|
||||
VALUE rb_imemo_class_fields_new(VALUE klass, size_t capa);
|
||||
VALUE rb_imemo_class_fields_new_complex(VALUE klass, size_t capa);
|
||||
VALUE rb_imemo_class_fields_clone(VALUE fields_obj);
|
||||
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_clone(VALUE fields_obj);
|
||||
|
||||
static inline VALUE *
|
||||
rb_imemo_class_fields_ptr(VALUE obj_fields)
|
||||
rb_imemo_fields_ptr(VALUE obj_fields)
|
||||
{
|
||||
if (!obj_fields) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj_fields, imemo_class_fields));
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj_fields, imemo_fields));
|
||||
|
||||
if (RB_UNLIKELY(FL_TEST_RAW(obj_fields, OBJ_FIELD_EXTERNAL))) {
|
||||
return IMEMO_OBJ_FIELDS(obj_fields)->as.external.ptr;
|
||||
|
@ -300,13 +300,13 @@ rb_imemo_class_fields_ptr(VALUE obj_fields)
|
|||
}
|
||||
|
||||
static inline st_table *
|
||||
rb_imemo_class_fields_complex_tbl(VALUE obj_fields)
|
||||
rb_imemo_fields_complex_tbl(VALUE obj_fields)
|
||||
{
|
||||
if (!obj_fields) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj_fields, imemo_class_fields));
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj_fields, imemo_fields));
|
||||
|
||||
return IMEMO_OBJ_FIELDS(obj_fields)->as.complex.table;
|
||||
}
|
||||
|
|
2
shape.c
2
shape.c
|
@ -877,7 +877,7 @@ shape_get_next(rb_shape_t *shape, VALUE obj, ID id, bool emit_warnings)
|
|||
#endif
|
||||
|
||||
VALUE klass;
|
||||
if (IMEMO_TYPE_P(obj, imemo_class_fields)) { // HACK
|
||||
if (IMEMO_TYPE_P(obj, imemo_fields)) { // HACK
|
||||
klass = CLASS_OF(obj);
|
||||
}
|
||||
else {
|
||||
|
|
4
shape.h
4
shape.h
|
@ -111,7 +111,7 @@ static inline shape_id_t
|
|||
RBASIC_SHAPE_ID(VALUE obj)
|
||||
{
|
||||
RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
|
||||
RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO) || IMEMO_TYPE_P(obj, imemo_class_fields));
|
||||
RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO) || IMEMO_TYPE_P(obj, imemo_fields));
|
||||
#if RBASIC_SHAPE_ID_FIELD
|
||||
return (shape_id_t)((RBASIC(obj)->shape_id));
|
||||
#else
|
||||
|
@ -135,7 +135,7 @@ static inline void
|
|||
RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
||||
{
|
||||
RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
|
||||
RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO) || IMEMO_TYPE_P(obj, imemo_class_fields));
|
||||
RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO) || IMEMO_TYPE_P(obj, imemo_fields));
|
||||
#if RBASIC_SHAPE_ID_FIELD
|
||||
RBASIC(obj)->shape_id = (VALUE)shape_id;
|
||||
#else
|
||||
|
|
48
variable.c
48
variable.c
|
@ -1393,11 +1393,11 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
|
|||
case T_IMEMO:
|
||||
// Handled like T_OBJECT
|
||||
{
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_class_fields));
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_fields));
|
||||
shape_id = RBASIC_SHAPE_ID(obj);
|
||||
|
||||
if (rb_shape_too_complex_p(shape_id)) {
|
||||
st_table *iv_table = rb_imemo_class_fields_complex_tbl(obj);
|
||||
st_table *iv_table = rb_imemo_fields_complex_tbl(obj);
|
||||
VALUE val;
|
||||
if (rb_st_lookup(iv_table, (st_data_t)id, (st_data_t *)&val)) {
|
||||
return val;
|
||||
|
@ -1408,7 +1408,7 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
|
|||
}
|
||||
|
||||
RUBY_ASSERT(!rb_shape_obj_too_complex_p(obj));
|
||||
ivar_list = rb_imemo_class_fields_ptr(obj);
|
||||
ivar_list = rb_imemo_fields_ptr(obj);
|
||||
break;
|
||||
}
|
||||
case T_OBJECT:
|
||||
|
@ -1486,7 +1486,7 @@ rb_ivar_delete(VALUE obj, ID id, VALUE undef)
|
|||
VALUE fields_obj = RCLASS_WRITABLE_FIELDS_OBJ(obj);
|
||||
if (fields_obj) {
|
||||
if (rb_multi_ractor_p()) {
|
||||
fields_obj = rb_imemo_class_fields_clone(fields_obj);
|
||||
fields_obj = rb_imemo_fields_clone(fields_obj);
|
||||
val = rb_ivar_delete(fields_obj, id, undef);
|
||||
RCLASS_WRITABLE_SET_FIELDS_OBJ(obj, fields_obj);
|
||||
}
|
||||
|
@ -1523,8 +1523,8 @@ rb_ivar_delete(VALUE obj, ID id, VALUE undef)
|
|||
rb_bug("Unreachable");
|
||||
break;
|
||||
case T_IMEMO:
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_class_fields));
|
||||
fields = rb_imemo_class_fields_ptr(obj);
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_fields));
|
||||
fields = rb_imemo_fields_ptr(obj);
|
||||
break;
|
||||
case T_OBJECT:
|
||||
fields = ROBJECT_FIELDS(obj);
|
||||
|
@ -1576,8 +1576,8 @@ too_complex:
|
|||
break;
|
||||
|
||||
case T_IMEMO:
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_class_fields));
|
||||
table = rb_imemo_class_fields_complex_tbl(obj);
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_fields));
|
||||
table = rb_imemo_fields_complex_tbl(obj);
|
||||
break;
|
||||
|
||||
case T_OBJECT:
|
||||
|
@ -2156,8 +2156,8 @@ ivar_defined0(VALUE obj, ID id)
|
|||
break;
|
||||
|
||||
case T_IMEMO:
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_class_fields));
|
||||
table = rb_imemo_class_fields_complex_tbl(obj);
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_fields));
|
||||
table = rb_imemo_fields_complex_tbl(obj);
|
||||
break;
|
||||
|
||||
case T_OBJECT:
|
||||
|
@ -2235,10 +2235,10 @@ iterate_over_shapes_callback(shape_id_t shape_id, void *data)
|
|||
case T_MODULE:
|
||||
rb_bug("Unreachable");
|
||||
case T_IMEMO:
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(itr_data->obj, imemo_class_fields));
|
||||
RUBY_ASSERT(IMEMO_TYPE_P(itr_data->obj, imemo_fields));
|
||||
RUBY_ASSERT(!rb_shape_obj_too_complex_p(itr_data->obj));
|
||||
|
||||
iv_list = rb_imemo_class_fields_ptr(itr_data->obj);
|
||||
iv_list = rb_imemo_fields_ptr(itr_data->obj);
|
||||
break;
|
||||
default:
|
||||
iv_list = itr_data->fields_tbl->as.shape.fields;
|
||||
|
@ -2313,7 +2313,7 @@ gen_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, b
|
|||
static void
|
||||
class_fields_each(VALUE fields_obj, rb_ivar_foreach_callback_func *func, st_data_t arg, bool ivar_only)
|
||||
{
|
||||
IMEMO_TYPE_P(fields_obj, imemo_class_fields);
|
||||
IMEMO_TYPE_P(fields_obj, imemo_fields);
|
||||
|
||||
struct iv_itr_data itr_data = {
|
||||
.obj = fields_obj,
|
||||
|
@ -2324,10 +2324,10 @@ class_fields_each(VALUE fields_obj, rb_ivar_foreach_callback_func *func, st_data
|
|||
|
||||
shape_id_t shape_id = RBASIC_SHAPE_ID(fields_obj);
|
||||
if (rb_shape_too_complex_p(shape_id)) {
|
||||
rb_st_foreach(rb_imemo_class_fields_complex_tbl(fields_obj), each_hash_iv, (st_data_t)&itr_data);
|
||||
rb_st_foreach(rb_imemo_fields_complex_tbl(fields_obj), each_hash_iv, (st_data_t)&itr_data);
|
||||
}
|
||||
else {
|
||||
itr_data.fields = rb_imemo_class_fields_ptr(fields_obj);
|
||||
itr_data.fields = rb_imemo_fields_ptr(fields_obj);
|
||||
iterate_over_shapes(shape_id, func, &itr_data);
|
||||
}
|
||||
}
|
||||
|
@ -2427,7 +2427,7 @@ rb_field_foreach(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg,
|
|||
if (SPECIAL_CONST_P(obj)) return;
|
||||
switch (BUILTIN_TYPE(obj)) {
|
||||
case T_IMEMO:
|
||||
if (IMEMO_TYPE_P(obj, imemo_class_fields)) {
|
||||
if (IMEMO_TYPE_P(obj, imemo_fields)) {
|
||||
class_fields_each(obj, func, arg, ivar_only);
|
||||
}
|
||||
break;
|
||||
|
@ -2476,7 +2476,7 @@ rb_ivar_count(VALUE obj)
|
|||
return 0;
|
||||
}
|
||||
if (rb_shape_obj_too_complex_p(fields_obj)) {
|
||||
return rb_st_table_size(rb_imemo_class_fields_complex_tbl(fields_obj));
|
||||
return rb_st_table_size(rb_imemo_fields_complex_tbl(fields_obj));
|
||||
}
|
||||
return RBASIC_FIELDS_COUNT(fields_obj);
|
||||
}
|
||||
|
@ -4690,7 +4690,7 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
|
|||
{
|
||||
bool existing = true;
|
||||
const VALUE original_fields_obj = fields_obj;
|
||||
fields_obj = original_fields_obj ? original_fields_obj : rb_imemo_class_fields_new(klass, 1);
|
||||
fields_obj = original_fields_obj ? original_fields_obj : rb_imemo_fields_new(klass, 1);
|
||||
|
||||
shape_id_t current_shape_id = RBASIC_SHAPE_ID(fields_obj);
|
||||
shape_id_t next_shape_id = current_shape_id;
|
||||
|
@ -4711,9 +4711,9 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
|
|||
next_shape_id = rb_shape_transition_add_ivar(fields_obj, id);
|
||||
if (UNLIKELY(rb_shape_too_complex_p(next_shape_id))) {
|
||||
attr_index_t current_len = RSHAPE_LEN(current_shape_id);
|
||||
fields_obj = rb_imemo_class_fields_new_complex(klass, current_len + 1);
|
||||
fields_obj = rb_imemo_fields_new_complex(klass, current_len + 1);
|
||||
if (current_len) {
|
||||
rb_obj_copy_fields_to_hash_table(original_fields_obj, rb_imemo_class_fields_complex_tbl(fields_obj));
|
||||
rb_obj_copy_fields_to_hash_table(original_fields_obj, rb_imemo_fields_complex_tbl(fields_obj));
|
||||
RBASIC_SET_SHAPE_ID(fields_obj, next_shape_id);
|
||||
}
|
||||
goto too_complex;
|
||||
|
@ -4727,9 +4727,9 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
|
|||
|
||||
// We allocate a new fields_obj even when concurrency isn't a concern
|
||||
// so that we're embedded as long as possible.
|
||||
fields_obj = rb_imemo_class_fields_new(klass, next_capacity);
|
||||
fields_obj = rb_imemo_fields_new(klass, next_capacity);
|
||||
if (original_fields_obj) {
|
||||
MEMCPY(rb_imemo_class_fields_ptr(fields_obj), rb_imemo_class_fields_ptr(original_fields_obj), VALUE, RSHAPE_LEN(current_shape_id));
|
||||
MEMCPY(rb_imemo_fields_ptr(fields_obj), rb_imemo_fields_ptr(original_fields_obj), VALUE, RSHAPE_LEN(current_shape_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4737,7 +4737,7 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
|
|||
RUBY_ASSERT(index == (RSHAPE_LEN(next_shape_id) - 1));
|
||||
}
|
||||
|
||||
VALUE *fields = rb_imemo_class_fields_ptr(fields_obj);
|
||||
VALUE *fields = rb_imemo_fields_ptr(fields_obj);
|
||||
RB_OBJ_WRITE(fields_obj, &fields[index], val);
|
||||
|
||||
if (!existing) {
|
||||
|
@ -4749,7 +4749,7 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
|
|||
|
||||
too_complex:
|
||||
{
|
||||
st_table *table = rb_imemo_class_fields_complex_tbl(fields_obj);
|
||||
st_table *table = rb_imemo_fields_complex_tbl(fields_obj);
|
||||
existing = st_insert(table, (st_data_t)id, (st_data_t)val);
|
||||
RB_OBJ_WRITTEN(fields_obj, Qundef, val);
|
||||
|
||||
|
|
|
@ -1252,8 +1252,8 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
|
|||
if (!fields_obj) {
|
||||
return default_value;
|
||||
}
|
||||
ivar_list = rb_imemo_class_fields_ptr(fields_obj);
|
||||
shape_id = fields_obj ? RBASIC_SHAPE_ID_FOR_READ(fields_obj) : ROOT_SHAPE_ID;
|
||||
ivar_list = rb_imemo_fields_ptr(fields_obj);
|
||||
shape_id = RBASIC_SHAPE_ID_FOR_READ(fields_obj);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1325,7 +1325,7 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
|
|||
switch (BUILTIN_TYPE(obj)) {
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
table = rb_imemo_class_fields_complex_tbl(fields_obj);
|
||||
table = rb_imemo_fields_complex_tbl(fields_obj);
|
||||
break;
|
||||
|
||||
case T_OBJECT:
|
||||
|
|
2
yjit/src/cruby_bindings.inc.rs
generated
2
yjit/src/cruby_bindings.inc.rs
generated
|
@ -410,7 +410,7 @@ pub const imemo_parser_strterm: imemo_type = 10;
|
|||
pub const imemo_callinfo: imemo_type = 11;
|
||||
pub const imemo_callcache: imemo_type = 12;
|
||||
pub const imemo_constcache: imemo_type = 13;
|
||||
pub const imemo_class_fields: imemo_type = 14;
|
||||
pub const imemo_fields: imemo_type = 14;
|
||||
pub type imemo_type = u32;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
|
2
zjit/src/cruby_bindings.inc.rs
generated
2
zjit/src/cruby_bindings.inc.rs
generated
|
@ -227,7 +227,7 @@ pub const imemo_parser_strterm: imemo_type = 10;
|
|||
pub const imemo_callinfo: imemo_type = 11;
|
||||
pub const imemo_callcache: imemo_type = 12;
|
||||
pub const imemo_constcache: imemo_type = 13;
|
||||
pub const imemo_class_fields: imemo_type = 14;
|
||||
pub const imemo_fields: imemo_type = 14;
|
||||
pub type imemo_type = u32;
|
||||
pub const METHOD_VISI_UNDEF: rb_method_visibility_t = 0;
|
||||
pub const METHOD_VISI_PUBLIC: rb_method_visibility_t = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue