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

494 Коммитов

Автор SHA1 Сообщение Дата
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 174bafe9b0
[runtime] MapKit is available on macOS/arm64. (#11363) 2021-04-29 14:45:58 +02:00
Rolf Bjarne Kvinge fdd386b68f
[runtime] Remove dead code. (#11354)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2021-04-29 13:56:54 +02:00
Rolf Bjarne Kvinge a01a96a407
[runtime] Implement xamarin_[get|set]_flags_for_nsobject. (#11347) 2021-04-28 07:40:43 +02:00
Rolf Bjarne Kvinge 2b0a9f5bc1
[CoreCLR] Implement xamarin_get_nsobject_handle. (#11346) 2021-04-28 07:34:57 +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 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 5d42c933f1
[runtime] Move xamarin_create_managed_ref internal call to managed code. (#11271)
Move the xamarin_create_managed_ref internal call to managed code, to ease things
with CoreCLR.

In order to preserve performance, this wasn't a straight forward port.

* monotouch_create_managed_ref used to detect if there already was a GCHandle for
  a native object. To avoid a managed->native transition, this logic has now been
  moved into the code that sets the GCHandle (the xamarinSetGCHandle🎏 / xamarin_set_gchandle_trampoline
  code), and these methods return a value saying whether the GCHandle was set or
  not.

* xamarin_create_gchandle will check the retain count to determine whether to create
  a weak or a strong GCHandle for the managed object. In this particular case we
  should never need to create a strong GCHandle, which means that we don't need to
  check the retain count (saving a managed->native transition).

Using the new perftest (#11298), I get very similar numbers for both old code and new code: https://gist.github.com/rolfbjarne/e0fc2ae0f21da15062b4f051138679af (multiple runs). Sometimes the old code is faster, sometimes the new code is faster (although the old code tends to be the one who wins).

In any case there aren't any significant performance hits due to this change, so it should be good to go.
2021-04-23 18:42:11 +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
Sebastien Pouliot 5accd102cf
[dotnet][tvos] Enable ICU (instead of using Invariant) and additional tests (#11247) 2021-04-21 20:19:05 -04: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
dotnet-maestro[bot] e8f437319a
[main] Update dependencies from dotnet/installer (#11175)
* Update dependencies from https://github.com/dotnet/installer build 20210408.1

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21208.1

* Update dependencies from https://github.com/dotnet/installer build 20210409.4

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21209.4

* Update dependencies from https://github.com/dotnet/installer build 20210410.1

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21210.1

* same P4 specific fix as ccb43cba56
but the ICU support was added based on P3 but merged after ^

* Update dependencies from https://github.com/dotnet/installer build 20210412.5

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21212.5

* Update dependencies from https://github.com/dotnet/installer build 20210413.70

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21213.70

* Update dependencies from https://github.com/dotnet/installer build 20210414.14

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21214.14

* Update to new package names

Thanks @pjcollins for the heads up https://github.com/xamarin/xamarin-macios/pull/11175#issuecomment-819936692

* Update dependencies from https://github.com/dotnet/installer build 20210415.1

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21215.1

* Fix build (path changed to include '.mono')

* remove more '.mono' special case that are not needed anymore

* Update dependencies from https://github.com/dotnet/installer build 20210415.12

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21215.12

* Fix building apps (it now finds the native libs)

Credits to @filipnavara

8325f8dadc

* Add back IsTrimmable (or nothing gets linked)

* Update dependencies from https://github.com/dotnet/installer build 20210418.6

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.3.21202.5 -> To Version 6.0.100-preview.4.21218.6

* Keep downloading the CoreCLR runtime packs.

* [runtime] Adjust the build to link with the correct runtime library for CoreCLR.

* [tests][monotouch-test] Ignore NSTimeZoneTest / All_28300 on dotnet as it hangs

Introduced with https://github.com/dotnet/runtime/pull/48931

Issue https://unicode-org.atlassian.net/browse/ICU-21591
PR https://github.com/unicode-org/icu/pull/1699

* [dotnet][msbuild] Add more (missing) '\'

Fix satellite/location assemblies and some unit tests

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Sebastien Pouliot <sebastien.pouliot@microsoft.com>
Co-authored-by: Sebastien Pouliot <sebastien.pouliot@gmail.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-04-20 09:09:56 -04:00
Sebastien Pouliot f85af095da
[dotnet] Add ICU support for iOS builds (#11163)
and re-enable some tests for dotnet

Part of the fix for https://github.com/xamarin/xamarin-macios/issues/8906

Known Issues
* [some Calendar are not the expected ones](https://github.com/dotnet/runtime/issues/50859)
* [No support for tvOS (bitcode)](https://github.com/dotnet/runtime/issues/48508)
2021-04-09 17:06:26 -04:00
Peter Collins 5c12fdfac9
[build] Use arcade dependency management tooling (#10890)
* [build] Use arcade dependency management tooling

* Apply feedback

* Apply second round of feedback

* Always make dotnet.config before trying to read it

* Debugging

* Update dependencies, trim tabs and spaces

* [dotnet] Remove the existing workload shipped with .NET and install our locally built ones.

The new version of .NET ships with our workloads, but those aren't
the workloads we want to use, so replace them with our own.

* Update .gitignores.

* Bump to 6.0.100-preview.3.21181.5

That required renaming simulator runtime packs...

* More rename for simulator packages

* moar (hopefully all)

* Bump to 6.0.100-preview.3.21201.11

This fix the issue with `Wait` that failed several tests in monotouch-tests

However it does not include the fix for AppConext.GetData on device (AOT)

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Sebastien Pouliot <sebastien@xamarin.com>
2021-04-02 00:02:27 -04: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
Rolf Bjarne Kvinge 6ce364860c
[CoreCLR] Implement xamarin_gchandle_new[_weakref] and xamarin_gchandle_free. (#10985) 2021-03-30 18:04:44 -04:00
Rolf Bjarne Kvinge 77b470cfaf
[CoreCLR] Implement mono_domain_get. (#10992) 2021-03-30 17:46:36 -04:00
Sebastien Pouliot b186bd675a
[dotnet] Call monovm_initialize before mono_jit_init (#11014)
Those are called respectively inside `xamarin_vm_initialize` and
`xamarin_bridge_initialize` functions.

This fix the **AppContext.GetData always return null for iOS** issue
https://github.com/dotnet/runtime/issues/50290

Thanks for @filipnavara for diagnosing this quicker than anyone else!

Added unit tests to ensure `AppContext.GetData` can read back the values
we're providing at startup.
2021-03-29 16:23:38 -04:00
Rolf Bjarne Kvinge a82575189b [CoreCLR] Add support for mono_assembly_open.
This includes going through all uses of mono_assembly_open, and make sure the release
the returned assembly.
2021-03-25 07:32:32 +01:00
Rolf Bjarne Kvinge 18ac48c5c8 [runtime] Make it possible to implement Mono Embedding API in the CoreCLR bridge
By making it possible to skip the automatically generated Mono Embedding API that
just asserts.
2021-03-25 07:32:32 +01:00
Rolf Bjarne Kvinge 2527679e34 [runtime] Add a MonoObject implementation for CoreCLR.
We need a way to represent a managed object in native code, and since most our existing
runtime code uses MonoObjects, we use the same for the CoreCLR bridge, just our own
version of it. In Mono, the MonoObjects are tracked by the GC (which scans the stack),
but we can't make CoreCLR scan the stack, so we use a reference counted version of
MonoObject instead - we just put the GCHandle into a reference counted MonoObject,
and when the MonoObject is freed, then we free the GCHandle as well.
2021-03-25 07:32:32 +01:00
Rolf Bjarne Kvinge 9a643594fb [runtime] Add support for generating managed delegates only for CoreCLR.
However, since our managed code is shared between CoreCLR and MonoVM, the best we
can do is to make these CoreCLR-only delegates .NET-only.
2021-03-25 07:32:32 +01:00
Rolf Bjarne Kvinge c8b6bc6c85
[dotnet] Build macOS/.NET for ARM64 as well. (#10959)
Partial fix for #10959.
2021-03-25 07:26:48 +01:00
Rolf Bjarne Kvinge 253061bf74
[runtime] Implement calling the managed Runtime.Initialize method from the CoreCLR bridge. (#10951)
* Move the existing logic to call Runtime.Initialize into the MonoVM code.
* Implement calling the managed Runtime.Initialize method from the CoreCLR bridge.

The call to Runtime.Initialize succeeds, which means we're now executing
managed code with CoreCLR for the first time.
2021-03-25 07:25:20 +01:00
Rolf Bjarne Kvinge 1b658149ff
[runtime] Fix argument name confusion in the xamarin_gchandle_new[_weakref] methods. (#10952)
This way the argument names match the argument names in the corresponding Mono Embedding API.

This is just an argument rename, no functional changes.
2021-03-24 17:38:01 +01:00
Rolf Bjarne Kvinge 3b2fa0d0b1
[runtime] Move the declaration of the MonoObject struct to MonoVM-specific code. (#10938)
The fields of the MonoObject struct is specific to MonoVM, so this makes sure
we don't accidentally poke into random memory on CoreCLR.

Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2021-03-24 14:55:03 +01:00
Rolf Bjarne Kvinge 43d3f8b0f5
[runtime] Make the exception_gchandle argument optional for callbacks to managed code in CoreCLR. (#10939)
If no exception handling is provided when calling a managed delegate from native
code, and the managed code throws, then we'll abort.

It's not entirely clear how we'll handle managed exceptions that go through native
code yet, so this makes the initial implementation easier. By making the exception
handling optional, it'll be easy to find all cases where we need to fix it later,
by making it non-optional. The alternative is to add exception handling code all
over the place that would potentially have to be updated when we figure out exactly
what needs to be done.
2021-03-24 09:26:31 +01:00
Rolf Bjarne Kvinge 9153edebda
[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
2021-03-24 09:17:35 +01:00
Rolf Bjarne Kvinge b2248993de
[runtime] Don't register for GC callbacks with CoreCLR, this will be done in a completely different manner (through managed code). (#10931) 2021-03-23 07:35:38 +01:00
Rolf Bjarne Kvinge c406cc1da7
[runtime] Don't install any logging/printing handlers for CoreCLR, there's no equivalent. (#10927)
This also means that we don't have to generate CoreCLR wrappers for the corresponding
embedding API, so adjust the generated code accordingly.
2021-03-22 15:18:37 +01:00
Rolf Bjarne Kvinge d778cc28c8
[runtime/dotnet] Call coreclr_initialize/monovm_initialize at startup. (#10909)
We need to call coreclr_initialize/monovm_initialize at startup, so do that.
This is a partial implementation, in that we're not setting all the properties
that we should, and also the PINVOKE_OVERRIDE callback is not doing everything
it should either yet.

Ref: #10504.
2021-03-22 08:04:56 +01:00
Rolf Bjarne Kvinge 307f97e529
[dotnet] Add a IsCoreCLR initialization flag. (#10900)
So that we can detect in managed code whether we're running with CoreCLR or
MonoVM.
2021-03-18 14:29:06 +01:00
Rolf Bjarne Kvinge af5651accf
[runtime] Move MonoVM-specific initialization to MonoVM-specific code. (#10899)
* [runtime] Download the CoreCLR embedding header file

* [runtime] Create VM-specific code and header files and include them in the build

* [runtime] Move MonoVM-specific initialization to MonoVM-specific code.
2021-03-18 07:23:39 +01:00
mathieubourgeois a921ee2fb1
Xamarin.Mac native Apple Silicon targetting support (#10115)
* Add support for Xamarin.Mac arm64

* Add compile product definition task

Xamarin.Mac can be provided with a ProductDefinition file for the generated pkg. Normally, providing a product definition was optional. However, with Apple Silicon, we have an extra issue : `productbuild` needs to know what architectures your package target. If not provided with them, it will guess to the best of its abilities. However, on Catalina and lower, the guess is x86_64, even if you have an arm64 slice. To fix this, we add a new task to compile the product definition and use this file to create the pkg. If you provide your own Product Definition, we can check and warn if the architectures don't match what we expect. If the file doesn't exist or there is no architecture, we set it ourselves based on our target architectures.

* Don't reference dynamic objC_send on arm64

When building in debug, we currently try to link dynamic objC_send symbols when targeting a 64-bit architecture. However, this is actually only defined on Intel architectures, not on arm64, so we end up failing because we're referring symbols that don't exist. Rework the `GetRequiredSymbols` to take an abi, and tag those symbols to only be valid on i386/x86_64, so they don't get referred at all when building on arm64, but still get referred in x86_64.

* Fix improper delete/move with already existing directories

* Fix stret requirement for Xamarin.Mac in arm64.

The generator supposes that we're running in x64 mode, refactor to take into account the possibility of running in arm64.

* Implement OS version generation in Product.plist, based on MinimumSystemVersion of the app

* Re-generalize some mmp registrar rules

`Microsoft.macOS.registrar` was missed by the current rule set

* Fix mmp tests

* Set E7072 as not translated

Tests were failing otherwise

* Rename Xamarin.Mac lib/x86_64 folder to 64bits (currently all targeted archs are the same)

* Fix style issues

* Fix `ToLower` usage for invariant usage

* Fix xtro-sharpie test
2021-03-17 21:48:02 -04:00
Rolf Bjarne Kvinge 46c999f0ad
[runtime] Resolve symlinks using API provided by NSString instead of Mono. (#10889)
Mono's way doesn't work with CoreCLR anyway.
2021-03-17 07:54:52 +01:00
Rolf Bjarne Kvinge ddf1645748
[runtime] Remove unnecessary cast (#10875) 2021-03-16 15:23:58 +01:00
Rolf Bjarne Kvinge 3087174202
[runtime] Use xamarin_gchandle_free instead of mono_gchandle_free. (#10874)
Our own functions support pointer-sized GCHandles, so this is one less place
to fix for CoreCLR.
2021-03-16 14:00:35 +01:00
Rolf Bjarne Kvinge bc340502fe
[runtime] Move parts of NSObject creation from native to managed. (#10869)
Move the creation of an uninitialized NSObject from native to managed, which:

* Removes the need for the mono_object_new Embedding API.
* Removes one location where we write to managed memory from native code (to
  write the handle + flags in the uninitialized NSObject).
* Makes things easier for CoreCLR.
2021-03-16 07:40:19 +01:00
Rolf Bjarne Kvinge a5f970069a
[runtime] Make xamarin_release_managed_ref a normal P/Invoke. (#10864)
* We already switch to GC Safe mode anyway, so there were no benefits from
  entering native code in a GC unsafe mode. In fact we used to switch to GC
  Safe mode for every statement in xamarin_release_managed_ref, and now we can
  execute everything in GC Safe mode without switching back and forth. This
  also means there should be no difference in behavior.

* All parameters are blittable, so there's no extra marshalling cost.

* Easier for CoreCLR.
2021-03-15 08:02:59 +01:00
Rolf Bjarne Kvinge 52aa993bba
[runtime] Move setting the NSObject flags in xamarin_create_managed_ref from native to managed code. (#10858)
* Less poking into managed memory from native code.
* Makes things easier for CoreCLR support.
2021-03-12 23:19:07 +01:00
Rolf Bjarne Kvinge 1003c987f2
[runtime] Move the call to Runtime.UnregisterNSObject from native to managed code. (#10857)
* Avoids a native->managed transition
* Avoids creating/destroying a GCHandle.
* Makes it possible to remove an argument from the call to
  xamarin_release_managed_ref.
* Makes things easier for CoreCLR.
2021-03-12 23:14:10 +01:00
Rolf Bjarne Kvinge 4e0978e46c
[runtime] Link the CoreCLR version of libxamarin with CoreCLR instead of Mono. (#10853)
* [runtime] Link the coreclr version of libxamarin with CoreCLR instead of Mono.

The diff might look a bit weird, because there's no changes specific to CoreCLR -
the difference is that we're in fact removing a special-case to link with Mono: we
used the DOTNET_$(rid)_LIBDIR variable to specify the directory where to find libcoreclr,
we now use DOTNET_CORECLR_$(rid)_LIBDIR when building for CoreCLR, but that's handled
by the default case, so no need to add any special casing. We still override DOTNET_osx-<arch>_LIBDIR
for MonoVM (no change needed for that).

* [runtime] Generate stubs for the mono embedding API when building for CoreCLR.

This makes libxamarin link successfully when building for CoreCLR.
2021-03-12 18:40:48 +01:00
Rolf Bjarne Kvinge e6247e0c6f
[runtime] Port the is_user_type function from native to managed code. (#10841)
* [runtime] Port the is_user_type function from native to managed code.

* This is a straight forward port of native code to managed code, and
  shouldn't have any significant side effects.

* Makes it possible to move more code from native to managed for
  xamarin_create_managed_ref and xamarin_release_managed_ref in the future.

* Update xtro.
2021-03-12 07:38:27 +01:00
Rolf Bjarne Kvinge e53176383e
[builds] Remove the code to optionally inject an x64 slice into our binaries. (#10846)
It's been disabled for a while, which indicates that Apple has fixed the issue
on their side, and we don't need this code anymore.
2021-03-12 07:38:07 +01:00
Rolf Bjarne Kvinge a392035fa7
[runtime] Move a few mono function declaration to the generated logic for mono function declarations instead of doing it manually. (#10849)
This makes things a little bit easier to when starting work with CoreCLR.
2021-03-12 07:37:27 +01:00
Rolf Bjarne Kvinge 4cfa6928ae
[runtime] Simplify the various print_all_exceptions methods a bit. (#10847)
Unify them into a single one (xamarin_print_all_exceptions), which takes the
GCHandle of the exception to create an NSString representation of.
2021-03-12 07:37:13 +01:00
Rolf Bjarne Kvinge 37723f600c
[runtime] Speed up make (#10848)
Make variables can have dashes, which means we don't have to convert dashes in
rids to underscores to be able to compose variable names.

This speeds up make because now we don't have to execute hundreds of
subprocesses when parsing the makefile.

Before:

    $ make -j16 > /dev/null && /usr/bin/time make && /usr/bin/time make && /usr/bin/time make
        2.11 real         0.57 user         1.26 sys
        2.15 real         0.57 user         1.28 sys
        2.17 real         0.58 user         1.30 sys

After:

    $ make -j16 > /dev/null && /usr/bin/time make && /usr/bin/time make && /usr/bin/time make
        0.52 real         0.18 user         0.25 sys
        0.52 real         0.18 user         0.25 sys
        0.52 real         0.18 user         0.26 sys

So now it's ~4x faster (1.6s) for make to figure out there's nothing to do.
2021-03-12 07:36:41 +01:00
Rolf Bjarne Kvinge 3af399e21f
[runtime] Remove unused mono functions. (#10825) 2021-03-11 08:48:17 +01:00