зеркало из https://github.com/github/ruby.git
Move shape ID to flags for classes on 32 bit
Moves shape ID to FL_USER4 to FL_USER19 for the shape ID on 32 bit systems. This makes the rb_classext_struct smaller so that it can be embedded.
This commit is contained in:
Родитель
d7bb7e70cc
Коммит
24b137336b
|
@ -62,9 +62,6 @@ struct rb_classext_struct {
|
|||
} singleton_class;
|
||||
} as;
|
||||
const VALUE includer;
|
||||
#if !SHAPE_IN_BASIC_FLAGS
|
||||
shape_id_t shape_id;
|
||||
#endif
|
||||
attr_index_t max_iv_count;
|
||||
unsigned char variation_count;
|
||||
bool permanent_classpath : 1;
|
||||
|
|
7
shape.c
7
shape.c
|
@ -69,13 +69,6 @@ rb_shape_get_parent(rb_shape_t * shape)
|
|||
}
|
||||
|
||||
#if !SHAPE_IN_BASIC_FLAGS
|
||||
shape_id_t
|
||||
rb_rclass_shape_id(VALUE obj)
|
||||
{
|
||||
RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
|
||||
return RCLASS_EXT(obj)->shape_id;
|
||||
}
|
||||
|
||||
shape_id_t rb_generic_shape_id(VALUE obj);
|
||||
#endif
|
||||
|
||||
|
|
50
shape.h
50
shape.h
|
@ -77,16 +77,15 @@ rb_current_shape_tree(void)
|
|||
}
|
||||
#define GET_SHAPE_TREE() rb_current_shape_tree()
|
||||
|
||||
#if SHAPE_IN_BASIC_FLAGS
|
||||
static inline shape_id_t
|
||||
RBASIC_SHAPE_ID(VALUE obj)
|
||||
get_shape_id_from_flags(VALUE obj)
|
||||
{
|
||||
RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
|
||||
return (shape_id_t)(SHAPE_MASK & ((RBASIC(obj)->flags) >> SHAPE_FLAG_SHIFT));
|
||||
}
|
||||
|
||||
static inline void
|
||||
RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
||||
set_shape_id_in_flags(VALUE obj, shape_id_t shape_id)
|
||||
{
|
||||
// Ractors are occupying the upper 32 bits of flags, but only in debug mode
|
||||
// Object shapes are occupying top bits
|
||||
|
@ -94,52 +93,49 @@ RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
|||
RBASIC(obj)->flags |= ((VALUE)(shape_id) << SHAPE_FLAG_SHIFT);
|
||||
}
|
||||
|
||||
|
||||
#if SHAPE_IN_BASIC_FLAGS
|
||||
static inline shape_id_t
|
||||
RBASIC_SHAPE_ID(VALUE obj)
|
||||
{
|
||||
return get_shape_id_from_flags(obj);
|
||||
}
|
||||
|
||||
static inline void
|
||||
RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
||||
{
|
||||
set_shape_id_in_flags(obj, shape_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline shape_id_t
|
||||
ROBJECT_SHAPE_ID(VALUE obj)
|
||||
{
|
||||
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
||||
return RBASIC_SHAPE_ID(obj);
|
||||
return get_shape_id_from_flags(obj);
|
||||
}
|
||||
|
||||
static inline void
|
||||
ROBJECT_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
||||
{
|
||||
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
||||
RBASIC_SET_SHAPE_ID(obj, shape_id);
|
||||
set_shape_id_in_flags(obj, shape_id);
|
||||
}
|
||||
|
||||
static inline shape_id_t
|
||||
RCLASS_SHAPE_ID(VALUE obj)
|
||||
{
|
||||
RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
|
||||
return RBASIC_SHAPE_ID(obj);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline shape_id_t
|
||||
ROBJECT_SHAPE_ID(VALUE obj)
|
||||
{
|
||||
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
||||
return (shape_id_t)(SHAPE_MASK & (RBASIC(obj)->flags >> SHAPE_FLAG_SHIFT));
|
||||
return get_shape_id_from_flags(obj);
|
||||
}
|
||||
|
||||
static inline void
|
||||
ROBJECT_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
||||
RCLASS_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
||||
{
|
||||
RBASIC(obj)->flags &= SHAPE_FLAG_MASK;
|
||||
RBASIC(obj)->flags |= ((VALUE)(shape_id) << SHAPE_FLAG_SHIFT);
|
||||
RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
|
||||
set_shape_id_in_flags(obj, shape_id);
|
||||
}
|
||||
|
||||
shape_id_t rb_rclass_shape_id(VALUE obj);
|
||||
|
||||
static inline shape_id_t RCLASS_SHAPE_ID(VALUE obj)
|
||||
{
|
||||
return rb_rclass_shape_id(obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
rb_shape_t * rb_shape_get_root_shape(void);
|
||||
int32_t rb_shape_id_offset(void);
|
||||
|
||||
|
|
|
@ -1527,7 +1527,7 @@ rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id)
|
|||
break;
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
RCLASS_EXT(obj)->shape_id = shape_id;
|
||||
RCLASS_SET_SHAPE_ID(obj, shape_id);
|
||||
break;
|
||||
default:
|
||||
if (shape_id != SPECIAL_CONST_SHAPE_ID) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче