Simple example
{$MODE OBJFPC}
unit Unit1;
interface
uses Classes;
type
T1 = class(TObject)
private
FList: TList;
function GetCount: Integer; inline;
public
constructor Create;
destructor Destroy; override;
property Count: Integer read GetCount;
end;
implementation
constructor T1.Create;
begin
inherited;
FList := TList.Create;
FList.Add(nil);
end;
destructor T1.Destroy;
begin
FList.Free;
inherited;
end;
function T1.GetCount: Integer;
begin
Result := FList.Count;
end;
end.
{$MODE OBJFPC}
{$APPTYPE CONSOLE}
program Project1;
uses unit1;
var
C1: T1;
Cnt: Integer;
begin
C1 := T1.Create;
try
Cnt := C1.Count;
Writeln(Cnt);
finally
C1.Free;
end;
Readln;
end.
Even with the optimization turned off, the source code on the assembler:
# [13] Cnt := C1.Count;
movq U_$P$PROJECT1_$$_C1(%rip),%rax
movq 8(%rax),%rcx
call CLASSES$_$TLIST_$__$$_GETCOUNT$$LONGINT
movl %eax,U_$P$PROJECT1_$$_CNT(%rip)
That is, the code is inlined.
FPC 3.0.4, Win64.
By the way, Delphi inlining this code only if there is "uses Classes" in the place of the call.