[fpc-devel] Passing parameters through the stack to interfaces

Hans-Peter Diettrich DrDiettrich1 at aol.com
Thu Aug 5 21:54:38 CEST 2010

Joost van der Sluis schrieb:

> It seems like that when you call a method of an interface, a 'hidden'
> wrapper is generated by the compiler to adjust the 'self' parameter so
> that it does not refers to the interface-pointer, but the actual
> class-pointer.

This is common practice, also in C++.

> The problem is only that the extra 'call' which is made adds one extra
> value to the stack, so that the parameters which are passed on the stack
> are all shifted. This is especially troublesome when the method is
> defined as cdecl and the 'self' parameter itself is also passed using
> the stack. (self is not on the location EBP+8 anymore, but EBP+12)

This argument shift IMO could be fixed by tail-call optimization.


More information about the fpc-devel mailing list