summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/compile.c b/compile.c
index 71f60b9b1b..68d4bf549a 100644
--- a/compile.c
+++ b/compile.c
@@ -563,15 +563,6 @@ APPEND_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *const anchor, LINK_ELEMENT *before, LI
#endif
static int
-iseq_add_mark_object(const rb_iseq_t *iseq, VALUE v)
-{
- if (!SPECIAL_CONST_P(v)) {
- rb_iseq_add_mark_object(iseq, v);
- }
- return COMPILE_OK;
-}
-
-static int
iseq_add_mark_object_compile_time(const rb_iseq_t *iseq, VALUE v)
{
if (!SPECIAL_CONST_P(v)) {
@@ -749,6 +740,7 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
encoded[i] = (VALUE)table[insn];
i += len;
}
+ FL_SET(iseq, ISEQ_TRANSLATED);
#endif
return COMPILE_OK;
}
@@ -1235,7 +1227,7 @@ new_child_iseq(rb_iseq_t *iseq, const NODE *const node,
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
INT2FIX(line_no), parent, type, ISEQ_COMPILE_DATA(iseq)->option);
debugs("[new_child_iseq]< ---------------------------------------\n");
- iseq_add_mark_object(iseq, (VALUE)ret_iseq);
+ iseq_add_mark_object_compile_time(iseq, (VALUE)ret_iseq);
return ret_iseq;
}
@@ -1250,7 +1242,7 @@ new_child_iseq_ifunc(rb_iseq_t *iseq, const struct vm_ifunc *ifunc,
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
INT2FIX(line_no), parent, type, ISEQ_COMPILE_DATA(iseq)->option);
debugs("[new_child_iseq_ifunc]< ---------------------------------------\n");
- iseq_add_mark_object(iseq, (VALUE)ret_iseq);
+ iseq_add_mark_object_compile_time(iseq, (VALUE)ret_iseq);
return ret_iseq;
}
@@ -1566,7 +1558,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
switch (nd_type(val_node)) {
case NODE_LIT:
dv = val_node->nd_lit;
- iseq_add_mark_object(iseq, dv);
+ iseq_add_mark_object_compile_time(iseq, dv);
break;
case NODE_NIL:
dv = Qnil;
@@ -2096,6 +2088,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
rb_hash_rehash(map);
freeze_hide_obj(map);
generated_iseq[code_index + 1 + j] = map;
+ FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
break;
}
case TS_LINDEX:
@@ -2106,6 +2099,9 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
{
VALUE v = operands[j];
generated_iseq[code_index + 1 + j] = v;
+ if (!SPECIAL_CONST_P(v)) {
+ FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
+ }
break;
}
case TS_VALUE: /* VALUE */
@@ -2113,7 +2109,9 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
VALUE v = operands[j];
generated_iseq[code_index + 1 + j] = v;
/* to mark ruby object */
- iseq_add_mark_object(iseq, v);
+ if (!SPECIAL_CONST_P(v)) {
+ FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
+ }
break;
}
case TS_IC: /* inline cache */
@@ -2126,6 +2124,17 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
generated_iseq[code_index + 1 + j] = (VALUE)ic;
break;
}
+ case TS_ISE: /* inline storage entry */
+ {
+ unsigned int ic_index = FIX2UINT(operands[j]);
+ IC ic = (IC)&iseq->body->is_entries[ic_index];
+ if (UNLIKELY(ic_index >= iseq->body->is_size)) {
+ rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->body->is_size);
+ }
+ generated_iseq[code_index + 1 + j] = (VALUE)ic;
+ FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
+ break;
+ }
case TS_CALLINFO: /* call info */
{
struct rb_call_info *base_ci = (struct rb_call_info *)operands[j];
@@ -2278,11 +2287,6 @@ iseq_set_exception_table(rb_iseq_t *iseq)
entry->end = label_get_position((LABEL *)(ptr[2] & ~1));
entry->iseq = (rb_iseq_t *)ptr[3];
- /* register iseq as mark object */
- if (entry->iseq != 0) {
- iseq_add_mark_object(iseq, (VALUE)entry->iseq);
- }
-
/* stack depth */
if (ptr[4]) {
LABEL *lobj = (LABEL *)(ptr[4] & ~1);
@@ -4897,7 +4901,7 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
}
if (only_special_literals) {
- iseq_add_mark_object(iseq, literals);
+ iseq_add_mark_object_compile_time(iseq, literals);
ADD_INSN(ret, nd_line(orig_node), dup);
ADD_INSN2(ret, nd_line(orig_node), opt_case_dispatch, literals, elselabel);
@@ -7374,6 +7378,7 @@ insn_data_to_s_detail(INSN *iobj)
break;
}
case TS_IC: /* inline cache */
+ case TS_ISE: /* inline storage entry */
rb_str_catf(str, "<ic:%d>", FIX2INT(OPERAND_AT(iobj, j)));
break;
case TS_CALLINFO: /* call info */
@@ -7613,7 +7618,6 @@ iseq_build_load_iseq(const rb_iseq_t *iseq, VALUE op)
}
loaded_iseq = rb_iseqw_to_iseq(iseqw);
- iseq_add_mark_object(iseq, (VALUE)loaded_iseq);
return loaded_iseq;
}
@@ -7744,7 +7748,6 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
break;
case TS_VALUE:
argv[j] = op;
- iseq_add_mark_object(iseq, op);
break;
case TS_ISEQ:
{
@@ -7761,6 +7764,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
argv[j] = (VALUE)rb_global_entry(SYM2ID(op));
break;
case TS_IC:
+ case TS_ISE:
argv[j] = op;
if (NUM2UINT(op) >= iseq->body->is_size) {
iseq->body->is_size = NUM2INT(op) + 1;
@@ -7791,7 +7795,6 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
}
RB_GC_GUARD(op);
argv[j] = map;
- rb_iseq_add_mark_object(iseq, map);
}
break;
case TS_FUNCPTR:
@@ -8395,6 +8398,7 @@ ibf_dump_code(struct ibf_dump *dump, const rb_iseq_t *iseq)
code[code_index] = (VALUE)ibf_dump_iseq(dump, (const rb_iseq_t *)op);
break;
case TS_IC:
+ case TS_ISE:
{
unsigned int i;
for (i=0; i<iseq->body->is_size; i++) {
@@ -8455,11 +8459,15 @@ ibf_load_code(const struct ibf_load *load, const rb_iseq_t *iseq, const struct r
case TS_CDHASH:
case TS_VALUE:
code[code_index] = ibf_load_object(load, op);
+ FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
break;
case TS_ISEQ:
code[code_index] = (VALUE)ibf_load_iseq(load, (const rb_iseq_t *)op);
+ FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
break;
case TS_IC:
+ FL_SET(iseq, ISEQ_MARKABLE_ISEQ);
+ case TS_ISE:
code[code_index] = (VALUE)&is_entries[(int)op];
break;
case TS_CALLINFO:
@@ -8760,7 +8768,8 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
dump_body.is_entries = NULL;
dump_body.ci_entries = ibf_dump_ci_entries(dump, iseq);
dump_body.cc_entries = NULL;
- dump_body.mark_ary = ISEQ_FLIP_CNT(iseq);
+ dump_body.variable.coverage = Qnil;
+ dump_body.variable.original_iseq = Qnil;
return ibf_dump_write(dump, &dump_body, sizeof(dump_body));
}
@@ -8792,7 +8801,9 @@ ibf_load_iseq_each(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t of
load_body->ci_kw_size = body->ci_kw_size;
load_body->insns_info.size = body->insns_info.size;
- RB_OBJ_WRITE(iseq, &load_body->mark_ary, iseq_mark_ary_create((int)body->mark_ary));
+ ISEQ_COVERAGE_SET(iseq, Qnil);
+ ISEQ_ORIGINAL_ISEQ_CLEAR(iseq);
+ iseq->body->variable.flip_count = body->variable.flip_count;
{
VALUE realpath = Qnil, path = ibf_load_object(load, body->location.pathobj);
@@ -9433,7 +9444,6 @@ ibf_load_object(const struct ibf_load *load, VALUE object_index)
rb_ary_store(load->obj_list, (long)object_index, obj);
}
- iseq_add_mark_object(load->iseq, obj);
return obj;
}
}
@@ -9655,9 +9665,6 @@ ibf_load_iseq(const struct ibf_load *load, const rb_iseq_t *index_iseq)
fprintf(stderr, "ibf_load_iseq: iseq=%p loaded %p\n",
iseq, load->iseq);
#endif
- if (load->iseq) {
- iseq_add_mark_object(load->iseq, (VALUE)iseq);
- }
return iseq;
}
}