From 96d29dff66a0d2e045d09ce6bb7bb3b382c59c2c Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 13 Nov 2022 21:14:46 -0800 Subject: Fix invokebuiltin in Ruby MJIT https://github.com/ruby/ruby/blob/45fe7f757522ed7d1d3ec754da59d41d45dd6bab/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb#L21 has not been ported correctly. --- test/ruby/test_mjit.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_mjit.rb b/test/ruby/test_mjit.rb index 4c6cc6f39f..2fc878154b 100644 --- a/test/ruby/test_mjit.rb +++ b/test/ruby/test_mjit.rb @@ -24,9 +24,6 @@ class TestMJIT < Test::Unit::TestCase # not supported yet :defineclass, - # to be tested - :invokebuiltin, - # never used :opt_invokebuiltin_delegate, ].each do |insn| @@ -600,6 +597,15 @@ class TestMJIT < Test::Unit::TestCase assert_compile_once("'true' =~ /true/", result_inspect: '0', insns: %i[opt_regexpmatch2]) 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 iseq = eval(EnvUtil.invoke_ruby(['-e', <<~'EOS'], '', true).first) p RubyVM::InstructionSequence.of("\x00".method(:unpack)).to_a -- cgit v1.2.3