Sign in Join

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

Mailing lists / fpc-devel / 2012-12

ABI question PPC, ARM: position of SELF

7 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Martin

Does anyone know how self is passed on PPC or ARM?

On the one hand IRRC I read self is passed as additional param at the end of the list.

But looking at intel code 32 bit, it looks like it always goes into EAX (calling method register)
On Intel 64 bit it is RCX or RDI depending on it in Windows or not

What on the others, fixed register, or simply as if it was the last param?

Reply by email

Jonas Maebe
to Martin
Martin wrote
Does anyone know how self is passed on PPC or ARM? On the one hand IRRC I read self is passed as additional param at the end of the list.

I don't think that has ever been the case.

But looking at intel code 32 bit, it looks like it always goes into EAX (calling method register)

That is not true if the method is declared as cdecl or so.

On Intel 64 bit it is RCX or RDI depending on it in Windows or not What on the others, fixed register, or simply as if it was the last param?

It is *currently* (I don't think we specify anywhere how or in what order hidden parameters are passed) always passed as the first parameter. Whether this is a register or a memory location depends on the architecture, ABI and specified calling convention. On PPC resp. ARM this is always R3 resp. R0 with the currently existing ABIs.

Jonas

Reply by email

Martin
to Jonas Maebe
Jonas Maebe wrote 6 lines
On 07 Dec 2012, at 17:51, Martin wrote: > Does anyone know how self is passed on PPC or ARM? > > On the one hand IRRC I read self is passed as additional param at the end of the list. I don't think that has ever been the case.

Ok then I IIRCed wrong...

> But looking at intel code 32 bit, it looks like it always goes into EAX (calling method register) That is not true if the method is declared as cdecl or so.

"(calling method register)" (which I believe is default, if no specification is made?

Show quoted text 5 lines
> On Intel 64 bit it is RCX or RDI depending on it in Windows or not > > What on the others, fixed register, or simply as if it was the last param? It is *currently* (I don't think we specify anywhere how or in what order hidden parameters are passed) always passed as the first parameter. Whether this is a register or a memory location depends on the architecture, ABI and specified calling convention. On PPC resp. ARM this is always R3 resp. R0 with the currently existing ABIs.

Oh ox, I IIRCed half right. "Always first" not "always last"

Thanks for the info.

Yes, I know that this is only the current version, and can change and all the risk.
But today, there is no better way, to use PascalScript in a compiled app. Once a released FPC offers a better way, well great. But till then, I must go the risky way (or not go at all).

I have a testcase, that calls every function I use. So I can at least, test (or ask people to test) with every new fpc version.

Reply by email

Jonas Maebe
to Martin
Martin wrote
But today, there is no better way, to use PascalScript in a compiled app. Once a released FPC offers a better way, well great. But till then, I must go the risky way (or not go at all).

Mixing dynamically calling routines whose calling ABI interface is not rigidly defined is broken by design. The proper way would be to generate cdecl wrappers (because the cdecl calling convention is fully specified in the various ABIs) and calling those.

Jonas

Reply by email

Martin
to Jonas Maebe
Jonas Maebe wrote 6 lines
On 07 Dec 2012, at 18:10, Martin wrote: > But today, there is no better way, to use PascalScript in a compiled app. Once a released FPC offers a better way, well great. But till then, I must go the risky way (or not go at all). Mixing dynamically calling routines whose calling ABI interface is not rigidly defined is broken by design. The proper way would be to generate cdecl wrappers (because the cdecl calling convention is fully specified in the various ABIs) and calling those.

Well ok.

For explanation:

I don't plan to make this my problem right now (it may later force itself, but not now)
My plan was to use PascalScript. Not to rewrite it. Now I already am fixing it (so strictly speaking, those fixes are (as you pointed out) not a real solution)

I looks only 32bit intel has all calling conventions already implemented in PascalScript. The other would need to be written from scratch. Not something, that I plan to do now. After all, it isnt my project. I will contribute those "fixes" that I do need.

Thanks again for all the help. For the rest, I will simple hope, that it works until a better solution exists.

Reply by email

Martin
to Jonas Maebe: I don't think that has ever been the case. That is not true if the method is declared as…
Jonas Maebe wrote 6 lines
> On Intel 64 bit it is RCX or RDI depending on it in Windows or not > > What on the others, fixed register, or simply as if it was the last param? It is *currently* (I don't think we specify anywhere how or in what order hidden parameters are passed) always passed as the first parameter. Whether this is a register or a memory location depends on the architecture, ABI and specified calling convention. On PPC resp. ARM this is always R3 resp. R0 with the currently existing ABIs.

According to the current PascalScript (may be wrong):

looks like on ppc, Result (if static array or record) is also passed before params (on other platforms, it is passed last)

What is the order of Result, and self?

Reply by email

Martin
to Martin
Martin wrote 19 lines
On 07/12/2012 17:03, Jonas Maebe wrote: >> On Intel 64 bit it is RCX or RDI depending on it in Windows or not >> >> What on the others, fixed register, or simply as if it was the last >> param? > It is *currently* (I don't think we specify anywhere how or in what > order hidden parameters are passed) always passed as the first > parameter. Whether this is a register or a memory location depends on > the architecture, ABI and specified calling convention. On PPC resp. > ARM this is always R3 resp. R0 with the currently existing ABIs. > > According to the current PascalScript (may be wrong): looks like on ppc, Result (if static array or record) is also passed before params (on other platforms, it is passed last) What is the order of Result, and self?

Same on arm?

Reply by email