Skip to content

Commit e05343d

Browse files
committed
[jit] Replace usage of mini_emit_stobj with mini_emit_memory_copy and simplify usage since the later can handle ref types.
1 parent 45f1fb7 commit e05343d

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

mono/mini/decompose.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,8 @@ mono_decompose_vtype_opts (MonoCompile *cfg)
12271227

12281228
EMIT_NEW_VARLOADA ((cfg), (src), src_var, src_var->inst_vtype);
12291229
EMIT_NEW_VARLOADA ((cfg), (dest), dest_var, dest_var->inst_vtype);
1230+
mini_emit_memory_copy (cfg, dest, src, src_var->klass, src_var->backend.is_pinvoke, 0);
12301231

1231-
mini_emit_stobj (cfg, dest, src, src_var->klass, src_var->backend.is_pinvoke);
12321232
break;
12331233
}
12341234
case OP_VZERO:
@@ -1273,7 +1273,7 @@ mono_decompose_vtype_opts (MonoCompile *cfg)
12731273

12741274
dreg = alloc_preg (cfg);
12751275
EMIT_NEW_BIALU_IMM (cfg, dest, OP_ADD_IMM, dreg, ins->inst_destbasereg, ins->inst_offset);
1276-
mini_emit_stobj (cfg, dest, src, src_var->klass, src_var->backend.is_pinvoke);
1276+
mini_emit_memory_copy (cfg, dest, src, src_var->klass, src_var->backend.is_pinvoke, 0);
12771277
break;
12781278
}
12791279
case OP_LOADV_MEMBASE: {
@@ -1290,7 +1290,7 @@ mono_decompose_vtype_opts (MonoCompile *cfg)
12901290
dreg = alloc_preg (cfg);
12911291
EMIT_NEW_BIALU_IMM (cfg, src, OP_ADD_IMM, dreg, ins->inst_basereg, ins->inst_offset);
12921292
EMIT_NEW_VARLOADA (cfg, dest, dest_var, dest_var->inst_vtype);
1293-
mini_emit_stobj (cfg, dest, src, dest_var->klass, dest_var->backend.is_pinvoke);
1293+
mini_emit_memory_copy (cfg, dest, src, dest_var->klass, dest_var->backend.is_pinvoke, 0);
12941294
break;
12951295
}
12961296
case OP_OUTARG_VT: {

mono/mini/method-to-ir.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,8 @@ mini_emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
28632863
if (!cfg->gen_write_barriers)
28642864
return;
28652865

2866+
//method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER && !MONO_INS_IS_PCONST_NULL (sp [1])
2867+
28662868
card_table = mono_gc_get_card_table (&card_table_shift_bits, &card_table_mask);
28672869

28682870
mono_gc_get_nursery (&nursery_shift_bits, &nursery_size);
@@ -9853,23 +9855,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
98539855
klass = mini_get_class (method, token, generic_context);
98549856
CHECK_TYPELOAD (klass);
98559857
sp -= 2;
9856-
if (generic_class_is_reference_type (cfg, klass)) {
9857-
MonoInst *store, *load;
9858-
int dreg = alloc_ireg_ref (cfg);
9859-
9860-
NEW_LOAD_MEMBASE (cfg, load, OP_LOAD_MEMBASE, dreg, sp [1]->dreg, 0);
9861-
load->flags |= ins_flag;
9862-
MONO_ADD_INS (cfg->cbb, load);
9863-
9864-
NEW_STORE_MEMBASE (cfg, store, OP_STORE_MEMBASE_REG, sp [0]->dreg, 0, dreg);
9865-
store->flags |= ins_flag;
9866-
MONO_ADD_INS (cfg->cbb, store);
9867-
9868-
if (cfg->gen_write_barriers && cfg->method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER)
9869-
mini_emit_write_barrier (cfg, sp [0], sp [1]);
9870-
} else {
9871-
mini_emit_stobj (cfg, sp [0], sp [1], klass, FALSE);
9872-
}
9858+
mini_emit_memory_copy (cfg, sp [0], sp [1], klass, FALSE, ins_flag);
98739859
ins_flag = 0;
98749860
ip += 5;
98759861
break;
@@ -9918,14 +9904,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
99189904
}
99199905

99209906
/* Optimize the ldobj+stobj combination */
9921-
/* The reference case ends up being a load+store anyway */
9922-
/* Skip this if the operation is volatile. */
9923-
if (((ip [5] == CEE_STOBJ) && ip_in_bb (cfg, cfg->cbb, ip + 5) && read32 (ip + 6) == token) && !generic_class_is_reference_type (cfg, klass) && !(ins_flag & MONO_INST_VOLATILE)) {
9907+
if (((ip [5] == CEE_STOBJ) && ip_in_bb (cfg, cfg->cbb, ip + 5) && read32 (ip + 6) == token)) {
99249908
CHECK_STACK (1);
99259909

99269910
sp --;
99279911

9928-
mini_emit_stobj (cfg, sp [0], sp [1], klass, FALSE);
9912+
mini_emit_memory_copy (cfg, sp [0], sp [1], klass, FALSE, ins_flag);
99299913

99309914
ip += 5 + 5;
99319915
ins_flag = 0;
@@ -10582,7 +10566,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
1058210566
dreg = alloc_ireg_mp (cfg);
1058310567
EMIT_NEW_BIALU (cfg, ins, OP_PADD, dreg, sp [0]->dreg, offset_ins->dreg);
1058410568
wbarrier_ptr_ins = ins;
10585-
/* The decomposition will call mini_emit_stobj () which will emit a wbarrier if needed */
10569+
/* The decomposition will call mini_emit_memory_copy () which will emit a wbarrier if needed */
1058610570
EMIT_NEW_STORE_MEMBASE_TYPE (cfg, store, field->type, dreg, 0, sp [1]->dreg);
1058710571
} else {
1058810572
EMIT_NEW_STORE_MEMBASE_TYPE (cfg, store, field->type, sp [0]->dreg, foffset, sp [1]->dreg);
@@ -11843,7 +11827,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
1184311827
temp = mono_compile_create_var (cfg, &klass->byval_arg, OP_LOCAL);
1184411828
temp->backend.is_pinvoke = 1;
1184511829
EMIT_NEW_TEMPLOADA (cfg, dest, temp->inst_c0);
11846-
mini_emit_stobj (cfg, dest, src, klass, TRUE);
11830+
mini_emit_memory_copy (cfg, dest, src, klass, TRUE, 0);
1184711831

1184811832
EMIT_NEW_TEMPLOAD (cfg, dest, temp->inst_c0);
1184911833
dest->type = STACK_VTYPE;
@@ -11874,7 +11858,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
1187411858
} else {
1187511859
EMIT_NEW_RETLOADA (cfg, ins);
1187611860
}
11877-
mini_emit_stobj (cfg, ins, sp [0], klass, TRUE);
11861+
mini_emit_memory_copy (cfg, ins, sp [0], klass, TRUE, 0);
1187811862

1187911863
if (sp != stack_start)
1188011864
UNVERIFIED;

0 commit comments

Comments
 (0)