Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dotnet][linker] Enable the sealer optimization #12009

Merged
merged 7 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@
-->
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --disable-opt unusedtypechecks</_ExtraTrimmerArgs>

<!-- If a release build and the app is not extensible (no interpreter or JIT/code-loading for macOS) then the sealer optimization can be used -->
<_ExtraTrimmerArgs Condition="'$(_BundlerDebug)' != 'true' And '$(MtouchInterpreter)' == '' And '$(_RunAotCompiler)' == 'true' And '$(_PlatformName)' != 'macOS'">$(_ExtraTrimmerArgs) --enable-opt sealer</_ExtraTrimmerArgs>

<!-- We always want the linker to process debug symbols, even when building in Release mode, because the AOT compiler uses the managed debug symbols to output DWARF debugging symbols -->
<TrimmerRemoveSymbols Condition="'$(TrimmerRemoveSymbols)' == ''">false</TrimmerRemoveSymbols>

Expand Down
20 changes: 11 additions & 9 deletions tests/linker/ios/link all/SealerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ public class Subclass : Base, Interface {
[Preserve (AllMembers = true)]
public class SealerTest {

#if !DEBUG && NET
[Ignore ("https://github.com/xamarin/xamarin-macios/issues/9573")]
#if NET
[SetUp]
public void SetUp ()
{
// XML serialization mechanism is controlled by RuntimeFeature.IsDynamicCodeSupported
// which will be true for simulator / JIT builds
// so the optimization is disabled unless AOT is used
TestRuntime.AssertDevice ();
}
#endif

[Test]
public void Sealed ()
{
Expand All @@ -62,9 +70,6 @@ public void Sealed ()
#endif
}

#if !DEBUG && NET
[Ignore ("https://github.com/xamarin/xamarin-macios/issues/9573")]
#endif
[Test]
public void Final ()
{
Expand All @@ -81,13 +86,10 @@ public void Final ()
// but it can be optimized / sealed as nothing else is (or can) overrides it
Assert.True (a.IsFinal, "A");
Assert.True (b.IsFinal, "B");
Assert.True (c.IsFinal, "C");
Assert.False (c.IsFinal, "C"); // devirtualized
#endif
}

#if !DEBUG && NET
[Ignore ("https://github.com/xamarin/xamarin-macios/issues/9573")]
#endif
[Test]
public void Virtual ()
{
Expand Down
1 change: 1 addition & 0 deletions tools/linker/MonoTouch.Tuner/SealerSubStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected override void Process (TypeDefinition type)
// look if this method is an override to existing _marked_ methods
if (!AreMarked (bases)) {
method.IsVirtual = false;
method.IsFinal = false; // since it's not virtual anymore
#if DEBUG
Console.WriteLine ("Devirtualize {0} ({1})", method, ++devirtualize);
#endif
Expand Down