compile.c: fix dangling link
* compile.c (iseq_peephole_optimize): should not replace the current target INSN, not to follow the replaced dangling link in the caller. [ruby-core:74993] [Bug #11816] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0a38e38aea
commit
6ee3a2cd15
@ -1,3 +1,9 @@
|
|||||||
|
Mon Apr 18 16:07:01 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* compile.c (iseq_peephole_optimize): should not replace the
|
||||||
|
current target INSN, not to follow the replaced dangling link in
|
||||||
|
the caller. [ruby-core:74993] [Bug #11816]
|
||||||
|
|
||||||
Mon Apr 18 12:56:31 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Apr 18 12:56:31 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* numeric.c (flo_truncate): add an optional parameter, digits, as
|
* numeric.c (flo_truncate): add an optional parameter, digits, as
|
||||||
|
10
compile.c
10
compile.c
@ -852,6 +852,7 @@ INSERT_ELEM_PREV(LINK_ELEMENT *elem1, LINK_ELEMENT *elem2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* elemX, elem1, elemY => elemX, elem2, elemY
|
* elemX, elem1, elemY => elemX, elem2, elemY
|
||||||
*/
|
*/
|
||||||
@ -867,6 +868,7 @@ REPLACE_ELEM(LINK_ELEMENT *elem1, LINK_ELEMENT *elem2)
|
|||||||
elem1->next->prev = elem2;
|
elem1->next->prev = elem2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
REMOVE_ELEM(LINK_ELEMENT *elem)
|
REMOVE_ELEM(LINK_ELEMENT *elem)
|
||||||
@ -2056,15 +2058,13 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
|||||||
* LABEL:
|
* LABEL:
|
||||||
* leave
|
* leave
|
||||||
*/
|
*/
|
||||||
INSN *eiobj = new_insn_core(iseq, iobj->line_no, BIN(leave),
|
|
||||||
diobj->operand_size, diobj->operands);
|
|
||||||
INSN *popiobj = new_insn_core(iseq, iobj->line_no,
|
INSN *popiobj = new_insn_core(iseq, iobj->line_no,
|
||||||
BIN(pop), 0, 0);
|
BIN(pop), 0, 0);
|
||||||
/* replace */
|
/* replace */
|
||||||
unref_destination(iobj, 0);
|
unref_destination(iobj, 0);
|
||||||
REPLACE_ELEM((LINK_ELEMENT *)iobj, (LINK_ELEMENT *)eiobj);
|
iobj->insn_id = BIN(leave);
|
||||||
INSERT_ELEM_NEXT((LINK_ELEMENT *)eiobj, (LINK_ELEMENT *)popiobj);
|
iobj->operand_size = 0;
|
||||||
iobj = eiobj;
|
INSERT_ELEM_NEXT(&iobj->link, &popiobj->link);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -424,4 +424,9 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
assert_nil result, '[ruby-dev:49423] [Bug #11804]'
|
assert_nil result, '[ruby-dev:49423] [Bug #11804]'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_nil_safe_conditional_assign
|
||||||
|
bug11816 = '[ruby-core:74993] [Bug #11816]'
|
||||||
|
assert_ruby_status([], 'nil&.foo &&= false', bug11816)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user