[sgen] "align-up" requested allocation sizes within the managed allocator, instead...
authorAlexis Christoforides <alexis@thenull.net>
Thu, 24 Mar 2016 13:56:50 +0000 (09:56 -0400)
committerAlexis Christoforides <alexis@thenull.net>
Mon, 8 Aug 2016 20:22:34 +0000 (16:22 -0400)
All code paths will still align-up the size to be allocated, but now it's easier to gather the real size of an object.

mono/metadata/sgen-mono.c
mono/mini/method-to-ir.c

index 8421b903ba6f967366bba0f2d7c7b337510ac1ee..12ab4c173ee7b26c702fcd4f7fbc4e72a4e1e811 100644 (file)
@@ -1252,16 +1252,16 @@ create_allocator (int atype, gboolean slowpath)
                g_assert_not_reached ();
        }
 
-       if (atype != ATYPE_SMALL) {
-               /* size += ALLOC_ALIGN - 1; */
                mono_mb_emit_ldloc (mb, size_var);
-               mono_mb_emit_icon (mb, SGEN_ALLOC_ALIGN - 1);
-               mono_mb_emit_byte (mb, CEE_ADD);
-               /* size &= ~(ALLOC_ALIGN - 1); */
-               mono_mb_emit_icon (mb, ~(SGEN_ALLOC_ALIGN - 1));
-               mono_mb_emit_byte (mb, CEE_AND);
-               mono_mb_emit_stloc (mb, size_var);
        }
+       /* size += ALLOC_ALIGN - 1; */
+       mono_mb_emit_ldloc (mb, size_var);
+       mono_mb_emit_icon (mb, SGEN_ALLOC_ALIGN - 1);
+       mono_mb_emit_byte (mb, CEE_ADD);
+       /* size &= ~(ALLOC_ALIGN - 1); */
+       mono_mb_emit_icon (mb, ~(SGEN_ALLOC_ALIGN - 1));
+       mono_mb_emit_byte (mb, CEE_AND);
+       mono_mb_emit_stloc (mb, size_var);
 
        /* if (size > MAX_SMALL_OBJ_SIZE) goto slowpath */
        if (atype != ATYPE_SMALL) {
index 3d295db2a358a479cdce82160444b1066145b036..10b9f17dc7ef4c9cc78087034211f95a14b23695 100644 (file)
@@ -4229,7 +4229,7 @@ handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box, int context_
                                if (size < sizeof (MonoObject))
                                        g_error ("Invalid size %d for class %s", size, mono_type_get_full_name (klass));
 
-                               EMIT_NEW_ICONST (cfg, iargs [1], mono_gc_get_aligned_size_for_allocator (size));
+                               EMIT_NEW_ICONST (cfg, iargs [1], size);
                        }
                        return mono_emit_method_call (cfg, managed_alloc, iargs, NULL);
                }
@@ -4266,7 +4266,7 @@ handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box, int context_
                                g_error ("Invalid size %d for class %s", size, mono_type_get_full_name (klass));
 
                        EMIT_NEW_VTABLECONST (cfg, iargs [0], vtable);
-                       EMIT_NEW_ICONST (cfg, iargs [1], mono_gc_get_aligned_size_for_allocator (size));
+                       EMIT_NEW_ICONST (cfg, iargs [1], size);
                        return mono_emit_method_call (cfg, managed_alloc, iargs, NULL);
                }
                alloc_ftn = mono_class_get_allocation_ftn (vtable, for_box, &pass_lw);