[linker] Instead of preserving every method with a [Register] attribute...
authorRadek Doulik <rodo@xamarin.com>
Fri, 5 Jun 2015 11:42:03 +0000 (13:42 +0200)
committerRadek Doulik <rodo@xamarin.com>
Sun, 19 Jul 2015 08:42:43 +0000 (10:42 +0200)
[merged from monodroid by rodo]

part of

commit 0b9c100b60fc2502a0d6347d50cac444bb82b285
Author: Jonathan Pobst <monkey@jpobst.com>
Date:   Wed Sep 28 15:50:39 2011 -0500

    Instead of preserving every method with a [Register] attribute on it in Mono.Android.dll, only save the things that the user actually uses.  Reduces HelloWorld release apk by ~1.3MB.

mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs

index a7db9c61aaa6fead564b5693021eb67b29cab7be..c9b66af44ab1d6d16bed8dae33b598a1c3be3da0 100644 (file)
@@ -514,6 +514,8 @@ namespace Mono.Linker.Steps {
                                MarkMethodsIf (type.Methods, IsStaticConstructorPredicate);
                        }
 
+                       DoAdditionalTypeProcessing (type);
+
                        Annotations.Mark (type);
 
                        ApplyPreserveInfo (type);
@@ -521,6 +523,11 @@ namespace Mono.Linker.Steps {
                        return type;
                }
 
+               // Allow subclassers to mark additional things when marking a method
+               protected virtual void DoAdditionalTypeProcessing (TypeDefinition method)
+               {
+               }
+
                void MarkTypeSpecialCustomAttributes (TypeDefinition type)
                {
                        if (!type.HasCustomAttributes)
@@ -961,11 +968,18 @@ namespace Mono.Linker.Steps {
                        if (ShouldParseMethodBody (method))
                                MarkMethodBody (method.Body);
 
+                       DoAdditionalMethodProcessing (method);
+
                        Annotations.Mark (method);
 
                        ApplyPreserveMethods (method);
                }
 
+               // Allow subclassers to mark additional things when marking a method
+               protected virtual void DoAdditionalMethodProcessing (MethodDefinition method)
+               {
+               }
+
                void MarkBaseMethods (MethodDefinition method)
                {
                        IList base_methods = Annotations.GetBaseMethods (method);