diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-14 06:44:36 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-14 06:44:36 +0000 |
commit | 30a1b86e68d549a7013277b7b57ea5692b57c07b (patch) | |
tree | 015c3c1a8624a8ffc3e060c04543b8d3d6683e97 /iseq.c | |
parent | 73176ef9396754d0a9d9f03264059d19b33294a0 (diff) |
merge revision(s) 44568: [Backport #9399]
* iseq.c (iseq_load): keep type_map to get rid of memory leak.
based on a patch by Eric Wong at [ruby-core:59699]. [Bug #9399]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@44946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -450,6 +450,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) VALUE type, body, locals, args, exception; st_data_t iseq_type; + static struct st_table *type_map_cache = 0; struct st_table *type_map = 0; rb_iseq_t *iseq; rb_compile_option_t option; @@ -488,7 +489,9 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) GetISeqPtr(iseqval, iseq); iseq->self = iseqval; + type_map = type_map_cache; if (type_map == 0) { + struct st_table *cached_map; type_map = st_init_numtable(); st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP); st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD); @@ -499,6 +502,11 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL); st_insert(type_map, ID2SYM(rb_intern("main")), ISEQ_TYPE_MAIN); st_insert(type_map, ID2SYM(rb_intern("defined_guard")), ISEQ_TYPE_DEFINED_GUARD); + cached_map = ATOMIC_PTR_CAS(type_map_cache, (struct st_table *)0, type_map); + if (cached_map) { + st_free_table(type_map); + type_map = cached_map; + } } if (st_lookup(type_map, type, &iseq_type) == 0) { |