Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-11

win64 calling convention

6 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

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)

Reply by email

Jonas Maebe
to Martin
Martin wrote 11 lines
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)

And it can change at any time. Interfacing with such routines at the assembler level is simply not supportable in FPC code, and trying to do so anyway is guaranteed to only lead to much frustration. Either use constref (by reference) or a value parameter (by value).

Jonas

Reply by email

Hans-Peter Diettrich
to Martin: Just to confirm my observations. (again trying to get pascal script to work) 64 bit…
Show quoted text 13 lines
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

Reply by email

luiz americo pereira camara
to Martin: Just to confirm my observations. (again trying to get pascal script to work) 64 bit…

2012/11/29 Martin :

Just to confirm my observations. (again trying to get pascal script to work) 64 bit windows

Recently, i faced similar situation (porting assembly to 64bit).

You can look there how i managed:

http://lazarus-ccr.svn.sourceforge.net/viewvc/lazarus-ccr/components/virtualtreeview-new/branches/4.8/include/intf/win32/vtgraphicsi.inc?r1=2543&r2=2544

You can take into account also that Win64 is different from non windows

See that i needed to ifdef in qt:

http://lazarus-ccr.svn.sourceforge.net/viewvc/lazarus-ccr/components/virtualtreeview-new/branches/4.8/include/intf/qt/vtgraphicsi.inc?r1=2534&r2=2548

Luiz

Show quoted text 15 lines
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) _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Michael Schnell
to Martin: Just to confirm my observations. (again trying to get pascal script to work) 64 bit…
Martin wrote 10 lines
Just to confirm my observations. (again trying to get pascal script to work) 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)

It does make sense.

"Not const" forces copying the data during the function all, "const" uses the (supposedly) more efficient call by reference, while the compiler prevents modifying the data.

(Beware that with objects the object reference is the "variable", and not the object instance.)

-Michael

Reply by email