2009-05-21 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Wed, 20 May 2009 23:50:25 +0000 (23:50 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 20 May 2009 23:50:25 +0000 (23:50 -0000)
* aot-compiler.c (add_wrappers): Add StructureToPtr/PtrToStructure wrappers.

* basic.cs: Move the test_2_cprop_bug () test to generics.cs as it involves
generics.

svn path=/trunk/mono/; revision=134489

mono/mini/ChangeLog
mono/mini/aot-compiler.c
mono/mini/basic.cs
mono/mini/generics.cs

index fa420726773e4444df5464881b53272e120e93a5..b9885cb3a0904fc57afe3b8a69fa0a848babeeae 100644 (file)
@@ -1,3 +1,10 @@
+2009-05-21  Zoltan Varga  <vargaz@gmail.com>
+
+       * aot-compiler.c (add_wrappers): Add StructureToPtr/PtrToStructure wrappers.
+
+       * basic.cs: Move the test_2_cprop_bug () test to generics.cs as it involves
+       generics.
+
 2009-05-20 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * local-propagation.c (mono_local_cprop): Avoid local propagation
index 3f45ee649683bf0771695a8230a8728ed73bb5b7..e3b76e5dbcda1adbcefc44459a843c711ad05364 100644 (file)
@@ -1652,6 +1652,50 @@ add_wrappers (MonoAotCompile *acfg)
                        add_method (acfg, mono_marshal_get_native_wrapper (method, TRUE, TRUE));
                }
        }
+
+       /* StructureToPtr/PtrToStructure wrappers */
+       for (i = 0; i < acfg->image->tables [MONO_TABLE_TYPEDEF].rows; ++i) {
+               MonoClass *klass;
+               
+               token = MONO_TOKEN_TYPE_DEF | (i + 1);
+               klass = mono_class_get (acfg->image, token);
+
+               if (klass->valuetype && !klass->generic_container && ((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) != TYPE_ATTRIBUTE_AUTO_LAYOUT)) {
+                       MonoMarshalType *info;
+                       gboolean can_marshal = TRUE;
+                       int j;
+
+                       info = mono_marshal_load_type_info (klass);
+
+                       /* Only allow a few field types to avoid asserts in the marshalling code */
+                       for (j = 0; j < info->num_fields; j++) {
+                               switch (info->fields [j].field->type->type) {
+                               case MONO_TYPE_I4:
+                               case MONO_TYPE_U4:
+                               case MONO_TYPE_I1:
+                               case MONO_TYPE_U1:
+                               case MONO_TYPE_BOOLEAN:
+                               case MONO_TYPE_I2:
+                               case MONO_TYPE_U2:
+                               case MONO_TYPE_CHAR:
+                               case MONO_TYPE_I8:
+                               case MONO_TYPE_U8:
+                               case MONO_TYPE_PTR:
+                               case MONO_TYPE_R4:
+                               case MONO_TYPE_R8:
+                                       break;
+                               default:
+                                       can_marshal = FALSE;
+                                       break;
+                               }
+                       }
+
+                       if (can_marshal) {
+                               add_method (acfg, mono_marshal_get_struct_to_ptr (klass));
+                               add_method (acfg, mono_marshal_get_ptr_to_struct (klass));
+                       }
+               }
+       }
 }
 
 static gboolean
index 3f736d506932733084a923eb9f1bbc5907a91fd9..c9b22c20510ec5e150c8a4e2720a37d61e89ff36 100644 (file)
@@ -1326,16 +1326,4 @@ class Tests {
                return 0;
        }
 
-       //repro for #505375
-       public static int test_2_cprop_bug () {
-               int idx = 0;
-               int a = 1;
-               var cmp = System.Collections.Generic.Comparer<int>.Default ;
-               if (cmp.Compare (a, 0) > 0)
-                       a = 0;
-               do { idx++; } while (cmp.Compare (idx - 1, a) == 0);
-               return idx;
-       }
-
-
 }
index 398ac0ef5b2c0dd71c9be396779aa73488b41376..1cdfc2b356782faf915afa28d198ad399159f146 100644 (file)
@@ -431,6 +431,18 @@ class Tests {
                return 0;
        }
 
+       //repro for #505375
+       [Category ("!FULLAOT")]
+       public static int test_2_cprop_bug () {
+               int idx = 0;
+               int a = 1;
+               var cmp = System.Collections.Generic.Comparer<int>.Default ;
+               if (cmp.Compare (a, 0) > 0)
+                       a = 0;
+               do { idx++; } while (cmp.Compare (idx - 1, a) == 0);
+               return idx;
+       }
+
        public static void VirtualInterfaceCallFromGenericMethod <T> (IFoo f) {
                f.Bar <T> ();
        }