summaryrefslogtreecommitdiff
path: root/yjit_codegen.c
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <[email protected]>2021-05-18 15:37:11 -0400
committerAlan Wu <[email protected]>2021-10-20 18:19:35 -0400
commit03da234eb019902176f8d456fceaefee11858a59 (patch)
tree942f8d657191d2e2384440fbd149fb4480b60ff2 /yjit_codegen.c
parenta66dce146a1ea2c38a8f4133f598d4316c39c910 (diff)
Add T_OBJECT check to getivar
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r--yjit_codegen.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c
index e04a065061..33efb927ec 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -1010,7 +1010,15 @@ gen_get_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt
jit_jump_to_next_insn(jit, ctx);
return YJIT_END_BLOCK;
}
- RUBY_ASSERT(BUILTIN_TYPE(comptime_receiver) == T_OBJECT); // because we checked the allocator
+
+ // FIXME: we should be able to eliminate this check with object shapes
+ // Guard that the receiver is T_OBJECT
+ // #define RB_BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & RUBY_T_MASK)
+ ADD_COMMENT(cb, "guard receiver is T_OBJECT");
+ mov(cb, REG1, member_opnd(REG0, struct RBasic, flags));
+ and(cb, REG1, imm_opnd(RUBY_T_MASK));
+ cmp(cb, REG1, imm_opnd(T_OBJECT));
+ jit_chain_guard(JCC_JNE, jit, &starting_context, max_chain_depth, side_exit);
// ID for the name of the ivar
ID id = ivar_name;