@@ -727,7 +727,7 @@ enum {
727727// - receiver has the same class as CLASS_OF(comptime_receiver)
728728// - no stack push or pops to ctx since the entry to the codegen of the instruction being compiled
729729static codegen_status_t
730- gen_get_ivar (jitstate_t * jit , ctx_t * ctx , const int max_chain_depth , VALUE comptime_receiver , ID ivar_name , bool pop_receiver , uint8_t * side_exit )
730+ gen_get_ivar (jitstate_t * jit , ctx_t * ctx , const int max_chain_depth , VALUE comptime_receiver , ID ivar_name , insn_opnd_t reg0_opnd , uint8_t * side_exit )
731731{
732732 VALUE comptime_val_klass = CLASS_OF (comptime_receiver );
733733 const ctx_t starting_context = * ctx ; // make a copy for use with jit_chain_guard
@@ -751,7 +751,8 @@ gen_get_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt
751751 if (iv_index_tbl && rb_iv_index_tbl_lookup (iv_index_tbl , id , & ent )) {
752752 uint32_t ivar_index = ent -> index ;
753753
754- if (pop_receiver ) {
754+ // Pop receiver if it's on the temp stack
755+ if (!reg0_opnd .is_self ) {
755756 (void )ctx_stack_pop (ctx , 1 );
756757 }
757758
@@ -846,7 +847,7 @@ gen_getinstancevariable(jitstate_t *jit, ctx_t *ctx)
846847
847848 jit_guard_known_klass (jit , ctx , comptime_val_klass , OPND_SELF , GETIVAR_MAX_DEPTH , side_exit );
848849
849- return gen_get_ivar (jit , ctx , GETIVAR_MAX_DEPTH , comptime_val , ivar_name , false , side_exit );
850+ return gen_get_ivar (jit , ctx , GETIVAR_MAX_DEPTH , comptime_val , ivar_name , OPND_SELF , side_exit );
850851}
851852
852853static codegen_status_t
@@ -1840,8 +1841,9 @@ gen_opt_send_without_block(jitstate_t* jit, ctx_t* ctx)
18401841
18411842 // Points to the receiver operand on the stack
18421843 x86opnd_t recv = ctx_stack_opnd (ctx , argc );
1844+ insn_opnd_t recv_opnd = OPND_STACK (argc );
18431845 mov (cb , REG0 , recv );
1844- if (!jit_guard_known_klass (jit , ctx , comptime_recv_klass , OPND_STACK ( argc ) , OSWB_MAX_DEPTH , side_exit )) {
1846+ if (!jit_guard_known_klass (jit , ctx , comptime_recv_klass , recv_opnd , OSWB_MAX_DEPTH , side_exit )) {
18451847 return YJIT_CANT_COMPILE ;
18461848 }
18471849
@@ -1893,7 +1895,7 @@ gen_opt_send_without_block(jitstate_t* jit, ctx_t* ctx)
18931895 mov (cb , REG0 , recv );
18941896
18951897 ID ivar_name = cme -> def -> body .attr .id ;
1896- return gen_get_ivar (jit , ctx , OSWB_MAX_DEPTH , comptime_recv , ivar_name , true , side_exit );
1898+ return gen_get_ivar (jit , ctx , OSWB_MAX_DEPTH , comptime_recv , ivar_name , recv_opnd , side_exit );
18971899 }
18981900 case VM_METHOD_TYPE_ATTRSET :
18991901 GEN_COUNTER_INC (cb , oswb_ivar_set_method );
0 commit comments