Skip to content

Commit

Permalink
[mono][interp] Add missing sign extend
Browse files Browse the repository at this point in the history
Fix passing of i4 to wrapper accepting native int. The wrapper no longer does the sign extend in order to not lose high bits of native int.
  • Loading branch information
BrzVlad committed Aug 22, 2023
1 parent cad4e2e commit caf60c0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -4453,8 +4453,18 @@ mini_emit_array_store (MonoCompile *cfg, MonoClass *klass, MonoInst **sp, gboole
if (sp [2]->type != STACK_OBJ)
return NULL;

MonoInst *index_ins = sp [1];
#if SIZEOF_REGISTER == 8
if (sp [1]->type == STACK_I4) {
// stelemref wrapper recevies index as native int, sign extend it
guint32 dreg = alloc_preg (cfg);
guint32 sreg = index_ins->dreg;
EMIT_NEW_UNALU (cfg, index_ins, OP_SEXT_I4, dreg, sreg);
}
#endif

iargs [2] = sp [2];
iargs [1] = sp [1];
iargs [1] = index_ins;
iargs [0] = sp [0];

MonoClass *array_class = sp [0]->klass;
Expand Down

0 comments on commit caf60c0

Please sign in to comment.