diff options
| author | Aaron Patterson <tenderlove@ruby-lang.org> | 2024-02-14 11:49:10 -0800 |
|---|---|---|
| committer | Aaron Patterson <aaron.patterson@gmail.com> | 2024-02-14 12:49:36 -0800 |
| commit | 7943cb22f667cc4382e8ea3f7ca674c470f601c6 (patch) | |
| tree | 318dfde896320602ac33c9422aab923719f9de2b | |
| parent | fadb7d412b813ca8b484df4c5d7b2ccce3f8fd1e (diff) | |
Consider rb_str_getbyte as leaf sometimes
If YJIT knows the parameter to rb_str_getbyte is a fixnum, then I think
we can consider the function to be a leaf
| -rw-r--r-- | yjit/src/codegen.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index afdf3a8712..e080905ea0 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -5395,11 +5395,18 @@ fn jit_rb_str_getbyte( extern "C" { fn rb_str_getbyte(str: VALUE, index: VALUE) -> VALUE; } - // Raises when non-integers are passed in - jit_prepare_non_leaf_call(jit, asm); let index = asm.stack_opnd(0); let recv = asm.stack_opnd(1); + + let arg0_type = asm.ctx.get_opnd_type(index.into()); + + // rb_str_getbyte should be leaf if the index is a fixnum + if arg0_type != Type::Fixnum { + // Raises when non-integers are passed in + jit_prepare_non_leaf_call(jit, asm); + } + let ret_opnd = asm.ccall(rb_str_getbyte as *const u8, vec![recv, index]); asm.stack_pop(2); // Keep them on stack during ccall for GC |
