From f363bbdf1042562e40aaccbd1bdd7b783c096ff0 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 29 Oct 2015 22:43:45 +0000 Subject: * insns.def (getinlinecache/setinlinecache): compare ic->ic_cref and current cref only when cached CREF list includes singleton class. Singleton classes have own namespaces, so that we need to check cref as a key (#10943). However, if current CREF list does not include singleton class, no need to check CREF beacuse it should be same name space. * vm_insnhelper.c (vm_get_const_key_cref): add a function returns CREF only when it includes singleton class. * vm_core.h: constify iseq_inline_cache_entry::ic_cref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 6a7bba92d4..ae6195ef4c 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -500,6 +500,23 @@ rb_vm_get_cref(const VALUE *ep) } } +static const rb_cref_t * +vm_get_const_key_cref(const VALUE *ep) +{ + const rb_cref_t *cref = rb_vm_get_cref(ep); + const rb_cref_t *key_cref = cref; + + while (cref) { + if (FL_TEST(CREF_CLASS(cref), FL_SINGLETON)) { + return key_cref; + } + cref = CREF_NEXT(cref); + } + + /* does not incldue singleton class */ + return NULL; +} + void rb_vm_rewrite_cref(rb_cref_t *cref, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr) { -- cgit v1.2.3