From: Alexis Christoforides Date: Thu, 24 Mar 2016 13:56:50 +0000 (-0400) Subject: [sgen] "align-up" requested allocation sizes within the managed allocator, instead... X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=08f47d56938aa6413f3797b70d21d8250001ffc0;p=mono.git [sgen] "align-up" requested allocation sizes within the managed allocator, instead of sometimes before. 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. --- diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c index 8421b903ba6..12ab4c173ee 100644 --- a/mono/metadata/sgen-mono.c +++ b/mono/metadata/sgen-mono.c @@ -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) { diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index 3d295db2a35..10b9f17dc7e 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -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);