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

1535 Коммитов

Автор SHA1 Сообщение Дата
Jeffrey Stedfast 350f497e7a [msbuild] Validate that WatchOS2 App Extensions do not have watch-companion set (#1089) 2016-11-02 10:52:40 +01:00
Rolf Bjarne Kvinge 7728c4cd19 [registrar] Use metadata tokens instead of strings to find types and methods. (#1085)
Use metadata tokens instead of strings to find types and methods.

This makes the code to find methods more compact (a lot less strings in the
executable, and additionally in most cases a compact representation (32-bit
integer) of the corresponding metadata token and additional information can be
used, which results in less executable code (fewer parameters to methods,
etc)), resulting in smaller executables.

Size savings are around 200kb for dont link apps, and 20-60kb for linked apps
(this obviously varies a lot depending on how much has to registered by the
registrar).

|                |    Before     |     After     |       Diff        |
|----------------|--------------:|--------------:|------------------:|
| dontlink/32bit |  102.810.144  |  102.609.456  | -200.688 = -0,20% |
| dontlink/64bit |  107.420.576  |  107.221.792  | -198.784 = -0,19% |
| linksdk/32bit  |   40.957.296  |   40.936.864  |  -20.432 = -0,05% |
| linksdk/64bit  |   43.113.136  |   43.093.936  |  -19.200 = -0,04% |
| linkall/32bit  |   38.410.032  |   38.348.288  |  -61.744 = -0,16% |
| linkall/64bit  |   40.315.200  |   40.267.344  |  -47.856 = -0,12% |

Additionally I've removed the `lazy_map` dictionary, which we populated at
startup and was used to map between Class instances and the corresponding
managed type's FullName, and instead iterate over a native array of Class ->
metadata token mappings whenever we need to look up the managed type for a
certain Class instance.

This is slightly slower for each type we need to look up (for a non-linked app
there might be a 2000-3000 entries in the native array, which would be
iterated instead of using a hashtable lookup), but it's only done once per
type and there's a significant startup memory improvement.

For a non-linked test app I get the following using the Xamarin profiler:

|                   |  Before |  After  |       Diff      |
|-------------------|--------:|--------:|----------------:|
| Memory allocated  |  2,8 MB |  2,4 MB | -0,4 MB = -14 % |
| Objects allocated |   43678 |   38463 |   -5215 = -12 % |
| Private bytes     | 26,6 MB | 24,4 MB | -2,2 MB = -8,3% |
| Working set       | 26,6 MB | 24,4 MB | -2,2 MB = -8,3% |
2016-11-01 14:34:56 -04:00
Rolf Bjarne Kvinge dddd243dfd [xharness] Update to remove OpenTK-1.0 instead of OpenTK references after XI/Classic removal. (#1084) 2016-11-01 13:13:52 -04:00
Sebastien Pouliot 7b38187479 [mtouch][mmp] Unify user resources removal as a link step (#1026)
Right now the logic exists in a few places, both in and outside the
linker. We recently began to use part of the linker pipeline in normal /
all builds so it's easier to share (and unify) the code now.

The real gain is to avoid copying assemblies, in particular large ones,
more than strictly needed while building.

E.g. a build including a very large 1.3GB assembly, with several
native libraries embedded, save a lot of time avoiding the rewrites

mtouch (before)
		Total time: 64202 ms

mtouch (after)
		Total time: 34840 ms

* Add XM support for RemoveUserResourcesSubStep

* Tests supplied by @chamons
2016-11-01 13:11:25 -04:00
Sebastien Pouliot 953e189c85 Bump version to 10.5 to avoid confusion with cycle9 branch 2016-11-01 11:54:46 -04:00
Rolf Bjarne Kvinge ac98469ddd [mtouch] Run the partial static registrar separately for 32-bit and 64-bit. (#1078)
Run the partial static registrar separately for 32-bit and 64-bit, since this
is required with the upcoming changes to embed metadata tokens inside the
generated output, because the metadata tokens are different between the 32-bit
and 64-bit versions of Xamarin.iOS.dll.

Also make sure to properly resolve the 32-bit and 64-bit assemblies correctly
(by setting the ArchDirectory on the assembly resolver), so that we don't pick
up the reference assembly (which does not have the right metadata tokens).

Additionally stop running the partial static registrar for MonoTouch.Dialog-1,
since with the upcoming changes to use metadata tokens in the generated
output, we won't support registering anything more than once. This shouldn't
make much of an impact, because MonoTouch.Dialog-1 is fairly small, and
doesn't take long to register in the dynamic registrar. For device builds (or
when the static registrar is selected) this has no effect, since in that case
we're registering everythinga anyway.
2016-11-01 16:41:41 +01:00
Rolf Bjarne Kvinge 70cea2e7a3 Add a MTOUCH_VERBOSITY make variable to toggle verbosity depending on the V variable. (#1081) 2016-11-01 16:38:43 +01:00
Rolf Bjarne Kvinge 3e19d604a1 [mtouch] Link the executable with LinkWith attributes' libraries in the simulator when doing incremental builds. (#1080)
Link the executable with LinkWith attributes' libraries in the simulator when
doing incremental builds, since we don't create dylibs there.

Fixes several mtouch test failures:

1) Test Failure : Xamarin.MTouch.FastDev_NoFastSim_LinkAll(Unified)
2) Test Failure : Xamarin.MTouch.FastDev_NoFastSim_LinkAll(TVOS)
3) Test Failure : Xamarin.MTouch.FastDev_NoFastSim_LinkSDK(Unified)
4) Test Failure : Xamarin.MTouch.FastDev_NoFastSim_LinkSDK(TVOS)
5) Test Failure : Xamarin.MTouch.FastDev_NoFastSim_NoLink(Unified)
6) Test Failure : Xamarin.MTouch.FastDev_NoFastSim_NoLink(TVOS)
7) Test Failure : Xamarin.MTouch.FastDev_Sim(Unified)
8) Test Failure : Xamarin.MTouch.FastDev_Sim(TVOS)
2016-11-01 16:31:10 +01:00
Rolf Bjarne Kvinge 23b693c5ff [mtouch] Update mdb files even if the corresponding assembly didn't change. Fixes #39535. (#1072)
Update mdb files even if the corresponding assembly didn't change, because the
mdb can change even if the assembly didn't (if whitespace was modified in the
source code, causing code lines to move).

https://bugzilla.xamarin.com/show_bug.cgi?id=39535
2016-11-01 15:37:37 +01:00
Rolf Bjarne Kvinge 5415c90092 [xharness] Add support for running the mtouch tests on Jenkins. (#1077) 2016-11-01 14:43:37 +01:00
Sebastien Pouliot 11390f119c [mtouch] Don't set Force when the cache is invalid (as it will be deleted) (#1016)
If the cache is invalid we print a warning:

> A full rebuild will be performed because the cache is either incomplete or entirely missing.

and set `Driver.Force = true;` (in Application.cs).

This later means that extracting the native code is done on each target:

```
		public static bool IsUptodate (string source, string target)
		{
			if (Driver.Force)
				return false;
```

even if this is identical between 32 and 64 bits (targets). That's
inefficient and, for large binding libraries (e.g. > 1GB), has a
noticable impact on build time (see timestamps).

Considering that the cache is cleaned (when detected as invalid) then
this Force condition is not really needed.

E.g. in `IsUptodate`
* the first time (arch) it's called will have to extract the native library;
* if a 2nd arch is built (fat) then it will be found as present and will
  not be extracted again

Removing the `Driver.Force = true;` in this condition let the `-f` option
continue to extract it twice, which can be useful in debugging and testing.
As such the check is not removed from `IsUptodate`

Timestamps (before)

		Setup: 25 ms
		Resolve References: 1605 ms
		Extracted native link info: 10465 ms
		...

Timestamps (after)
		Setup: 24 ms
		Resolve References: 1560 ms
		Extracted native link info: 5473 ms
		...

Total build times (from XS) was around 90-100 seconds so 5 seconds is
about 10%. The actual savings will depend on how much native code needs
to be extracted, but it should help most release builds (almost always
fat builds).
2016-11-01 09:10:09 -04:00
Sebastien Pouliot 4bb5c6d255 [mtouch] Remove incorrect comment and extraneous call to LoadSymbols (#1013)
* Comment is wrong: the code is never executed in parallel

* If reached then RemoveResources will be called and already check for
  symbols (and load them when needed). Just a simplification (it won't
  really save time as it's not loaded twice)
2016-11-01 09:09:27 -04:00
Rolf Bjarne Kvinge 4aea22ef15 [ObjCRuntime] Store a pointer to the initialization options in managed memory. (#1076)
This makes it possible to access the initialization options at a later point
(soon to be used by the registrar).
2016-11-01 12:40:51 +01:00
Sebastien Pouliot 4a2648e38f [mtouch] Remove the code to reset the resolver as it does nothing (#1012)
IIRC this used to be needed with a (rather old) version of Cecil.
The current code does nothing as the Load will only hit the cache
and not other properties are changed (compared to the old commented
code)
2016-10-31 22:31:22 -04:00
Sebastien Pouliot f015a954ec [mtouch] Add missing HasParameters check inside linker and static registrar (#1010)
* [mtouch] Add missing HasParameters check inside linker and static registrar

Without the checks new, empty collections can be allocated and their
whole and only purpose will be to iterate up to 0 (nop).

The checks saves a small amount of memory (collections) and time.

* [registrar] Fix method comparison when they have no parameters
2016-10-31 22:31:07 -04:00
Sebastien Pouliot eb34a6a74f [mtouch] Reduce the number of file lookups inside AssemblyResolver (#1009)
The SDK does not ship any, non-tool, .exe files. In fact .exe _should_
never need to be resolved since the main .exe is always given as an input
to mtouch.

Still it's possible (if quite uncommon) to refer to other .exe assemblies
just like if they were .dll. However those can only come from the
RootDirectory (and not the other places that ship with the SDK).

This "fix" ensure lookups for *.exe is done only inside the RootDirectory
location, speeding up (a bit) resolving assemblies.
2016-10-31 22:30:32 -04:00
Rolf Bjarne Kvinge c521bfde62 [mtouch] Don't link native libraries into the main executable if we're doing an incremental build. Fixes #42473. (#1073)
Native libraries are already linked into the dylib for the binding assembly,
which means that if we also link it into the main executable, the native code
ends up twice in the app (which is bad for many reasons).

https://bugzilla.xamarin.com/show_bug.cgi?id=42473
2016-10-31 16:55:45 -04:00
Rolf Bjarne Kvinge 1c81c8a5a8 [mtouch] Improve logging a bit. (#1071)
* Show log statements from assembly comparison.
2016-10-31 16:53:02 -04:00
Rolf Bjarne Kvinge e8789f2af6 [mtouch] Copy frameworks referenced by watch extensions to the bundle. (#1070)
Watch extensions do not have access to the containing app bundle on the phone,
so instead copy frameworks to the extension itself.
2016-10-31 17:02:37 +01:00
Rolf Bjarne Kvinge 0b3ab9cc15 [mtouch] Copy third-party frameworks from extensions to the main app's Frameworks directory. Fixes #45800. (#1069)
The container app may not reference the same third-party frameworks as
extensions, which means that we must make sure the extension's frameworks are
also included in the app bundle.

So when building extensions save a list of all third-party frameworks, and
then read that list and include those frameworks when building the main app.

https://bugzilla.xamarin.com/show_bug.cgi?id=45800
2016-10-31 12:36:06 +01:00
Chris Hamons 612f52bd80 Fix binding project LinkWithAttributes generation to prevent unnecess… (#1029)
* Fix binding project LinkWithAttributes generation to prevent unnecessary rebuilds

- https://bugzilla.xamarin.com/show_bug.cgi?id=45762

* Remove duplicate ToString call
2016-10-31 10:37:10 +01:00
Rolf Bjarne Kvinge f1af70998f [tests] Fix test compilation. (#1065) 2016-10-31 10:09:57 +01:00
Chris Hamons 0443d38028 [xm] Fix multiple NullAllowed issues in NSMenu (#1068)
- https://bugzilla.xamarin.com/show_bug.cgi?id=46162
2016-10-28 20:49:33 -04:00
Sebastien Pouliot e6b65f2a7e Bump Xcode 8.1 to the final version (#1062) 2016-10-28 20:48:29 -04:00
Rolf Bjarne Kvinge 1ca1c3a004 Bump mono requirement to fix mmp tests. (#1066)
This fixes the following mmptests:

1) Classic_NewRefCount_Warns (Xamarin.MMP.Tests.MMPTests.Classic_NewRefCount_Warns)
2) SystemMono_SmokeTest (Xamarin.MMP.Tests.MMPTests.SystemMono_SmokeTest)

That fails like this with earlier versions of Mono 4.8:

    Undefined symbols for architecture i386:
      "_mono_btls_x509_lookup_method_mono_init", referenced from:
         -u command line option
      "_mono_btls_x509_name_list_add", referenced from:
         -u command line option
      "_mono_btls_x509_name_list_free", referenced from:
         -u command line option
      "_mono_btls_x509_name_list_get_count", referenced from:
         -u command line option
      "_mono_btls_x509_name_list_get_item", referenced from:
         -u command line option
      "_mono_btls_x509_name_list_new", referenced from:
         -u command line option
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    error MM5109: Native linking failed with error code 1.  Check build log for details.
2016-10-28 14:22:58 -04:00
Rolf Bjarne Kvinge 0c43ddc615 Disable managed exception marshaling when the debugger is attached. Fixes #45116. (#1055)
Managed exception marshaling interferes with the debugger, because it adds
exception handlers to executing code, which makes the Mono runtime think an
exception is handled when logically it's not (although technically it is).

The consequence is that the IDEs will only be notified when we re-throw the
exception after catching it, making it impossible for the IDEs to stop when
the exception is thrown (they will instead stop when we re-throw the
exception).

So disable managed exception marshaling (unless the user changed the default
behavior) when a debugger is attached.

This is the same behavior as Xamarin.Android.

https://bugzilla.xamarin.com/show_bug.cgi?id=45116
2016-10-28 19:07:01 +02:00
Rolf Bjarne Kvinge 4371ea4540 [static registrar] Fix registration of generic types. Fixes #44926. (#1063)
https://bugzilla.xamarin.com/show_bug.cgi?id=44926
2016-10-28 18:42:45 +02:00
Manuel de la Pena 31a07e3bf1 [AVFoundation] Add new constructor for AVAssetExportSession. (#1037)
* [AVFoundation] Add new constructor for AVAssetExportSession.

Add a new constructor that takes an enum instead of a string to have
a strong typed version of the default constructor to reduce possible
errors when passing a random string.

Fixes bug https://bugzilla.xamarin.com/show_bug.cgi?id=44443

* Use smart enums as requested in the PR review.

* Set manually the enum int values.
2016-10-28 17:52:34 +02:00
Rolf Bjarne Kvinge dde242c32a Allow using LinkWith attribute without a native library. (#997)
This makes it possible to set linker flags per assembly:

    [assembly: LinkWith (LinkerFlags = "-lsqlite3")]

Which is required when incremental builds is enabled and a particular assembly
needs special linker flags (because we don't propagate the global -gcc_flags
to each dylib we build when doing incremental builds).

Also add an option to set the dlsym mode for an assembly (using the LinkWith
attribute).
2016-10-28 10:50:42 -04:00
Rolf Bjarne Kvinge b6a0d06143 [tests] Remove dead code. (#1056) 2016-10-28 10:15:12 -04:00
Rolf Bjarne Kvinge bdbbea962a [tests] Unifiy namespaces in mtouch tests. (#1057) 2016-10-28 10:15:00 -04:00
Rolf Bjarne Kvinge f6d7ddb9f1 [docs] Remove mention of old Xamarin.iOS version. (#1059)
There's no need to mention that something was introduced in Xamarin.iOS 5.2.
2016-10-28 10:11:50 -04:00
Rolf Bjarne Kvinge 7e3cdb35f4 [docs] Document that the LinkWith.LinkTarget property is ignored. (#1060) 2016-10-28 10:11:42 -04:00
Rolf Bjarne Kvinge 6104a514fc [registrar] Cache the System.Void type. (#1024)
Duration before: 1,60s
Duration after:  1,54s
Difference:     -0,06s = -3,8%

Memory usage hardly changed (-21 kb of 540 MB), but the number of method calls
shrunk significantly.

Method calls before: 86.720.379
Method calls after:  74.390.061
Difference:         -12.330.318 = -14,2%

The call to `GetSystemVoidType` was #2 on the list of method calls (whens
sorted by 'self'), called 1072 times taking 1429 ms each time. After this
change it's only called once (and obviously pushed way down the list).
2016-10-28 09:52:58 -04:00
Rolf Bjarne Kvinge ea1a08785d [mtouch] Verify the correct SDK version when referencing frameworks from watchOS projects. (#1058) 2016-10-28 09:16:35 -04:00
Vincent Dondain 5d25bdc754 [mtouch/tests] BuildAndLaunchTime + RegistrarTime test (#1051)
- BuildAndLaunchTime is replacing AppLaunchTime as it calculates both
  build time and launch time for different linker modes.

* [mtouch/tests] Add RegistrarTime test

- Also fix MTouchTool --registrar:dynamic
2016-10-28 08:44:13 -04:00
Rolf Bjarne Kvinge 4e62423fcd [system-dependencies] Add support for installing Xcode's first-launch installs, and fix xip extraction. (#1041)
* [system-dependencies] Add support for installing Xcode's first-launch installs.

* [system-dependencies] Use the Archive Utility to extract Xcode xips.

Apple changed their format (again), so don't try to process the xip manually,
just invoke Apple's Archive Utility.

Another advantage is that the Archive Utility compresses the output (to about
half), saving multiple GB of hard disk space (from ~10 GB to ~5 GB).

* [system-dependencies] Add Xcode testing comment.

* [system-dependencies] Check if an Xcode package is in ~/Downloads, and if so use it.

This makes it easier to verify that provisioning works correctly whenever a new Xcode comes out.
2016-10-28 08:42:25 -04:00
Rolf Bjarne Kvinge 852209e72e [src] Fix project templates. (#1045) 2016-10-28 08:39:07 -04:00
Rolf Bjarne Kvinge a1644f6e13 [registrar] Improve an error message. (#1047) 2016-10-28 08:38:38 -04:00
Rolf Bjarne Kvinge 8cca6171cb [ObjCRuntime] Remove dead code. (#1046) 2016-10-28 08:37:47 -04:00
Rolf Bjarne Kvinge d1df84e01e [docs] Show bugzilla links (and to the right product) whenever it makes sense. (#1048) 2016-10-28 08:37:16 -04:00
Rolf Bjarne Kvinge 21eb5d5355 [ObjCRuntime] Simplify dynamic registrar creation a little bit. (#1044)
There's only one dynamic registrar now, so no need to make it complicated (nor
does the linker process this code anymore).
2016-10-28 08:33:57 -04:00
Rolf Bjarne Kvinge 23a0186a99 [registrar] Fix compiler warning. (#1054) 2016-10-28 08:33:18 -04:00
Chris Hamons b5edf16711 [XM] Teach XM resolver to load all of assemblies into memory (#1034)
- Profiling suggesting that loading all of sub-100 MB assemblies into
 memory is a performance win, and mtouch already does it.
2016-10-28 08:28:43 -04:00
Rolf Bjarne Kvinge c6d7a3adec [linker] Use ordinal instead of invariant comparison. (#1025)
Profiled when running the partial static registrar on Xamarin.iOS.dll

Duration before: 1,60s
Duration after:  1,41s
Difference:     -0,19s = -11,9%

Memory usage before: 541.887.736 bytes
Memory usage after:  509.111.944 bytes
Difference:          -32.775.792 bytes = -6,0%

Method calls before: 86.720.379
Method calls after:  63.073.602
Difference:         -23.646.777 = -27,3%
2016-10-28 08:28:02 -04:00
Rolf Bjarne Kvinge ab58a1f808 Bump mono to get fix for #45223. (#1053)
commit mono/mono@a06e82f6c0
    Author: Aleksey Kliger <aleksey@xamarin.com>
    Date:   Fri Oct 21 11:00:04 2016 -0400

    [coop handles] Don't scan null object references

    Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=45223
2016-10-28 13:03:54 +02:00
Sebastien Pouliot 81c94cd683 Update XML definition for XM C8SR1 (from cycle8 branch) 2016-10-27 18:37:25 -04:00
Rolf Bjarne Kvinge 3cf1b75749 [generator] Use ordinal string comparison. (#1022)
Test results when running the generator for XM/full:

Profile output size before: 9,4 GB
Profile output size after:  5,6 GB

Duration before: 21,5 s
Duration after:  19,0 s
Difference:     - 2,5 s = -11,6 %

Total memory usage barely changed (5kb less within a total of 1,0 GB),
but the number of method calls fell drastically:

Method calls before: 868.053.383
Method calls after:  492.325.187
Difference:        - 375.728.196 = -43,3%

The top 10 method calls also changed significantly.

Method call summary before

```
Total(ms) Self(ms)      Calls Method name
  128879    28400    3509251 Mono.Globalization.Unicode.SimpleCollator:CompareInternal (string,int,int,string,int,int,bool&,bool&,bool,bool,Mono.Globalization.Unicode.SimpleCollator/Context&)
   16074    16074   79118946 Mono.Globalization.Unicode.CodePointIndexer:ToIndex (int)
   15952    10492   26747901 Mono.Globalization.Unicode.MSCompatUnicodeTable:Category (int)
   26425    10473   26747901 Mono.Globalization.Unicode.SimpleCollator:Category (int)
   14743     8679   14952304 Mono.Globalization.Unicode.MSCompatUnicodeTable:IsIgnorable (int,byte)
   31345     8113   10413595 System.RuntimeType:GetBaseType ()
   12266     7303   12523021 Mono.Globalization.Unicode.SimpleCollator:GetContraction (string,int,int)
   20555     5812   14952304 Mono.Globalization.Unicode.SimpleCollator:IsIgnorable (int,System.Globalization.CompareOptions)
   93341     5529    2674913 System.MonoCustomAttrs:GetCustomAttributes (System.Reflection.ICustomAttributeProvider,System.Type,bool)
    8229     5337   13551378 System.RuntimeType:GetAttributeFlagsImpl ()
```

Method call summary after

```
Total(ms) Self(ms)      Calls Method name
   31646     8168   10412459 System.RuntimeType:GetBaseType ()
   94899     5672    2674880 System.MonoCustomAttrs:GetCustomAttributes (System.Reflection.ICustomAttributeProvider,System.Type,bool)
    8343     5395   13550176 System.RuntimeType:GetAttributeFlagsImpl ()
    5646     5243    2914268 (wrapper managed-to-native) System.MonoCustomAttrs:GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type,bool)
    5147     5147    9727785 (wrapper managed-to-native) object:__icall_wrapper_ves_icall_array_new_specific (intptr,int)
   11140     4432   10948127 System.Type:get_Attributes ()
   19601     4362   10716826 System.Type:get_IsInterface ()
   15238     4344   10716826 System.RuntimeTypeHandle:IsInterface (System.RuntimeType)
    4133     4133          1 (wrapper managed-to-native) System.Threading.WaitHandle:WaitOne_internal (intptr,int)
    5922     3851    9541170 (wrapper stelemref) object:virt_stelemref_class (intptr,object)
```
2016-10-27 18:34:05 -04:00
Rolf Bjarne Kvinge d0209f4b27 [src] Improve makefile to create correct directories for pmcs.exe. (#1021) 2016-10-27 17:48:24 -04:00
Sebastien Pouliot 405bf0e979 [mtouch] Fix MT1009 to report the inner exception (#1008)
Found out it was missing by breaking (locally) something else :)
2016-10-27 17:45:33 -04:00