Skip to content

Commit 61723b7

Browse files
author
Maxime Chevalier-Boisvert
committed
Fix frozen check (use jnz) and move heap object check.
1 parent 565473a commit 61723b7

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

yjit_codegen.c

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

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

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

785-
x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags);
780+
// Bail if the value to write is a heap object, because this needs a write barrier
781+
ADD_COMMENT(cb, "guard value is immediate");
782+
test(cb, REG1, imm_opnd(RUBY_IMMEDIATE_MASK));
783+
jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_val_heapobject));
786784

787785
// Bail if this object is frozen
788786
ADD_COMMENT(cb, "guard self is not frozen");
787+
x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags);
789788
test(cb, flags_opnd, imm_opnd(RUBY_FL_FREEZE));
790-
jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_frozen));
789+
jnz_ptr(cb, COUNTED_EXIT(side_exit, setivar_frozen));
791790

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

0 commit comments

Comments
 (0)