aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-11 12:27:34 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-11 12:27:34 +0000
commitac28b985bdc2f85eada8070d40f6de9f11dab7f8 (patch)
tree7032a0f9ca75346ea1316ff2d8254c2606de93da /vm_insnhelper.c
parent734146a459564e8b6aa221d8a5d4d55c8610d557 (diff)
downloadruby-ac28b985bdc2f85eada8070d40f6de9f11dab7f8.tar.gz
* 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
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index b2481834de..9a30986275 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -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;
}