Skip to content

Commit

Permalink
Add compaction notes for class/module creation C APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
XrXr committed Dec 11, 2020
1 parent 9022621 commit 8b83e28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions class.c
Expand Up @@ -791,6 +791,7 @@ rb_define_class(const char *name, VALUE super)
*
* \note if a class named \a name is already defined and its superclass is
* \a super, the function just returns the defined class.
* \note the compaction GC does not move classes returned by this function.
*/
VALUE
rb_define_class_under(VALUE outer, const char *name, VALUE super)
Expand All @@ -814,6 +815,7 @@ rb_define_class_under(VALUE outer, const char *name, VALUE super)
*
* \note if a class named \a name is already defined and its superclass is
* \a super, the function just returns the defined class.
* \note the compaction GC does not move classes returned by this function.
*/
VALUE
rb_define_class_id_under(VALUE outer, ID id, VALUE super)
Expand Down Expand Up @@ -866,6 +868,9 @@ rb_define_module_id(ID id)
return rb_module_new();
}

/*!
* \note the compaction GC does not move modules returned by this function.
*/
VALUE
rb_define_module(const char *name)
{
Expand All @@ -890,6 +895,9 @@ rb_define_module(const char *name)
return module;
}

/*!
* \note the compaction GC does not move modules returned by this function.
*/
VALUE
rb_define_module_under(VALUE outer, const char *name)
{
Expand Down
4 changes: 4 additions & 0 deletions include/ruby/internal/module.h
Expand Up @@ -25,6 +25,10 @@

RBIMPL_SYMBOL_EXPORT_BEGIN()

/**
* GC compaction note: class and modules returned these four functions
* do not move.
*/
VALUE rb_define_class(const char*,VALUE);
VALUE rb_define_module(const char*);
VALUE rb_define_class_under(VALUE, const char*, VALUE);
Expand Down

0 comments on commit 8b83e28

Please sign in to comment.