Skip to content

Commit 74e4871

Browse files
committed
[interp] handle box + brtrue/brfalse pattern for byreflike types
In cases where we don't do cprop and deadce (for example if ~mono_interp_opt~ is 0 because we're debugging) don't emit a box_vt opcode before a branch. Instead just emit a constant true Fixes dotnet#102988
1 parent 40ff2ec commit 74e4871

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/mono/mono/mini/interp/transform.c

+19
Original file line numberDiff line numberDiff line change
@@ -4827,6 +4827,25 @@ interp_handle_box_patterns (TransformData *td, MonoClass *box_class, const unsig
48274827
td->ip = next_ip + 5;
48284828
return TRUE;
48294829
}
4830+
if (m_class_is_byreflike (box_class)) {
4831+
if (*next_ip == CEE_BRTRUE || *next_ip == CEE_BRTRUE_S || *next_ip == CEE_BRFALSE || *next_ip == CEE_BRFALSE_S) {
4832+
// replace
4833+
// box ByRefLike
4834+
// brtrue/brfalse
4835+
//
4836+
// by
4837+
//
4838+
// ldc.i4.s 1
4839+
// brtrue/brfalse
4840+
td->sp--;
4841+
interp_add_ins (td, MINT_LDC_I4_S);
4842+
td->last_ins->data[0] = (guint16) 1;
4843+
push_simple_type (td, STACK_TYPE_I4);
4844+
interp_ins_set_dreg (td->last_ins, td->sp [-1].var);
4845+
td->ip += 5;
4846+
return TRUE;
4847+
}
4848+
}
48304849
return FALSE;
48314850
}
48324851

0 commit comments

Comments
 (0)