YJIT: Optimize putobject+opt_ltlt for integers

In `jit_rb_int_lshift()`, we guard against the right hand side changing
since we want to avoid generating variable length shifts. When control
reaches a `putobject` and `opt_ltlt` pair, though, we know that the right
hand side never changes.

This commit detects this situation and substitutes an implementation
that does not guard against the right hand side changing, saving that
work.

Deleted some `putobject` Rust tests since they aren't that valuable and
cause linking issues.

Nice boost to `optcarrot` and `protoboeuf`:

```
----------  ------------------
bench       yjit-pre/yjit-post
optcarrot   1.09
protoboeuf  1.12
----------  ------------------
```
This commit is contained in:
Alan Wu 2024-03-28 15:46:08 -04:00
parent 817eecf685
commit f3c35749fe
2 changed files with 98 additions and 56 deletions

View file

@ -4769,3 +4769,20 @@ assert_equal '[:ok, :ok, :ok]', %q{
tests
}
# test integer left shift with constant rhs
assert_equal [0x80000000000, 'a+', :ok].inspect, %q{
def shift(val) = val << 43
def tests
int = shift(1)
str = shift("a")
Integer.define_method(:<<) { |_| :ok }
redef = shift(1)
[int, str, redef]
end
tests
}