[fpc-pascal] Inline methods

Sven Barth pascaldragon at googlemail.com
Mon May 23 17:18:36 CEST 2016


Am 23.05.2016 11:37 schrieb "LacaK" <lacak at zoznam.sk>:
>
> Dňa 20.5.2016 o 14:42 Sven Barth napísal(a):
>
>>
>> Am 19.05.2016 08:52 schrieb "LacaK" <lacak at zoznam.sk <mailto:
lacak at zoznam.sk>>:
>> >
>> >
>> >>
>> >> >> Additionally, it's possible that it's not possible to inline
generic routines in regular routines,
>> >> >
>> >> > It is not my case.
>> >> > I use this generic in another generic and then it is specialized in
interface section of same unit.
>> >> >
>> >> > Later this specialized object is used in another class type, which
comes after specialization.
>> >> > So this object is not used in regular procedure, but in methods of
another class ...
>> >> >
>> >> > I did also attempt to put all this stuff (with generics and
specializations) into separate unit and then I have used this unit ( in
interface section ) in "main" unit
>> >> > But still does not inline ...
>> >>
>> >> You need to call the function in another unit than where the
specialization is.
>> >>
>> > Yes I do it so (in attached example it is in one unit, but in my real
generic and specialization is in separate unit, that is used by another in
interface section)
>> >
>> >
>> >> Maybe provide a small (compileable) example that shows what you're
doing so that we can check that ourselves.
>> >>
>> > Attached
>>
>> Moving GT and T1 to a separate unit results in inlined code, as expected
(tested with 2.6.4, 3.0.0 and 3.1.1), also if T2 is in another separate
unit.
>>
>
> Yes I can confirm, that this works .
> So if I have specialized object type (with inline methods), which is used
by another type in same unit inline methods are not inlined ?
> (assume, that specialized type is defined before type which uses it in
interface section and is implemented also before in implementation section)

Your assumption is correct.

> Can this be fixed or is this some kind of design limitation, which can
not be bypassed (nor in future) ?

This *might* get fixed in the future. After all by definition inlining is
completely up to the compiler, so even if you add "inline" to some method
or function there is no guarantee that it will be inlined.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160523/81ca09ca/attachment.html>


More information about the fpc-pascal mailing list