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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bf74f633c5
commit
8efe878d11
@ -1,3 +1,9 @@
|
|||||||
|
Wed Dec 10 13:39:27 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Wed Dec 10 09:38:40 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* thread.c (exec_recursive): use the same last method name as
|
* thread.c (exec_recursive): use the same last method name as
|
||||||
|
8
iseq.c
8
iseq.c
@ -548,7 +548,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
|
|||||||
return iseqval;
|
return iseqval;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_iseq_t *
|
VALUE
|
||||||
rb_method_for_self_aref(VALUE name, VALUE arg)
|
rb_method_for_self_aref(VALUE name, VALUE arg)
|
||||||
{
|
{
|
||||||
VALUE iseqval = iseq_alloc(rb_cISeq);
|
VALUE iseqval = iseq_alloc(rb_cISeq);
|
||||||
@ -591,10 +591,10 @@ rb_method_for_self_aref(VALUE name, VALUE arg)
|
|||||||
rb_iseq_build_from_ary(iseq, misc, locals, params, exception, body);
|
rb_iseq_build_from_ary(iseq, misc, locals, params, exception, body);
|
||||||
cleanup_iseq_build(iseq);
|
cleanup_iseq_build(iseq);
|
||||||
|
|
||||||
return iseq;
|
return iseqval;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_iseq_t *
|
VALUE
|
||||||
rb_method_for_self_aset(VALUE name, VALUE arg)
|
rb_method_for_self_aset(VALUE name, VALUE arg)
|
||||||
{
|
{
|
||||||
VALUE iseqval = iseq_alloc(rb_cISeq);
|
VALUE iseqval = iseq_alloc(rb_cISeq);
|
||||||
@ -646,7 +646,7 @@ rb_method_for_self_aset(VALUE name, VALUE arg)
|
|||||||
rb_iseq_build_from_ary(iseq, misc, locals, params, exception, body);
|
rb_iseq_build_from_ary(iseq, misc, locals, params, exception, body);
|
||||||
cleanup_iseq_build(iseq);
|
cleanup_iseq_build(iseq);
|
||||||
|
|
||||||
return iseq;
|
return iseqval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
14
struct.c
14
struct.c
@ -13,8 +13,8 @@
|
|||||||
#include "vm_core.h"
|
#include "vm_core.h"
|
||||||
#include "method.h"
|
#include "method.h"
|
||||||
|
|
||||||
rb_iseq_t *rb_method_for_self_aref(VALUE name, VALUE arg);
|
VALUE 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_aset(VALUE name, VALUE arg);
|
||||||
|
|
||||||
VALUE rb_cStruct;
|
VALUE rb_cStruct;
|
||||||
static ID id_members;
|
static ID id_members;
|
||||||
@ -175,19 +175,21 @@ new_struct(VALUE name, VALUE super)
|
|||||||
static void
|
static void
|
||||||
define_aref_method(VALUE nstr, VALUE name, VALUE off)
|
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_add_method(nstr, SYM2ID(name), VM_METHOD_TYPE_ISEQ, iseq, NOEX_PUBLIC);
|
||||||
RB_GC_GUARD(iseq->self);
|
RB_GC_GUARD(iseqval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
define_aset_method(VALUE nstr, VALUE name, VALUE off)
|
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_add_method(nstr, SYM2ID(name), VM_METHOD_TYPE_ISEQ, iseq, NOEX_PUBLIC);
|
||||||
RB_GC_GUARD(iseq->self);
|
RB_GC_GUARD(iseqval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user