зеркало из https://github.com/github/ruby.git
compile.c: fix tailcall optimization
* compile.c (iseq_peephole_optimize): don't apply tailcall optimization to send/invokesuper instructions with blockiseq. This is a follow-up to the changes in r51903; blockiseq is now the third operand of send/invokesuper instructions. [ruby-core:73413] [Bug #12018] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
667c0a3a8c
Коммит
f4ca0739ec
|
@ -1,3 +1,11 @@
|
||||||
|
Tue Jan 26 15:14:01 2016 Kazuki Yamaguchi <k@rhe.jp>
|
||||||
|
|
||||||
|
* compile.c (iseq_peephole_optimize): don't apply tailcall
|
||||||
|
optimization to send/invokesuper instructions with blockiseq.
|
||||||
|
This is a follow-up to the changes in r51903; blockiseq is now
|
||||||
|
the third operand of send/invokesuper instructions.
|
||||||
|
[ruby-core:73413] [Bug #12018]
|
||||||
|
|
||||||
Tue Jan 26 14:26:46 2016 Eric Wong <e@80x24.org>
|
Tue Jan 26 14:26:46 2016 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
* signal.c (sig_list): use fstring for hash key
|
* signal.c (sig_list): use fstring for hash key
|
||||||
|
|
|
@ -2248,8 +2248,12 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
||||||
|
|
||||||
if (piobj) {
|
if (piobj) {
|
||||||
struct rb_call_info *ci = (struct rb_call_info *)piobj->operands[0];
|
struct rb_call_info *ci = (struct rb_call_info *)piobj->operands[0];
|
||||||
rb_iseq_t *blockiseq = (rb_iseq_t *)piobj->operands[1];
|
if (piobj->insn_id == BIN(send) || piobj->insn_id == BIN(invokesuper)) {
|
||||||
if (blockiseq == 0) {
|
if (piobj->operands[2] == 0) { /* no blockiseq */
|
||||||
|
ci->flag |= VM_CALL_TAILCALL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
ci->flag |= VM_CALL_TAILCALL;
|
ci->flag |= VM_CALL_TAILCALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,6 +275,22 @@ class TestRubyOptimization < Test::Unit::TestCase
|
||||||
assert_equal(123, delay { 123 }.call, bug6901)
|
assert_equal(123, delay { 123 }.call, bug6901)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def just_yield
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_tailcall_inhibited_by_block
|
||||||
|
assert_separately([], <<~'end;')
|
||||||
|
def just_yield
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
iseq = RubyVM::InstructionSequence
|
||||||
|
result = iseq.compile("just_yield {:ok}", __FILE__, __FILE__, __LINE__,
|
||||||
|
tailcall_optimization: true).eval
|
||||||
|
assert_equal(:ok, result)
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
|
||||||
class Bug10557
|
class Bug10557
|
||||||
def [](_)
|
def [](_)
|
||||||
block_given?
|
block_given?
|
||||||
|
|
Загрузка…
Ссылка в новой задаче