Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make rb_define_module{,_id}_under pin like rb_define_class{,_id}_under #3885

Merged
merged 2 commits into from Jan 27, 2021

Conversation

XrXr
Copy link
Member

@XrXr XrXr commented Dec 11, 2020

And add docs. The change makes these APIs consistent when it comes to pinning objects they return.

Just like rb_define_class_id_under(). Also makes
rb_define_module_under() consistent with rb_define_class_under() in the
same regard.
@XrXr XrXr requested review from tenderlove and ko1 December 11, 2020 02:32
@@ -908,6 +916,8 @@ rb_define_module_id_under(VALUE outer, ID id)
" (%"PRIsVALUE")",
outer, rb_id2str(id), rb_obj_class(module));
}
/* Module may have been defined in Ruby and not pin-rooted */
rb_gc_register_mark_object(module);
Copy link
Member Author

@XrXr XrXr Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, rb_vm_add_root_module() now seems to serve exactly the same purpose as rb_gc_register_mark_object(). They both root and pin. Maybe we can delete rb_vm_add_root_module() since it's not a public API.

rb_gc_register_mark_object uses an array of arrays and rb_vm_add_root_module() uses an st_table.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can. AFAIK the array of arrays is to prevent bloating (but I am just guessing). I think it would be better to use that than an st_table.

@@ -908,6 +916,8 @@ rb_define_module_id_under(VALUE outer, ID id)
" (%"PRIsVALUE")",
outer, rb_id2str(id), rb_obj_class(module));
}
/* Module may have been defined in Ruby and not pin-rooted */
rb_gc_register_mark_object(module);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can. AFAIK the array of arrays is to prevent bloating (but I am just guessing). I think it would be better to use that than an st_table.

@tenderlove tenderlove merged commit 216e660 into ruby:master Jan 27, 2021
@XrXr XrXr deleted the module-class-compaction branch January 27, 2021 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants