diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-13 04:44:20 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-13 04:44:20 +0000 |
commit | 0ac93a1a405d3642a1e73294c04f428c79f5f947 (patch) | |
tree | a69d80efd9c14750358fe223f9c6ff254df5eb3f /vm_insnhelper.c | |
parent | 405452b5bb8ea4e64735bf22a2070ffc75963434 (diff) | |
download | ruby-0ac93a1a405d3642a1e73294c04f428c79f5f947.tar.gz |
* insns.def, vm_insnhelper.c (getinstancevariable):
fix to use inline cache.
* compile.c: fix to skip inline cache entry (IC). IC is added
automatically by compiler.
* insns.def, vm_insnhelper.h: fix IC positions.
* iseq.c: increment minor_version of ISeq because of above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index de1f812d24..de53d533b8 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1171,6 +1171,53 @@ vm_get_cvar_base(NODE *cref) return klass; } +static VALUE +vm_getivar(VALUE obj, ID id, IC ic) +{ +#if 1 + if (TYPE(obj) == T_OBJECT) { + VALUE val = Qundef; + VALUE klass = RBASIC(obj)->klass; + + if (ic->ic_class == klass) { + long index = ic->ic_vmstat; + long len = ROBJECT_NUMIV(obj); + VALUE *ptr = ROBJECT_IVPTR(obj); + + if (index < len) { + val = ptr[index]; + } + } + else { + st_data_t index; + long len = ROBJECT_NUMIV(obj); + VALUE *ptr = ROBJECT_IVPTR(obj); + struct st_table *iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj); + + if (iv_index_tbl) { + if (st_lookup(iv_index_tbl, id, &index)) { + if (index < len) { + val = ptr[index]; + } + ic->ic_class = CLASS_OF(obj); + ic->ic_vmstat = index; + } + } + } + if (UNLIKELY(val == Qundef)) { + rb_warning("instance variable %s not initialized", rb_id2name(id)); + val = Qnil; + } + return val; + } + else { + return rb_ivar_get(obj, id); + } +#else + return rb_ivar_get(obj, id); +#endif +} + static inline NODE * vm_method_search(VALUE id, VALUE klass, IC ic) { |