* 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
This commit is contained in:
parent
15d735de15
commit
f363bbdf10
16
ChangeLog
16
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>
|
Fri Oct 30 06:43:50 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* vm_insnhelper.c (vm_env_cref): make it inline for performance.
|
* vm_insnhelper.c (vm_env_cref): make it inline for performance.
|
||||||
|
@ -1164,7 +1164,7 @@ getinlinecache
|
|||||||
(VALUE val)
|
(VALUE val)
|
||||||
{
|
{
|
||||||
if (ic->ic_serial == GET_GLOBAL_CONSTANT_STATE() &&
|
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;
|
val = ic->ic_value.value;
|
||||||
JUMP(dst);
|
JUMP(dst);
|
||||||
}
|
}
|
||||||
@ -1188,7 +1188,7 @@ setinlinecache
|
|||||||
VM_ASSERT(ic->ic_value.value != Qundef);
|
VM_ASSERT(ic->ic_value.value != Qundef);
|
||||||
ic->ic_value.value = val;
|
ic->ic_value.value = val;
|
||||||
ic->ic_serial = GET_GLOBAL_CONSTANT_STATE() - ruby_vm_const_missing_count;
|
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;
|
ruby_vm_const_missing_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ typedef struct rb_compile_option_struct rb_compile_option_t;
|
|||||||
|
|
||||||
struct iseq_inline_cache_entry {
|
struct iseq_inline_cache_entry {
|
||||||
rb_serial_t ic_serial;
|
rb_serial_t ic_serial;
|
||||||
rb_cref_t *ic_cref;
|
const rb_cref_t *ic_cref;
|
||||||
union {
|
union {
|
||||||
size_t index;
|
size_t index;
|
||||||
VALUE value;
|
VALUE value;
|
||||||
|
@ -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
|
void
|
||||||
rb_vm_rewrite_cref(rb_cref_t *cref, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr)
|
rb_vm_rewrite_cref(rb_cref_t *cref, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user