ruby-changes:36673
From: nobu <ko1@a...>
Date: Wed, 10 Dec 2014 13:39:50 +0900 (JST)
Subject: [ruby-changes:36673] nobu:r48754 (trunk): struct.c: use iseqval
nobu 2014-12-10 13:39:29 +0900 (Wed, 10 Dec 2014) New Revision: 48754 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48754 Log: struct.c: use iseqval * struct.c (define_aref_method, define_aset_method): use iseq VALUE instead of rb_iseq_t to prevent from GC, as RB_GC_GUARD makes sense only for local variables. [Feature #10575] Modified files: trunk/ChangeLog trunk/iseq.c trunk/struct.c Index: ChangeLog =================================================================== --- ChangeLog (revision 48753) +++ ChangeLog (revision 48754) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Dec 10 13:39:27 2014 Nobuyoshi Nakada <nobu@r...> + + * struct.c (define_aref_method, define_aset_method): use iseq + VALUE instead of rb_iseq_t to prevent from GC, as RB_GC_GUARD + makes sense only for local variables. [Feature #10575] + Wed Dec 10 09:38:40 2014 Nobuyoshi Nakada <nobu@r...> * thread.c (exec_recursive): use the same last method name as Index: iseq.c =================================================================== --- iseq.c (revision 48753) +++ iseq.c (revision 48754) @@ -548,7 +548,7 @@ iseq_load(VALUE self, VALUE data, VALUE https://github.com/ruby/ruby/blob/trunk/iseq.c#L548 return iseqval; } -rb_iseq_t * +VALUE rb_method_for_self_aref(VALUE name, VALUE arg) { VALUE iseqval = iseq_alloc(rb_cISeq); @@ -591,10 +591,10 @@ rb_method_for_self_aref(VALUE name, VALU https://github.com/ruby/ruby/blob/trunk/iseq.c#L591 rb_iseq_build_from_ary(iseq, misc, locals, params, exception, body); cleanup_iseq_build(iseq); - return iseq; + return iseqval; } -rb_iseq_t * +VALUE rb_method_for_self_aset(VALUE name, VALUE arg) { VALUE iseqval = iseq_alloc(rb_cISeq); @@ -646,7 +646,7 @@ rb_method_for_self_aset(VALUE name, VALU https://github.com/ruby/ruby/blob/trunk/iseq.c#L646 rb_iseq_build_from_ary(iseq, misc, locals, params, exception, body); cleanup_iseq_build(iseq); - return iseq; + return iseqval; } /* Index: struct.c =================================================================== --- struct.c (revision 48753) +++ struct.c (revision 48754) @@ -13,8 +13,8 @@ https://github.com/ruby/ruby/blob/trunk/struct.c#L13 #include "vm_core.h" #include "method.h" -rb_iseq_t *rb_method_for_self_aref(VALUE name, VALUE arg); -rb_iseq_t *rb_method_for_self_aset(VALUE name, VALUE arg); +VALUE rb_method_for_self_aref(VALUE name, VALUE arg); +VALUE rb_method_for_self_aset(VALUE name, VALUE arg); VALUE rb_cStruct; static ID id_members; @@ -175,19 +175,21 @@ new_struct(VALUE name, VALUE super) https://github.com/ruby/ruby/blob/trunk/struct.c#L175 static void define_aref_method(VALUE nstr, VALUE name, VALUE off) { - rb_iseq_t *iseq = rb_method_for_self_aref(name, off); + VALUE iseqval = rb_method_for_self_aref(name, off); + rb_iseq_t *iseq = DATA_PTR(iseqval); rb_add_method(nstr, SYM2ID(name), VM_METHOD_TYPE_ISEQ, iseq, NOEX_PUBLIC); - RB_GC_GUARD(iseq->self); + RB_GC_GUARD(iseqval); } static void define_aset_method(VALUE nstr, VALUE name, VALUE off) { - rb_iseq_t *iseq = rb_method_for_self_aset(name, off); + VALUE iseqval = rb_method_for_self_aset(name, off); + rb_iseq_t *iseq = DATA_PTR(iseqval); rb_add_method(nstr, SYM2ID(name), VM_METHOD_TYPE_ISEQ, iseq, NOEX_PUBLIC); - RB_GC_GUARD(iseq->self); + RB_GC_GUARD(iseqval); } static VALUE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/