Skip to content

Commit d710bf2

Browse files
authored
Merge pull request ruby#175 from Shopify/getivar_undef_cmov
Use cmov to handle Qundef case in getivar instead of side-exit
2 parents 14945e9 + 4ac6de3 commit d710bf2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

yjit_codegen.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,10 +1451,9 @@ gen_get_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt
14511451
mov(cb, REG1, ivar_opnd);
14521452

14531453
// Guard that the variable is not Qundef
1454-
// TODO: use cmov to push Qnil in this case
1455-
ADD_COMMENT(cb, "guard value not Qundef");
14561454
cmp(cb, REG1, imm_opnd(Qundef));
1457-
je_ptr(cb, COUNTED_EXIT(side_exit, getivar_undef));
1455+
mov(cb, REG0, imm_opnd(Qnil));
1456+
cmove(cb, REG1, REG0);
14581457

14591458
// Push the ivar on the stack
14601459
x86opnd_t out_opnd = ctx_stack_push(ctx, TYPE_UNKNOWN);
@@ -1488,7 +1487,8 @@ gen_get_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt
14881487

14891488
// Check that the ivar is not Qundef
14901489
cmp(cb, REG0, imm_opnd(Qundef));
1491-
je_ptr(cb, COUNTED_EXIT(side_exit, getivar_undef));
1490+
mov(cb, REG1, imm_opnd(Qnil));
1491+
cmove(cb, REG0, REG1);
14921492

14931493
// Push the ivar on the stack
14941494
x86opnd_t out_opnd = ctx_stack_push(ctx, TYPE_UNKNOWN);

yjit_iface.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ YJIT_DECLARE_COUNTERS(
5252

5353
getivar_se_self_not_heap,
5454
getivar_idx_out_of_range,
55-
getivar_undef,
5655
getivar_name_not_mapped,
5756

5857
setivar_se_self_not_heap,

0 commit comments

Comments
 (0)