From 084b602d9a52b62a04d17f65ba1a9b8a767d1e3e Mon Sep 17 00:00:00 2001 From: tmm1 Date: Tue, 3 Dec 2013 08:11:07 +0000 Subject: * include/ruby/ruby.h (struct RClass): Add wrapper struct around RClass->m_tbl with serial. This prevents double marking method tables, since many classes/modules can share the same method table. This improves minor mark time in a large application by 30%. * internal.h (struct method_table_wrapper): Define new wrapper struct with additional serial. * internal.h (RCLASS_M_TBL_INIT): New macro for initializing method table wrapper and st_table. * method.h (void rb_sweep_method_entry): Rename rb_free_m_table to rb_free_m_tbl for consistentcy * .gdbinit (define rb_method_entry): Update rb_method_entry gdb helper for new method table structure. * class.c: Use RCLASS_M_TBL_WRAPPER and RCLASS_M_TBL_INIT macros. * class.c (rb_include_class_new): Share WRAPPER between module and iclass, so serial can prevent double marking. * eval.c (rb_prepend_module): ditto. * eval.c (rb_using_refinement): ditto. * gc.c: Mark and free new wrapper struct. * gc.c (obj_memsize_of): Count size of additional wrapper struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- internal.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'internal.h') diff --git a/internal.h b/internal.h index 43a08a6063..f1c9e94041 100644 --- a/internal.h +++ b/internal.h @@ -276,6 +276,11 @@ struct rb_classext_struct { rb_alloc_func_t allocator; }; +struct method_table_wrapper { + st_table *tbl; + size_t serial; +}; + /* class.c */ void rb_class_subclass_add(VALUE super, VALUE klass); void rb_class_remove_from_super_subclasses(VALUE); @@ -283,11 +288,22 @@ void rb_class_remove_from_super_subclasses(VALUE); #define RCLASS_EXT(c) (RCLASS(c)->ptr) #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl) #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl) -#define RCLASS_M_TBL(c) (RCLASS(c)->m_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_ORIGIN(c) (RCLASS_EXT(c)->origin) #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class) +static inline void +RCLASS_M_TBL_INIT(VALUE c) +{ + struct method_table_wrapper *wrapper; + wrapper = ALLOC(struct method_table_wrapper); + wrapper->tbl = st_init_numtable(); + wrapper->serial = 0; + RCLASS_M_TBL_WRAPPER(c) = wrapper; +} + #undef RCLASS_SUPER static inline VALUE RCLASS_SUPER(VALUE klass) -- cgit v1.2.3