diff options
| author | nagachika <nagachika@ruby-lang.org> | 2025-01-25 14:51:31 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2025-01-25 14:51:31 +0900 |
| commit | 7c0c2df9b497dbf9c1376a995eebe6d43a00e21b (patch) | |
| tree | 6ecdae56fb7211b709d0356e7d71d4e82cd92228 | |
| parent | 97243cc9c76b9cc2803cfd1c01165ab5bd432450 (diff) | |
merge revision(s) dd80d9b089e35729d585bae2f8866c845c48f3b7: [Backport #20997]
YJIT: Filter `&` calls from specialized C method codegen
Evident with the crash reported in [Bug #20997], the C replacement
codegen functions aren't authored to handle block arguments (nor
should they because the extra code from the complexity defeats
optimization). Filter sites with VM_CALL_ARGS_BLOCKARG.
| -rw-r--r-- | bootstraptest/test_yjit.rb | 8 | ||||
| -rw-r--r-- | version.h | 2 | ||||
| -rw-r--r-- | yjit/src/codegen.rs | 4 |
3 files changed, 11 insertions, 3 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index fc579dd4c2..5c655b8f25 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -3520,3 +3520,11 @@ assert_equal 'ok', %q{ cw(4) } + +assert_normal_exit %{ + class Bug20997 + def foo(&) = self.class.name(&) + + new.foo + end +} @@ -11,7 +11,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 6 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 251 +#define RUBY_PATCHLEVEL 252 #include "ruby/version.h" #include "ruby/internal/abi.h" diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index f8107aff3e..2eb63398f3 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -4584,8 +4584,8 @@ fn gen_send_cfunc( return CantCompile; } - // Delegate to codegen for C methods if we have it. - if kw_arg.is_null() && flags & VM_CALL_OPT_SEND == 0 && flags & VM_CALL_ARGS_SPLAT == 0 && (cfunc_argc == -1 || argc == cfunc_argc) { + // Delegate to codegen for C methods if we have it and the callsite is simple enough. + if kw_arg.is_null() && flags & VM_CALL_OPT_SEND == 0 && flags & VM_CALL_ARGS_SPLAT == 0 && flags & VM_CALL_ARGS_BLOCKARG == 0 && (cfunc_argc == -1 || argc == cfunc_argc) { let codegen_p = lookup_cfunc_codegen(unsafe { (*cme).def }); let expected_stack_after = ctx.get_stack_size() as i32 - argc; if let Some(known_cfunc_codegen) = codegen_p { |
