[jit] Add mini_emit_memory_store and use it for STOBJ.
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 1 May 2017 23:36:33 +0000 (16:36 -0700)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 8 May 2017 23:33:40 +0000 (16:33 -0700)
mono/mini/memory-access.c
mono/mini/method-to-ir.c
mono/mini/mini.h

index 8c948d2b9c5a2e728f517ec08a57af13691d32a2..76c42e0b04f64a577bc3a17723a49553c74553fb 100644 (file)
@@ -165,4 +165,25 @@ mini_emit_memory_load (MonoCompile *cfg, MonoType *type, MonoInst *src, int offs
        return ins;
 }
 
+
+void
+mini_emit_memory_store (MonoCompile *cfg, MonoType *type, MonoInst *dest, MonoInst *value, int ins_flag)
+{
+       MonoInst *ins;
+
+       if (ins_flag & MONO_INST_VOLATILE) {
+               /* Volatile stores have release semantics, see 12.6.7 in Ecma 335 */
+               mini_emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_REL);
+       }
+       /* FIXME: should check item at sp [1] is compatible with the type of the store. */
+
+       EMIT_NEW_STORE_MEMBASE_TYPE (cfg, ins, type, dest->dreg, 0, value->dreg);
+       ins->flags |= ins_flag;
+       if (cfg->gen_write_barriers && cfg->method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER &&
+               mini_type_is_reference (type) && !MONO_INS_IS_PCONST_NULL (value)) {
+               /* insert call to write barrier */
+               mini_emit_write_barrier (cfg, dest, value);
+       }
+}
+
 #endif
index 8d64aabc8a8ca471c9f43b0e1a021418f1c9109b..e29c55d8025d7c1e73ffefd32a38a6722f070336 100644 (file)
@@ -11012,18 +11012,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        token = read32 (ip + 1);
                        klass = mini_get_class (method, token, generic_context);
                        CHECK_TYPELOAD (klass);
-                       if (ins_flag & MONO_INST_VOLATILE) {
-                               /* Volatile stores have release semantics, see 12.6.7 in Ecma 335 */
-                               mini_emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_REL);
-                       }
+
                        /* FIXME: should check item at sp [1] is compatible with the type of the store. */
-                       EMIT_NEW_STORE_MEMBASE_TYPE (cfg, ins, &klass->byval_arg, sp [0]->dreg, 0, sp [1]->dreg);
-                       ins->flags |= ins_flag;
-                       if (cfg->gen_write_barriers && cfg->method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER &&
-                               generic_class_is_reference_type (cfg, klass) && !MONO_INS_IS_PCONST_NULL (sp [1])) {
-                               /* insert call to write barrier */
-                               mini_emit_write_barrier (cfg, sp [0], sp [1]);
-                       }
+                       mini_emit_memory_store (cfg, &klass->byval_arg, sp [0], sp [1], ins_flag);
                        ins_flag = 0;
                        ip += 5;
                        inline_costs += 1;
index bfcf681b37420f21d94714c1865af61676e9b195..d23005d6b8bf865c841a063ba7a034d816b9e323 100644 (file)
@@ -2635,6 +2635,7 @@ MonoInst*         mini_emit_memory_barrier (MonoCompile *cfg, int kind);
 void              mini_emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value);
 gboolean          mini_emit_wb_aware_memcpy (MonoCompile *cfg, MonoClass *klass, MonoInst *iargs[4], int size, int align);
 MonoInst*         mini_emit_memory_load (MonoCompile *cfg, MonoType *type, MonoInst *src, int offset, int ins_flag);
+void              mini_emit_memory_store (MonoCompile *cfg, MonoType *type, MonoInst *dest, MonoInst *value, int ins_flag);
 
 MonoMethod*       mini_get_memcpy_method (void);
 MonoMethod*       mini_get_memset_method (void);