summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--class.c8
-rw-r--r--internal/class.h23
2 files changed, 21 insertions, 10 deletions
@@ -394,7 +394,7 @@ class_classext_foreach_i(st_data_t key, st_data_t value, st_data_t arg)
void
rb_class_classext_foreach(VALUE klass, rb_class_classext_foreach_callback_func *func, void *arg)
{
- st_table *tbl = RCLASS(klass)->ns_classext_tbl;
struct class_classext_foreach_arg foreach_arg;
if (tbl) {
foreach_arg.func = func;
@@ -649,7 +649,11 @@ class_alloc(enum ruby_value_type type, VALUE klass)
rb_ns_subclasses_t *ns_subclasses;
rb_subclass_anchor_t *anchor;
const rb_namespace_t *ns = rb_definition_namespace();
- size_t alloc_size = sizeof(struct RClass) + sizeof(rb_classext_t);
// class_alloc is supposed to return a new object that is not promoted yet.
// So, we need to avoid GC after NEWOBJ_OF.
@@ -136,7 +136,6 @@ STATIC_ASSERT(shape_max_variations, SHAPE_MAX_VARIATIONS < (1 << (sizeof(((rb_cl
struct RClass {
struct RBasic basic;
- st_table *ns_classext_tbl; // ns_object -> (rb_classext_t *)
VALUE object_id;
/*
* If ns_classext_tbl is NULL, then the prime classext is readable (because no other classext exists).
@@ -144,16 +143,22 @@ struct RClass {
*/
};
-// Assert that classes can be embedded in heaps[2] (which has 160B slot size)
-// On 32bit platforms there is no variable width allocation so it doesn't matter.
-// TODO: restore this assertion after shrinking rb_classext_t
-// STATIC_ASSERT(sizeof_rb_classext_t, sizeof(struct RClass) + sizeof(rb_classext_t) <= 4 * RVALUE_SIZE || SIZEOF_VALUE < SIZEOF_LONG_LONG);
-
struct RClass_and_rb_classext_t {
struct RClass rclass;
rb_classext_t classext;
};
static const uint16_t RCLASS_MAX_SUPERCLASS_DEPTH = ((uint16_t)-1);
static inline bool RCLASS_SINGLETON_P(VALUE klass);
@@ -297,7 +302,8 @@ static inline st_table *
RCLASS_CLASSEXT_TBL(VALUE klass)
{
if (FL_TEST_RAW(klass, RCLASS_NAMESPACEABLE)) {
- return RCLASS(klass)->ns_classext_tbl;
}
return NULL;
}
@@ -306,7 +312,8 @@ static inline void
RCLASS_SET_CLASSEXT_TBL(VALUE klass, st_table *tbl)
{
RUBY_ASSERT(FL_TEST_RAW(klass, RCLASS_NAMESPACEABLE));
- RCLASS(klass)->ns_classext_tbl = tbl;
}
/* class.c */