[fpc-devel] "Maybe Gareth can be convinced to spend his energy on this ... "

Ben Grasset operator97 at gmail.com
Thu Jun 27 16:23:28 CEST 2019


On Thu, Jun 27, 2019 at 8:15 AM Sven Barth via fpc-devel <
fpc-devel at lists.freepascal.org> wrote:

> I think having record fields in registers would already go a long way.
> Global variables aren't used /that/ often in modern, object oriented code
> anyway.
>

Aren't they already?
<https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:pascal,source:'unit+output%3B%0A%0A%7B$mode+ObjFPC%7D%7B$H%2B%7D%0A%7B$ImplicitExceptions+Off%7D%0A%0Ainterface%0A%0Auses+SysUtils%3B%0A%0Atype+%0A++TRec+%3D+record%0A++++A:+LongInt%3B%0A++++B:+Double%3B%0A++++C:+String%5B8%5D%3B%0A++++D:+Boolean%3B%0A++end%3B%0A%0Avar+R:+TRec+%3D+(A:+1%3B+B:+2.35%3B+C:+!'ABCDEFGH!'%3B+D:+True)%3B%0A%0Aprocedure+TakesARecordByValue(Rec:+TRec)%3B%0Aprocedure+TakesARecordByReference(constref+Rec:+TRec)%3B%0A%0Aimplementation%0A%0Aprocedure+TakesARecordByValue(Rec:+TRec)%3B%0Abegin%0A++with+Rec+do+%0A++++WriteLn(Format(!'%5BA:+%25d,+B:+%25f,+C:+%25s,+D:+%25d%5D!',+%5BA,+B,+C,+Ord(D)%5D))%3B%0Aend%3B%0A%0Aprocedure+TakesARecordByReference(constref+Rec:+TRec)%3B%0Abegin%0A++with+Rec+do+%0A++++WriteLn(Format(!'%5BA:+%25d,+B:+%25f,+C:+%25s,+D:+%25d%5D!',+%5BA,+B,+C,+Ord(D)%5D))%3B%0Aend%3B%0A%0Aend.%0A'),l:'5',n:'0',o:'Pascal+source+%231',t:'0')),k:55.826666565704016,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:fpc304,filters:(b:'0',binary:'1',commentOnly:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1'),lang:pascal,libs:!(),options:'-O3+-Ci-+-Cr-+-g-+-CX+-XXs',source:1),l:'5',n:'0',o:'x86-64+fpc+3.0.4+(Editor+%231,+Compiler+%231)+Pascal',t:'0')),k:42.8345650377193,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,wrap:'1'),l:'5',n:'0',o:'%231+with+x86-64+fpc+3.0.4',t:'0')),k:1.3387683965766675,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4>

As far as I've ever been able to surmise, the general problem is more that
people continue to think they can pass records by value and have the
compiler optimize the access for them, which it just simply doesn't.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190627/2b540b38/attachment-0001.html>


More information about the fpc-devel mailing list