[fpc-devel] win64 calling convention
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Thu Nov 29 22:36:19 CET 2012
Martin schrieb:
> Just to confirm my observations. (again trying to get pascal script to
> work)
> 64 bit windows
>
> procedure FOO(Sender: TSynEdit; const M: String; const P1, P2: TPoint);
>
> "const P1, P2: TPoint" versus "P1, P2: TPoint"
>
> if "const" is NOT used, then TPoint is put into a register
> if "const" is used, then TPoint is in mem, and the register is a reference.
>
> Is that right? (I know the doc says, no assumption, and can be ref or
> value)
In Delphi it's clear:
Without "const" the data *must* be copied (by-val), so that the
subroutine cannot change the original data.
"const" *allows* the compiler to pass the original data structure
by-ref, because the subroutine will not change the data. Whether the
parameter is passed by value or reference depends, on e.g. the sizeof
the data structures and pointers, and whether optimizing for speed or size.
FPC has added "constref", definitely forcing by-ref. AFAIR this was
required for the ObjectiveC interface.
DoDi
More information about the fpc-devel
mailing list