From 2e4fb84f7c78d7d9cd24d1802ef97fda6d2466d0 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 30 Jun 2011 23:23:32 +0000 Subject: * vm_insnhelper.c (vm_getivar): check vm state version to invalidate inline chache (ivar index). fixes Bug #4926. * vm_insnhelper.c (vm_setivar): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index a02628dabb..10f76ca8d7 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1265,7 +1265,8 @@ vm_getivar(VALUE obj, ID id, IC ic) VALUE val = Qundef; VALUE klass = RBASIC(obj)->klass; - if (ic->ic_class == klass) { + if (LIKELY(ic->ic_class == klass && + ic->ic_vmstat == GET_VM_STATE_VERSION())) { long index = ic->ic_value.index; long len = ROBJECT_NUMIV(obj); VALUE *ptr = ROBJECT_IVPTR(obj); @@ -1287,6 +1288,7 @@ vm_getivar(VALUE obj, ID id, IC ic) } ic->ic_class = klass; ic->ic_value.index = index; + ic->ic_vmstat = GET_VM_STATE_VERSION(); } } } @@ -1318,7 +1320,8 @@ vm_setivar(VALUE obj, ID id, VALUE val, IC ic) VALUE klass = RBASIC(obj)->klass; st_data_t index; - if (ic->ic_class == klass) { + if (LIKELY(ic->ic_class == klass && + ic->ic_vmstat == GET_VM_STATE_VERSION())) { long index = ic->ic_value.index; long len = ROBJECT_NUMIV(obj); VALUE *ptr = ROBJECT_IVPTR(obj); @@ -1334,6 +1337,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, IC ic) if (iv_index_tbl && st_lookup(iv_index_tbl, (st_data_t)id, &index)) { ic->ic_class = klass; ic->ic_value.index = index; + ic->ic_vmstat = GET_VM_STATE_VERSION(); } /* fall through */ } -- cgit v1.2.3