From ee3b4bec0ead8cef949a992df46ef8b237ed4a26 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Wed, 14 Feb 2024 11:19:04 -0500 Subject: YJIT: Simplify Kernel#send guards and admit more cases (#9956) Previously, our compile time check rejected dynamic symbols (e.g. what String#to_sym could return) even though we could handle them just fine. The runtime guards for the type of method name was also overly restrictive and didn't accept dynamic symbols. Fold the type check into the rb_get_symbol_id() and take advantage of the guard already checking for 0. This also avoids generating the same call twice in case the same method name is presented as different types. --- test/ruby/test_yjit.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 33cb7b16cf..f1b32226ec 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -1560,6 +1560,19 @@ class TestYJIT < Test::Unit::TestCase RUBY end + def test_send_polymorphic_method_name + assert_compiles(<<~'RUBY', result: %i[ok ok], no_send_fallbacks: true) + mid = "dynamic_mid_#{rand(100..200)}" + mid_dsym = mid.to_sym + + define_method(mid) { :ok } + + define_method(:send_site) { send(_1) } + + [send_site(mid), send_site(mid_dsym)] + RUBY + end + private def code_gc_helpers -- cgit v1.2.3