Skip to content

Commit dc01e87

Browse files
fanyang-monomatouskozak
authored andcommitted
Check if type is compatible right before emitting box (dotnet#101509)
1 parent 08c06e6 commit dc01e87

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
@@ -9632,8 +9632,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
96329632

96339633
if (klass == mono_defaults.void_class)
96349634
UNVERIFIED;
9635-
if (target_type_is_incompatible (cfg, m_class_get_byval_arg (klass), val))
9636-
UNVERIFIED;
9635+
96379636
/* frequent check in generic code: box (struct), brtrue */
96389637

96399638
/*
@@ -9992,6 +9991,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
99929991
MONO_ADD_INS (cfg->cbb, ins);
99939992
*sp++ = ins;
99949993
} else {
9994+
if (target_type_is_incompatible (cfg, m_class_get_byval_arg (klass), val))
9995+
UNVERIFIED;
99959996
*sp++ = mini_emit_box (cfg, val, klass, context_used);
99969997
}
99979998
CHECK_CFG_EXCEPTION;

0 commit comments

Comments
 (0)