* internal.h (RCLASS_SERIAL): Add RCLASS_SERIAL as a convenience
accessor for RCLASS_EXT(klass)->class_serial. * class.c, vm_insnhelper.c, vm_method.c: Use RCLASS_SERIAL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7df9798126
commit
c039c70815
@ -1,3 +1,10 @@
|
|||||||
|
Mon Dec 9 20:00:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
|
||||||
|
|
||||||
|
* internal.h (RCLASS_SERIAL): Add RCLASS_SERIAL as a convenience
|
||||||
|
accessor for RCLASS_EXT(klass)->class_serial.
|
||||||
|
|
||||||
|
* class.c, vm_insnhelper.c, vm_method.c: Use RCLASS_SERIAL
|
||||||
|
|
||||||
Mon Dec 9 19:50:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
|
Mon Dec 9 19:50:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
|
||||||
|
|
||||||
* compile.c, insns.def, test/ruby/test_rubyvm.rb, vm.c, vm_core.h,
|
* compile.c, insns.def, test/ruby/test_rubyvm.rb, vm.c, vm_core.h,
|
||||||
|
2
class.c
2
class.c
@ -166,7 +166,7 @@ class_alloc(VALUE flags, VALUE klass)
|
|||||||
RCLASS_EXT(obj)->subclasses = NULL;
|
RCLASS_EXT(obj)->subclasses = NULL;
|
||||||
RCLASS_EXT(obj)->parent_subclasses = NULL;
|
RCLASS_EXT(obj)->parent_subclasses = NULL;
|
||||||
RCLASS_EXT(obj)->module_subclasses = NULL;
|
RCLASS_EXT(obj)->module_subclasses = NULL;
|
||||||
RCLASS_EXT(obj)->class_serial = rb_next_class_serial();
|
RCLASS_SERIAL(obj) = rb_next_class_serial();
|
||||||
|
|
||||||
RCLASS_REFINED_CLASS(obj) = Qnil;
|
RCLASS_REFINED_CLASS(obj) = Qnil;
|
||||||
RCLASS_EXT(obj)->allocator = 0;
|
RCLASS_EXT(obj)->allocator = 0;
|
||||||
|
@ -296,6 +296,7 @@ void rb_class_remove_from_super_subclasses(VALUE);
|
|||||||
#define RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl)
|
#define RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl)
|
||||||
#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin)
|
#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin)
|
||||||
#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
|
#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
|
||||||
|
#define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
RCLASS_M_TBL_INIT(VALUE c)
|
RCLASS_M_TBL_INIT(VALUE c)
|
||||||
|
@ -487,7 +487,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
|
|||||||
VALUE val = Qundef;
|
VALUE val = Qundef;
|
||||||
VALUE klass = RBASIC(obj)->klass;
|
VALUE klass = RBASIC(obj)->klass;
|
||||||
|
|
||||||
if (LIKELY((!is_attr && ic->ic_serial == RCLASS_EXT(klass)->class_serial) ||
|
if (LIKELY((!is_attr && ic->ic_serial == RCLASS_SERIAL(klass)) ||
|
||||||
(is_attr && ci->aux.index > 0))) {
|
(is_attr && ci->aux.index > 0))) {
|
||||||
long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index - 1;
|
long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index - 1;
|
||||||
long len = ROBJECT_NUMIV(obj);
|
long len = ROBJECT_NUMIV(obj);
|
||||||
@ -510,7 +510,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
|
|||||||
}
|
}
|
||||||
if (!is_attr) {
|
if (!is_attr) {
|
||||||
ic->ic_value.index = index;
|
ic->ic_value.index = index;
|
||||||
ic->ic_serial = RCLASS_EXT(klass)->class_serial;
|
ic->ic_serial = RCLASS_SERIAL(klass);
|
||||||
}
|
}
|
||||||
else { /* call_info */
|
else { /* call_info */
|
||||||
ci->aux.index = index + 1;
|
ci->aux.index = index + 1;
|
||||||
@ -542,7 +542,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, IC ic, rb_call_info_t *ci, int is_attr)
|
|||||||
st_data_t index;
|
st_data_t index;
|
||||||
|
|
||||||
if (LIKELY(
|
if (LIKELY(
|
||||||
(!is_attr && ic->ic_serial == RCLASS_EXT(klass)->class_serial) ||
|
(!is_attr && ic->ic_serial == RCLASS_SERIAL(klass)) ||
|
||||||
(is_attr && ci->aux.index > 0))) {
|
(is_attr && ci->aux.index > 0))) {
|
||||||
long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index-1;
|
long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index-1;
|
||||||
long len = ROBJECT_NUMIV(obj);
|
long len = ROBJECT_NUMIV(obj);
|
||||||
@ -559,7 +559,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, IC ic, rb_call_info_t *ci, int is_attr)
|
|||||||
if (iv_index_tbl && st_lookup(iv_index_tbl, (st_data_t)id, &index)) {
|
if (iv_index_tbl && st_lookup(iv_index_tbl, (st_data_t)id, &index)) {
|
||||||
if (!is_attr) {
|
if (!is_attr) {
|
||||||
ic->ic_value.index = index;
|
ic->ic_value.index = index;
|
||||||
ic->ic_serial = RCLASS_EXT(klass)->class_serial;
|
ic->ic_serial = RCLASS_SERIAL(klass);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ci->aux.index = index + 1;
|
ci->aux.index = index + 1;
|
||||||
@ -823,7 +823,7 @@ vm_search_method(rb_call_info_t *ci, VALUE recv)
|
|||||||
VALUE klass = CLASS_OF(recv);
|
VALUE klass = CLASS_OF(recv);
|
||||||
|
|
||||||
#if OPT_INLINE_METHOD_CACHE
|
#if OPT_INLINE_METHOD_CACHE
|
||||||
if (LIKELY(GET_GLOBAL_METHOD_STATE() == ci->method_state && RCLASS_EXT(klass)->class_serial == ci->class_serial)) {
|
if (LIKELY(GET_GLOBAL_METHOD_STATE() == ci->method_state && RCLASS_SERIAL(klass) == ci->class_serial)) {
|
||||||
/* cache hit! */
|
/* cache hit! */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -834,7 +834,7 @@ vm_search_method(rb_call_info_t *ci, VALUE recv)
|
|||||||
ci->call = vm_call_general;
|
ci->call = vm_call_general;
|
||||||
#if OPT_INLINE_METHOD_CACHE
|
#if OPT_INLINE_METHOD_CACHE
|
||||||
ci->method_state = GET_GLOBAL_METHOD_STATE();
|
ci->method_state = GET_GLOBAL_METHOD_STATE();
|
||||||
ci->class_serial = RCLASS_EXT(klass)->class_serial;
|
ci->class_serial = RCLASS_SERIAL(klass);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ static struct cache_entry global_method_cache[GLOBAL_METHOD_CACHE_SIZE];
|
|||||||
static void
|
static void
|
||||||
rb_class_clear_method_cache(VALUE klass)
|
rb_class_clear_method_cache(VALUE klass)
|
||||||
{
|
{
|
||||||
RCLASS_EXT(klass)->class_serial = rb_next_class_serial();
|
RCLASS_SERIAL(klass) = rb_next_class_serial();
|
||||||
rb_class_foreach_subclass(klass, rb_class_clear_method_cache);
|
rb_class_foreach_subclass(klass, rb_class_clear_method_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user