Skip to content

Commit

Permalink
Check if type is compatible right before emitting box (dotnet#101509)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang-mono authored and michaelgsharp committed May 8, 2024
1 parent 6000c7e commit 0ec49d0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -9595,8 +9595,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b

if (klass == mono_defaults.void_class)
UNVERIFIED;
if (target_type_is_incompatible (cfg, m_class_get_byval_arg (klass), val))
UNVERIFIED;

/* frequent check in generic code: box (struct), brtrue */

/*
Expand Down Expand Up @@ -9955,6 +9954,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
MONO_ADD_INS (cfg->cbb, ins);
*sp++ = ins;
} else {
if (target_type_is_incompatible (cfg, m_class_get_byval_arg (klass), val))
UNVERIFIED;
*sp++ = mini_emit_box (cfg, val, klass, context_used);
}
CHECK_CFG_EXCEPTION;
Expand Down

0 comments on commit 0ec49d0

Please sign in to comment.