2006-01-03 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / inssel.brg
index 40c00f1df2155c897b58ba5546000c4eca0991b7..ddeb206fb2deee101d2e13675f6618a7c0419b10 100644 (file)
@@ -408,6 +408,10 @@ stmt: OP_DUMMY_STORE {
 stmt: OP_NOT_REACHED {
 }
 
+stmt: OP_MEMORY_BARRIER {
+       mono_bblock_add_inst (s->cbb, tree);
+}
+
 #
 # load/store operations
 #
@@ -746,7 +750,7 @@ reg: OP_TLS_GET {
        mono_bblock_add_inst (s->cbb, tree);
 }
 
-stmt: CEE_SWITCH (reg) {
+stmt: CEE_SWITCH (reg) "2" {
        MonoInst *label;
        int offset_reg = mono_regstate_next_int (s->rs);
        int target_reg = mono_regstate_next_int (s->rs);
@@ -1064,6 +1068,10 @@ reg: CEE_ISINST (reg) {
                                /* the object_is_null target simply copies the input register to the output */
                                mini_emit_isninst_cast (s, eclass_reg, klass->cast_class, false_label, object_is_null);
                        }
+               } else if (mono_class_is_nullable (klass)) {
+                       MONO_EMIT_NEW_LOAD_MEMBASE (s, klass_reg, vtable_reg, G_STRUCT_OFFSET (MonoVTable, klass));
+                       /* the object_is_null target simply copies the input register to the output */
+                       mini_emit_isninst_cast (s, klass_reg, klass->cast_class, false_label, object_is_null);
                } else {
                        if (!s->compile_aot && !(s->opt & MONO_OPT_SHARED) && (klass->flags & TYPE_ATTRIBUTE_SEALED)) {
                                /* the remoting code is broken, access the class for now */
@@ -1864,7 +1872,7 @@ mini_emit_memcpy (MonoCompile *s, int destreg, int doffset, int srcreg, int soff
 }
 
 void 
-mini_emit_memset (MonoCompile *s, int destreg, int offset, int size, int val, int alignl)
+mini_emit_memset (MonoCompile *s, int destreg, int offset, int size, int val, int align)
 {
        int val_reg = mono_regstate_next_int (s->rs);
 
@@ -1873,13 +1881,21 @@ mini_emit_memset (MonoCompile *s, int destreg, int offset, int size, int val, in
        else
                MONO_EMIT_NEW_ICONST (s, val_reg, val);
 
+       /* FIXME: consider alignment for archs that need it. */
+#if !NO_UNALIGNED_ACCESS
        if (sizeof (gpointer) == 8) {
+               if (offset % 8) {
+                       MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREI4_MEMBASE_REG, destreg, offset, val_reg);
+                       offset += 4;
+                       size -= 4;
+               }
                while (size >= 8) {
                        MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREI8_MEMBASE_REG, destreg, offset, val_reg);
                        offset += 8;
                        size -= 8;
                }
        }       
+#endif
 
        while (size >= 4) {
                MONO_EMIT_NEW_STORE_MEMBASE (s, OP_STOREI4_MEMBASE_REG, destreg, offset, val_reg);