Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2359,32 +2359,33 @@ fn guard_two_fixnums(ctx: &mut Context, cb: &mut CodeBlock, side_exit: CodePtr)
ctx.upgrade_opnd_type(StackOpnd(1), Type::Fixnum);
}

/*
// Conditional move operation used by comparison operators
typedef void (*cmov_fn)(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
type CmovFn = fn(cb: &mut CodeBlock, opnd0: X86Opnd, opnd1: X86Opnd) -> ();

fn gen_fixnum_cmp(jitstate_t *jit, ctx_t *ctx, cmov_fn cmov_op)
fn gen_fixnum_cmp(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb, cmov_op:CmovFn) -> CodegenStatus
{
// Defer compilation so we can specialize base on a runtime receiver
if (!jit_at_current_insn(jit)) {
if !jit_at_current_insn(jit) {
defer_compilation(jit, cb, ctx);
return EndBlock;
}

VALUE comptime_a = jit_peek_at_stack(jit, ctx, 1);
VALUE comptime_b = jit_peek_at_stack(jit, ctx, 0);
let comptime_a = jit_peek_at_stack(jit, ctx, 1);
let comptime_b = jit_peek_at_stack(jit, ctx, 0);

if (FIXNUM_P(comptime_a) && FIXNUM_P(comptime_b)) {
if comptime_a.fixnum_p() && comptime_b.fixnum_p() {
// Create a side-exit to fall back to the interpreter
// Note: we generate the side-exit before popping operands from the stack
uint8_t *side_exit = get_side_exit(jit, ocb, ctx);
let side_exit = get_side_exit(jit, ocb, ctx);

/*
if (!assume_bop_not_redefined(jit, INTEGER_REDEFINED_OP_FLAG, BOP_LT)) {
return CantCompile;
}
*/

// Check that both operands are fixnums
guard_two_fixnums(ctx, side_exit);
guard_two_fixnums(ctx, cb, side_exit);

// Get the operands from the stack
let arg1 = ctx.stack_pop(1);
Expand All @@ -2394,7 +2395,7 @@ fn gen_fixnum_cmp(jitstate_t *jit, ctx_t *ctx, cmov_fn cmov_op)
xor(cb, REG0_32, REG0_32); // REG0 = Qfalse
mov(cb, REG1, arg0);
cmp(cb, REG1, arg1);
mov(cb, REG1, imm_opnd(Qtrue));
mov(cb, REG1, uimm_opnd(Qtrue.into()));
cmov_op(cb, REG0, REG1);

// Push the output on the stack
Expand All @@ -2404,30 +2405,31 @@ fn gen_fixnum_cmp(jitstate_t *jit, ctx_t *ctx, cmov_fn cmov_op)
KeepCompiling
}
else {
return gen_opt_send_without_block(jit, ctx, cb);
gen_opt_send_without_block(jit, ctx, cb, ocb)
}
}

fn gen_opt_lt(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
{
return gen_fixnum_cmp(jit, ctx, cmovl);
gen_fixnum_cmp(jit, ctx, cb, ocb, cmovl)
}

fn gen_opt_le(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
{
return gen_fixnum_cmp(jit, ctx, cmovle);
gen_fixnum_cmp(jit, ctx, cb, ocb, cmovle)
}

fn gen_opt_ge(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
{
return gen_fixnum_cmp(jit, ctx, cmovge);
gen_fixnum_cmp(jit, ctx, cb, ocb, cmovge)
}

fn gen_opt_gt(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
{
return gen_fixnum_cmp(jit, ctx, cmovg);
gen_fixnum_cmp(jit, ctx, cb, ocb, cmovg)
}

/*
// Implements specialized equality for either two fixnum or two strings
// Returns true if code was generated, otherwise false
static bool
Expand Down Expand Up @@ -5232,6 +5234,10 @@ fn get_gen_fn(opcode: VALUE) -> Option<CodeGenFn>
OP_OPT_PLUS => Some(gen_opt_plus),
OP_NEWHASH => Some(gen_newhash),
OP_CHECKTYPE => Some(gen_checktype),
OP_OPT_LT => Some(gen_opt_lt),
OP_OPT_LE => Some(gen_opt_le),
OP_OPT_GT => Some(gen_opt_gt),
OP_OPT_GE => Some(gen_opt_ge),

/*
yjit_reg_op(BIN(newarray), gen_newarray);
Expand Down