Skip to content

Commit cf69abe

Browse files
maximecbXrXr
authored andcommitted
Don't check if value is immediate if context has type info
1 parent ae72986 commit cf69abe

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

yjit_codegen.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,13 +775,20 @@ gen_set_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt
775775
if (iv_index_tbl && rb_iv_index_tbl_lookup(iv_index_tbl, id, &ent)) {
776776
uint32_t ivar_index = ent->index;
777777

778-
x86opnd_t val_to_write = ctx_stack_pop(ctx, 1);
778+
val_type_t val_type = ctx_get_opnd_type(ctx, OPND_STACK(0));
779+
x86opnd_t val_to_write = ctx_stack_opnd(ctx, 0);
779780
mov(cb, REG1, val_to_write);
780781

781782
// Bail if the value to write is a heap object, because this needs a write barrier
782-
ADD_COMMENT(cb, "guard value is immediate");
783-
test(cb, REG1, imm_opnd(RUBY_IMMEDIATE_MASK));
784-
jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_val_heapobject));
783+
if (!val_type.is_imm) {
784+
ADD_COMMENT(cb, "guard value is immediate");
785+
test(cb, REG1, imm_opnd(RUBY_IMMEDIATE_MASK));
786+
jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_val_heapobject));
787+
ctx_set_opnd_type(ctx, OPND_STACK(0), TYPE_IMM);
788+
}
789+
790+
// Pop the value to write
791+
ctx_stack_pop(ctx, 1);
785792

786793
// Bail if this object is frozen
787794
ADD_COMMENT(cb, "guard self is not frozen");

0 commit comments

Comments
 (0)