diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index b7427cc8ad21a..83718c8c63e7f 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -2897,7 +2897,7 @@ mini_emit_stobj (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *kla n = mono_class_value_size (klass, &align); /* if native is true there should be no references in the struct */ - if (cfg->gen_write_barriers && klass->has_references && !native) { + if (cfg->gen_write_barriers && (klass->has_references || size_ins) && !native) { /* Avoid barriers when storing to the stack */ if (!((dest->opcode == OP_ADD_IMM && dest->sreg1 == cfg->frame_reg) || (dest->opcode == OP_LDADDR))) { @@ -9491,8 +9491,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b offset_ins = emit_get_rgctx_field (cfg, context_used, field, MONO_RGCTX_INFO_FIELD_OFFSET); dreg = alloc_ireg_mp (cfg); EMIT_NEW_BIALU (cfg, ins, OP_PADD, dreg, sp [0]->dreg, offset_ins->dreg); + /* The decomposition will call mini_emit_stobj () which will emit a wbarrier if needed */ EMIT_NEW_STORE_MEMBASE_TYPE (cfg, store, field->type, dreg, 0, sp [1]->dreg); - // FIXME-VT: wbarriers ? } else { EMIT_NEW_STORE_MEMBASE_TYPE (cfg, store, field->type, sp [0]->dreg, foffset, sp [1]->dreg); }