@@ -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 }
@@ -1302,8 +1295,6 @@ rb_gc_obj_free(void *objspace, VALUE obj)
13021295 case T_MODULE :
13031296 case T_CLASS :
13041297 args .klass = obj ;
1305- args .obj_too_complex = rb_shape_obj_too_complex_p (obj ) ? true : false;
1306-
13071298 rb_class_classext_foreach (obj , classext_free , (void * )& args );
13081299 if (RCLASS (obj )-> ns_classext_tbl ) {
13091300 st_free_table (RCLASS (obj )-> ns_classext_tbl );
@@ -1495,6 +1486,8 @@ internal_object_p(VALUE obj)
14951486 return rb_singleton_class_internal_p (obj );
14961487 }
14971488 return 0 ;
1489+ case T_OBJECT :
1490+ if (FL_TEST_RAW (obj , ROBJECT_HIDDEN )) break ;
14981491 default :
14991492 if (!RBASIC (obj )-> klass ) break ;
15001493 return 0 ;
@@ -2274,20 +2267,6 @@ classext_memsize(rb_classext_t *ext, bool prime, VALUE namespace, void *arg)
22742267 * size += s ;
22752268}
22762269
2277- static void
2278- classext_fields_hash_memsize (rb_classext_t * ext , bool prime , VALUE namespace , void * arg )
2279- {
2280- size_t * size = (size_t * )arg ;
2281- size_t count ;
2282- RB_VM_LOCK_ENTER ();
2283- {
2284- count = rb_st_table_size ((st_table * )RCLASSEXT_FIELDS (ext ));
2285- }
2286- RB_VM_LOCK_LEAVE ();
2287- // class IV sizes are allocated as powers of two
2288- * size += SIZEOF_VALUE << bit_length (count );
2289- }
2290-
22912270static void
22922271classext_superclasses_memsize (rb_classext_t * ext , bool prime , VALUE namespace , void * arg )
22932272{
@@ -2326,15 +2305,6 @@ rb_obj_memsize_of(VALUE obj)
23262305 case T_MODULE :
23272306 case T_CLASS :
23282307 rb_class_classext_foreach (obj , classext_memsize , (void * )& size );
2329-
2330- if (rb_shape_obj_too_complex_p (obj )) {
2331- rb_class_classext_foreach (obj , classext_fields_hash_memsize , (void * )& size );
2332- }
2333- else {
2334- // class IV sizes are allocated as powers of two
2335- size += SIZEOF_VALUE << bit_length (RCLASS_FIELDS_COUNT (obj ));
2336- }
2337-
23382308 rb_class_classext_foreach (obj , classext_superclasses_memsize , (void * )& size );
23392309 break ;
23402310 case T_ICLASS :
@@ -3107,10 +3077,7 @@ gc_mark_classext_module(rb_classext_t *ext, bool prime, VALUE namespace, void *a
31073077 gc_mark_internal (RCLASSEXT_SUPER (ext ));
31083078 }
31093079 mark_m_tbl (objspace , RCLASSEXT_M_TBL (ext ));
3110- if (rb_shape_obj_too_complex_p (obj )) {
3111- gc_mark_tbl_no_pin ((st_table * )RCLASSEXT_FIELDS (ext ));
3112- // for the case ELSE is written in rb_gc_mark_children() because it's per RClass, not classext
3113- }
3080+ gc_mark_internal (RCLASSEXT_FIELDS_OBJ (ext ));
31143081 if (!RCLASSEXT_SHARED_CONST_TBL (ext ) && RCLASSEXT_CONST_TBL (ext )) {
31153082 mark_const_tbl (objspace , RCLASSEXT_CONST_TBL (ext ));
31163083 }
@@ -3191,11 +3158,7 @@ rb_gc_mark_children(void *objspace, VALUE obj)
31913158 foreach_args .obj = obj ;
31923159 rb_class_classext_foreach (obj , gc_mark_classext_module , (void * )& foreach_args );
31933160
3194- if (!rb_shape_obj_too_complex_p (obj )) {
3195- for (attr_index_t i = 0 ; i < RCLASS_FIELDS_COUNT (obj ); i ++ ) {
3196- gc_mark_internal (RCLASS_PRIME_FIELDS (obj )[i ]);
3197- }
3198- }
3161+ gc_mark_internal (RCLASS_PRIME_FIELDS_OBJ (obj ));
31993162 break ;
32003163
32013164 case T_ICLASS :
@@ -3827,7 +3790,6 @@ static void
38273790update_classext (rb_classext_t * ext , bool is_prime , VALUE namespace , void * arg )
38283791{
38293792 struct classext_foreach_args * args = (struct classext_foreach_args * )arg ;
3830- VALUE klass = args -> klass ;
38313793 rb_objspace_t * objspace = args -> objspace ;
38323794
38333795 if (RCLASSEXT_SUPER (ext )) {
@@ -3836,16 +3798,7 @@ update_classext(rb_classext_t *ext, bool is_prime, VALUE namespace, void *arg)
38363798
38373799 update_m_tbl (objspace , RCLASSEXT_M_TBL (ext ));
38383800
3839- if (args -> obj_too_complex ) {
3840- gc_ref_update_table_values_only ((st_table * )RCLASSEXT_FIELDS (ext ));
3841- }
3842- else {
3843- // Classext is not copied in this case
3844- for (attr_index_t i = 0 ; i < RCLASS_FIELDS_COUNT (klass ); i ++ ) {
3845- UPDATE_IF_MOVED (objspace , RCLASSEXT_FIELDS (RCLASS_EXT_PRIME (klass ))[i ]);
3846- }
3847- }
3848-
3801+ UPDATE_IF_MOVED (objspace , ext -> fields_obj );
38493802 if (!RCLASSEXT_SHARED_CONST_TBL (ext )) {
38503803 update_const_tbl (objspace , RCLASSEXT_CONST_TBL (ext ));
38513804 }
@@ -4202,7 +4155,6 @@ rb_gc_update_object_references(void *objspace, VALUE obj)
42024155 // Continue to the shared T_CLASS/T_MODULE
42034156 case T_MODULE :
42044157 args .klass = obj ;
4205- args .obj_too_complex = rb_shape_obj_too_complex_p (obj );
42064158 args .objspace = objspace ;
42074159 rb_class_classext_foreach (obj , update_classext , (void * )& args );
42084160 break ;
0 commit comments