Optimize and extend System.Array intrinsic identification. (mono/mono#17047)
authorJay Krell <jaykrell@microsoft.com>
Sun, 6 Oct 2019 08:27:42 +0000 (01:27 -0700)
committerMarek Safar <marek.safar@gmail.com>
Sun, 6 Oct 2019 08:27:42 +0000 (10:27 +0200)
* Optimize and extend System.Array intrinsic identification.
i.e. do the strcmp last.
Add GetRawArrayData.

* Use [Intrinsic] attribute instead of comment.

Commit migrated from https://github.com/mono/mono/commit/f57af77e69ebe0f47da00716cef4a8ff5ec9d9fc

src/mono/mono/mini/intrinsics.c
src/mono/netcore/System.Private.CoreLib/src/System/Array.cs

index dbeafbe..87117bf 100644 (file)
@@ -738,11 +738,11 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                } else
                        return NULL;
        } else if (cmethod->klass == mono_defaults.array_class) {
-               if (strcmp (cmethod->name, "GetGenericValueImpl") == 0 && fsig->param_count + fsig->hasthis == 3 && !cfg->gsharedvt)
+               if (fsig->param_count + fsig->hasthis == 3 && !cfg->gsharedvt && strcmp (cmethod->name, "GetGenericValueImpl") == 0)
                        return emit_array_generic_access (cfg, fsig, args, FALSE);
-               else if (strcmp (cmethod->name, "SetGenericValueImpl") == 0 && fsig->param_count + fsig->hasthis == 3 && !cfg->gsharedvt)
+               else if (fsig->param_count + fsig->hasthis == 3 && !cfg->gsharedvt && strcmp (cmethod->name, "SetGenericValueImpl") == 0)
                        return emit_array_generic_access (cfg, fsig, args, TRUE);
-               else if (!strcmp (cmethod->name, "GetRawSzArrayData")) {
+               else if (!strcmp (cmethod->name, "GetRawSzArrayData") || !strcmp (cmethod->name, "GetRawArrayData")) {
                        int dreg = alloc_preg (cfg);
                        EMIT_NEW_BIALU_IMM (cfg, ins, OP_PADD_IMM, dreg, args [0]->dreg, MONO_STRUCT_OFFSET (MonoArray, vector));
                        return ins;
index 403fccf..e5761a9 100644 (file)
@@ -429,12 +429,14 @@ namespace System
                        return GetLowerBound (dimension) + GetLength (dimension) - 1;
                }
 
+               [Intrinsic]
                [MethodImpl (MethodImplOptions.AggressiveInlining)]
                internal ref byte GetRawSzArrayData ()
                {
                        return ref Unsafe.As<RawData>(this).Data;
                }
 
+               [Intrinsic]
                [MethodImpl (MethodImplOptions.AggressiveInlining)]
                internal ref byte GetRawArrayData ()
                {