ruby-changes:32215
From: tmm1 <ko1@a...>
Date: Fri, 20 Dec 2013 14:10:17 +0900 (JST)
Subject: [ruby-changes:32215] tmm1:r44294 (trunk): ruby.h: swap iv_index_tbl and super for struct RClass
tmm1 2013-12-20 14:10:07 +0900 (Fri, 20 Dec 2013) New Revision: 44294 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44294 Log: ruby.h: swap iv_index_tbl and super for struct RClass * include/ruby/ruby.h (struct RClass): add super, remove iv_index_tbl. since RCLASS_SUPER() is commonly used inside while loops, we move it back inside struct RClass to improve cache hits. this provides a small improvement (1%) in hotspots like rb_obj_is_kind_of() * internal.h (struct rb_classext_struct): remove super, add iv_index_table * internal.h (RCLASS_SUPER): update for new location * internal.h (RCLASS_SET_SUPER): ditto * internal.h (RCLASS_IV_INDEX_TBL): ditto * object.c (rb_class_get_superclass): ditto * include/ruby/backward/classext.h (RCLASS_SUPER): ditto Modified files: trunk/ChangeLog trunk/include/ruby/backward/classext.h trunk/include/ruby/ruby.h trunk/internal.h trunk/object.c Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 44293) +++ include/ruby/ruby.h (revision 44294) @@ -789,9 +789,9 @@ typedef struct rb_classext_struct rb_cla https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L789 struct RClass { struct RBasic basic; + VALUE super; rb_classext_t *ptr; struct method_table_wrapper *m_tbl_wrapper; - struct st_table *iv_index_tbl; }; #define RCLASS_SUPER(c) rb_class_get_superclass(c) #define RMODULE_IV_TBL(m) RCLASS_IV_TBL(m) Index: include/ruby/backward/classext.h =================================================================== --- include/ruby/backward/classext.h (revision 44293) +++ include/ruby/backward/classext.h (revision 44294) @@ -13,6 +13,6 @@ typedef struct rb_deprecated_classext_st https://github.com/ruby/ruby/blob/trunk/include/ruby/backward/classext.h#L13 #undef RCLASS_SUPER(c) #define RCLASS_EXT(c) ((rb_deprecated_classext_t *)RCLASS(c)->ptr) -#define RCLASS_SUPER(c) (RCLASS_EXT(c)->super) +#define RCLASS_SUPER(c) (RCLASS(c)->super) #endif /* RUBY_BACKWARD_CLASSEXT_H */ Index: ChangeLog =================================================================== --- ChangeLog (revision 44293) +++ ChangeLog (revision 44294) @@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Dec 20 14:00:01 2013 Aman Gupta <ruby@t...> + + * include/ruby/ruby.h (struct RClass): add super, remove iv_index_tbl. + since RCLASS_SUPER() is commonly used inside while loops, we move it + back inside struct RClass to improve cache hits. this provides a + small improvement (1%) in hotspots like rb_obj_is_kind_of() + * internal.h (struct rb_classext_struct): remove super, add + iv_index_table + * internal.h (RCLASS_SUPER): update for new location + * internal.h (RCLASS_SET_SUPER): ditto + * internal.h (RCLASS_IV_INDEX_TBL): ditto + * object.c (rb_class_get_superclass): ditto + * include/ruby/backward/classext.h (RCLASS_SUPER): ditto + Fri Dec 20 07:07:35 2013 Eric Hodel <drbrain@s...> * lib/rubygems: Update to RubyGems master 03d6ae7. Changes include: Index: object.c =================================================================== --- object.c (revision 44293) +++ object.c (revision 44294) @@ -1884,7 +1884,7 @@ rb_class_superclass(VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L1884 VALUE rb_class_get_superclass(VALUE klass) { - return RCLASS_EXT(klass)->super; + return RCLASS(klass)->super; } #define id_for_setter(name, type, message) \ Index: internal.h =================================================================== --- internal.h (revision 44293) +++ internal.h (revision 44294) @@ -262,7 +262,7 @@ typedef unsigned long rb_serial_t; https://github.com/ruby/ruby/blob/trunk/internal.h#L262 #endif struct rb_classext_struct { - VALUE super; + struct st_table *iv_index_tbl; struct st_table *iv_tbl; struct st_table *const_tbl; rb_subclass_entry_t *subclasses; @@ -293,7 +293,7 @@ void rb_class_remove_from_super_subclass https://github.com/ruby/ruby/blob/trunk/internal.h#L293 #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl) #define RCLASS_M_TBL_WRAPPER(c) (RCLASS(c)->m_tbl_wrapper) #define RCLASS_M_TBL(c) (RCLASS_M_TBL_WRAPPER(c) ? RCLASS_M_TBL_WRAPPER(c)->tbl : 0) -#define RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl) +#define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl) #define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin) #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class) #define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial) @@ -312,7 +312,7 @@ RCLASS_M_TBL_INIT(VALUE c) https://github.com/ruby/ruby/blob/trunk/internal.h#L312 static inline VALUE RCLASS_SUPER(VALUE klass) { - return RCLASS_EXT(klass)->super; + return RCLASS(klass)->super; } static inline VALUE @@ -322,7 +322,7 @@ RCLASS_SET_SUPER(VALUE klass, VALUE supe https://github.com/ruby/ruby/blob/trunk/internal.h#L322 rb_class_remove_from_super_subclasses(klass); rb_class_subclass_add(super, klass); } - OBJ_WRITE(klass, &RCLASS_EXT(klass)->super, super); + OBJ_WRITE(klass, &RCLASS(klass)->super, super); return super; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/