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

87 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge a0b858ad47
[runtime] Call mono_unhandled_exception to raise AppDomain.UnhandledException. (#20656)
Call mono_unhandled_exception to raise AppDomain.UnhandledException when
managed exceptions are unhandled.

Partial fix for #15252 (for MonoVM, still pending for CoreCLR, which
needs https://github.com/dotnet/runtime/issues/102730 fixed first).
2024-05-29 20:14:47 +02:00
Rolf Bjarne Kvinge 60fbd4d37e
[runtime] Remove native usage of MonoReferenceQueue and use a ConditionalWeakTable in managed code instead. (#17429)
This makes it possible to simplify and remove a good chunk of related code.

Especially for CoreCLR this should be a minor perf improvement, because we'll do fewer transitions between managed and native code.
2023-02-06 07:57:51 +01:00
Rolf Bjarne Kvinge 2f684ca72b
[runtime] Use the built-in support in MonoVM for autorelease pools on threadpool threads. Fixes #11788. (#16751)
MonoVM in .NET 6+ supports automatic autorelease pools on threadpool threads
just like CoreCLR does, so we can remove our custom mono profiler hooks to
accomplish this.

Fixes https://github.com/xamarin/xamarin-macios/issues/11788.
2022-11-15 17:44:41 +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
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 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 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 d60514b02b
[runtime] Postpone implementing mono_domain_set_config for CoreCLR. (#11610) 2021-05-20 07:33:26 +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 022fa9c697
[runtime] Throw a runtime exception instead of execution engine exception. (#11599)
* One less Mono Embedding method used: good for CoreCLR.
* More consistent with the rest of our code / behavior.
2021-05-19 07:34:13 +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 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 83dbeda8c6
[runtime] Refactor xamarin_get_nsnumber_converter to use string comparisons instead of mono_type_get_type. (#11530)
This makes it easier for CoreCLR. Also, at least for CoreCLR, it's unlikely to
be slower, since we'd have to compute the MONO_TYPE_* value in any
compatibility function.
2021-05-13 20:56:02 +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 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 0285689aa3
[runtime] Never disable exception marshalling for CoreCLR. (#11407) 2021-05-04 08:28:34 +02:00
Rolf Bjarne Kvinge f0a0d08aeb
[runtime] Call into managed code to handle runtime exceptions. (#11381)
* [runtime] Call into managed code to handle runtime exceptions.

This makes things easier for CoreCLR.

There should be no significant performance hits; this code path is
exceptional, and exceptions are already very heavy-weight anyways.

* Update to use xamarin_free instead of mono_free as per review.

* Port more to managed code.
2021-05-04 08:19:46 +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 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 7b5a1c251c
[runtime] There's no need to attach/detach the current thread in CoreCLR. (#11307) 2021-04-26 07:46:55 +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
Rolf Bjarne Kvinge 6d127660d5
[runtime] Move the code to wrap every managed thread with an NSAutoreleasePool to the MonoVM bridge. (#11257)
The current implementation is MonoVM-specific, and won't work with CoreCLR
(something else will have to be implemented for CoreCLR, which is tracked
here: https://github.com/xamarin/xamarin-macios/issues/11256).
2021-04-21 16:21:09 +02:00
Rolf Bjarne Kvinge 320527a29b
[CoreCLR] Implement mono_assembly_get_object. (#11254) 2021-04-21 15:00:10 +02:00
Rolf Bjarne Kvinge 7bc45c097a
[runtime] Don't start the toggle ref machinery in CoreCLR. (#10990)
The implementation will be completely different, where the hook into CoreCLR
is in managed code.

We still need to initialize the framework_peer_release_lock mutex, so move
that code out of gc_enable_new_refcount.
2021-03-30 18:06:23 -04:00