From 9e06a244f20a6a81d17865688815158c49accceb Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Wed, 29 Jul 2020 00:23:56 +0300 Subject: [PATCH] Intrinsify MemoryMarshal.GetArrayDataReference for interp (#39920) --- src/mono/mono/mini/interp/interp.c | 7 +++++++ src/mono/mono/mini/interp/mintops.def | 1 + src/mono/mono/mini/interp/transform.c | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index d107b8d..8d86279 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -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); diff --git a/src/mono/mono/mini/interp/mintops.def b/src/mono/mono/mini/interp/mintops.def index 488fc86..6e4d90f 100644 --- a/src/mono/mono/mini/interp/mintops.def +++ b/src/mono/mono/mini/interp/mintops.def @@ -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) diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index f0a333d..13c9108 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -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; -- 2.7.4