summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-08-10 18:19:17 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2020-08-17 17:17:47 -0400
commit264e4cd04fbcdcb739a1ff9a84e19afe66005cb2 (patch)
tree4c6f96983327df97576f4bde498e96ef9b7dc9fd /gc.c
parent1b347534904e9c8d85d1c025d0ba7b179fee82d7 (diff)
Remove write barrier exemption for T_ICLASS
Before this commit, iclasses were "shady", or not protected by write barriers. Because of that, the GC needs to spend more time marking these objects than otherwise. Applications that make heavy use of modules should see reduction in GC time as they have a significant number of live iclasses on the heap. - Put logic for iclass method table ownership into a function - Remove calls to WB_UNPROTECT and insert write barriers for iclasses This commit relies on the following invariant: for any non oirigin iclass `I`, `RCLASS_M_TBL(I) == RCLASS_M_TBL(RBasic(I)->klass)`. This invariant did not hold prior to 98286e9 for classes and modules that have prepended modules. [Feature #16984]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3410
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/gc.c b/gc.c
index 788f06f158..11a79e69fe 100644
--- a/gc.c
+++ b/gc.c
@@ -2854,8 +2854,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
break;
case T_ICLASS:
/* Basically , T_ICLASS shares table with the module */
- if (FL_TEST(obj, RICLASS_IS_ORIGIN) &&
- !FL_TEST(obj, RICLASS_ORIGIN_SHARED_MTBL)) {
+ if (RICLASS_OWNS_M_TBL_P(obj)) {
/* Method table is not shared for origin iclasses of classes */
rb_id_table_free(RCLASS_M_TBL(obj));
}
@@ -3974,8 +3973,7 @@ obj_memsize_of(VALUE obj, int use_all_types)
}
break;
case T_ICLASS:
- if (FL_TEST(obj, RICLASS_IS_ORIGIN) &&
- !FL_TEST(obj, RICLASS_ORIGIN_SHARED_MTBL)) {
+ if (RICLASS_OWNS_M_TBL_P(obj)) {
if (RCLASS_M_TBL(obj)) {
size += rb_id_table_memsize(RCLASS_M_TBL(obj));
}
@@ -5504,8 +5502,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
break;
case T_ICLASS:
- if (FL_TEST(obj, RICLASS_IS_ORIGIN) &&
- !FL_TEST(obj, RICLASS_ORIGIN_SHARED_MTBL)) {
+ if (RICLASS_OWNS_M_TBL_P(obj)) {
mark_m_tbl(objspace, RCLASS_M_TBL(obj));
}
if (RCLASS_SUPER(obj)) {