@@ -2863,6 +2863,8 @@ mini_emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
2863
2863
if (!cfg -> gen_write_barriers )
2864
2864
return ;
2865
2865
2866
+ //method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER && !MONO_INS_IS_PCONST_NULL (sp [1])
2867
+
2866
2868
card_table = mono_gc_get_card_table (& card_table_shift_bits , & card_table_mask );
2867
2869
2868
2870
mono_gc_get_nursery (& nursery_shift_bits , & nursery_size );
@@ -9853,23 +9855,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
9853
9855
klass = mini_get_class (method , token , generic_context );
9854
9856
CHECK_TYPELOAD (klass );
9855
9857
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 );
9873
9859
ins_flag = 0 ;
9874
9860
ip += 5 ;
9875
9861
break ;
@@ -9918,14 +9904,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
9918
9904
}
9919
9905
9920
9906
/* 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 )) {
9924
9908
CHECK_STACK (1 );
9925
9909
9926
9910
sp -- ;
9927
9911
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 );
9929
9913
9930
9914
ip += 5 + 5 ;
9931
9915
ins_flag = 0 ;
@@ -10582,7 +10566,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
10582
10566
dreg = alloc_ireg_mp (cfg );
10583
10567
EMIT_NEW_BIALU (cfg , ins , OP_PADD , dreg , sp [0 ]-> dreg , offset_ins -> dreg );
10584
10568
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 */
10586
10570
EMIT_NEW_STORE_MEMBASE_TYPE (cfg , store , field -> type , dreg , 0 , sp [1 ]-> dreg );
10587
10571
} else {
10588
10572
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
11843
11827
temp = mono_compile_create_var (cfg , & klass -> byval_arg , OP_LOCAL );
11844
11828
temp -> backend .is_pinvoke = 1 ;
11845
11829
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 );
11847
11831
11848
11832
EMIT_NEW_TEMPLOAD (cfg , dest , temp -> inst_c0 );
11849
11833
dest -> type = STACK_VTYPE ;
@@ -11874,7 +11858,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
11874
11858
} else {
11875
11859
EMIT_NEW_RETLOADA (cfg , ins );
11876
11860
}
11877
- mini_emit_stobj (cfg , ins , sp [0 ], klass , TRUE);
11861
+ mini_emit_memory_copy (cfg , ins , sp [0 ], klass , TRUE, 0 );
11878
11862
11879
11863
if (sp != stack_start )
11880
11864
UNVERIFIED ;
0 commit comments