diff options
author | Zoltan Varga <vargaz@gmail.com> | 2018-09-07 23:08:07 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2018-09-11 09:57:27 +0300 |
commit | 89cabf420567c8495d31e563458e838173a2d283 (patch) | |
tree | 4d5731844edd856ff121e9d24c782b890667cd34 | |
parent | 8d13a8428dfdc1be3c5974755b83816d85251888 (diff) |
[arm64] Add dyncall support for ArgVtypeByRefOnStack arguments.
Fixes https://github.com/mono/mono/issues/10483.
-rw-r--r-- | mono/mini/aot-tests.cs | 32 | ||||
-rw-r--r-- | mono/mini/mini-arm64.c | 4 |
2 files changed, 29 insertions, 7 deletions
diff --git a/mono/mini/aot-tests.cs b/mono/mini/aot-tests.cs index bdfbdf4cc6d..c513eeb7a2c 100644 --- a/mono/mini/aot-tests.cs +++ b/mono/mini/aot-tests.cs @@ -267,6 +267,12 @@ class Tests public static Nullable<T> GetNull<T>() where T : struct { return null; } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + public static bool GetHasValueManyArgs<T>(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, T? value) where T : struct + { + return value.HasValue; + } } [Category ("DYNCALL")] @@ -300,6 +306,24 @@ class Tests return 0; } + [Category ("DYNCALL")] + [Category ("!WASM")] //Interp fails + public static int test_0_arm64_dyncall_vtypebyrefonstack () { + var s = new LargeStruct () { a = 1, b = 2, c = 3, d = 4 }; + + NullableMethods.GetHasValueManyArgs<LargeStruct> (1, 2, 3, 4, 5, 6, 7, 8, s); + + Type type = typeof (LargeStruct?).GetGenericArguments () [0]; + var m = typeof(NullableMethods).GetMethod("GetHasValueManyArgs", BindingFlags.Static | BindingFlags.Public); + bool b1 = (bool)m.MakeGenericMethod (new Type[] {type}).Invoke (null, new object[] { 1, 2, 3, 4, 5, 6, 7, 8, s }); + if (!b1) + return 1; + bool b2 = (bool)m.MakeGenericMethod (new Type[] {type}).Invoke (null, new object[] { 1, 2, 3, 4, 5, 6, 7, 8, null }); + if (b2) + return 2; + return 0; + } + enum AnEnum { A = 0, B = 1 @@ -425,13 +449,9 @@ class Tests public static int test_0_large_nullable_invoke () { var s = new LargeStruct () { a = 1, b = 2, c = 3, d = 4 }; - GetHasValue<LargeStruct> (s); + NullableMethods.GetHasValue<LargeStruct> (s); -#if __MOBILE__ - var m = typeof(AotTests).GetMethod("GetHasValue", BindingFlags.Static | BindingFlags.Public); -#else - var m = typeof(Tests).GetMethod("GetHasValue", BindingFlags.Static | BindingFlags.Public); -#endif + var m = typeof(NullableMethods).GetMethod("GetHasValue", BindingFlags.Static | BindingFlags.Public); Type type = typeof (LargeStruct?).GetGenericArguments () [0]; bool b1 = (bool)m.MakeGenericMethod (new Type[] {type}).Invoke (null, new object[] { s }); diff --git a/mono/mini/mini-arm64.c b/mono/mini/mini-arm64.c index 45b7475bd01..24a43830663 100644 --- a/mono/mini/mini-arm64.c +++ b/mono/mini/mini-arm64.c @@ -1609,6 +1609,7 @@ dyn_call_supported (CallInfo *cinfo, MonoMethodSignature *sig) case ArgInFRegR4: case ArgHFA: case ArgVtypeByRef: + case ArgVtypeByRefOnStack: case ArgOnStack: case ArgVtypeOnStack: break; @@ -1725,7 +1726,7 @@ mono_arch_start_dyn_call (MonoDynCallInfo *info, gpointer **args, guint8 *ret, g ArgInfo *ainfo = &cinfo->args [aindex + sig->hasthis]; int slot = -1; - if (ainfo->storage == ArgOnStack || ainfo->storage == ArgVtypeOnStack) { + if (ainfo->storage == ArgOnStack || ainfo->storage == ArgVtypeOnStack || ainfo->storage == ArgVtypeByRefOnStack) { slot = PARAM_REGS + 1 + (ainfo->offset / sizeof (mgreg_t)); } else { slot = ainfo->reg; @@ -1848,6 +1849,7 @@ mono_arch_start_dyn_call (MonoDynCallInfo *info, gpointer **args, guint8 *ret, g p->n_fpargs += ainfo->nregs; break; case ArgVtypeByRef: + case ArgVtypeByRefOnStack: p->regs [slot] = (mgreg_t)arg; break; case ArgVtypeOnStack: |