@@ -1212,7 +1212,6 @@ rb_data_free(void *objspace, VALUE obj)
12121212
12131213struct classext_foreach_args {
12141214 VALUE klass ;
1215- bool obj_too_complex ;
12161215 rb_objspace_t * objspace ; // used for update_*
12171216};
12181217
@@ -1224,12 +1223,6 @@ classext_free(rb_classext_t *ext, bool is_prime, VALUE namespace, void *arg)
12241223
12251224 rb_id_table_free (RCLASSEXT_M_TBL (ext ));
12261225 rb_cc_tbl_free (RCLASSEXT_CC_TBL (ext ), args -> klass );
1227- if (args -> obj_too_complex ) {
1228- st_free_table ((st_table * )RCLASSEXT_FIELDS (ext ));
1229- }
1230- else {
1231- xfree (RCLASSEXT_FIELDS (ext ));
1232- }
12331226 if (!RCLASSEXT_SHARED_CONST_TBL (ext ) && (tbl = RCLASSEXT_CONST_TBL (ext )) != NULL ) {
12341227 rb_free_const_table (tbl );
12351228 }
@@ -1303,8 +1296,6 @@ rb_gc_obj_free(void *objspace, VALUE obj)
13031296 case T_MODULE :
13041297 case T_CLASS :
13051298 args .klass = obj ;
1306- args .obj_too_complex = rb_shape_obj_too_complex_p (obj ) ? true : false;
1307-
13081299 rb_class_classext_foreach (obj , classext_free , (void * )& args );
13091300 if (RCLASS (obj )-> ns_classext_tbl ) {
13101301 st_free_table (RCLASS (obj )-> ns_classext_tbl );
@@ -1499,6 +1490,8 @@ internal_object_p(VALUE obj)
14991490 return rb_singleton_class_internal_p (obj );
15001491 }
15011492 return 0 ;
1493+ case T_OBJECT :
1494+ if (FL_TEST_RAW (obj , ROBJECT_HIDDEN )) break ;
15021495 default :
15031496 if (!RBASIC (obj )-> klass ) break ;
15041497 return 0 ;
@@ -2267,18 +2260,6 @@ classext_memsize(rb_classext_t *ext, bool prime, VALUE namespace, void *arg)
22672260 * size += s ;
22682261}
22692262
2270- static void
2271- classext_fields_hash_memsize (rb_classext_t * ext , bool prime , VALUE namespace , void * arg )
2272- {
2273- size_t * size = (size_t * )arg ;
2274- size_t count ;
2275- RB_VM_LOCKING () {
2276- count = rb_st_table_size ((st_table * )RCLASSEXT_FIELDS (ext ));
2277- }
2278- // class IV sizes are allocated as powers of two
2279- * size += SIZEOF_VALUE << bit_length (count );
2280- }
2281-
22822263static void
22832264classext_superclasses_memsize (rb_classext_t * ext , bool prime , VALUE namespace , void * arg )
22842265{
@@ -2316,15 +2297,6 @@ rb_obj_memsize_of(VALUE obj)
23162297 case T_MODULE :
23172298 case T_CLASS :
23182299 rb_class_classext_foreach (obj , classext_memsize , (void * )& size );
2319-
2320- if (rb_shape_obj_too_complex_p (obj )) {
2321- rb_class_classext_foreach (obj , classext_fields_hash_memsize , (void * )& size );
2322- }
2323- else {
2324- // class IV sizes are allocated as powers of two
2325- size += SIZEOF_VALUE << bit_length (RCLASS_FIELDS_COUNT (obj ));
2326- }
2327-
23282300 rb_class_classext_foreach (obj , classext_superclasses_memsize , (void * )& size );
23292301 break ;
23302302 case T_ICLASS :
@@ -3097,10 +3069,7 @@ gc_mark_classext_module(rb_classext_t *ext, bool prime, VALUE namespace, void *a
30973069 gc_mark_internal (RCLASSEXT_SUPER (ext ));
30983070 }
30993071 mark_m_tbl (objspace , RCLASSEXT_M_TBL (ext ));
3100- if (rb_shape_obj_too_complex_p (obj )) {
3101- gc_mark_tbl_no_pin ((st_table * )RCLASSEXT_FIELDS (ext ));
3102- // for the case ELSE is written in rb_gc_mark_children() because it's per RClass, not classext
3103- }
3072+ gc_mark_internal (RCLASSEXT_FIELDS_OBJ (ext ));
31043073 if (!RCLASSEXT_SHARED_CONST_TBL (ext ) && RCLASSEXT_CONST_TBL (ext )) {
31053074 mark_const_tbl (objspace , RCLASSEXT_CONST_TBL (ext ));
31063075 }
@@ -3181,11 +3150,7 @@ rb_gc_mark_children(void *objspace, VALUE obj)
31813150 foreach_args .obj = obj ;
31823151 rb_class_classext_foreach (obj , gc_mark_classext_module , (void * )& foreach_args );
31833152
3184- if (!rb_shape_obj_too_complex_p (obj )) {
3185- for (attr_index_t i = 0 ; i < RCLASS_FIELDS_COUNT (obj ); i ++ ) {
3186- gc_mark_internal (RCLASS_PRIME_FIELDS (obj )[i ]);
3187- }
3188- }
3153+ gc_mark_internal (RCLASS_PRIME_FIELDS_OBJ (obj ));
31893154 break ;
31903155
31913156 case T_ICLASS :
@@ -3811,7 +3776,6 @@ static void
38113776update_classext (rb_classext_t * ext , bool is_prime , VALUE namespace , void * arg )
38123777{
38133778 struct classext_foreach_args * args = (struct classext_foreach_args * )arg ;
3814- VALUE klass = args -> klass ;
38153779 rb_objspace_t * objspace = args -> objspace ;
38163780
38173781 if (RCLASSEXT_SUPER (ext )) {
@@ -3820,16 +3784,7 @@ update_classext(rb_classext_t *ext, bool is_prime, VALUE namespace, void *arg)
38203784
38213785 update_m_tbl (objspace , RCLASSEXT_M_TBL (ext ));
38223786
3823- if (args -> obj_too_complex ) {
3824- gc_ref_update_table_values_only ((st_table * )RCLASSEXT_FIELDS (ext ));
3825- }
3826- else {
3827- // Classext is not copied in this case
3828- for (attr_index_t i = 0 ; i < RCLASS_FIELDS_COUNT (klass ); i ++ ) {
3829- UPDATE_IF_MOVED (objspace , RCLASSEXT_FIELDS (RCLASS_EXT_PRIME (klass ))[i ]);
3830- }
3831- }
3832-
3787+ UPDATE_IF_MOVED (objspace , ext -> fields_obj );
38333788 if (!RCLASSEXT_SHARED_CONST_TBL (ext )) {
38343789 update_const_tbl (objspace , RCLASSEXT_CONST_TBL (ext ));
38353790 }
@@ -4186,7 +4141,6 @@ rb_gc_update_object_references(void *objspace, VALUE obj)
41864141 // Continue to the shared T_CLASS/T_MODULE
41874142 case T_MODULE :
41884143 args .klass = obj ;
4189- args .obj_too_complex = rb_shape_obj_too_complex_p (obj );
41904144 args .objspace = objspace ;
41914145 rb_class_classext_foreach (obj , update_classext , (void * )& args );
41924146 break ;
0 commit comments