[runtime] Redirect to our objc_msgSend wrapper functions when needed for .NET code. (#10932)

This makes the mono_dllmap_insert function unnecessary for .NET, so remove it.

Ref: https://github.com/dotnet/runtime/issues/48110
Ref: https://github.com/dotnet/runtime/issues/43204
Ref: #10504
This commit is contained in:
Rolf Bjarne Kvinge 2021-03-24 09:17:35 +01:00 коммит произвёл GitHub
Родитель 2b7dc07d20
Коммит 9153edebda
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 27 добавлений и 22 удалений

Просмотреть файл

@ -323,7 +323,9 @@
"const char *", "func",
"const char *", "tdll",
"const char *", "tfunc"
),
) {
Mode = DotNetMode.OnlyLegacy,
},
#endregion

Просмотреть файл

@ -31,6 +31,11 @@ extern "C" {
void *xamarin_marshal_return_value (SEL sel, MonoType *mtype, const char *type, MonoObject *retval, bool retain, MonoMethod *method, MethodDescription *desc, GCHandle *exception_gchandle);
void xamarin_dyn_objc_msgSend ();
void xamarin_dyn_objc_msgSendSuper ();
void xamarin_dyn_objc_msgSend_stret ();
void xamarin_dyn_objc_msgSendSuper_stret ();
#ifdef __cplusplus
}
#endif

Просмотреть файл

@ -1354,7 +1354,9 @@ xamarin_initialize ()
xamarin_initialize_dynamic_runtime (NULL);
#endif
#if !DOTNET
xamarin_insert_dllmap ();
#endif
MONO_ENTER_GC_UNSAFE;
@ -2449,6 +2451,8 @@ xamarin_create_product_exception_with_inner_exception (int code, GCHandle inner_
return exception_gchandle;
return handle;
}
#if !DOTNET
void
xamarin_insert_dllmap ()
{
@ -2467,6 +2471,7 @@ xamarin_insert_dllmap ()
LOG (PRODUCT ": Added dllmap for objc_msgSend");
#endif // defined (__i386__) || defined (__x86_64__)
}
#endif // !DOTNET
#if DOTNET
void
@ -2499,6 +2504,20 @@ xamarin_pinvoke_override (const char *libraryName, const char *entrypointName)
if (!strcmp (libraryName, "__Internal")) {
symbol = dlsym (RTLD_DEFAULT, entrypointName);
#if defined (__i386__) || defined (__x86_64__)
} else if (!strcmp (libraryName, "/usr/lib/libobjc.dylib")) {
if (xamarin_marshal_objectivec_exception_mode != MarshalObjectiveCExceptionModeDisable) {
if (!strcmp (entrypointName, "objc_msgSend")) {
symbol = (void *) &xamarin_dyn_objc_msgSend;
} else if (!strcmp (entrypointName, "objc_msgSendSuper")) {
symbol = (void *) &xamarin_dyn_objc_msgSendSuper;
} else if (!strcmp (entrypointName, "objc_msgSend_stret")) {
symbol = (void *) &xamarin_dyn_objc_msgSend_stret;
} else if (!strcmp (entrypointName, "objc_msgSendSuper_stret")) {
symbol = (void *) &xamarin_dyn_objc_msgSendSuper_stret;
}
}
#endif // defined (__i386__) || defined (__x86_64__)
}
return symbol;

Просмотреть файл

@ -96,10 +96,6 @@ namespace MonoTouchFixtures.ObjCRuntime {
Assert.Ignore ("This test only works in debug mode in the simulator.");
#endif
#if NET && (__MACOS__ || __MACCATALYST__)
Assert.Ignore ("Exception marshalling hasn't been completely implemented on macOS/Mac Catalyst yet, due to removal of the dllmap support");
#endif
InstallHandlers ();
try {
@ -149,10 +145,6 @@ namespace MonoTouchFixtures.ObjCRuntime {
#endif
var hasDebugger = global::System.Diagnostics.Debugger.IsAttached;
#if NET && (__MACOS__ || __MACCATALYST__)
Assert.Ignore ("Exception marshalling hasn't been completely implemented on macOS/Mac Catalyst yet, due to removal of the dllmap support");
#endif
InstallHandlers ();
try {
using (var e = new ManagedExceptionTest ()) {

Просмотреть файл

@ -15,7 +15,6 @@
<DefineConstants>$(DefineConstants);MONOMAC;XAMMAC_TESTS</DefineConstants>
<DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);DEBUG;DYNAMIC_REGISTRAR</DefineConstants>
<RootTestsDirectory>..\..\..</RootTestsDirectory>
<MonoBundlingExtraArgs>--marshal-objectivec-exceptions:disable</MonoBundlingExtraArgs>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1359,14 +1359,7 @@ namespace Xamarin.Bundler {
break;
case ApplePlatform.MacOSX:
case ApplePlatform.MacCatalyst:
#if NET
// Mono doesn't support dllmaps for Mac Catalyst / macOS in .NET for now:
// macOS: https://github.com/dotnet/runtime/issues/43204
// Mac Catalyst: https://github.com/dotnet/runtime/issues/48110
MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.Disable;
#else
MarshalObjectiveCExceptions = EnableDebug ? MarshalObjectiveCExceptionMode.ThrowManagedException : MarshalObjectiveCExceptionMode.Disable;
#endif
break;
default:
throw ErrorHelper.CreateError (71, Errors.MX0071 /* Unknown platform: {0}. This usually indicates a bug in {1}; please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new with a test case. */, Platform, ProductName);

Просмотреть файл

@ -613,12 +613,7 @@ namespace Xamarin.Bundler {
sw.WriteLine ("\txamarin_executable_name = \"{0}\";", App.AssemblyName);
if (!App.IsDefaultMarshalManagedExceptionMode)
sw.WriteLine ("\txamarin_marshal_managed_exception_mode = MarshalManagedExceptionMode{0};", App.MarshalManagedExceptions);
#if NET
// We require support for dllmap, which isn't in .NET/macOS yet (https://github.com/dotnet/runtime/issues/43204), so disable
sw.WriteLine ("\txamarin_marshal_objectivec_exception_mode = MarshalObjectiveCExceptionModeDisable;");
#else
sw.WriteLine ("\txamarin_marshal_objectivec_exception_mode = MarshalObjectiveCExceptionMode{0};", App.MarshalObjectiveCExceptions);
#endif
if (App.DisableLldbAttach.HasValue ? App.DisableLldbAttach.Value : !App.EnableDebug)
sw.WriteLine ("\txamarin_disable_lldb_attach = true;");
if (App.DisableOmitFramePointer ?? App.EnableDebug)