YJIT: Fallback Integer#<< if a shift amount varies (#9426)
* YJIT: Fallback Integer#<< if a shift amount varies * YJIT: Do not fallback lshift in the first chain
This commit is contained in:
parent
85a7da742a
commit
a0eecfb5ba
2
yjit.rb
2
yjit.rb
@ -288,7 +288,7 @@ module RubyVM::YJIT
|
|||||||
].each do |insn|
|
].each do |insn|
|
||||||
print_counters(stats, out: out, prefix: "#{insn}_", prompt: "#{insn} exit reasons:", optional: true)
|
print_counters(stats, out: out, prefix: "#{insn}_", prompt: "#{insn} exit reasons:", optional: true)
|
||||||
end
|
end
|
||||||
print_counters(stats, out: out, prefix: 'lshift_', prompt: 'left shift (ltlt) exit reasons: ')
|
print_counters(stats, out: out, prefix: 'lshift_', prompt: 'left shift (opt_ltlt) exit reasons: ')
|
||||||
print_counters(stats, out: out, prefix: 'invalidate_', prompt: 'invalidation reasons: ')
|
print_counters(stats, out: out, prefix: 'invalidate_', prompt: 'invalidation reasons: ')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4637,17 +4637,28 @@ fn jit_rb_int_lshift(
|
|||||||
|
|
||||||
// Untag the fixnum shift amount
|
// Untag the fixnum shift amount
|
||||||
let shift_amt = comptime_shift.as_isize() >> 1;
|
let shift_amt = comptime_shift.as_isize() >> 1;
|
||||||
|
|
||||||
if shift_amt > 63 || shift_amt < 0 {
|
if shift_amt > 63 || shift_amt < 0 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback to a C call if the shift amount varies
|
||||||
|
if asm.ctx.get_chain_depth() > 1 {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let rhs = asm.stack_pop(1);
|
let rhs = asm.stack_pop(1);
|
||||||
let lhs = asm.stack_pop(1);
|
let lhs = asm.stack_pop(1);
|
||||||
|
|
||||||
// Guard on the shift value we speculated on
|
// Guard on the shift amount we speculated on
|
||||||
asm.cmp(rhs, comptime_shift.into());
|
asm.cmp(rhs, comptime_shift.into());
|
||||||
asm.jne(Target::side_exit(Counter::lshift_amt_changed));
|
jit_chain_guard(
|
||||||
|
JCC_JNE,
|
||||||
|
jit,
|
||||||
|
asm,
|
||||||
|
ocb,
|
||||||
|
2, // defer_compilation increments chain_depth
|
||||||
|
Counter::lshift_amount_changed,
|
||||||
|
);
|
||||||
|
|
||||||
let in_val = asm.sub(lhs, 1.into());
|
let in_val = asm.sub(lhs, 1.into());
|
||||||
let shift_opnd = Opnd::UImm(shift_amt as u64);
|
let shift_opnd = Opnd::UImm(shift_amt as u64);
|
||||||
|
@ -447,7 +447,7 @@ make_counters! {
|
|||||||
opt_mod_zero,
|
opt_mod_zero,
|
||||||
opt_div_zero,
|
opt_div_zero,
|
||||||
|
|
||||||
lshift_amt_changed,
|
lshift_amount_changed,
|
||||||
lshift_overflow,
|
lshift_overflow,
|
||||||
|
|
||||||
opt_aref_argc_not_one,
|
opt_aref_argc_not_one,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user