Skip to content

Commit

Permalink
Emit a null check when loading valuetype fields (#1866)
Browse files Browse the repository at this point in the history
Co-authored-by: Bill Holmes <bill.holmes@unity3d.com>
  • Loading branch information
jhcdunity3d and bholmes committed Oct 24, 2023
1 parent 705cdd8 commit 2d3b912
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -9745,7 +9745,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
} else {
MonoInst *load;

MONO_EMIT_NULL_CHECK (cfg, sp [0]->dreg, foffset > mono_target_pagesize ());
// We may call a copy / wbarrier function which doesn't do null checks;
// passing MONO_TYPE_ISSTRUCT to macro so that we emit the null check when accessing fields that are structs */
MONO_EMIT_NULL_CHECK (cfg, sp [0]->dreg, foffset > mono_target_pagesize () || MONO_TYPE_ISSTRUCT(field->type));

#ifdef MONO_ARCH_SIMD_INTRINSICS
if (sp [0]->opcode == OP_LDADDR && m_class_is_simd_type (klass) && cfg->opt & MONO_OPT_SIMD) {
Expand Down

0 comments on commit 2d3b912

Please sign in to comment.