[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>
Thu, 14 Apr 2016 20:43:20 +0000 (16:43 -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 0ffea956f7fce324006748046e72fe2a828cdb0a..6b31775a563ea7cef4cf983772ea07600b900415 100644 (file)
@@ -1242,16 +1242,14 @@ 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 587d08254e5f2143e2555a1d3bc579ddb2bb42e5..8bf63dcfbfe1b221dbc800d6924d91ea3a40e20e 100644 (file)
@@ -4230,7 +4230,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);
                }
@@ -4267,7 +4267,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);