[fpc-devel] Local procedures as procedural parameter
Adriaan van Os
fpc at microbizz.nl
Wed Mar 16 17:42:36 CET 2005
Jonas Maebe wrote:
> olle.r at automagika.se wrote:
>
>> Example Powerpc with static link first:
>> local
>> static link r3
>> param no 1 r4
>> ...
>>
>> global
>> param no 1 r3
>> ...
>>
>> To avoid this problem, it would be better to have the static link
>> last.
>
> That won't work on x86 when the static link would be on the stack,
> because there the callee removes the parameters from the stack (so if
> it's a global function, it will remove sizeof(pointer) bytes too
> little from the stack.
On x86, you can generate code that checks the static link pointer at
runtime, to see if it is nil or not (e.g. a global function or not).
Then, you pass the static link pointer as the last parameter (for local
procedures) or not (for global procedures).
Regards,
Adriaan van Os
More information about the fpc-devel
mailing list