1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Check for comptime fixnum in gen_fixnum_cmp

This commit is contained in:
John Hawthorn 2021-09-14 08:58:05 -07:00 committed by Alan Wu
parent f1b7568f5a
commit 7d99e85601

View file

@ -1880,6 +1880,16 @@ typedef void (*cmov_fn)(codeblock_t* cb, x86opnd_t opnd0, x86opnd_t opnd1);
static codegen_status_t
gen_fixnum_cmp(jitstate_t* jit, ctx_t* ctx, cmov_fn cmov_op)
{
// Defer compilation so we can specialize base on a runtime receiver
if (!jit_at_current_insn(jit)) {
defer_compilation(jit->block, jit->insn_idx, ctx);
return YJIT_END_BLOCK;
}
VALUE comptime_a = jit_peek_at_stack(jit, ctx, 1);
VALUE comptime_b = jit_peek_at_stack(jit, ctx, 0);
if (FIXNUM_P(comptime_a) && FIXNUM_P(comptime_b)) {
// Create a size-exit to fall back to the interpreter
// Note: we generate the side-exit before popping operands from the stack
uint8_t* side_exit = yjit_side_exit(jit, ctx);
@ -1907,6 +1917,9 @@ gen_fixnum_cmp(jitstate_t* jit, ctx_t* ctx, cmov_fn cmov_op)
mov(cb, dst, REG0);
return YJIT_KEEP_COMPILING;
} else {
return gen_opt_send_without_block(jit, ctx);
}
}
static codegen_status_t