Skip to content

Commit ff873c9

Browse files
maximecbXrXr
authored andcommitted
Fix frozen check (use jnz) and move heap object check.
1 parent ad7f25b commit ff873c9

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

yjit_codegen.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -771,24 +771,23 @@ gen_set_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt
771771
struct rb_iv_index_tbl_entry *ent;
772772
struct st_table *iv_index_tbl = ROBJECT_IV_INDEX_TBL(comptime_receiver);
773773

774-
// Bail if this is a heap object, because this needs a write barrier
775-
ADD_COMMENT(cb, "guard value is immediate");
776-
test(cb, REG1, imm_opnd(RUBY_IMMEDIATE_MASK));
777-
jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_val_heapobject));
778-
779774
// Lookup index for the ivar the instruction loads
780775
if (iv_index_tbl && rb_iv_index_tbl_lookup(iv_index_tbl, id, &ent)) {
781776
uint32_t ivar_index = ent->index;
782777

783778
x86opnd_t val_to_write = ctx_stack_pop(ctx, 1);
784779
mov(cb, REG1, val_to_write);
785780

786-
x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags);
781+
// 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));
787785

788786
// Bail if this object is frozen
789787
ADD_COMMENT(cb, "guard self is not frozen");
788+
x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags);
790789
test(cb, flags_opnd, imm_opnd(RUBY_FL_FREEZE));
791-
jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_frozen));
790+
jnz_ptr(cb, COUNTED_EXIT(side_exit, setivar_frozen));
792791

793792
// Pop receiver if it's on the temp stack
794793
if (!reg0_opnd.is_self) {

0 commit comments

Comments
 (0)