summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--insns.def4
-rw-r--r--vm_core.h2
-rw-r--r--vm_insnhelper.c17
4 files changed, 36 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a34c2cb777..41d13141a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Fri Oct 30 07:38:29 2015 Koichi Sasada <ko1@atdot.net>
+
+ * 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.
+
Fri Oct 30 06:43:50 2015 Koichi Sasada <ko1@atdot.net>
* vm_insnhelper.c (vm_env_cref): make it inline for performance.
diff --git a/insns.def b/insns.def
index 6b3f6dcf7e..563266bf22 100644
--- a/insns.def
+++ b/insns.def
@@ -1164,7 +1164,7 @@ getinlinecache
(VALUE val)
{
if (ic->ic_serial == GET_GLOBAL_CONSTANT_STATE() &&
- ic->ic_cref == rb_vm_get_cref(GET_EP())) {
+ (ic->ic_cref == NULL || ic->ic_cref == rb_vm_get_cref(GET_EP()))) {
val = ic->ic_value.value;
JUMP(dst);
}
@@ -1188,7 +1188,7 @@ setinlinecache
VM_ASSERT(ic->ic_value.value != Qundef);
ic->ic_value.value = val;
ic->ic_serial = GET_GLOBAL_CONSTANT_STATE() - ruby_vm_const_missing_count;
- ic->ic_cref = rb_vm_get_cref(GET_EP());
+ ic->ic_cref = vm_get_const_key_cref(GET_EP());
ruby_vm_const_missing_count = 0;
}
diff --git a/vm_core.h b/vm_core.h
index 0684e85456..aacdd3b897 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -180,7 +180,7 @@ typedef struct rb_compile_option_struct rb_compile_option_t;
struct iseq_inline_cache_entry {
rb_serial_t ic_serial;
- rb_cref_t *ic_cref;
+ const rb_cref_t *ic_cref;
union {
size_t index;
VALUE value;
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)
{