Bug 10291 - Better linked-away codegen
Summary: Better linked-away codegen
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 6.3.x
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2013-02-14 04:08 UTC by Marek Safar
Modified: 2013-02-14 13:16 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Marek Safar 2013-02-14 04:08:15 UTC
Generated linked away code can be ~50% smaller if we used instead of

// 11 bytes
throw new System.NotSupportedException ("Linked away");


code like

// 6 bytes + factory class which is negligible
throw <Linker>$Impl.LinkedAway ();

static class <Linker>$Impl
{
static internsl Exception ()
{
return new NotSupportedException ("Linked away");
}
}


Native code would be smaller as well.
Comment 1 Sebastien Pouliot 2013-02-14 13:16:20 UTC
4f41be6dbb60e8a386658700e79788adf2cbc0cb (master) adds an internal static method LinkAway to NotSupportedException (instead of a new type) and calls it.

That's a good idea but the gains are not really big (if any) because:
a) the linker can eliminate most of them (once their IL is removed); and
b) the IL is stripped in release builds (so the .dll size is identical)

Debug                  mscorlib.dll            linksdk binary *
linksdk before:     1074688                30073184
linksdk after:        1074688 [1]           30074064 [2]

Release                 mscorlib.dll (b)       linksdk binary *
linksdk before:     624640                  9641088
linksdk after:        624640 [3]             9641088 [4]

* this project uses ARMv7 w/LLVM for device builds

[1] the IL reduction is lost in the noise (most cases are totally removed by the linker)
[2] looks like this generates a bit more native code when debugging is enabled (surprising)
[3] once IL is stripped then the size are identical (as expected, (b))
[4] the difference between the generated code is not large enough to be noticable (again lost in noise)