summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-18 11:53:14 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-18 11:53:14 +0000
commitd191339b9eea8ae1e3500f75ec539e5d4ea03b00 (patch)
tree97c12a96f408cb7fbe8bd1a5b4db54611bf597b4 /compile.c
parent15f641a5f5c700603b81042bd39822b9b8c6296f (diff)
Revert r62426
it cause test failure git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/compile.c b/compile.c
index e8460d2220..fb385f9ee6 100644
--- a/compile.c
+++ b/compile.c
@@ -2295,55 +2295,33 @@ replace_destination(INSN *dobj, INSN *nobj)
if (!dl->refcnt) ELEM_REMOVE(&dl->link);
}
-static LABEL*
-find_destination(INSN *i)
-{
- int pos, len = insn_len(i->insn_id);
- for (pos = 0; pos < len; ++pos) {
- if (insn_op_types(i->insn_id)[pos] == TS_OFFSET) {
- return (LABEL *)OPERAND_AT(i, pos);
- }
- }
- return 0;
-}
-
static int
remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
{
LINK_ELEMENT *first = i, *end;
- int *unref_counts = 0, nlabels = ISEQ_COMPILE_DATA(iseq)->label_no;
if (!i) return 0;
- unref_counts = ALLOCA_N(int, nlabels);
- MEMZERO(unref_counts, int, nlabels);
- end = i;
- do {
- LABEL *lab;
+ while (i) {
if (IS_INSN(i)) {
- if (IS_INSN_ID(i, leave)) {
- end = i;
+ if (IS_INSN_ID(i, jump) || IS_INSN_ID(i, leave)) {
break;
}
- else if ((lab = find_destination((INSN *)i)) != 0) {
- if (lab->unremovable) break;
- unref_counts[lab->label_no]++;
- }
}
else if (IS_LABEL(i)) {
- lab = (LABEL *)i;
- if (lab->unremovable) return 0;
- if (lab->refcnt > unref_counts[lab->label_no]) {
+ if (((LABEL *)i)->unremovable) return 0;
+ if (((LABEL *)i)->refcnt > 0) {
if (i == first) return 0;
+ i = i->prev;
break;
}
- continue;
}
else if (IS_TRACE(i)) {
/* do nothing */
}
else return 0;
- end = i;
- } while ((i = i->next) != 0);
+ i = i->next;
+ }
+ end = i;
i = first;
do {
if (IS_INSN(i)) {
@@ -2438,7 +2416,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
goto again;
}
else if (IS_INSN_ID(diobj, leave)) {
- INSN *pop;
/*
* jump LABEL
* ...
@@ -2446,7 +2423,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
* leave
* =>
* leave
- * pop
* ...
* LABEL:
* leave
@@ -2456,9 +2432,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
iobj->insn_id = BIN(leave);
iobj->operand_size = 0;
iobj->insn_info = diobj->insn_info;
- /* adjust stack depth */
- pop = new_insn_body(iseq, diobj->insn_info.line_no, BIN(pop), 0);
- ELEM_INSERT_NEXT(&iobj->link, &pop->link);
goto again;
}
else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 &&