ruby-changes:65051
From: Alan <ko1@a...>
Date: Wed, 27 Jan 2021 09:24:28 +0900 (JST)
Subject: [ruby-changes:65051] 216e6605a4 (master): Add compaction notes for class/module creation C APIs
https://git.ruby-lang.org/ruby.git/commit/?id=216e6605a4 From 216e6605a47fccbbadcb6b0b7e81dcf21547e14c Mon Sep 17 00:00:00 2001 From: Alan Wu <XrXr@u...> Date: Wed, 25 Nov 2020 16:35:40 -0500 Subject: Add compaction notes for class/module creation C APIs --- class.c | 8 ++++++++ include/ruby/internal/module.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/class.c b/class.c index 56185b4..8cd96f6 100644 --- a/class.c +++ b/class.c @@ -791,6 +791,7 @@ rb_define_class(const char *name, VALUE super) https://github.com/ruby/ruby/blob/trunk/class.c#L791 * * \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) @@ -814,6 +815,7 @@ rb_define_class_under(VALUE outer, const char *name, VALUE super) https://github.com/ruby/ruby/blob/trunk/class.c#L815 * * \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) @@ -866,6 +868,9 @@ rb_define_module_id(ID id) https://github.com/ruby/ruby/blob/trunk/class.c#L868 return rb_module_new(); } +/*! + * \note the compaction GC does not move modules returned by this function. + */ VALUE rb_define_module(const char *name) { @@ -890,6 +895,9 @@ rb_define_module(const char *name) https://github.com/ruby/ruby/blob/trunk/class.c#L895 return module; } +/*! + * \note the compaction GC does not move modules returned by this function. + */ VALUE rb_define_module_under(VALUE outer, const char *name) { diff --git a/include/ruby/internal/module.h b/include/ruby/internal/module.h index 0f2dfdb..1dc6b82 100644 --- a/include/ruby/internal/module.h +++ b/include/ruby/internal/module.h @@ -25,6 +25,10 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/module.h#L25 RBIMPL_SYMBOL_EXPORT_BEGIN() +/** + * GC compaction note: class and modules returned by 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); -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/