summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-02 13:58:07 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-02 13:58:07 +0000
commit2962b6e063e4e6e8bd4b8be5c45166972caf41c2 (patch)
treef46856c3f6070bba675fee950b04724a8227464c /iseq.c
parentafd564ee3f7f2c42359e20d5083a214f82744812 (diff)
* vm_core.h, iseq.h: remove rb_iseq_t::variable_body.
Fields in rb_iseq_t::variable_body are contained by rb_iseq_t::body::mark_ary (hidden Array object). Index 0 to 2 of mark_ary are reserved by these objects. * iseq.c: catch up this fix. * compile.c (rb_iseq_original_iseq): trivial rewrite. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/iseq.c b/iseq.c
index 3a53917..667cca5 100644
--- a/iseq.c
+++ b/iseq.c
@@ -92,8 +92,6 @@ rb_iseq_free(const rb_iseq_t *iseq)
ruby_xfree((void *)iseq->body->param.keyword);
}
compile_data_free(ISEQ_COMPILE_DATA(iseq));
- ruby_xfree(iseq->variable_body->iseq_);
- ruby_xfree(iseq->variable_body);
ruby_xfree(iseq->body);
}
RUBY_FREE_LEAVE("iseq");
@@ -116,10 +114,6 @@ rb_iseq_mark(const rb_iseq_t *iseq)
RUBY_MARK_UNLESS_NULL(body->location.absolute_path);
}
- if (iseq->variable_body) {
- RUBY_MARK_UNLESS_NULL(ISEQ_COVERAGE(iseq));
- }
-
if (ISEQ_COMPILE_DATA(iseq) != 0) {
const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
@@ -148,19 +142,10 @@ static size_t
iseq_memsize(const rb_iseq_t *iseq)
{
size_t size = 0; /* struct already counted as RVALUE size */
- const struct rb_iseq_variable_body *variable_body;
- const struct rb_iseq_constant_body *body;
+ const struct rb_iseq_constant_body *body = iseq->body;
const struct iseq_compile_data *compile_data;
- variable_body = iseq->variable_body;
- body = iseq->body;
-
- if (variable_body) {
- size += sizeof(struct rb_iseq_variable_body);
- if (variable_body->iseq_ && body) {
- size += body->iseq_size * sizeof(VALUE);
- }
- }
+ /* TODO: should we count original_iseq? */
if (body) {
struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&body->ci_entries[body->ci_size];
@@ -220,7 +205,6 @@ iseq_alloc(void)
{
rb_iseq_t *iseq = (rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
iseq->body = ZALLOC(struct rb_iseq_constant_body);
- iseq->variable_body = ZALLOC(struct rb_iseq_variable_body);
return iseq;
}
@@ -269,11 +253,18 @@ set_relation(rb_iseq_t *iseq, const rb_iseq_t *piseq)
void
rb_iseq_add_mark_object(const rb_iseq_t *iseq, VALUE obj)
{
- if (!RTEST(iseq->body->mark_ary)) {
- RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, rb_ary_tmp_new(3));
- RBASIC_CLEAR_CLASS(iseq->body->mark_ary);
- }
- rb_ary_push(iseq->body->mark_ary, obj);
+ /* TODO: check dedup */
+ rb_ary_push(ISEQ_MARK_ARY(iseq), obj);
+}
+
+static VALUE
+iseq_mark_ary_create(int flip_cnt)
+{
+ VALUE ary = rb_ary_tmp_new(3);
+ rb_ary_push(ary, Qnil); /* ISEQ_MARK_ARY_COVERAGE */
+ rb_ary_push(ary, INT2FIX(flip_cnt)); /* ISEQ_MARK_ARY_FLIP_CNT */
+ rb_ary_push(ary, Qnil); /* ISEQ_MARK_ARY_ORIGINAL_ISEQ */
+ return ary;
}
static VALUE
@@ -292,7 +283,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
if (iseq != iseq->body->local_iseq) {
RB_OBJ_WRITE(iseq, &iseq->body->location.base_label, iseq->body->local_iseq->body->location.label);
}
- RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, 0);
+ RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, iseq_mark_ary_create(0));
ISEQ_COMPILE_DATA(iseq) = ZALLOC(struct iseq_compile_data);
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, Qnil);