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

59 Коммитов

Автор SHA1 Сообщение Дата
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 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 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 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 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 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 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 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 a33a86a9b7
[runtime] Implement mono_get_exception_out_of_memory for CoreCLR. (#11608) 2021-05-20 07:33:16 +02:00
Rolf Bjarne Kvinge ab14e07146
[runtime] Implement mono_class_value_size for CoreCLR. (#11554) 2021-05-14 15:19:34 +02:00
Rolf Bjarne Kvinge eab3accf26
[runtime] Implement mono_class_is_enum and mono_class_enum_basetype for CoreCLR. (#11553)
* [runtime] Implement mono_class_is_enum for CoreCLR.

* [runtime] Implement mono_class_enum_basetype for CoreCLR.
2021-05-14 15:19:23 +02:00
Rolf Bjarne Kvinge 9a013fd4a7
[runtime] Implement xamarin_get_[nsnumber|nsvalue]_type for CoreCLR. (#11552)
* Remove a few unused xamarin_get_*_class functions.
* Make the remaining two (xamarin_get_[nsnumber|nsvalue]_type) return a
  MonoType* instead of MonoClass* - that makes things slightly simpler for
  CoreCLR (the MonoClass* return values from the previous functions were
  always converted to MonoType*s anyway).
* Implement the xamarin_get_[nsnumber|nsvalue]_type functions.
* Make the existing mono_get_string_class use the new (and more generic)
  xamarin_bridge_lookup_class method instead of the specific
  xamarin_bridge_get_string_class (which can now be removed).
2021-05-14 07:29:48 +02:00
Rolf Bjarne Kvinge 42740a5c95
[runtime] Make xamarin_bridge_free_mono_signature accept NULL signatures. (#11550) 2021-05-14 07:28:53 +02:00
Rolf Bjarne Kvinge adb355b757
[runtime] Add support for creating managed exceptions from native code for CoreCLR. (#11538) 2021-05-14 07:27:42 +02:00
Rolf Bjarne Kvinge 5795a62f77
[runtime] Implement mono_method_full_name for CoreCLR. (#11536) 2021-05-13 22:04:09 +02:00
Rolf Bjarne Kvinge 0a0a849b02
[runtime] Implement mono_class_is_nullable for CoreCLR. (#11528) 2021-05-13 22:03:22 +02:00
Rolf Bjarne Kvinge 64e19d2d34
[runtime] Implement mono_class_get_nullable_param for CoreCLR. (#11531) 2021-05-13 20:39:07 +02:00
Rolf Bjarne Kvinge 95dfc4fa39
[runtime] Implement mono_value_box for CoreCLR. (#11533) 2021-05-13 20:38:21 +02:00
Rolf Bjarne Kvinge 751976a769
[CoreCLR] Stub out mono_runtime_set_pending_exception for CoreCLR. (#11521)
We need additional API in CoreCLR to support pending exception properly, and
this is in progress [1]. In the meantime, stub out parts of it, so that the
process doesn't abort. This way we'll have failing tests instead (and work in
other areas can progress, since the process doesn't abort).

[1]: https://github.com/dotnet/runtime/pull/52146
2021-05-13 07:12:17 +02:00
Rolf Bjarne Kvinge 39b0ca4934
[runtime] Implement mono_reflection_type_get_type for CoreCLR. (#11513)
This also meant reviewing calling code to make sure that the return value is
released when it should be.
2021-05-12 23:37:40 +02:00
Rolf Bjarne Kvinge b4fd5f1e63
[runtime] Implement mono_get_string_class for CoreCLR. (#11514) 2021-05-12 15:22:11 +02:00
Rolf Bjarne Kvinge 6e9d9b483d
[runtime] Implement mono_array_new and mono_array_length for CoreCLR. (#11515)
* [runtime] Implement mono_array_new for CoreCLR.

* [runtime] Implement mono_array_length for CoreCLR.
2021-05-12 15:21:56 +02:00
Rolf Bjarne Kvinge af41f128de
[runtime] Implement mono_class_get_element_class for CoreCLR. (#11500) 2021-05-12 07:31:26 +02:00
Rolf Bjarne Kvinge a09a7d2523
[runtime] Implement the mono_g_hash_table functions for CoreCLR. (#11495) 2021-05-11 22:16:41 +02:00
Rolf Bjarne Kvinge 8bb65492ec
[runtime] Implement mono_string_new and mono_string_to_utf8 for CoreCLR. (#11492)
* [runtime] Implement mono_string_to_utf8 for CoreCLR.

* [runtime] Implement mono_string_new for CoreCLR.
2021-05-11 15:16:01 +02:00
Rolf Bjarne Kvinge feed3b2636
[runtime] Implement mono_object_unbox for CoreCLR. (#11493) 2021-05-11 15:15:41 +02:00
Rolf Bjarne Kvinge 5692f34d4e
[runtime] Implement mono_class_get_type for CoreCLR. (#11494)
This also meant reviewing calling code to make sure that the return value is
released when it should be.
2021-05-11 15:15:03 +02:00
Rolf Bjarne Kvinge 88b8c332a7
[runtime] Implement mono_method_get_object for CoreCLR. (#11488)
This also meant reviewing calling code to make sure that the return value is
released when it should be.
2021-05-11 07:21:18 +02:00
Rolf Bjarne Kvinge e4fbc5198b
[runtime] Implement several xamarin_is_class_* variants for CoreCLR. (#11481)
When using the MonoVM, we compare MonoClass instances by pointer. This turns
out a bit complicated for CoreCLR, because our MonoClass instances are not
unique (there can be multiple MonoClass instances that refer to the same
type), so instead implement helper methods that do the comparison. This also
has the benefit of not requiring any memory allocations on CoreCLR.
2021-05-10 23:12:52 +02:00
Rolf Bjarne Kvinge 3623a13ab2
[runtime] Implement a managed implementation of a mono_reference_queue for CoreCLR. (#11487)
Also remove the declaration of mono_gc_reference_queue_free, it's never called.
2021-05-10 23:09:39 +02:00
Rolf Bjarne Kvinge 8fc51f7e8e
[runtime] Implement mono_type_get_object for CoreCLR. (#11484) 2021-05-10 15:38:13 +02:00
Rolf Bjarne Kvinge c14fa03336
[runtime] Implement mono_class_is_[valuetype|byref] for CoreCLR. (#11482)
* [runtime] Implement mono_type_is_byref for CoreCLR.

* [runtime] Implement mono_class_is_valuetype for CoreCLR.
2021-05-10 15:10:03 +02:00
Rolf Bjarne Kvinge d89d97d1fe
[runtime] Implement mono_class_get_name[space] for CoreCLR. (#11483) 2021-05-10 14:42:47 +02:00
Rolf Bjarne Kvinge 695eb003fb
[runtime] Implement mono_thread_detach_if_exiting and mono_free for CoreCLR. (#11480)
* [runtime] Implement mono_free for CoreCLR.

* [runtime] Implement mono_thread_detach_if_exiting for CoreCLR.
2021-05-10 07:25:45 +02:00
Rolf Bjarne Kvinge f61cc98c53
[runtime] Implement mono_class_is_delegate for CoreCLR. (#11476) 2021-05-07 22:21:19 +02:00
Rolf Bjarne Kvinge 1a689d3b14
[runtime] Implement mono_class_from_mono_type for CoreCLR. (#11470) 2021-05-07 15:47:03 +02:00
Rolf Bjarne Kvinge 63db14ec7d
[runtime] Implement mono_method_signature and related signature methods for CoreCLR. (#11465) 2021-05-06 16:19:59 +02:00
Rolf Bjarne Kvinge c51cba525a
[runtime] Implement mono_runtime_invoke for CoreCLR. (#11439)
* [runtime] Implement mono_runtime_invoke for CoreCLR.

* [runtime] We always need a native xamarin_mono_object_retain function.
2021-05-06 07:25:43 +02:00
Rolf Bjarne Kvinge 50b68d4aab
[runtime] Print more information about the exception for unhandled managed exceptions. (#11440)
This eases debugging when trying to figure out what went wrong.
2021-05-05 16:31:03 +02:00
Rolf Bjarne Kvinge 81300576ff
[runtime] Implement mono_object_isinst for CoreCLR. (#11427) 2021-05-04 20:20:46 +02:00
Rolf Bjarne Kvinge 41bf71a0e2
[runtime] Implement mono_object_get_class for CoreCLR. (#11398) 2021-05-04 14:31:20 +02:00
Rolf Bjarne Kvinge 8e9f86aad8
[runtime] Implement mono_method_get_class for CoreCLR. (#11389) 2021-04-30 07:53:30 +02:00
Rolf Bjarne Kvinge 655f2f921f
[runtime] Implement xamarin_get_reflection_method_method for CoreCLR. (#11383) 2021-04-30 07:49:25 +02:00
Rolf Bjarne Kvinge e4960ad9e3
[dotnet] Build the partial static registrar for CoreCLR. (#11345)
* The generated static registration code will eventually be different.
* The generated code has to be compiled with different compiler flags.

This also required adding a new overload of xamarin_mono_object_release for the generated
code to compile.
2021-04-28 07:34:40 +02:00
Rolf Bjarne Kvinge 43f1d02dae
[CoreCLR] Implement xamarin_gchandle_get_target. (#11333)
This also meant reviewing calling code to make sure that MonoObject*s are
released when they should be, which meant reviewing every method that returns
a MonoObject*, and release the result.
2021-04-27 14:59:03 +02:00
Rolf Bjarne Kvinge e2082fd04c
[CoreCLR] Implement mono_jit_exec. (#11264)
This required adding a helper method to get the assembly name for a given
MonoAssembly, since that's what CoreCLR uses to determine what to execute.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2021-04-22 07:46:56 +02:00