Fix invokebuiltin in Ruby MJIT
45fe7f7575/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb (L21)
has not been ported correctly.
This commit is contained in:
parent
3dd4e381fe
commit
96d29dff66
@ -446,9 +446,10 @@ module RubyVM::MJIT
|
|||||||
def compile_invokebuiltin(f, insn, stack_size, sp_inc, body, operands)
|
def compile_invokebuiltin(f, insn, stack_size, sp_inc, body, operands)
|
||||||
bf = C.RB_BUILTIN.new(operands[0])
|
bf = C.RB_BUILTIN.new(operands[0])
|
||||||
if bf.compiler > 0
|
if bf.compiler > 0
|
||||||
|
index = (insn.name == :invokebuiltin ? -1 : operands[1])
|
||||||
C.fprintf(f, "{\n")
|
C.fprintf(f, "{\n")
|
||||||
C.fprintf(f, " VALUE val;\n")
|
C.fprintf(f, " VALUE val;\n")
|
||||||
C.builtin_compiler(f, bf, operands[1], stack_size, body.builtin_inline_p)
|
C.builtin_compiler(f, bf, index, stack_size, body.builtin_inline_p)
|
||||||
C.fprintf(f, " stack[#{stack_size + sp_inc - 1}] = val;\n")
|
C.fprintf(f, " stack[#{stack_size + sp_inc - 1}] = val;\n")
|
||||||
C.fprintf(f, "}\n")
|
C.fprintf(f, "}\n")
|
||||||
return true
|
return true
|
||||||
|
@ -24,9 +24,6 @@ class TestMJIT < Test::Unit::TestCase
|
|||||||
# not supported yet
|
# not supported yet
|
||||||
:defineclass,
|
:defineclass,
|
||||||
|
|
||||||
# to be tested
|
|
||||||
:invokebuiltin,
|
|
||||||
|
|
||||||
# never used
|
# never used
|
||||||
:opt_invokebuiltin_delegate,
|
:opt_invokebuiltin_delegate,
|
||||||
].each do |insn|
|
].each do |insn|
|
||||||
@ -600,6 +597,15 @@ class TestMJIT < Test::Unit::TestCase
|
|||||||
assert_compile_once("'true' =~ /true/", result_inspect: '0', insns: %i[opt_regexpmatch2])
|
assert_compile_once("'true' =~ /true/", result_inspect: '0', insns: %i[opt_regexpmatch2])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_compile_insn_invokebuiltin
|
||||||
|
iseq = eval(EnvUtil.invoke_ruby(['-e', <<~'EOS'], '', true).first)
|
||||||
|
p RubyVM::InstructionSequence.of([].method(:sample)).to_a
|
||||||
|
EOS
|
||||||
|
insns = collect_insns(iseq)
|
||||||
|
mark_tested_insn(:invokebuiltin, used_insns: insns)
|
||||||
|
assert_eval_with_jit('print [].sample(1)', stdout: '[]', success_count: 1)
|
||||||
|
end
|
||||||
|
|
||||||
def test_compile_insn_opt_invokebuiltin_delegate_leave
|
def test_compile_insn_opt_invokebuiltin_delegate_leave
|
||||||
iseq = eval(EnvUtil.invoke_ruby(['-e', <<~'EOS'], '', true).first)
|
iseq = eval(EnvUtil.invoke_ruby(['-e', <<~'EOS'], '', true).first)
|
||||||
p RubyVM::InstructionSequence.of("\x00".method(:unpack)).to_a
|
p RubyVM::InstructionSequence.of("\x00".method(:unpack)).to_a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user