summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2019-08-09 11:00:34 +0900
committerKoichi Sasada <ko1@atdot.net>2019-08-09 11:05:11 +0900
commit71efad1ed391ee0c5398a76306fdbaaadd4dc52e (patch)
treed560b4a717ee7d15d23dc4ea02b1708f7d1d71ea /class.c
parentc7acb37248d4cef76647f8bc7ebd7dc291d9a853 (diff)
introduce RCLASS_CLONED flag for inline cache.
Methods on duplicated class/module refer same constant inline cache (IC). Constant access lookup should be done for cloned class/modules but inline cache doesn't check it. To check it, this patch introduce new RCLASS_CLONED flag which are set when if class/module is cloned (both orig and dst). [Bug #15877]
Diffstat (limited to 'class.c')
-rw-r--r--class.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/class.c b/class.c
index 243f8c4..08c0a19 100644
--- a/class.c
+++ b/class.c
@@ -308,11 +308,17 @@ class_init_copy_check(VALUE clone, VALUE orig)
rb_raise(rb_eTypeError, "can't copy singleton class");
}
}
-
+#include "gc.h"
/* :nodoc: */
VALUE
rb_mod_init_copy(VALUE clone, VALUE orig)
{
+ /* cloned flag is refer at constant inline cache
+ * see vm_get_const_key_cref() in vm_insnhelper.c
+ */
+ FL_SET(clone, RCLASS_CLONED);
+ FL_SET(orig , RCLASS_CLONED);
+
if (RB_TYPE_P(clone, T_CLASS)) {
class_init_copy_check(clone, orig);
}