mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Check for comptime fixnums in opt_and and opt_or
This commit is contained in:
parent
cb9bc13fcb
commit
f1b7568f5a
1 changed files with 64 additions and 36 deletions
|
@ -2206,6 +2206,16 @@ gen_opt_aset(jitstate_t *jit, ctx_t *ctx)
|
|||
static codegen_status_t
|
||||
gen_opt_and(jitstate_t* jit, ctx_t* ctx)
|
||||
{
|
||||
// Defer compilation so we can specialize on a runtime `self`
|
||||
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);
|
||||
|
@ -2230,11 +2240,25 @@ gen_opt_and(jitstate_t* jit, ctx_t* ctx)
|
|||
mov(cb, dst, REG0);
|
||||
|
||||
return YJIT_KEEP_COMPILING;
|
||||
} else {
|
||||
// Delegate to send, call the method on the recv
|
||||
return gen_opt_send_without_block(jit, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
static codegen_status_t
|
||||
gen_opt_or(jitstate_t* jit, ctx_t* ctx)
|
||||
{
|
||||
// Defer compilation so we can specialize on a runtime `self`
|
||||
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);
|
||||
|
@ -2259,6 +2283,10 @@ gen_opt_or(jitstate_t* jit, ctx_t* ctx)
|
|||
mov(cb, dst, REG0);
|
||||
|
||||
return YJIT_KEEP_COMPILING;
|
||||
} else {
|
||||
// Delegate to send, call the method on the recv
|
||||
return gen_opt_send_without_block(jit, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
static codegen_status_t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue