diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-17 03:17:25 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-17 03:17:25 +0000 |
commit | 3c55b643aec09bbe779dab25b2397947eded2b9b (patch) | |
tree | d7705428a035cd7c4384a0e34d59415bf3de9ca4 /class.c | |
parent | fcd679ed11e3e801431f2f931dbe925edb8df0bf (diff) | |
download | ruby-3c55b643aec09bbe779dab25b2397947eded2b9b.tar.gz |
Adding `GC.compact` and compacting GC support.
This commit adds the new method `GC.compact` and compacting GC support.
Please see this issue for caveats:
https://bugs.ruby-lang.org/issues/15626
[Feature #15626]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -539,6 +539,7 @@ boot_defclass(const char *name, VALUE super) rb_name_class(obj, id); rb_const_set((rb_cObject ? rb_cObject : obj), id, obj); + rb_vm_add_root_module(id, obj); return obj; } @@ -730,6 +731,9 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super) " (%"PRIsVALUE" is given but was %"PRIsVALUE")", outer, rb_id2str(id), RCLASS_SUPER(klass), super); } + /* Class may have been defined in Ruby and not pin-rooted */ + rb_vm_add_root_module(id, klass); + return klass; } if (!super) { @@ -740,6 +744,7 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super) rb_set_class_path_string(klass, outer, rb_id2str(id)); rb_const_set(outer, id, klass); rb_class_inherited(super, klass); + rb_vm_add_root_module(id, klass); rb_gc_register_mark_object(klass); return klass; @@ -777,10 +782,13 @@ rb_define_module(const char *name) rb_raise(rb_eTypeError, "%s is not a module (%"PRIsVALUE")", name, rb_obj_class(module)); } + /* Module may have been defined in Ruby and not pin-rooted */ + rb_vm_add_root_module(id, module); return module; } module = rb_define_module_id(id); rb_vm_add_root_module(id, module); + rb_gc_register_mark_object(module); rb_const_set(rb_cObject, id, module); return module; |