Skip to content

Commit 5e41dde

Browse files
authored
Check if type is compatible right before emitting box (#101509)
1 parent 0cff35e commit 5e41dde

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/mono/mono/mini/method-to-ir.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9595,8 +9595,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
95959595

95969596
if (klass == mono_defaults.void_class)
95979597
UNVERIFIED;
9598-
if (target_type_is_incompatible (cfg, m_class_get_byval_arg (klass), val))
9599-
UNVERIFIED;
9598+
96009599
/* frequent check in generic code: box (struct), brtrue */
96019600

96029601
/*
@@ -9955,6 +9954,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
99559954
MONO_ADD_INS (cfg->cbb, ins);
99569955
*sp++ = ins;
99579956
} else {
9957+
if (target_type_is_incompatible (cfg, m_class_get_byval_arg (klass), val))
9958+
UNVERIFIED;
99589959
*sp++ = mini_emit_box (cfg, val, klass, context_used);
99599960
}
99609961
CHECK_CFG_EXCEPTION;

0 commit comments

Comments
 (0)