8000 merge revision(s) 44568: [Backport #9399] · github/ruby@276b6b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 276b6b8

Browse files
committed
merge revision(s) 44568: [Backport ruby#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 ruby#9399] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent df38246 commit 276b6b8

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Sat Feb 22 13:26:57 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* iseq.c (iseq_load): keep type_map to get rid of memory leak.
4+
based on a patch by Eric Wong at [ruby-core:59699]. [Bug #9399]
5+
16
Sat Feb 22 13:17:32 2014 Masaki Matsushita <glass.saga@gmail.com>
27

38
* ext/thread/thread.c (rb_szqueue_clear): notify SZQUEUE_WAITERS

iseq.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
483483
VALUE type, body, locals, args, exception;
484484

485485
st_data_t iseq_type;
486+
static struct st_table *type_map_cache = 0;
486487
struct st_table *type_map = 0;
487488
rb_iseq_t *iseq;
488489
rb_compile_option_t option;
@@ -523,7 +524,9 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
523524
iseq->self = iseqval;
524525
iseq->local_iseq = iseq;
525526

527+
type_map = type_map_cache;
526528
if (type_map == 0) {
529+
struct st_table *cached_map;
527530
type_map = st_init_numtable();
528531
st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP);
529532
st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD);
@@ -534,6 +537,11 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
534537
st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL);
535538
st_insert(type_map, ID2SYM(rb_intern("main")), ISEQ_TYPE_MAIN);
536539
st_insert(type_map, ID2SYM(rb_intern("defined_guard")), ISEQ_TYPE_DEFINED_GUARD);
540+
cached_map = ATOMIC_PTR_CAS(type_map_cache, (struct st_table *)0, type_map);
541+
if (cached_map) {
542+
st_free_table(type_map);
543+
type_map = cached_map;
544+
}
537545
}
538546

539547
if (st_lookup(type_map, type, &iseq_type) == 0) {

ruby_atomic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,10 @@ atomic_size_exchange(size_t *ptr, size_t val)
161161
# define ATOMIC_PTR_EXCHANGE(var, val) (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val))
162162
# endif
163163
#endif
164+
#ifndef ATOMIC_PTR_CAS
165+
# if SIZEOF_VOIDP == SIZEOF_SIZE_T
166+
# define ATOMIC_PTR_CAS(var, oldval, val) (void *)ATOMIC_SIZE_CAS(*(size_t *)&(var), (size_t)(oldval), (size_t)(val))
167+
# endif
168+
#endif
164169

165170
#endif /* RUBY_ATOMIC_H */

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.1"
22
#define RUBY_RELEASE_DATE "2014-02-22"
3-
#define RUBY_PATCHLEVEL 51
3+
#define RUBY_PATCHLEVEL 52
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 2

0 commit comments

Comments
 (0)
0