Skip to content

Commit c039c70

Browse files
author
charliesome
committed
* 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
1 parent 7df9798 commit c039c70

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Mon Dec 9 20:00:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
2+
3+
* internal.h (RCLASS_SERIAL): Add RCLASS_SERIAL as a convenience
4+
accessor for RCLASS_EXT(klass)->class_serial.
5+
6+
* class.c, vm_insnhelper.c, vm_method.c: Use RCLASS_SERIAL
7+
18
Mon Dec 9 19:50:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
29

310
* compile.c, insns.def, test/ruby/test_rubyvm.rb, vm.c, vm_core.h,

class.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class_alloc(VALUE flags, VALUE klass)
166166
RCLASS_EXT(obj)->subclasses = NULL;
167167
RCLASS_EXT(obj)->parent_subclasses = NULL;
168168
RCLASS_EXT(obj)->module_subclasses = NULL;
169-
RCLASS_EXT(obj)->class_serial = rb_next_class_serial();
169+
RCLASS_SERIAL(obj) = rb_next_class_serial();
170170

171171
RCLASS_REFINED_CLASS(obj) = Qnil;
172172
RCLASS_EXT(obj)->allocator = 0;

internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ void rb_class_remove_from_super_subclasses(VALUE);
296296
#define RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl)
297297
#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin)
298298
#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
299+
#define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
299300

300301
static inline void
301302
RCLASS_M_TBL_INIT(VALUE c)

vm_insnhelper.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
487487
VALUE val = Qundef;
488488
VALUE klass = RBASIC(obj)->klass;
489489

490-
if (LIKELY((!is_attr && ic->ic_serial == RCLASS_EXT(klass)->class_serial) ||
490+
if (LIKELY((!is_attr && ic->ic_serial == RCLASS_SERIAL(klass)) ||
491491
(is_attr && ci->aux.index > 0))) {
492492
long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index - 1;
493493
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)
510510
}
511511
if (!is_attr) {
512512
ic->ic_value.index = index;
513-
ic->ic_serial = RCLASS_EXT(klass)->class_serial;
513+
ic->ic_serial = RCLASS_SERIAL(klass);
514514
}
515515
else { /* call_info */
516516
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)
542542
st_data_t index;
543543

544544
if (LIKELY(
545-
(!is_attr && ic->ic_serial == RCLASS_EXT(klass)->class_serial) ||
545+
(!is_attr && ic->ic_serial == RCLASS_SERIAL(klass)) ||
546546
(is_attr && ci->aux.index > 0))) {
547547
long index = !is_attr ? (long)ic->ic_value.index : ci->aux.index-1;
548548
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)
559559
if (iv_index_tbl && st_lookup(iv_index_tbl, (st_data_t)id, &index)) {
560560
if (!is_attr) {
561561
ic->ic_value.index = index;
562-
ic->ic_serial = RCLASS_EXT(klass)->class_serial;
562+
ic->ic_serial = RCLASS_SERIAL(klass);
563563
}
564564
else {
565565
ci->aux.index = index + 1;
@@ -823,7 +823,7 @@ vm_search_method(rb_call_info_t *ci, VALUE recv)
823823
VALUE klass = CLASS_OF(recv);
824824

825825
#if OPT_INLINE_METHOD_CACHE
826-
if (LIKELY(GET_GLOBAL_METHOD_STATE() == ci->method_state && RCLASS_EXT(klass)->class_serial == ci->class_serial)) {
826+
if (LIKELY(GET_GLOBAL_METHOD_STATE() == ci->method_state && RCLASS_SERIAL(klass) == ci->class_serial)) {
827827
/* cache hit! */
828828
return;
829829
}
@@ -834,7 +834,7 @@ vm_search_method(rb_call_info_t *ci, VALUE recv)
834834
ci->call = vm_call_general;
835835
#if OPT_INLINE_METHOD_CACHE
836836
ci->method_state = GET_GLOBAL_METHOD_STATE();
837-
ci->class_serial = RCLASS_EXT(klass)->class_serial;
837+
ci->class_serial = RCLASS_SERIAL(klass);
838838
#endif
839839
}
840840

vm_method.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static struct cache_entry global_method_cache[GLOBAL_METHOD_CACHE_SIZE];
3939
static void
4040
rb_class_clear_method_cache(VALUE klass)
4141
{
42-
RCLASS_EXT(klass)->class_serial = rb_next_class_serial();
42+
RCLASS_SERIAL(klass) = rb_next_class_serial();
4343
rb_class_foreach_subclass(klass, rb_class_clear_method_cache);
4444
}
4545

0 commit comments

Comments
 (0)