summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-13 23:53:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-13 23:53:00 +0000
commit496b4267b2015254edb176f98943d7599b43d22f (patch)
treec86e64a09a1454741a8565cec831a4bc78befb90 /compile.c
parent24d38cc447ee122c07208cf87a7899fe77792b02 (diff)
compile.c: fixup r60727
* compile.c (iseq_peephole_optimize): skip next `freezestring` instruction after `concatstrings` instruction when frozen string literal is enabled. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index de9cd01b67..b79f970cf4 100644
--- a/compile.c
+++ b/compile.c
@@ -2302,6 +2302,21 @@ iseq_pop_newarray(rb_iseq_t *iseq, INSN *iobj)
}
static int
+same_debug_pos_p(LINK_ELEMENT *iobj1, LINK_ELEMENT *iobj2)
+{
+ VALUE debug1 = OPERAND_AT(iobj1, 0);
+ VALUE debug2 = OPERAND_AT(iobj2, 0);
+ if (debug1 == debug2) return TRUE;
+ if (!RB_TYPE_P(debug1, T_ARRAY)) return FALSE;
+ if (!RB_TYPE_P(debug2, T_ARRAY)) return FALSE;
+ if (RARRAY_LEN(debug1) != 2) return FALSE;
+ if (RARRAY_LEN(debug2) != 2) return FALSE;
+ if (RARRAY_AREF(debug1, 0) != RARRAY_AREF(debug2, 0)) return FALSE;
+ if (RARRAY_AREF(debug1, 1) != RARRAY_AREF(debug2, 1)) return FALSE;
+ return TRUE;
+}
+
+static int
iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcallopt)
{
INSN *const iobj = (INSN *)list;
@@ -2637,6 +2652,14 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
OPERAND_AT(jump, 0) = (VALUE)label;
}
label->refcnt++;
+ if (freeze && IS_NEXT_INSN_ID(next, freezestring)) {
+ if (same_debug_pos_p(freeze, next->next)) {
+ REMOVE_ELEM(freeze);
+ }
+ else {
+ next = next->next;
+ }
+ }
INSERT_ELEM_NEXT(next, &label->link);
CHECK(iseq_peephole_optimize(iseq, get_next_insn(jump), do_tailcallopt));
}