diff options
| author | Alan Wu <XrXr@users.noreply.github.com> | 2024-02-14 11:19:04 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-14 11:19:04 -0500 |
| commit | ee3b4bec0ead8cef949a992df46ef8b237ed4a26 (patch) | |
| tree | f953e82cb47247d19b7b0fdca33c88534ae00456 /test/ruby | |
| parent | f4a0e1cdb453ee4389b1db258601e4a96471a4f5 (diff) | |
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.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_yjit.rb | 13 |
1 files changed, 13 insertions, 0 deletions
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 |
