From 264e4cd04fbcdcb739a1ff9a84e19afe66005cb2 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 10 Aug 2020 18:19:17 -0400 Subject: 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] --- internal/class.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'internal/class.h') diff --git a/internal/class.h b/internal/class.h index 40938255af..663a1e8dbf 100644 --- a/internal/class.h +++ b/internal/class.h @@ -144,6 +144,12 @@ RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass) FL_SET(iclass, RICLASS_ORIGIN_SHARED_MTBL); } +static inline bool +RICLASS_OWNS_M_TBL_P(VALUE iclass) +{ + return FL_TEST_RAW(iclass, RICLASS_IS_ORIGIN | RICLASS_ORIGIN_SHARED_MTBL) == RICLASS_IS_ORIGIN; +} + static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass) { -- cgit v1.2.1