Skip to content

Commit

Permalink
Pull iseq_add_mark_object_compile_time out of freeze_string
Browse files Browse the repository at this point in the history
`freeze_string` essentially called iseq_add_mark_object_compile_time.  I
need to know where all writes occur on the `rb_iseq_t`, so this commit
separates the function calls so we can add write barriers in the right
place.
  • Loading branch information
tenderlove committed Sep 26, 2019
1 parent f639e04 commit 98d7583
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions compile.c
Expand Up @@ -587,9 +587,7 @@ iseq_add_mark_object_compile_time(const rb_iseq_t *iseq, VALUE v)
static inline VALUE
freeze_literal(rb_iseq_t *iseq, VALUE lit)
{
lit = rb_fstring(lit);
rb_ary_push(ISEQ_COMPILE_DATA(iseq)->mark_ary, lit);
return lit;
return rb_fstring(lit);
}

static int
Expand Down Expand Up @@ -3657,6 +3655,7 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons
}
lit = freeze_literal(iseq, lit);
ADD_INSN1(ret, nd_line(node), putobject, lit);
iseq_add_mark_object_compile_time(iseq, lit);
if (RSTRING_LEN(lit) == 0) first_lit = LAST_ELEMENT(ret);
}

Expand All @@ -3665,6 +3664,7 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons
if (nd_type(head) == NODE_STR) {
lit = freeze_literal(iseq, head->nd_lit);
ADD_INSN1(ret, nd_line(head), putobject, lit);
iseq_add_mark_object_compile_time(iseq, lit);
lit = Qnil;
}
else {
Expand Down Expand Up @@ -4283,6 +4283,7 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
debugp_param("nd_lit", val->nd_lit);
lit = freeze_literal(iseq, val->nd_lit);
ADD_INSN1(cond_seq, nd_line(val), putobject, lit);
iseq_add_mark_object_compile_time(iseq, lit);
}
else {
if (!COMPILE(cond_seq, "when cond", val)) return -1;
Expand Down Expand Up @@ -6665,6 +6666,7 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
new_callinfo(iseq, idFreeze, 0, 0, NULL, FALSE),
Qundef /* CALL_CACHE */);
}
iseq_add_mark_object_compile_time(iseq, str);
if (popped) {
ADD_INSN(ret, line, pop);
}
Expand All @@ -6684,6 +6686,7 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
ADD_INSN3(ret, line, opt_aref_with, str,
new_callinfo(iseq, idAREF, 1, 0, NULL, FALSE),
NULL/* CALL_CACHE */);
iseq_add_mark_object_compile_time(iseq, str);
if (popped) {
ADD_INSN(ret, line, pop);
}
Expand Down Expand Up @@ -7760,6 +7763,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
if (!ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) {
lit = freeze_literal(iseq, lit);
ADD_INSN1(ret, line, putstring, lit);
iseq_add_mark_object_compile_time(iseq, lit);
}
else {
if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
Expand Down Expand Up @@ -7799,7 +7803,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
case NODE_XSTR:{
ADD_CALL_RECEIVER(ret, line);
ADD_INSN1(ret, line, putobject, freeze_literal(iseq, node->nd_lit));
VALUE str = freeze_literal(iseq, node->nd_lit);
ADD_INSN1(ret, line, putobject, str);
iseq_add_mark_object_compile_time(iseq, str);
ADD_CALL(ret, line, idBackquote, INT2FIX(1));

if (popped) {
Expand Down Expand Up @@ -8249,6 +8255,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
ADD_INSN3(ret, line, opt_aset_with, str,
new_callinfo(iseq, idASET, 2, 0, NULL, FALSE),
NULL/* CALL_CACHE */);
iseq_add_mark_object_compile_time(iseq, str);
ADD_INSN(ret, line, pop);
break;
}
Expand Down

0 comments on commit 98d7583

Please sign in to comment.