зеркало из https://github.com/github/ruby.git
* vm_insnhelper.c: use T_IMEMO to create SVAR.
* internal.h, vm_insnhelper.h: move definition `struct SVAR' from vm_insnhelper.h to internal.h. And rename it to strcut vm_svar. new imemo_type imemo_svar is added. * gc.c (gc_mark_children): mark imemo_svar. * node.c (rb_gc_mark_node): remove useless marking. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
734146a459
Коммит
ac28b985bd
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Wed Mar 11 21:21:56 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm_insnhelper.c: use T_IMEMO to create SVAR.
|
||||
|
||||
* internal.h, vm_insnhelper.h: move definition `struct SVAR'
|
||||
from vm_insnhelper.h to internal.h. And rename it to strcut vm_svar.
|
||||
|
||||
new imemo_type imemo_svar is added.
|
||||
|
||||
* gc.c (gc_mark_children): mark imemo_svar.
|
||||
|
||||
* node.c (rb_gc_mark_node): remove useless marking.
|
||||
|
||||
Wed Mar 11 19:35:46 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* include/ruby/ruby.h: introduce new type T_IMEMO.
|
||||
|
|
9
gc.c
9
gc.c
|
@ -382,6 +382,7 @@ typedef struct RVALUE {
|
|||
struct RComplex complex;
|
||||
union {
|
||||
rb_cref_t cref;
|
||||
struct vm_svar svar;
|
||||
} imemo;
|
||||
struct {
|
||||
struct RBasic basic;
|
||||
|
@ -4156,8 +4157,14 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
|
|||
gc_mark(objspace, (VALUE)RANY(obj)->as.imemo.cref.next);
|
||||
gc_mark(objspace, RANY(obj)->as.imemo.cref.refinements);
|
||||
return;
|
||||
case imemo_svar:
|
||||
gc_mark(objspace, (VALUE)RANY(obj)->as.imemo.svar.cref);
|
||||
gc_mark(objspace, RANY(obj)->as.imemo.svar.lastline);
|
||||
gc_mark(objspace, RANY(obj)->as.imemo.svar.backref);
|
||||
gc_mark(objspace, RANY(obj)->as.imemo.svar.others);
|
||||
return;
|
||||
default:
|
||||
rb_bug("unreachable");
|
||||
rb_bug("T_IMEMO: unreachable");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
internal.h
11
internal.h
|
@ -532,6 +532,7 @@ struct RIMemo {
|
|||
enum imemo_type {
|
||||
imemo_none,
|
||||
imemo_cref,
|
||||
imemo_svar,
|
||||
imemo_mask = 0x07
|
||||
};
|
||||
|
||||
|
@ -634,6 +635,16 @@ CREF_OMOD_SHARED_UNSET(rb_cref_t *cref)
|
|||
cref->flags &= ~NODE_FL_CREF_OMOD_SHARED_;
|
||||
}
|
||||
|
||||
/* SVAR */
|
||||
|
||||
struct vm_svar {
|
||||
VALUE flags;
|
||||
const rb_cref_t * const cref;
|
||||
const VALUE lastline;
|
||||
const VALUE backref;
|
||||
const VALUE others;
|
||||
};
|
||||
|
||||
/* MEMO */
|
||||
|
||||
struct MEMO {
|
||||
|
|
1
node.c
1
node.c
|
@ -947,7 +947,6 @@ rb_gc_mark_node(NODE *obj)
|
|||
{
|
||||
switch (nd_type(obj)) {
|
||||
case NODE_IF: /* 1,2,3 */
|
||||
rb_gc_mark(CREF_REFINEMENTS((rb_cref_t *)obj)); /* use as SVAR */
|
||||
case NODE_FOR:
|
||||
case NODE_ITER:
|
||||
case NODE_WHEN:
|
||||
|
|
|
@ -141,7 +141,7 @@ rb_error_arity(int argc, int min, int max)
|
|||
|
||||
/* svar */
|
||||
|
||||
static inline struct SVAR **
|
||||
static inline struct vm_svar **
|
||||
lep_svar_place(rb_thread_t *th, const VALUE *lep)
|
||||
{
|
||||
const VALUE *svar;
|
||||
|
@ -153,14 +153,14 @@ lep_svar_place(rb_thread_t *th, const VALUE *lep)
|
|||
svar = &th->root_svar;
|
||||
}
|
||||
|
||||
return (struct SVAR **)svar;
|
||||
return (struct vm_svar **)svar;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
lep_svar_get(rb_thread_t *th, const VALUE *lep, rb_num_t key)
|
||||
{
|
||||
struct SVAR ** const svar_place = lep_svar_place(th, lep);
|
||||
const struct SVAR *const svar = *svar_place;
|
||||
struct vm_svar ** const svar_place = lep_svar_place(th, lep);
|
||||
const struct vm_svar *const svar = *svar_place;
|
||||
|
||||
if (NIL_P((VALUE)svar)) return Qnil;
|
||||
if (RB_TYPE_P((VALUE)svar, T_IMEMO) && imemo_type((VALUE)svar) == imemo_cref) return Qnil;
|
||||
|
@ -183,20 +183,24 @@ lep_svar_get(rb_thread_t *th, const VALUE *lep, rb_num_t key)
|
|||
}
|
||||
}
|
||||
|
||||
static struct vm_svar *
|
||||
svar_new(const rb_cref_t *cref)
|
||||
{
|
||||
return (struct vm_svar *)rb_imemo_new(imemo_svar, Qnil, Qnil, Qnil, (VALUE)cref);
|
||||
}
|
||||
|
||||
static void
|
||||
lep_svar_set(rb_thread_t *th, VALUE *lep, rb_num_t key, VALUE val)
|
||||
{
|
||||
struct SVAR **svar_place = lep_svar_place(th, lep);
|
||||
struct SVAR *svar = *svar_place;
|
||||
struct vm_svar **svar_place = lep_svar_place(th, lep);
|
||||
struct vm_svar *svar = *svar_place;
|
||||
|
||||
if (NIL_P((VALUE)svar)) {
|
||||
svar = *svar_place = (struct SVAR *)NEW_IF(Qnil, Qnil, Qnil);
|
||||
svar->cref = NULL;
|
||||
svar = *svar_place = svar_new(NULL);
|
||||
}
|
||||
else if (RB_TYPE_P((VALUE)svar, T_IMEMO) && imemo_type((VALUE)svar) == imemo_cref) {
|
||||
const rb_cref_t *cref = (rb_cref_t *)svar;
|
||||
svar = *svar_place = (struct SVAR *)NEW_IF(Qnil, Qnil, Qnil);
|
||||
RB_OBJ_WRITE(svar, &svar->cref, (VALUE)cref);
|
||||
svar = *svar_place = svar_new(cref);
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
|
@ -265,7 +269,7 @@ lep_cref(const VALUE *ep)
|
|||
return (rb_cref_t *)svar;
|
||||
}
|
||||
else {
|
||||
return (rb_cref_t *)((struct SVAR *)svar)->cref;
|
||||
return (rb_cref_t *)((struct vm_svar *)svar)->cref;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,7 +314,7 @@ rb_vm_rewrite_cref_stack(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_c
|
|||
COPY_CREF_OMOD(new_node, node);
|
||||
node = CREF_NEXT(node);
|
||||
*new_cref_ptr = new_node;
|
||||
new_cref_ptr = &new_node->next;
|
||||
new_cref_ptr = (rb_cref_t **)&new_node->next;
|
||||
}
|
||||
*new_cref_ptr = NULL;
|
||||
}
|
||||
|
|
|
@ -229,16 +229,6 @@ enum vm_regan_acttype {
|
|||
static VALUE make_no_method_exception(VALUE exc, const char *format,
|
||||
VALUE obj, int argc, const VALUE *argv);
|
||||
|
||||
/* SVAR */
|
||||
|
||||
struct SVAR {
|
||||
VALUE flags;
|
||||
const rb_cref_t *cref;
|
||||
VALUE lastline;
|
||||
VALUE backref;
|
||||
VALUE others;
|
||||
};
|
||||
|
||||
struct THROW_DATA {
|
||||
VALUE flags;
|
||||
VALUE reserved;
|
||||
|
|
Загрузка…
Ссылка в новой задаче