From 65f260675e3428010c2655b42fbddae336f26182 Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Tue, 11 Apr 2017 11:36:49 -0700 Subject: [PATCH] [runtime] Fix get_virtual_stelemref_wrapper STELEMREF_CLASS case to actually do the base class check. The code was bailing straight to native which is significantly slower. This is the result of roslyn compiling corlib on my machine: Before: real 0m5.757s user 0m22.059s sys 0m1.736s After: real 0m5.816s user 0m23.623s sys 0m1.693s --- mono/metadata/marshal.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index 105655bd1b0..1f4613fb540 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -9163,7 +9163,7 @@ mono_marshal_isinst_with_cache (MonoObject *obj, MonoClass *klass, uintptr_t *ca /** * mono_marshal_get_isinst_with_cache: - * This does the equivalent of \c mono_object_isinst_with_cache. + * This does the equivalent of \c mono_marshal_isinst_with_cache. */ MonoMethod * mono_marshal_get_isinst_with_cache (void) @@ -9933,8 +9933,6 @@ get_virtual_stelemref_wrapper (int kind) break; case STELEMREF_CLASS: { - int b_fast; - /* the method: @@ -9975,17 +9973,6 @@ get_virtual_stelemref_wrapper (int kind) /* vklass = value->vtable->klass */ load_value_class (mb, vklass); - /* fastpath */ - mono_mb_emit_ldloc (mb, vklass); - mono_mb_emit_ldloc (mb, aklass); - b_fast = mono_mb_emit_branch (mb, CEE_BEQ); - - /*if (mono_object_isinst (value, aklass)) */ - mono_mb_emit_ldarg (mb, 2); - mono_mb_emit_ldloc (mb, aklass); - mono_mb_emit_icall (mb, mono_object_isinst_icall); - b2 = mono_mb_emit_branch (mb, CEE_BRFALSE); - /* if (vklass->idepth < aklass->idepth) goto failue */ mono_mb_emit_ldloc (mb, vklass); mono_mb_emit_ldflda (mb, MONO_STRUCT_OFFSET (MonoClass, idepth)); @@ -10017,14 +10004,12 @@ get_virtual_stelemref_wrapper (int kind) /* do_store: */ mono_mb_patch_branch (mb, b1); - mono_mb_patch_branch (mb, b_fast); mono_mb_emit_ldloc (mb, array_slot_addr); mono_mb_emit_ldarg (mb, 2); mono_mb_emit_byte (mb, CEE_STIND_REF); mono_mb_emit_byte (mb, CEE_RET); /* do_exception: */ - mono_mb_patch_branch (mb, b2); mono_mb_patch_branch (mb, b3); mono_mb_patch_branch (mb, b4); -- 2.25.1