From 4050436e57ce02f20058c90185f8711c299c8d3c Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 27 Jun 2013 17:32:35 +0000 Subject: merge revision(s) 40336: [Backport #8142] * compile.c (iseq_add_mark_object): Use new rb_iseq_add_mark_object(). * insns.def (setinlinecache): Ditto. * iseq.c (rb_iseq_add_mark_object): New function to allocate iseq->mark_ary on demand. [Bug #8142] * iseq.h (rb_iseq_add_mark_object): Ditto. * iseq.c (prepare_iseq_build): Avoid allocating mark_ary until needed. * iseq.c (rb_iseq_build_for_ruby2cext): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index 15c1fe13ae..567f9ea429 100644 --- a/iseq.c +++ b/iseq.c @@ -237,6 +237,17 @@ set_relation(rb_iseq_t *iseq, const VALUE parent) } } +void +rb_iseq_add_mark_object(rb_iseq_t *iseq, VALUE obj) +{ + if (!RTEST(iseq->mark_ary)) { + iseq->mark_ary = rb_ary_tmp_new(3); + OBJ_UNTRUST(iseq->mark_ary); + RBASIC(iseq->mark_ary)->klass = 0; + } + rb_ary_push(iseq->mark_ary, obj); +} + static VALUE prepare_iseq_build(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE absolute_path, VALUE first_lineno, @@ -259,9 +270,7 @@ prepare_iseq_build(rb_iseq_t *iseq, } iseq->defined_method_id = 0; - iseq->mark_ary = rb_ary_tmp_new(3); - OBJ_UNTRUST(iseq->mark_ary); - RBASIC(iseq->mark_ary)->klass = 0; + iseq->mark_ary = 0; /* @@ -2047,8 +2056,7 @@ rb_iseq_build_for_ruby2cext( iseq->location.label = rb_str_new2(name); iseq->location.path = rb_str_new2(path); iseq->location.first_lineno = first_lineno; - iseq->mark_ary = rb_ary_tmp_new(3); - OBJ_UNTRUST(iseq->mark_ary); + iseq->mark_ary = 0; iseq->self = iseqval; iseq->iseq = ALLOC_N(VALUE, iseq->iseq_size); -- cgit v1.2.3