diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-05 22:20:14 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-05 22:20:14 +0000 |
commit | 8f88ff4e37a5374e49025076905c57941379336a (patch) | |
tree | 91d54c45a4325f786b484bdbf6ffc9f61dc28527 /internal.h | |
parent | 908c25341ecfceb822b2b15288a8a3f53cf6add3 (diff) | |
download | ruby-8f88ff4e37a5374e49025076905c57941379336a.tar.gz |
* internal.h: remove struct method_table_wrapper.
struct method_table_wrapper was introduced to avoid duplicate marking
for method tables.
For example, `module M1; def foo; end; end` make one method table
(mtbl) contains a method `foo`. M1 (T_MODULE) points mtbl.
Classes C1 and C2 includes M1, then two T_ICLASS objects are created
and they points mtbl too. In this case, three objects (one T_MODULE
and two T_ICLASS objects) points same mtbl. On marking phase, these
three objects mark same mtbl. To avoid such duplication, struct
method_table_wrapper was introduced.
However, created two T_ICLASS objects have same or shorter lifetime
than M1 (T_MODULE) object. So that we only need to mark mtbl from M1,
not from T_ICLASS objects. This patch tries marking only from M1.
Note that one `Module#prepend` call creates two T_ICLASS objects.
One for refering to a prepending Module object, same as
`Module#include`. We don't nedd to care this T_ICLASS.
One for moving original mtbl from a prepending class. We need to
mark such mtbl from this T_ICLASS object. To mark the mtbl,
we need to use `RCLASS_ORIGIN(klass)` on marking from a prepended
class `klass`.
* class.c: ditto.
* eval.c (rb_using_refinement): ditto.
* gc.c: ditto.
* include/ruby/ruby.h: define m_tbl directly. The definition of
struct RClass should be moved to (srcdir)/internal.h.
* method.h: remove decl of rb_free_m_tbl_wrapper().
* object.c: use RCLASS_M_TBL() directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
-rw-r--r-- | internal.h | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/internal.h b/internal.h index c1b901348b..6d480eee3c 100644 --- a/internal.h +++ b/internal.h @@ -316,11 +316,6 @@ struct rb_classext_struct { rb_alloc_func_t allocator; }; -struct method_table_wrapper { - st_table *tbl; - size_t serial; -}; - #ifndef BDIGIT # if SIZEOF_INT*2 <= SIZEOF_LONG_LONG # define BDIGIT unsigned int @@ -480,8 +475,7 @@ 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_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_M_TBL(c) (RCLASS(c)->m_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) @@ -490,11 +484,7 @@ void rb_class_remove_from_super_subclasses(VALUE); 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; + RCLASS_M_TBL(c) = st_init_numtable(); } #undef RCLASS_SUPER |