Skip to content

Commit e677ca4

Browse files
maximecbXrXr
authored andcommitted
Fixed is-object check in opt_send_without_block
1 parent 7c9fdb5 commit e677ca4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ujit_compile.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,17 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx)
541541
//print_str(cb, rb_id2name(mid));
542542
//print_ptr(cb, RCX);
543543

544+
// IDEA: may be able to eliminate this in some cases if we know the previous instruction?
544545
// TODO: guard_is_object() helper function?
546+
// FIXME: an object can have QNil bit 1000 set
547+
// need to check for immediate mask, Qnil and Qfalse
545548
// Check that the receiver is an object
546-
cmp(cb, RCX, imm_opnd(0));
547-
je_ptr(cb, side_exit);
548-
test(cb, RCX, imm_opnd(RUBY_IMMEDIATE_MASK | RUBY_Qnil));
549+
test(cb, RCX, imm_opnd(RUBY_IMMEDIATE_MASK));
549550
jnz_ptr(cb, side_exit);
551+
cmp(cb, RCX, imm_opnd(Qfalse));
552+
je_ptr(cb, side_exit);
553+
cmp(cb, RCX, imm_opnd(Qnil));
554+
je_ptr(cb, side_exit);
550555

551556
// Pointer to the klass field of the receiver &(recv->klass)
552557
x86opnd_t klass_opnd = mem_opnd(64, RCX, offsetof(struct RBasic, klass));

0 commit comments

Comments
 (0)