On Tue, 16 Jul 2019, Ben Grasset wrote:

On Tue, Jul 16, 2019 at 5:28 AM Sven Barth via fpc-devel <
fpc-devel@lists.freepascal.org> wrote:

The output will then be two different addresses, thus showing that the
code had been generated twice.

However the compiler/linker is good at leaving out unused code and in this
case only the two Assign specializations are kept as their addresses are
taken, everything else is discarded. If you'd change one of the two to
another non-virtual method then Assign of the one specialization and the
other method of the other specialization would be kept.

If you use virtual methods inside generics then things are less likely to
be removed.


Ah, I understand now.

I guess my point overall was that, in my experience at least, while there's
indeed probably room for improvement in that area via something like WPO /
COMDAT support / e.t.c. as you'd suggested, the overall effect of generics
in FPC on binary size is not *unreasonable*.

I use Delphi only semi-regularly, but it does seem to be somewhat more of
an actual issue there (as frankly binary size in recent Delphis is in
general, with generics or not, when compared to FPC.)

I suspect this is also in part due to the liberal and generous use of extended 
RTTI.

Michael.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to