xamarin-macios/tools
Rolf Bjarne Kvinge 60a8731b35
Merge pull request #3462 from rolfbjarne/optimized-protocol-support
Add a 'register-protocols' optimization that:

Improves static registrar to:

* Generate a new table of protocol -> managed wrapper type. This is required
  to find the wrapper type without having the `[Protocol]` attribute around.

* Make the generated code implement protocols from [Adopts] attributes. This
  makes it possible to link away the `[Protocol]` attribute, because the
  native implementation of `conformsToProtocol:` does the right thing (we
  might even be able to link away our complete `ConformsToProtocol` logic when
  we remove the dynamic registrar).

Improves linker to:

* Not mark protocol interfaces by the mere virtue of having a type that
  implements them. This is implemented by not marking protocol interfaces when
  they're implementing a class, but instead when a method implementation is
  found to implement a method from a protocol interface.

* Mark the wrapper type for protocols (this allows us to remove the Protocol
  attribute, since that's the link between the protocol and its wrapper type).

* Remove the [Protocol], [ProtocolMember] and [Adopts] attributes (but only if
  optimizing protocols).

The static registrar still needs some of the information linked away, so a few
changes are required to make it available post linker.

Benchmark
---------

I've compared the size of entire apps built for device:

|test                          | Before |  After |   Diff |     % |
|:-----------------------------|-------:|-------:|-------:|------:|
|[monotouch-test/Debug][1]     |  101mb |  100mb | -888kb | -0.9% |
|[monotouch-test/Release][2]   | 99.2mb | 95.4mb | -830kb | -0.9% |
|[minimalistic app/Debug][3]   | 10.8mb | 10.4mb | -443kb | -4.1% |
|[minimalistic app/Release][4] |  4.7mb | 4.55mb | -157kb | -3.3% |

[1]: https://gist.github.com/rolfbjarne/0181ab8abe436c34cf4ee68ecfb8cd18#monotouch-test-debug
[2]: https://gist.github.com/rolfbjarne/0181ab8abe436c34cf4ee68ecfb8cd18#monotouch-test-release
[3]: https://gist.github.com/rolfbjarne/0181ab8abe436c34cf4ee68ecfb8cd18#minimal-xi-app-debug
[4]: https://gist.github.com/rolfbjarne/0181ab8abe436c34cf4ee68ecfb8cd18#minimal-xi-app-release
2018-02-14 17:47:31 +01:00
..
apidiff [src/apidiff] Don't hardcode input/output/build directories. (#3435) 2018-02-09 13:07:22 +01:00
common [static registrar] Fix finding derived [Export] attributes. 2018-02-14 09:19:31 +01:00
install-source Bump to mono:2017-12 (#3421) 2018-02-14 11:08:01 -05:00
linker Merge pull request #3462 from rolfbjarne/optimized-protocol-support 2018-02-14 17:47:31 +01:00
mmp Merge pull request #3462 from rolfbjarne/optimized-protocol-support 2018-02-14 17:47:31 +01:00
mtouch Merge pull request #3462 from rolfbjarne/optimized-protocol-support 2018-02-14 17:47:31 +01:00
.gitignore Add scripts to calculate API diffs and generated code diff between the current build and another revision. (#3447) 2018-02-13 07:47:47 +01:00
Makefile Install source code. 2016-04-24 14:47:27 -04:00
compare-commits.sh Add scripts to calculate API diffs and generated code diff between the current build and another revision. (#3447) 2018-02-13 07:47:47 +01:00
diff-to-html Add scripts to calculate API diffs and generated code diff between the current build and another revision. (#3447) 2018-02-13 07:47:47 +01:00