Intrinsify MemoryMarshal.GetArrayDataReference for interp (#39920)
authorEgor Bogatov <egorbo@gmail.com>
Tue, 28 Jul 2020 21:23:56 +0000 (00:23 +0300)
committerGitHub <noreply@github.com>
Tue, 28 Jul 2020 21:23:56 +0000 (23:23 +0200)
src/mono/mono/mini/interp/interp.c
src/mono/mono/mini/interp/mintops.def
src/mono/mono/mini/interp/transform.c

index d107b8d..8d86279 100644 (file)
@@ -5318,6 +5318,13 @@ call_newobj:
                        ++ip;
                        MINT_IN_BREAK;
                }
+               MINT_IN_CASE(MINT_INTRINS_MEMORYMARSHAL_GETARRAYDATAREF) {
+                       MonoObject* const o = sp [-1].data.o;
+                       NULL_CHECK (o);
+                       sp[-1].data.p = (guint8*)o + MONO_STRUCT_OFFSET (MonoArray, vector);
+                       ++ip;
+                       MINT_IN_BREAK;
+               }
                MINT_IN_CASE(MINT_INTRINS_ORDINAL_IGNORE_CASE_ASCII) {
                        sp--;
                        sp [-1].data.i = interp_intrins_ordinal_ignore_case_ascii ((guint32)sp [-1].data.i, (guint32)sp [0].data.i);
index 488fc86..6e4d90f 100644 (file)
@@ -795,6 +795,7 @@ OPDEF(MINT_INTRINS_RUNTIMEHELPERS_OBJECT_HAS_COMPONENT_SIZE, "intrins_runtimehel
 OPDEF(MINT_INTRINS_CLEAR_WITH_REFERENCES, "intrin_clear_with_references", 1, Pop2, Push0, MintOpNoArgs)
 OPDEF(MINT_INTRINS_MARVIN_BLOCK, "intrins_marvin_block", 1, Pop2, Push0, MintOpNoArgs)
 OPDEF(MINT_INTRINS_ASCII_CHARS_TO_UPPERCASE, "intrins_ascii_chars_to_uppercase", 1, Pop1, Push1, MintOpNoArgs)
+OPDEF(MINT_INTRINS_MEMORYMARSHAL_GETARRAYDATAREF, "intrins_memorymarshal_getarraydataref", 1, Pop1, Push1, MintOpNoArgs)
 OPDEF(MINT_INTRINS_ORDINAL_IGNORE_CASE_ASCII, "intrins_ordinal_ignore_case_ascii", 1, Pop2, Push1, MintOpNoArgs)
 OPDEF(MINT_INTRINS_64ORDINAL_IGNORE_CASE_ASCII, "intrins_64ordinal_ignore_case_ascii", 1, Pop2, Push1, MintOpNoArgs)
 OPDEF(MINT_INTRINS_U32_TO_DECSTR, "intrins_u32_to_decstr", 3, Pop1, Push1, MintOpNoArgs)
index f0a333d..13c9108 100644 (file)
@@ -1505,6 +1505,9 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas
        } else if (in_corlib && !strcmp (klass_name_space, "System") && !strcmp (klass_name, "Marvin")) {
                if (!strcmp (tm, "Block"))
                        *op = MINT_INTRINS_MARVIN_BLOCK;
+       } else if (in_corlib && !strcmp (klass_name_space, "System.Runtime.InteropServices") && !strcmp (klass_name, "MemoryMarshal")) {
+               if (!strcmp (tm, "GetArrayDataReference"))
+                       *op = MINT_INTRINS_MEMORYMARSHAL_GETARRAYDATAREF;
        } else if (in_corlib && !strcmp (klass_name_space, "System.Text.Unicode") && !strcmp (klass_name, "Utf16Utility")) {
                if (!strcmp (tm, "ConvertAllAsciiCharsInUInt32ToUppercase"))
                        *op = MINT_INTRINS_ASCII_CHARS_TO_UPPERCASE;