[fpc-devel] Inline methods
Ludo Brands
ludo.brands at free.fr
Wed Jan 16 12:16:32 CET 2013
Hi,
I'm running into a strange problem with inline methods.
TCircularBuffer=class
...
Pin:pointer;
Pout:pointer;
function IsFull:boolean;inline;
end;
function TCircularBuffer.IsFull: boolean;inline;
begin
result:=PIn=POut;
end;
When the method is called from outside the class then it is inlined (x64
linux):
dbcacheservercore.pas:197 if FBuffer[currbuf].IsFull then
0x000000000048e4bf <+47>: mov -0x18(%rbp),%rax
0x000000000048e4c3 <+51>: mov 0x8(%rax),%rdx
0x000000000048e4c7 <+55>: movslq -0x24(%rbp),%rax
0x000000000048e4cb <+59>: mov (%rdx,%rax,8),%rax
0x000000000048e4cf <+63>: mov %rax,-0x30(%rbp)
0x000000000048e4d3 <+67>: mov -0x30(%rbp),%rax
0x000000000048e4d7 <+71>: mov -0x30(%rbp),%rdx
0x000000000048e4db <+75>: mov 0x28(%rax),%rax
0x000000000048e4df <+79>: cmp 0x30(%rdx),%rax
0x000000000048e4e3 <+83>: sete %al
0x000000000048e4e6 <+86>: test %al,%al
0x000000000048e4e8 <+88>: je 0x48e585 <ADD+245>
But when the method is called from inside the class then a call is used:
dbcacheservercore.pas:109 if IsFull then
0x000000000048dfc8 <+24>: mov -0x18(%rbp),%rdi
0x000000000048dfcc <+28>: callq 0x48e170 <ISFULL>
0x000000000048dfd1 <+33>: test %al,%al
0x000000000048dfd3 <+35>: jne 0x48e042 <ADD+146>
Using Self.IsFull results in the same code.
FPC 2.6.0 and 2.7.1 from today.
A bug?
Thanks, Ludo
More information about the fpc-devel
mailing list