aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-20 05:10:07 +0000
committertmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-20 05:10:07 +0000
commit3409690957ae57822ef18189c006068476c035ff (patch)
treea120872626eaeeb748c18c1b2b07e0dc642253db
parent41c42afddab5173c281fd1b6a8af2f522c540cc8 (diff)
downloadruby-3409690957ae57822ef18189c006068476c035ff.tar.gz
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog14
-rw-r--r--include/ruby/backward/classext.h2
-rw-r--r--include/ruby/ruby.h2
-rw-r--r--internal.h8
-rw-r--r--object.c2
5 files changed, 21 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 4927f015db..9b8e187366 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Fri Dec 20 14:00:01 2013 Aman Gupta <ruby@tmm1.net>
+
+ * 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@segment7.net>
* lib/rubygems: Update to RubyGems master 03d6ae7. Changes include:
diff --git a/include/ruby/backward/classext.h b/include/ruby/backward/classext.h
index 615e6f6858..33f3b014b8 100644
--- a/include/ruby/backward/classext.h
+++ b/include/ruby/backward/classext.h
@@ -13,6 +13,6 @@ typedef struct rb_deprecated_classext_struct {
#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 */
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 9af062ec94..03b9bd0d1a 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -789,9 +789,9 @@ typedef struct rb_classext_struct rb_classext_t;
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)
diff --git a/internal.h b/internal.h
index d01f6cf6ec..338929ba8b 100644
--- a/internal.h
+++ b/internal.h
@@ -262,7 +262,7 @@ typedef unsigned long rb_serial_t;
#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_subclasses(VALUE);
#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)
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 super)
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;
}
diff --git a/object.c b/object.c
index 81c5c5643f..466ec75492 100644
--- a/object.c
+++ b/object.c
@@ -1884,7 +1884,7 @@ rb_class_superclass(VALUE klass)
VALUE
rb_class_get_superclass(VALUE klass)
{
- return RCLASS_EXT(klass)->super;
+ return RCLASS(klass)->super;
}
#define id_for_setter(name, type, message) \