The linker might remove interfaces that have already been linked away. Make
sure to look for the TypeDefinition for such interfaces among the types that
have already been linked away.
Fixes https://github.com/xamarin/xamarin-macios/issues/3513.
It seems the d15-5 version of VSfM has a non-optimal startup path, where
launching vstool takes almost 4 minutes on the bots, making it difficult to
build & run tests within the allotted time for those tests:
$ time /Applications/Visual\ Studio.app/Contents/MacOS/vstool help
[...]
real 3m30.172s
So bump to the latest d15-6 preview (which takes _only_ 12 seconds to launch
on my machine), hoping it will be enough to make tests build on the bots.
Implement support for optimizing away the dynamic registrar.
* Add a new property (Runtime.DynamicRegistrationSupported) that indicates at
runtime whether dynamic registration is available.
* Check this new property whenever we need dynamic registration.
* Add an optimization to mtouch/mmp that detects whether dynamic registration
is required, and if not, changes Runtime.DynamicRegistrationSupported to
return false.
* Add an optimization to mtouch/mmp that inlines
Runtime.DynamicRegistrationSupported as a constant value.
The end result is that the linker will link away the dynamic registrar if
mtouch/mmp detects that it's not needed.
Benchmark
---------
I've compared the size of entire apps built for device:
|test | Before | After | Diff | % |
|:-----------------------------|-------:|-------:|-------:|------:|
|[monotouch-test/Release][1] | 95.7mb | 95.0mb | -680kb | -0.7% |
|[link sdk/Release][2] | 21.2mb | 20.9mb | -245kb | -1.2% |
|[minimalistic app/Release][3] | 4.58mb | 4.32mb | -259kb | -5.7% |
[1]: https://gist.github.com/rolfbjarne/3871e36d2de8db1a8eee1d9f9276d3d2#monotouch-test-release-wall-optimizations-enabled
[2]: https://gist.github.com/rolfbjarne/3871e36d2de8db1a8eee1d9f9276d3d2#link-sdk
[3]: https://gist.github.com/rolfbjarne/3871e36d2de8db1a8eee1d9f9276d3d2#minimalistic-app
Fixes this test:
Xamarin.ApiTest.ApiTest.AlwaysOptimizable(iOS) : All methods calling optimizable API must be optimizable
The method System.IntPtr ObjCRuntime.BlockLiteral::GetBlockForDelegate(System.Reflection.MethodInfo,System.Object,System.String) calls System.Boolean ObjCRuntime.Runtime::get_DynamicRegistrationSupported(), but it does not have a [BindingImpl (BindingImplOptions.Optimizable)] attribute.
Also skip the BlockLiteral.SetupBlock optimization for this method, because
it's not optimizable (and thus produces a warning users can't ignore).
It seems LLVM freaks out if it finds unreachable exception handlers:
* Assertion at ../../../../external/mono/mono/mini/mini-llvm.c:7406, condition `err == 0' not met
Basic Block in function 'Xamarin_iOS_ObjCRuntime_Class_GetClassHandle_System_Type' does not have terminator!
label %BB7_CALL_HANDLER_TARGET
Mark managed callback functions if they're only used in the dynamic registrar,
and only initialize the corresponding delegate if the dynamic registrar is
available.
This will make it possible for the linker to remove those managed functions if
the dynamic registrar is being removed.