8000 Switch to 2-comparison heap object check · github/ruby@14e2f39 · GitHub
[go: up one dir, main page]

Skip to content

Commit 14e2f39

Browse files
committed
Switch to 2-comparison heap object check
1 parent c8740b0 commit 14e2f39

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

yjit_codegen.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -625,21 +625,15 @@ gen_setlocal_wc0(jitstate_t* jit, ctx_t* ctx)
625625
static void
626626
guard_self_is_heap(codeblock_t *cb, x86opnd_t self_opnd, uint8_t *side_exit, ctx_t *ctx)
627627
{
628+
628629
// `self` is constant throughout the entire region, so we only need to do this check once.
629630
if (!ctx->self_type.is_heap) {
630-
// FIXME: use two-comparison test
631631
ADD_COMMENT(cb, "guard self is heap");
632+
RUBY_ASSERT(Qfalse < Qnil);
632633
test(cb, self_opnd, imm_opnd(RUBY_IMMEDIATE_MASK));
633634
jnz_ptr(cb, side_exit);
634-
cmp(cb, self_opnd, imm_opnd(Qfalse));
635-
je_ptr(cb, side_exit);
636635
cmp(cb, self_opnd, imm_opnd(Qnil));
637-
je_ptr(cb, side_exit);
638-
639-
// maybe we can do
640-
// RUBY_ASSERT(Qfalse < Qnil);
641-
// cmp(cb, self_opnd, imm_opnd(Qnil));
642-
// jbe(cb, side_exit);
636+
jbe_ptr(cb, side_exit);
643637

644638
ctx->self_type.is_heap = 1;
645639
}
@@ -1432,12 +1426,11 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t* ctx, VALUE known_klass, insn_opnd_
14321426
{
14331427
// FIXME: use two comparisons instead of 3 here
14341428
ADD_COMMENT(cb, "guard not immediate");
1429+
RUBY_ASSERT(Qfalse < Qnil);
14351430
test(cb, REG0, imm_opnd(RUBY_IMMEDIATE_MASK));
14361431
jnz_ptr(cb, side_exit);
1437-
cmp(cb, REG0, imm_opnd(Qfalse));
1438-
je_ptr(cb, side_exit);
14391432
cmp(cb, REG0, imm_opnd(Qnil));
1440-
je_ptr(cb, side_exit);
1433+
jbe_ptr(cb, side_exit);
14411434

14421435
ctx_set_opnd_type(ctx, insn_opnd, TYPE_HEAP);
14431436
}

0 commit comments

Comments
 (0)
0