Граф коммитов

693 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge a09a42a1f3
Revert "[debugger] Work around a debugger issue when using the interpreter.". Fixes #15585. (#15827)
This reverts commit f7bb07efc0.

This workaround is no longer needed, since the dotnet/runtime hash we're using
contains this fix.

Fixes https://github.com/xamarin/xamarin-macios/issues/15585.
2022-09-01 20:49:18 +02:00
Rolf Bjarne Kvinge ff3aeb5073 Merge remote-tracking branch 'origin/main' into bump-main-in-xcode14-2022-08-30 2022-08-30 11:14:47 +02:00
Rolf Bjarne Kvinge 68de101ce6
[UIKit] Wrap the call to UIApplicationMain in a @try/@catch handler. (#15746)
Wrap the call to UIApplicationMain in a @try/@catch handler, and convert any
Objective-C exceptions to a managed exception.

This way the managed Main method (which calls UIApplication.Main) will be able
to catch any Objective-C exceptions.
2022-08-26 13:56:33 +02:00
Rolf Bjarne Kvinge 4289148b28 Merge remote-tracking branch 'origin/main' into bump-main-in-xcode14-2022-08-26 2022-08-26 13:24:27 +02:00
Rolf Bjarne Kvinge 2cbf60dd0a
[runtime] Only build macOS libraries if we're building for macOS. (#15754) 2022-08-26 08:46:58 +02:00
Rolf Bjarne Kvinge 15d27acd92
[runtime] Add some debugging aid to xamarin_release_managed_ref. (#15767)
It's fairly frequent (due to various types of coding errors) to have the
call to '[self release]' in xamarin_release_managed_ref crash. These
crashes are typically very hard to diagnose, because it can be hard to
figure out which object caused the crash. So now we store the native
object in a static variable, so that it can be read using lldb from a core
dump.

Ref: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1481312.
2022-08-26 08:14:41 +02:00
Sebastien Pouliot a3310342fd
[runtime] Allow `IntPtr` for native objects in the dynamic registrar. Fixes #15708 (#15712)
Allow code like this

```csharp
[DllImport(Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSendSuper")
static extern IntPtr IntPtr_objc_msgSendSuper(IntPtr receiver, IntPtr selector);

[DllImport(Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSendSuper")]
static extern void void_objc_msgSendSuper(IntPtr receiver, IntPtr selector, IntPtr arg);

[Export("selectedTextRange")]
public new IntPtr SelectedTextRange
{
    get { return IntPtr_objc_msgSendSuper(SuperHandle, Selector.GetHandle("selectedTextRange")); }
    set => void_objc_msgSendSuper(SuperHandle, Selector.GetHandle("setSelectedTextRange:"), value);
}
```

to work on the dynamic registrar since it already work with the static one.
This allows the simulators (which defaults to dynamic) to share the same code which is useful for implementing a workaround for related issue #15677.
2022-08-23 10:44:52 +02:00
Thays Grazia 7cd34d2501
[debugger] Work around a debugger issue when using the interpreter (#15451)
There's a bug in the Mono runtime where the interpreter does not disable optimizations when the debugger is attached, which leads to the interpreter optimizing code and the debugger ending up rather confused.

The bug is fixed in the Mono runtime (https://github.com/dotnet/runtime/pull/71436), but there's no immediate way for the runtime to release this fix, so here we're implementing a workaround that disables interpreter optimizations if the debugging is enabled. It's somewhat clunky because the Mono external API wasn't designed for this, so we have to abuse the API a bit to accomplish the effect we want.

This is somewhat risky (since we're changing the startup path in a pretty big way), but there's an escape hatch via an environment variable, and also the workaround will not be in effect for release builds.

While the runtime issue exists in legacy mono/mono as well, we'll fix the Mono runtime for legacy, because we don't have to wait to consume legacy mono (https://github.com/xamarin/xamarin-macios/pull/15507). This means that the workaround is for .NET scenarios only.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-07-15 13:46:14 +02:00
Rolf Bjarne Kvinge a99f6c928a
[runtime] Remove dead code. (#15479)
This has been dead code for over 9 years!
2022-07-13 20:33:40 +02:00
Rolf Bjarne Kvinge 4acb844e5c
[runtime] Adjust exception handling to always return managed exceptions if so requested. (#15432)
In the following scenario:

* Objective-C exception mode is to throw a managed exception.
* The xamarin_process_nsexception_using_mode was given a pointer to store any
  resulting exceptions.
* The Objective-C exception didn't already have an associated managed exception.

We'd throw the managed exception upon return to managed code instead of
returning the managed exception.

With this change the xamarin_process_nsexception_using_mode will always return
the resulting managed exception in the scenario above (this way the behavior
is identical independent of whether the Objective-C exception already has an
associated managed exception or not).
2022-07-13 10:59:40 +02:00
Rolf Bjarne Kvinge 76fbc898cc
[runtime] The InitializationFlagsDynamicRegistrar flag is never used, so remove it (#15435) 2022-07-13 10:59:13 +02:00
Rolf Bjarne Kvinge 4e1114fde6
[tools] Use MONO_AOT_MODE_INTERP_ONLY instead of MONO_AOT_MODE_INTERP for x86_64. (#15429)
The 'MONO_AOT_MODE_INTERP' mode is based on full AOT, which requires infinite
trampoline code to not potentially run out of trampolines. However, that mode
isn't implemented for x86_64, so in that case use 'MONO_AOT_MODE_INTERP_ONLY',
which will use the JIT as a fallback.

Ref: https://github.com/dotnet/runtime/issues/68808

Fixes: https://github.com/xamarin/xamarin-macios/issues/14887
2022-07-12 09:56:51 +02:00
Rolf Bjarne Kvinge 8adbefdac8
[runtime] Fix 'skip_nested_brace' to not read past the string. Fixes #15253. (#15257)
Fix 'skip_nested_brace' to not double skip characters.

Also add a test.

Fixes https://github.com/xamarin/xamarin-macios/issues/15253.
2022-06-14 14:26:07 +02:00
Rolf Bjarne Kvinge a1d0b6eba9
Make our local .NET the default .NET for the build. (#15086)
Make our local .NET the default .NET (in the root's global.json), and then if
a directory wants to use the system .NET, then that directory would have to
opt-in (using its own global.json).

This way we don't have to copy global.json/NuGet.config files around to run
tests with the correct .NET setup.
2022-06-07 10:11:02 +02:00
Rolf Bjarne Kvinge 6bccb1f1d3
[runtime] Improve error reporting when calling mono_assembly_open. (#15139) 2022-06-03 10:41:43 +02:00
Rolf Bjarne Kvinge 5de4754c31
[runtime] Skip passing ICU_DAT_FILE_PATH to the runtime if we don't have an ICU data file. (#15085) 2022-05-25 08:31:26 +02:00
Rolf Bjarne Kvinge 27d1d0292b
[runtime] Handle fatal managed exceptions a bit better in the runtime. (#15029)
Handle managed exceptions a bit better when we know there won't be any other
managed frames further up the stack (such as in the main method). In this
case, there's no use in trying to convert the managed exception into an
Objective-C exception, because we already know the process will be terminated.

Instead just print the exception to stderr, and abort immediately.

This means we'll actually get some useful information printed to stderr.
2022-05-16 21:31:37 +02:00
Rolf Bjarne Kvinge cf44501f0f
[runtime] Fix build when logging is enabled. (#14922) 2022-05-10 09:26:20 +02:00
Eric Sink b84b80902c
Build fixes (-dotnet) for app extensions (#14685)
Resolves #14285 

1.  Make sure `libextension-dotnet.a` gets built, and with the `-DEXTENSION` flag.
2.  Make sure `libextension-dotnet.a` gets included in the package alongside `libxamarin-dotnet.a`
3. At build time, make sure to link with the correct lib[tv]extension-dotnet.a library depending when we need to.
4. Add some tests.

Co-authored-by: Eric Sink <eric@Erics-MacBook-Pro.local>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-04-25 16:56:52 +02:00
Rolf Bjarne Kvinge 4fba6701e1
[runtime] Don't try process managed exceptions in xamarin_initialize. (#14792)
If we try to process any exceptions, we'll throw an Objective-C exception,
which will likely be unhandled because we're pretty much at the top of the
stack, and when we handle this Objective-C exception we'll try to convert it
into a managed exception and throw that, and since there are no managed frames
on the stack we'll end up converting it to an Objective-C exception, which
we'll try to throw, and so on, eventually running into a stack overflow.

This is unnecessary, so just abort directly.
2022-04-22 09:01:49 +02:00
Rolf Bjarne Kvinge 3afb12f692
[CoreCLR] Rework how we track the lifetime of managed NSObjects. (#14785)
* We now create a tracking GCHandle for all NSObjects, not only the toggled ones.
  CoreCLR will notify us when a tracked GCHandle's target enters finalization, and
  we need to be notified for all NSObjects, not just the toggled ones.
* Augment the tracking callback to know about non-toggled objects, and in that
  case report that the tracking GCHandle is a weak GCHandle.
* There's no need to store the tracking GCHandle in a field in the NSObject instance,
  since we store it in our runtime object_map.
* Remove one place where we set the InFinalizerQueue flag, since it's no longer
  required there (this reverts a previous attempt at fixing this problem - 0622ae4af2)
  - we only set the InFinalizerQueue flag in the xamarin_coreclr_reference_tracking_tracked_object_entered_finalization
  callback now.
* Update a few comments accordingly.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/13531.

Fixes https://github.com/xamarin/xamarin-macios/issues/13921 (again).
2022-04-21 08:22:24 +02:00
Rolf Bjarne Kvinge 7d229665c8
[runtime] Don't call 'retain' and 'autorelease' selectors on returned NativeObjects. (#14690)
We were trying to call the 'retain' and 'autorelease' selectors on objects
that weren't NSObjects when returning them from function calls. For some
unfathomable reason that has worked until now, but I started running into this
problem with other (unrelated) changes, so it needs to be fixed.

The fix is to not call the 'retain' and 'autorelease' selectors on
NativeObjects, instead call into managed code to either call the Retain method
on the managed NativeObject (if we're supposed to retain the return value), or
if we have to autorelease the return value, then check first if the input is
an NSObject, and only then call retain+autorelease.
2022-04-20 14:09:09 +02:00
Rolf Bjarne Kvinge 80a791cdc9
[runtime] Fix typo in comment. (#14687) 2022-04-07 18:30:06 +02:00
Alex Soto 35e2e45e98 [Xcode 13.3] Initial commit to Xcode 13.3 release 2022-03-14 22:54:33 -04:00
Rolf Bjarne Kvinge bd97933b60
[runtime] Remove ObjCRuntime.nfloat in favor of System.Runtime.InteropServices.NFloat. (#14197)
* Remove ObjCRuntime.nfloat (in favor of   System.Runtime.InteropServices.NFloat).
* Automatically add a reference to the System.Runtime.InteropServices.Internal
  package, so that developers get the new NFloat API (with operators) we've
  added post .NET 6 (but don't do this for .NET 7).
* Automatically add a global using alias for
  System.Runtime.InteropServices.NFloat -> nfloat. This is not behind the
  usual `ImplicitUsings` condition our other implicit usings are, because
  they're off by default for existing projects, and the main target for the
  global using alias for nfloat is upgraded projects.
* Automatically generate a global using alias (like above) in the generator
  for all code the generator compiles.
* Update xtro entries to reference System.Runtime.InteropServices.NFloat
  instead of ObjCRuntime.nfloat.
* Add a workaround for a hopefully temporary issue with .NET/CoreCLR where the
  wrong runtime pack is selected otherwise (without the new NFloat API, so
  nothing works at runtime).

Ref: https://github.com/xamarin/xamarin-macios/issues/13087
2022-02-24 16:51:12 +01:00
Rolf Bjarne Kvinge 5acea1a41f
[runtime] Ask curl to fail (--fail) if fetching the URL fails for coreclrhost.h. (#14216)
This fixes an issue where the build would continue if the server in question
serves an error page (and eventually fail with weird errors because the error
page wouldn't be valid C code).
2022-02-23 08:10:51 +01:00
Rolf Bjarne Kvinge e25163f573
[.NET] Rename our product assemblies. Fixes #13748. (#13847)
Rename our product assemblies to:

* Microsoft.iOS.dll
* Microsoft.tvOS.dll
* Microsoft.macOS.dll
* Microsoft.MacCatalyst.dll

This makes it easy to distinguish between legacy Xamarin and .NET whenever the
product assembly is mentioned, and I've also chosen the platform part of the
name to match how the platforms are named elsewhere (this also makes it
possible to simplify our build logic, since we can remove a lot of special
casing).

Fixes https://github.com/xamarin/xamarin-macios/issues/13748.
2022-02-16 21:30:32 +01:00
Rolf Bjarne Kvinge 8b3b6a7adf
[dotnet/runtime] Fix a few issues with regards to extensions in .NET. Fixes #13742. (#14115)
* Propagate the IsAppExtension variable correctly.

* Don't try to call mono_domain_set_config for app extensions in .NET.

  It doesn't look like it's needed, and it also immediately aborts anyway, so
  if it turns out to be needed, another solution would have to be implemented.

Fixes https://github.com/xamarin/xamarin-macios/issues/13742.
2022-02-15 08:27:25 +01:00
Stephane Delcroix f36606e654
[C] Clear OpenTK namespace (#13767)
fixes #13160

- remove unused types
- use System.Numerics when possible
- move own created types from OpenTK namespace to CoreGraphics
- create missing types in CoreGraphics namespace

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-02-14 18:50:23 +01:00
Rolf Bjarne Kvinge ef3b05478e
[tools/runtime] Enable exception marshalling by default for all platforms in .NET. (#14051)
When exception marshalling was originally implemented, for backwards
compatibility concerns it was only turned on by default for platforms that
really needed it (watchOS).

However, exception marshalling is by far the safest option, so in .NET we're
enabling it by default for all platforms (it's still possible to disable it
for those who wants to).

Ref: https://docs.microsoft.com/en-us/xamarin/ios/platform/exception-marshaling
2022-02-07 14:12:32 +01:00
Rolf Bjarne Kvinge 42c87ab2f7
[runtime] Make Runtime.Arch a readonly field in .NET. Fixes #5518. (#14076)
* Make Runtime.Arch a readonly field.
* Tell the AOT compiler Runtime.Arch is a constant value.
* Tell the linker to stub out the method we use to fetch the current
  architecture from native code (it turned out a bit complicated to set the
  Arch field when it's readonly - the solution I came up with was to call a
  P/Invoke).

Test case (size of the main executable): link all (debug)

* Before:  33.522.704 bytes
* After:   33.506.112 bytes
* Difference: -16.592 bytes (-0.05 %)

There were no size differences in release mode, nor were there any size
differences in the "don't link" test, neither for debug nor release mode.

Fixes https://github.com/xamarin/xamarin-macios/issues/5518.
2022-02-07 08:05:41 +01:00
Rolf Bjarne Kvinge d5697a8867
[runtime] Use the full managed description (including inner exceptions) as the reason when creating an NSException from a managed exception. (#14002)
This makes diagnosing what happens much easier in some cases.

Exhibit A, pre fix:

    *** Terminating app due to uncaught exception 'ObjCRuntime.RuntimeException', reason: 'Failed to lookup the required marshalling information.
    Additional information:
    	Selector: conformsToProtocol:
    	Type: ViewController

Exhibit B, post fix:

    *** Terminating app due to uncaught exception 'ObjCRuntime.RuntimeException', reason: 'Failed to lookup the required marshalling information.
    Additional information:
    	Selector: conformsToProtocol:
    	Type: ViewController
     (ObjCRuntime.RuntimeException)
    Failed to get the 'this' instance in a method call to templ.ViewController.InvokeConformsToProtocol. (ObjCRuntime.RuntimeException)
       at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
       at ObjCRuntime.Runtime.GetMethodAndObjectForSelector(IntPtr klass, IntPtr sel, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
       at ObjCRuntime.Runtime.get_method_and_object_for_selector(IntPtr cls, IntPtr sel, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc, IntPtr& exception_gchandle)
    Failed to marshal the Objective-C object 0x7f813fd2f470 (type: ViewController). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'templ.ViewController' does not have a constructor that takes one NativeHandle argument). (ObjCRuntime.RuntimeException)
       at ObjCRuntime.Runtime.MissingCtor(IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution)
       at ObjCRuntime.Runtime.ConstructNSObject[T](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution)
       at ObjCRuntime.Runtime.ConstructNSObject(IntPtr ptr, IntPtr klass, MissingCtorResolution missingCtorResolution)
       at ObjCRuntime.Runtime.GetNSObject(IntPtr ptr, MissingCtorResolution missingCtorResolution, Boolean evenInFinalizerQueue)
       at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
2022-02-02 16:22:34 +01:00
Rolf Bjarne Kvinge 241d821983
[runtime] Don't try to log an exception for GCHandle that has been freed. (#14003)
It does exactly what you'd think it does: nothing helpful at all.

Make sure to use a GCHandle that's alive instead.

Output before fix:

    Xamarin.Mac: Processing managed exception for exception marshalling (mode: 2):
    Failed to print exception: System.NullReferenceException: Object reference not set to an instance of an object.
       at ObjCRuntime.Runtime.PrintException(Exception exc, Boolean isInnerException, StringBuilder sb)
       at ObjCRuntime.Runtime.PrintAllExceptions(IntPtr exception_gchandle)

Output after fix:

    Xamarin.Mac: Processing managed exception for exception marshalling (mode: 2):
    Failed to lookup the required marshalling information.
    Additional information:
       Selector: conformsToProtocol:
       Type: ViewController
     (ObjCRuntime.RuntimeException)
    Failed to get the 'this' instance in a method call to templ.ViewController.InvokeConformsToProtocol. (ObjCRuntime.RuntimeException)
       at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
       at ObjCRuntime.Runtime.GetMethodAndObjectForSelector(IntPtr klass, IntPtr sel, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
       at ObjCRuntime.Runtime.get_method_and_object_for_selector(IntPtr cls, IntPtr sel, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc, IntPtr& exception_gchandle)
    Failed to marshal the Objective-C object 0x7f89e6c2a2a0 (type: ViewController). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'templ.ViewController' does not have a constructor that takes one NativeHandle argument). (ObjCRuntime.RuntimeException)
       at ObjCRuntime.Runtime.MissingCtor(IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution)
       at ObjCRuntime.Runtime.ConstructNSObject[T](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution)
       at ObjCRuntime.Runtime.ConstructNSObject(IntPtr ptr, IntPtr klass, MissingCtorResolution missingCtorResolution)
       at ObjCRuntime.Runtime.GetNSObject(IntPtr ptr, MissingCtorResolution missingCtorResolution, Boolean evenInFinalizerQueue)
       at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
2022-02-02 08:38:52 +01:00
Rolf Bjarne Kvinge b1ce33ba51
[Foundation/ObjCRuntime] Use 'ObjCException' as the native exception type name for all platforms in .NET. Fixes #13855. (#13915)
* Use 'ObjCException' instead of 'MonoTouchException' as the managed exception
  type wrapping an NSException for all platforms in .NET (that was already the
  case for macOS, so no change there).
* Make the ObjCException class behave like the MonoTouchException class does.
* Move the ObjCException type to the ObjCRuntime namespace in .NET.

Fixes https://github.com/xamarin/xamarin-macios/issues/13855.

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2022-02-01 17:24:57 +01:00
Rolf Bjarne Kvinge 00647d50a5
[ModelIO] Fix the MDLVoxelIndexExtent name for .NET. (#13893) 2022-01-27 10:37:51 +01:00
Rolf Bjarne Kvinge 9ab67cf9be Move some lookup tables in make to a more global location.
So that the tables can be used in more places.
2021-12-22 10:17:34 +01:00
Rolf Bjarne Kvinge c708eba312
[runtime] Make sure dlls come before exes in TRUSTED_PLATFORM_ASSEMBLIES. (#13545)
This works around dotnet/runtime's https://github.com/dotnet/runtime/issues/62735.
2021-12-14 08:18:47 +01:00
Rolf Bjarne Kvinge 23ac0f520f [registrar] Accept IntPtr/UIntPtr as target types for BindAs attribute for NSNumber conversions. 2021-12-03 08:02:49 +01:00
Rolf Bjarne Kvinge f8b6699ab2 Merge remote-tracking branch 'origin/main' into arm64-sim 2021-12-02 09:38:36 +01:00
Rolf Bjarne Kvinge b4aae072c8 [runtime] Build for ARM64/simulators. 2021-11-30 18:20:42 +01:00
Rolf Bjarne Kvinge afa1137691 [runtime] Update error message to say "NativeHandle" constructor instead of "IntPtr" constructor. 2021-11-26 14:25:21 +01:00
Rolf Bjarne Kvinge 249735647a [runtime] Handle NativeHandle as IntPtr when it comes to arguments in the dynamic registrar. 2021-11-26 14:25:19 +01:00
Rolf Bjarne Kvinge 84c8f0d13b [runtime] Add support for NativeHandle to the binding generator.
This means using NativeHandle in numerous signatures, as well as adding a few .NET-specific
signatures (because sometimes the IntPtr version would still be needed).
2021-11-26 14:25:19 +01:00
Rolf Bjarne Kvinge 6302878ad5
[runtime] Implement storing the original working directory for later retrieval for .NET. Fixes #13392. (#13403)
This also adds the Runtime.OriginalWorkingDirectory to all platforms.

Fixes https://github.com/xamarin/xamarin-macios/issues/13392.
2021-11-22 18:50:28 +01:00
Rolf Bjarne Kvinge 88eb5e1ac8
Rename any *OSX_SDK_VERSION variables to *MACOS_SDK_VERSION. (#13411)
This makes it easier to iterate over all the *_SDK_VERSION variables in
template code, because they're all named using the standard platform names we
use elsewhere.
2021-11-22 18:48:05 +01:00
Rolf Bjarne Kvinge 02431b9fc8
[.NET] Move the nfloat type to the ObjCRuntime namespace for .NET. (#13092)
Also move the NMath type from the System namespace to the ObjCRuntime namespace.

Ref: https://github.com/xamarin/xamarin-macios/issues/13087
2021-10-28 11:06:31 +02:00
Rolf Bjarne Kvinge fad9779840
[runtime] Pass value callbacks to free values when creating the 'gchandle_hash' dictionary. (#13109)
This way the values are actually freed.
2021-10-26 08:28:03 +02:00
Rolf Bjarne Kvinge c3574a53a3
[generator] Use '[U]IntPtr' in P/Invoke signatures instead of 'n[u]int'. (#13043)
* [generator] Use '[U]IntPtr' in the P/Invoke signature for native enums.

* Use '[U]IntPtr' as the parameter type in the P/Invoke signature for native enum
  parameters.
* Use '[U]IntPtr' in the P/Invoke method name for native enum parameters.
* Add an explicit conversion from UIntPtr to nuint (like we already have from IntPtr
  to nint).

This makes the code identical between .NET and legacy Xamarin when using C# n[u]ints,
because those are really [U]IntPtrs.

* Use IntPtr/UIntPtr for all nint/nuint types in P/Invokes, not only native enums.

* Add a few more casts

Fixes these generator tests:

* GeneratorTests.BGenTests.FieldEnumTests
* GeneratorTests.BGenTests.NativeEnum

* [registrar] Handle UIntPtr like we do IntPtr.

Fixes this error in numerous tests:

    error MT4169: Failed to generate a P/Invoke wrapper for objc_msgSend(System.IntPtr,System.IntPtr): The registrar cannot build a signature for type `System.Void' in method `ObjCRuntime.Messaging.objc_msgSend`.

* [NativeTypes] Make IntPtr and UIntPtr behave the same.

This fixes an issue where the linked output for a 32-bit mscorlib.dll and a
64-bit mscorlib.dll would be different, because different explicit operators
for UIntPtr would be kept.

The fix works because the conversion operators for nuint will not use
UIntPtr's explicit conversion operators anymore, it will just operate on plain
memory instead.
2021-10-25 10:56:02 +02:00
Rolf Bjarne Kvinge af23d61926
[runtime] Fix a toggle ref deadlock when retaining objects. Fixes #13066. (#13071)
The deadlock goes like this:

1. Thread A holds the framework_peer_release_lock lock, and tries to lock the
   refcount_mutex lock.
2. Thread B holds the refcount_mutex, and is waiting for the GC to complete
3. Thread C is trying to lock the framework_peer_release_lock while running
   the GC.

The fix is in thread A, by not doing anything at all with the
framework_peer_release_lock lock locked.

The code contains extensive comments explaining the situation and the solution.

Fixes https://github.com/xamarin/xamarin-macios/issues/13066.

Co-authored-by: Chris Hamons <chris.hamons@xamarin.com>
2021-10-22 09:05:07 +02:00
Rolf Bjarne Kvinge 666d0066f3
[runtime/tools] Change the 'xamarin_runtime_libraries' array to contain only the names of the runtime library in question. (#12792)
P/Invokes may point to a dylib, while the actual library linked into the .app
might be a static library, so make sure to compare without the extension.

This fixes an issue when linking with the static version of the runtime libraries.
2021-09-22 07:31:53 +02:00
Rolf Bjarne Kvinge f557936e9c
[runtime] Use the correct underlying types for our own nfloat/n(u)int types. (#12714)
Defining xm_nint_t to be 32-bit sized only on i386 is not the right thing to do for armv7.

Strangely enough this caused just a single test failure:

    MonoTouchFixtures.Foundation.CalendarTest
        [FAIL] TestFindNextDateAfterDateMatching :   Expected: <Foundation.MonoTouchException>
            But was:  null
            at MonoTouchFixtures.Foundation.CalendarTest.TestFindNextDateAfterDateMatching()

and that happened because:

1. We use a wrapper function around objc_msgSend:

    void *
    xamarin_IntPtr_objc_msgSend_IntPtr_IntPtr_nuint_exception (id self, SEL sel, void * p0, void * p1, xm_nuint_t p2, GCHandle *exception_gchandle)
    {
    	@try {
    		return ((func_xamarin_IntPtr_objc_msgSend_IntPtr_IntPtr_nuint_exception) objc_msgSend) (self, sel, p0, p1, p2);
    	} @catch (NSException *e) {
    		xamarin_process_nsexception_using_mode (e, true, exception_gchandle);
    		return NULL;
    	}
    }

2. Note that the second to last argument is an 'xm_nuint_t'. We told the
   native compiler this was a 64-bit value, when the managed P/Invoke would
   give it a 32-bit value. This had no effect on the 'p2' parameter, but it
   meant that clang would thing the next argument, 'exception_gchandle', would
   be somewhere it wasn't (the managed function would pass two 32-bit values,
   'p2' and 'exception_gchandle', which clang would merge into a single 64-bit
   'p2' argument, and then read random stuff for 'exception_gchandle').

3. Finally things would go sideways when we caught the exception and passed
   'exception_gchandle' to xamarin_process_nsexception_using_mode. In effect
   we'd ask xamarin_process_nsexception_using_mode to store the resulting
   gchandle in random memory. Amazingly it only resulted in a test failure
   (because upon return the managed location for the 'exception_gchandle'
   wasn't touched, and would have its initial value of 0, thus managed code
   would think no exception occurred).

So fix this to use the correct underlying types, instead of trying to figure
out the correct #if condition.

I'm not sure why we're using our own types here anyways, but this fix is the
smallest.
2021-09-15 09:17:43 +02:00
Rolf Bjarne Kvinge 048bee7080
[generator] Simplify native enums logic. (#12473)
Instead of generating one native P/Invoke signature with an int parameter and
another with a long parameter for methods that take [Native] enums, generate a
single nint parameter (and the same for the unsigned version).

This simplifies both the generator code and the generated code. The generator
diff contains *a lot* of changes like this:

    -	if (IntPtr.Size == 8) {
    -		ret = (ARAppClipCodeUrlDecodingState) global::ObjCRuntime.Messaging.Int64_objc_msgSend (this.Handle, Selector.GetHandle ("urlDecodingState"));
    -	} else {
    -		ret = (ARAppClipCodeUrlDecodingState) global::ObjCRuntime.Messaging.int_objc_msgSend (this.Handle, Selector.GetHandle ("urlDecodingState"));
    -	}
    +	ret = (ARKit.ARAppClipCodeUrlDecodingState) (long) global::ObjCRuntime.Messaging.nint_objc_msgSend (this.Handle, Selector.GetHandle ("urlDecodingState"));

An unlinked Xamarin.iOS.dll is ~300kb smaller (once linked the difference
should be minimal though).

I also made the min/max detection logic (check for int32.MinValue/MaxValue and
convert to int64.MinValue/MaxValue) specific to ARCH_32, since we don't need
it in 64-bit code.
2021-08-19 16:59:07 +02:00
Rolf Bjarne Kvinge 16ff955913
[runtime] Set the RUNTIME_IDENTIFER and APP_CONTEXT_BASE_DIRECTORY app context values. Fixes #12444. (#12446)
Mono and CoreCLR need this.

Fixes https://github.com/xamarin/xamarin-macios/issues/12444.
2021-08-17 15:30:27 +02:00
Rolf Bjarne Kvinge 7f5fcfc88b
[runtime] Skip early from xamarin_pinvoke_override to avoid a later logging statement. (#12443)
This avoids unnecessary and confusing logging which apparently claims that we
couldn't find a symbol, when we didn't even try (on purpose).
2021-08-17 08:05:18 +02:00
Rolf Bjarne Kvinge 2972e1b715
Fix some whitespace issues in various files. (#12399)
* Remove BOM
* Add EOL at end of file.
2021-08-11 10:06:46 +02:00
Rolf Bjarne Kvinge fb63f2388a
[runtime] Add support for logging exceptions that go through exception marshalling using an environment variable. Fixes #12343. (#12344)
Setting the XAMARIN_LOG_MARSHALLED_EXCEPTIONS environment variable will now
make us print all exceptions that go through exception marshalling, and how
we'll handle them.

Fixes https://github.com/xamarin/xamarin-macios/issues/12343.
2021-08-05 08:17:20 +02:00
Manuel de la Pena 9aef167b19
[PHASE] Add suppport for Xcode13 beta 2. (#12098) 2021-08-04 22:38:03 -04:00
Rolf Bjarne Kvinge eafe528591
[runtime/tools] Implement finding native support libraries when linking statically. Fixes #10950, #11145 and #12100. (#12323)
* Add support for Mono Components.

* Modify how we look up symbols from native libraries shipped with Mono: we keep
  track of which native libraries we linked with, and depending on how we linked
  to those assemblies, we look the symbols up at runtime in either the current executable
  (if linking statically), or the actual library (where the P/Invoke says they're
  supposed to be).

* This means that we have to propagate how libmono is linked from the MSBuild code
  to the Application class so that our existing logic is able to correctly determine
  which native mono lib to use.

* Modify how we list the P/Invokes we need to preserve by taking into account the
  list of native libraries from Mono we have to link with (for .NET). For legacy
  Xamarin, I've reverted the logic to how it was before we started adding .NET support.

Fixes https://github.com/xamarin/xamarin-macios/issues/10950.
Fixes https://github.com/xamarin/xamarin-macios/issues/11145.
Fixes https://github.com/xamarin/xamarin-macios/issues/12100.
2021-08-03 17:06:58 +02:00
Rolf Bjarne Kvinge 440ff7c706
[runtime] Implement computing and passing the NATIVE_DLL_SEARCH_DIRECTORIES runtime property. Fixes #10504. (#12309)
This adds support to compute the NATIVE_DLL_SEARCH_DIRECTORIES value and pass
it to the runtime. It's the last property listed in #10504, so this fixes that
issue.

Fixes https://github.com/xamarin/xamarin-macios/issues/10504
2021-08-02 09:25:54 +02:00
Rolf Bjarne Kvinge 3d822de007
[runtime] List all assemblies in TRUSTED_PLATFORM_ASSEMBLIES as pass it to MonoVM/CoreCLR. Fixes #12265. (#12272)
List all the assemblies in the app bundle and pass them to MonoVM/CoreCLR's in
the TRUSTED_PLATFORM_ASSEMBLIES initialization property.

This way CoreCLR knows where to find System.Private.CoreLib.dll for fat apps
(it's in the runtimeidentifier-specific subdirectory, and by default CoreCLR
will only look next to libcoreclr.dylib).

Fixes https://github.com/xamarin/xamarin-macios/issues/12265.
2021-07-29 07:45:24 +02:00
Rolf Bjarne Kvinge 9dcc4d07b4
[runtime] Fix the arguments to the managed main function when using CoreCLR. Fixes #12219. (#12239)
Also add tests.

Fixes https://github.com/xamarin/xamarin-macios/issues/12219.
2021-07-28 17:12:29 +02:00
Rolf Bjarne Kvinge 24351db16c [runtime/tools] Implement finding native mono lib for Mac Catalyst.
This also meant propagating how libmono is linked from the MSBuild code to the Application
class so that our existing logic is able to correctly determine which native mono
lib to use.
2021-07-22 10:36:21 +02:00
Rolf Bjarne Kvinge eddf7b6c8d [runtime] AOT is no longer limited to device builds. 2021-07-22 10:36:21 +02:00
Rolf Bjarne Kvinge 3c38f8ccd6
[dotnet] Enable autorelease pools for threadpools. Fixes #11750. (#12060)
Fixes https://github.com/xamarin/xamarin-macios/issues/11750.
2021-07-20 14:34:37 +02:00
Rolf Bjarne Kvinge d775794fd2
[dotnet] Create and parse runtimeconfig.bin when using CoreCLR. (#12122)
We need to process the runtimeconfig.json file somehow when using CoreCLR, and
the embedding API we use (coreclr_initialize) won't parse it for us. So re-use
the logic we already have to process runtimeconfig.json for MonoVM (which
involves converting it to a binary format at build time, which we then process
at runtime).
2021-07-16 16:15:17 +02:00
Rolf Bjarne Kvinge 6485ff2332
[runtime] Fix Runtime.Arch to be consistent on Mac Catalyst and work properly on ARM-based simulators. (#12125)
* Use the Apple-provided TARGET_OS_SIMULATOR define to determine if we're
  running in a simulator, instead of checking the current architecture. This
  way we properly detect ARM64-based simulators (and it'll work correctly in
  the future).

* Always set Runtime.Arch = SIMULATOR for Mac Catalyst. The final value for
  Runtime.Arch for Mac Catalyst is tracked in #10312, but this is a stop-gap
  measure to make sure we have the same value between X64 and ARM64 on Mac
  Catalyst, and until now we've had Runtime.Arch = SIMULATOR for X64, so just
  go with that for now.
2021-07-16 09:33:11 +02:00
Rolf Bjarne Kvinge d9664843e2
[runtime] Add logging when a P/Invoke can't be resolved in xamarin_pinvoke_override. (#12106)
Return early when we're not going to try resolving anything, which means that
if we didn't find something by the end, we know that it's because we failed
(and not because we weren't supposed to try), and we log that.

This makes it easier to diagnose a few failure conditions.
2021-07-14 17:52:40 +02:00
Rolf Bjarne Kvinge fc8fb4818c
[runtime] Set the current directory to the root directory of the app bundle for all platforms in .NET. (#12104)
To have consistent behavior in .NET, set the current directory to the root of
the app bundle for all platforms.

This is a breaking change for legacy Xamarin.Mac, which used to set the
current directory to the Contents/Resources subdirectory, but there's a simple
workaround for customers that depend on the old behavior (change it in Main
themselves), and I believe the consistent experience across platforms warrants
this change.

Note that we already had a breaking change here for macOS/.NET: we were
(unintentionally) setting the current directory to the Contents/MonoBundle
directory, which neither matched mobile platforms, nor the legacy Xamarin.Mac
behavior.

This solves the problem of what to do for Mac Catalyst apps, because there's
no need to choose between the macOS or the mobile behavior, since they're the
same.

This required changing the launch of macOS apps using CoreCLR to pass the full
path to the entry assembly, since the entry assembly isn't in the current
directory anymore.
2021-07-14 17:42:49 +02:00
Rolf Bjarne Kvinge 608dfb37bc [dotnet] Make the globalization data file an architecture-specific file.
This was adapted from https://github.com/xamarin/xamarin-macios/pull/11320.
2021-06-23 18:38:46 +02:00
Rolf Bjarne Kvinge f6e9f555de [runtime] Add a xamarin_locate_app_resource function. 2021-06-23 18:38:46 +02:00
Rolf Bjarne Kvinge 87de6ea653 [runtime] Add support for finding assemblies in an RID-specific subdirectory. 2021-06-18 10:24:28 +02:00
Rolf Bjarne Kvinge c8e854c151
[dotnet] Add support for generating a binary version of runtimeconfig.json. Fixes #11745. (#11887)
Use Mono's RuntimeConfigParserTask to parse the *.runtimeconfig.json file and
produce a binary version of it.

This also means implementing support for finding the on-disk location of the
file at runtime, and passing it to mono.

Ref: 01b7e73cd3/docs/design/mono/mobile-runtimeconfig-json.md

Fixes https://github.com/xamarin/xamarin-macios/issues/11745.
2021-06-16 15:22:02 +02:00
Rolf Bjarne Kvinge 7860ac8f85
[runtime] Disable LOG_MONOVM logging by default. (#11796)
This should have been disabled from the beginning.
2021-06-03 18:45:21 +02:00
Rolf Bjarne Kvinge 071ac6463e
[coreclr] Support for NSAutoreleasePools has now been implemented for background threads for both MonoVM and CoreCLR. Fixes #11256. (#11749)
Fixes https://github.com/xamarin/xamarin-macios/issues/11256.
2021-06-02 07:41:44 +02:00
Rolf Bjarne Kvinge f3b46b955f
[runtime] Add support for toggle refs to CoreCLR. (#11757)
The code contains comments explaining the new behavior.

Some tests that poked into the private 'flags' field on NSObject had to be
updated, because the field is now named differently in .NET.

I also added two more tests for toggle ref scenarios.
2021-06-02 00:13:49 +02:00
Rolf Bjarne Kvinge ebfeee6974
[runtime] Add missing release for call to mono_reflection_type_get_type. (#11756)
No more leaks!

Before:

    There were 205834 MonoObjects created, 205834 MonoObjects freed, so no leaked MonoObjects. (static registrar)
    There were 258092 MonoObjects created, 258013 MonoObjects freed, so 79 were not freed. (dynamic registrar)

After:

     There were 205834 MonoObjects created, 205834 MonoObjects freed, so no leaked MonoObjects. (static registrar)
     There were 258100 MonoObjects created, 258100 MonoObjects freed, so no leaked MonoObjects. (dynamic registrar)
2021-06-01 22:19:20 +02:00
Rolf Bjarne Kvinge 1c60b17bbe
[runtime] Show the typename of the MonoObjects we're leaking. (#11758)
This makes it a bit easier to figure out what's going on.
2021-06-01 20:43:50 +02:00
Rolf Bjarne Kvinge 1e1e0298bd
[runtime] Don't forget to free the method field in MonoMethodSignatures. (#11746)
Before:

    There were 258096 MonoObjects created, 246948 MonoObjects freed, so 11148 were not freed. (dynamic registrar)
    There were 205834 MonoObjects created, 205214 MonoObjects freed, so 620 were not freed. (static registrar)

After:

    There were 205834 MonoObjects created, 205222 MonoObjects freed, so 612 were not freed. (dynamic registrar)
    There were 258100 MonoObjects created, 258019 MonoObjects freed, so 81 were not freed. (static registrar)
2021-06-01 13:09:43 +02:00
Rolf Bjarne Kvinge 03685e70b8
[static registrar] Release the return value from xamarin_get_reflection_method_method in generated code. (#11748)
* If the return value from xamarin_get_reflection_method_method is cached in a
  static variable, we can only release at process exist.
* Otherwise just release at the end of the current method.

Before:

    There were 258096 MonoObjects created, 246948 MonoObjects freed, so 11148 were not freed. (dynamic registrar)
    There were 205834 MonoObjects created, 205214 MonoObjects freed, so 620 were not freed. (static registrar)

After:

    There were 258092 MonoObjects created, 246945 MonoObjects freed, so 11147 were not freed. (dynamic registrar)
    There were 205834 MonoObjects created, 205600 MonoObjects freed, so 234 were not freed. (static registrar)
2021-06-01 07:36:01 +02:00
Rolf Bjarne Kvinge 1b98f4ec9e
[runtime] Release the block_wrapper_queue and xamarin_wrapper_hash dictionaries upon process exit. (#11751)
While not strictly necessary to not leak (because the process is exiting
anyway), it makes it easier to read leak reports, because these dictionaries
won't show up as leaked memory anymore.

Before:

    There were 258096 MonoObjects created, 258015 MonoObjects freed, so 81 were not freed. (dynamic registrar)
    There were 205834 MonoObjects created, 205833 MonoObjects freed, so 1 were not freed. (static registrar)

After:

    There were 258104 MonoObjects created, 258025 MonoObjects freed, so 79 were not freed. (dynamic registrar)
    There were 205834 MonoObjects created, 205834 MonoObjects freed, so no leaked MonoObjects. (static registrar)
2021-06-01 07:35:29 +02:00
Rolf Bjarne Kvinge 2bee92225c
[runtime] Complete support for exception marshalling on CoreCLR. (#11734)
* [runtime] Add support for exception marshalling to CoreCLR.

* [runtime] Add an empty implementation of the toggle ref machinery.

We need this to use the unhandled exception handler support in CoreCLR,
because the ObjectiveCMarshal.Initialize call to initialize unhandled
exception support requires passing toggle ref callbacks as well.

* [tests] The TestConstrainedGenericType test can now be re-enabled, after a few updates.
2021-05-31 08:10:34 +02:00
Rolf Bjarne Kvinge 4f28fb2481
[dynamic registrar] Free the return value from mono_signature_get_params and mono_signature_get_return_type. (#11730)
Before:

    There were 258042 MonoObjects created, 235166 MonoObjects freed, so 22876 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204219 MonoObjects freed, so 1585 were not freed. (static registrar)

After:

    There were 258066 MonoObjects created, 246781 MonoObjects freed, so 11285 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204491 MonoObjects freed, so 1313 were not freed. (static registrar)
2021-05-31 08:02:45 +02:00
Rolf Bjarne Kvinge 6a83ed9169
[runtime] The return value from mono_class_from_mono_type must be released. (#11729)
Before:

    There were 258042 MonoObjects created, 235166 MonoObjects freed, so 22876 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204219 MonoObjects freed, so 1585 were not freed. (static registrar)

After:

    There were 258050 MonoObjects created, 235177 MonoObjects freed, so 22873 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204219 MonoObjects freed, so 1585 were not freed. (static registrar)
2021-05-31 08:02:11 +02:00
Rolf Bjarne Kvinge c12cb23414
[dynamic registrar] Out parameters must be released. (#11727)
Before:

    There were 258042 MonoObjects created, 235166 MonoObjects freed, so 22876 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204219 MonoObjects freed, so 1585 were not freed. (static registrar)

After:

    There were 258058 MonoObjects created, 235308 MonoObjects freed, so 22750 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204219 MonoObjects freed, so 1585 were not freed. (static registrar)
2021-05-31 08:01:24 +02:00
Rolf Bjarne Kvinge dc30bdf220
[registrar] Make sure to release the return value from xamarin_get_parameter_type. (#11725)
Before:

    There were 258046 MonoObjects created, 235142 MonoObjects freed, so 22904 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204193 MonoObjects freed, so 1611 were not freed. (static registrar)

After:

    There were 258054 MonoObjects created, 235172 MonoObjects freed, so 22882 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 205190 MonoObjects freed, so 614 were not freed. (static registrar)
2021-05-28 16:19:47 +02:00
Rolf Bjarne Kvinge 57288a5ad4
[registrar] Return values from mono_value_box must be released. (#11708)
Before:

    There were 258046 MonoObjects created, 235142 MonoObjects freed, so 22904 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204193 MonoObjects freed, so 1611 were not freed. (static registrar)

After:

    There were 258054 MonoObjects created, 235172 MonoObjects freed, so 22882 were not freed. (dynamic registrar)
    There were 205804 MonoObjects created, 204193 MonoObjects freed, so 1611 were not freed. (static registrar)
2021-05-27 16:43:11 +02:00
Rolf Bjarne Kvinge 013be35fc9
[runtime] Skip custom command line argument parsing for macOS and Mac Catalyst. (#11705)
Due to the following reasons:

* Desktop apps like macOS and Mac catalyst can be launched directly from the
  command line by users.
* It's trivial to set environment variables for desktop apps before launching
  them.
* All the different command line arguments we support for mobile targets can
  also be set using environment variables.

We don't need additional command line argument parsing for desktop platforms,
so just remove it.

The end result is that instead of doing this to run a specific unit test:

     path/to/macOS/app/MacOS/Contents/theapp --app-arg --test --app-arg MyTestFixture

This will now work:

     path/to/macOS/app/MacOS/Contents/theapp --test MyTestFixture

Which is how apps on desktop platforms should work anyway.
2021-05-27 16:42:09 +02:00
Rolf Bjarne Kvinge ba4fa19267
[runtime] Intercept the objc_msgSend family of functions using CoreCLR's supported mechanisms. (#11692)
This allows us to re-introduce a few tests.
2021-05-27 07:29:39 +02:00
Rolf Bjarne Kvinge 80c755ee2e
[runtime] Return values from mono_array_get must be released. (#11683)
Before:

    There were 257927 MonoObjects created, 144942 MonoObjects freed, so 112985 were not freed. (dynamic registrar)
    There were 205700 MonoObjects created, 113865 MonoObjects freed, so 91835 were not freed. (static registrar)

After:

    There were 257931 MonoObjects created, 235062 MonoObjects freed, so 22869 were not freed. (dynamic registrar)
    There were 205700 MonoObjects created, 203983 MonoObjects freed, so 1717 were not freed. (static registrar)
2021-05-26 15:09:51 +02:00
Rolf Bjarne Kvinge a266fd7ce7
[runtime] Don't include a workaround for a ancient bug anymore in .NET. (#11669)
The workaround doesn't work anymore anyway, this is printed on every launch:

> MonoTouch: Could not install sigaction override, unexpected sigaction implementation.

Ref: 054bbdce96
2021-05-25 21:30:35 +02:00
Rolf Bjarne Kvinge 5a0600491c
[runtime] Add support for tracking created and destroyed MonoObject* instances for CoreCLR. (#11657)
* [runtime] Add support for tracking created and destroyed MonoObject* instances for CoreCLR.

Implement a rudimentary way of tracking created and destroyed MonoObject*
instances, so that it's easy to find leaks.

* Add a xamarin_bridge_shutdown method that's called just before returning from xamarin_main.

And use it to dump the leaked MonoObject*s.
2021-05-25 08:19:27 +02:00
Rolf Bjarne Kvinge a447b3498a
[runtime/src] Update a few comments. (#11650) 2021-05-21 15:53:50 +02:00
Rolf Bjarne Kvinge 519c2f036f
[runtime] Fix typo in error message (#11651) 2021-05-21 15:53:10 +02:00
Rolf Bjarne Kvinge 279190e849
[runtime] Fix typo in logging statement (#11645) 2021-05-21 07:54:42 +02:00
Rolf Bjarne Kvinge 0dee77cd83
[runtime] Deal with the rest of the Mono Embedding API for CoreCLR. (#11642)
* [runtime] Mark numerous Mono Embedding API as used only by the MonoVM bridge.

* [runtime] Exclude more unused code from the CoreCLR build.

* There's no tracing in CoreCLR, so no need to process the MONO_TRACE environment
  variable (and set the trace options).
* There's no sdb debuggger, so that code can be skipped.
* The profiler support is very different, so skip that code too.
* We don't support AOT, nor aot data files, so skip that.

* [runtime] Stop generating dummy implementations of the Mono Embedding API for CoreCLR.

All of the Mono Embedding API now falls in either of these two categories:

* Only used by the MonoVM bridge.
* Has a CoreCLR implementation.

Which means that we don't need the code to generate dummy implementations for
methods that aren't in any of these two categories anymore.
2021-05-21 07:53:41 +02:00
Rolf Bjarne Kvinge fdf6b7f0cc
[runtime] Re-implement code that fetches the assembly name to use existing API implemented by CoreCLR. (#11612)
* [runtime] Re-implement code that fetches the assembly name to use existing API implemented by CoreCLR.

* Keep the MonoVM implementation as-is.
2021-05-20 19:04:58 +02:00
Rolf Bjarne Kvinge f8a19c7cbf
[runtime] Remove the declarations for mono_jit_parse_options and mono_gc_max_generation. (#11617)
We don't used these mono functions anymore.
2021-05-20 07:35:38 +02:00
Rolf Bjarne Kvinge f38187f054
[runtime] Refactor the toggle ref code to separate MonoVM-specific code and generic logic. (#11616)
This makes it simpler to impement the toggle ref logic for CoreCLR once we can
do that.
2021-05-20 07:35:23 +02:00
Rolf Bjarne Kvinge a6f0dbdd67
[runtime] Fix declaration of xamarin_bridge_get_method_declaring_type. (#11614)
The native xamarin_bridge_get_method_declaring_type method and the
corresponding managed method (GetMethodDeclaringType) takes and returns a
MonoObject*, not a GCHandle.

Due to the wonders of void pointers, this worked just fine before - there's no
actual change to the compiled code - but the code is now more consistent and
less confusing.
2021-05-20 07:34:17 +02:00
Rolf Bjarne Kvinge d60514b02b
[runtime] Postpone implementing mono_domain_set_config for CoreCLR. (#11610) 2021-05-20 07:33:26 +02:00