@@ -857,6 +857,7 @@ enum {
857
857
SEND_MAX_DEPTH = 5 , // up to 5 different classes
858
858
};
859
859
860
+ /*
860
861
// Codegen for setting an instance variable.
861
862
// Preconditions:
862
863
// - receiver is in REG0
@@ -967,6 +968,7 @@ gen_set_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt
967
968
GEN_COUNTER_INC(cb, setivar_name_not_mapped);
968
969
return YJIT_CANT_COMPILE;
969
970
}
971
+ */
970
972
971
973
// Codegen for getting an instance variable.
972
974
// Preconditions:
@@ -1116,9 +1118,36 @@ gen_getinstancevariable(jitstate_t *jit, ctx_t *ctx)
1116
1118
return gen_get_ivar (jit , ctx , GETIVAR_MAX_DEPTH , comptime_val , ivar_name , OPND_SELF , side_exit );
1117
1119
}
1118
1120
1121
+ void rb_vm_setinstancevariable (const rb_iseq_t * iseq , VALUE obj , ID id , VALUE val , IVC ic );
1122
+
1119
1123
static codegen_status_t
1120
1124
gen_setinstancevariable (jitstate_t * jit , ctx_t * ctx )
1121
1125
{
1126
+ ID id = (ID )jit_get_arg (jit , 0 );
1127
+ IVC ic = (IVC )jit_get_arg (jit , 1 );
1128
+
1129
+ // Save the PC and SP because the callee may allocate
1130
+ // Note that this modifies REG_SP, which is why we do it first
1131
+ jit_save_pc (jit , REG0 );
1132
+ jit_save_sp (jit , ctx );
1133
+
1134
+ // Get the operands from the stack
1135
+ x86opnd_t val_opnd = ctx_stack_pop (ctx , 1 );
1136
+
1137
+ // Call rb_vm_setinstancevariable(iseq, obj, id, val, ic);
1138
+ // Out of order because we're going to corrupt REG_SP and REG_CFP
1139
+ yjit_save_regs (cb );
1140
+ mov (cb , C_ARG_REGS [1 ], member_opnd (REG_CFP , rb_control_frame_t , self ));
1141
+ mov (cb , C_ARG_REGS [3 ], val_opnd );
1142
+ mov (cb , C_ARG_REGS [2 ], imm_opnd (id ));
1143
+ mov (cb , C_ARG_REGS [4 ], const_ptr_opnd (ic ));
1144
+ jit_mov_gc_ptr (jit , cb , C_ARG_REGS [0 ], (VALUE )jit -> iseq );
1145
+ call_ptr (cb , REG0 , (void * )rb_vm_setinstancevariable );
1146
+ yjit_load_regs (cb );
1147
+
1148
+ return YJIT_KEEP_COMPILING ;
1149
+
1150
+ /*
1122
1151
// Defer compilation so we can specialize on a runtime `self`
1123
1152
if (!jit_at_current_insn(jit)) {
1124
1153
defer_compilation(jit->block, jit->insn_idx, ctx);
@@ -1140,6 +1169,7 @@ gen_setinstancevariable(jitstate_t* jit, ctx_t* ctx)
1140
1169
jit_guard_known_klass(jit, ctx, comptime_val_klass, OPND_SELF, GETIVAR_MAX_DEPTH, side_exit);
1141
1170
1142
1171
return gen_set_ivar(jit, ctx, GETIVAR_MAX_DEPTH, comptime_val, ivar_name, OPND_SELF, side_exit);
1172
+ */
1143
1173
}
1144
1174
1145
1175
static void
0 commit comments