[gc] Fix gc bitmap for array of pointers. They don't contain references
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 8 Jan 2015 20:37:18 +0000 (15:37 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 8 Jan 2015 20:37:18 +0000 (15:37 -0500)
mono/metadata/object.c
mono/tests/sgen-descriptors.cs

index 083112159b93794e2c4c7dc5e45d59925305a275..cfb660e3930c4914295658d817a69cab9391d461 100644 (file)
@@ -986,7 +986,7 @@ mono_class_compute_gc_descriptor (MonoClass *class)
                class->gc_descr = (gpointer)mono_gc_make_descr_for_string (bitmap, 2);
        } else if (class->rank) {
                mono_class_compute_gc_descriptor (class->element_class);
-               if (!class->element_class->valuetype) {
+               if (MONO_TYPE_IS_REFERENCE (&class->element_class->byval_arg)) {
                        gsize abm = 1;
                        class->gc_descr = mono_gc_make_descr_for_array (class->byval_arg.type == MONO_TYPE_SZARRAY, &abm, 1, sizeof (gpointer));
                        /*printf ("new array descriptor: 0x%x for %s.%s\n", class->gc_descr,
index 246e5aac59d9f18e6c73202dc30b7c7ba5ec3e1c..16f9dd305b98c311ccd3981381f4652df5b8e687 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 
 public struct SmallMixed
@@ -88,11 +89,26 @@ class Driver {
                }
        }
 
+       static unsafe void FillPtr (int cycles) {
+               var l = new List<Byte*[]> ();
+               for (int i = 0; i < cycles; ++i)
+               {
+                       var a = new Byte* [128];
+                       for (int j = 0; j < a.Length; ++j)
+                               a [j] = (Byte*) new IntPtr (j).ToPointer ();
+                       if (i < 1000)
+                               l.Add (a);
+                       else
+                               l [i % 1000] = a;
+               }
+       }
+
        static void Main () {
                int loops = 3;
                int cycles = 200000;
                for (int i = 0; i < loops; ++i) {
                        Fill (cycles);
+                       FillPtr (cycles);
                }
        }
 }