diff options
author | Koichi Sasada <ko1@atdot.net> | 2019-08-09 11:00:34 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2019-08-09 11:05:11 +0900 |
commit | 71efad1ed391ee0c5398a76306fdbaaadd4dc52e (patch) | |
tree | d560b4a717ee7d15d23dc4ea02b1708f7d1d71ea /vm_insnhelper.c | |
parent | c7acb37248d4cef76647f8bc7ebd7dc291d9a853 (diff) | |
download | ruby-71efad1ed391ee0c5398a76306fdbaaadd4dc52e.tar.gz |
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 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 3aea68a370..29133861be 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -785,8 +785,9 @@ vm_get_const_key_cref(const VALUE *ep) const rb_cref_t *key_cref = cref; while (cref) { - if (FL_TEST(CREF_CLASS(cref), FL_SINGLETON)) { - return key_cref; + if (FL_TEST(CREF_CLASS(cref), FL_SINGLETON) || + FL_TEST(CREF_CLASS(cref), RCLASS_CLONED)) { + return key_cref; } cref = CREF_NEXT(cref); } @@ -3722,7 +3723,8 @@ static int vm_ic_hit_p(IC ic, const VALUE *reg_ep) { if (ic->ic_serial == GET_GLOBAL_CONSTANT_STATE()) { - return (ic->ic_cref == NULL || ic->ic_cref == vm_get_cref(reg_ep)); + return (ic->ic_cref == NULL || // no need to check CREF + ic->ic_cref == vm_get_cref(reg_ep)); } return FALSE; } |