[fpc-devel] Issue with open arrays passed by value

Sergei Gorelkin sergei_gorelkin at mail.ru
Sun Nov 20 17:22:37 CET 2011


Hello,

Currently compiler can place an array of const or open array parameter into register. Moreover, if 
such parameter is passed by value, a local copy is made on heap (except for i386 with non-fixed 
stack where a copy is made on stack).
A local copy on heap must be disposed in 'finally' block (i.e. procedure must get an implicit 
finally block if such parameter is present) and such parameter must not be placed into register. A 
local copy on stack does not have these restrictions.

However, the placement of local copy is determined by codegenerator, which is not available during 
the firstpass. And in tcg.g_copyvaluepara_openarray it is too late to change the location of parameter.

At the moment, I have no better idea than to check paramanager.use_fixed_stack, but it's somewhat 
indirect condition. Are there other possibilities?

Also, what is the correct place to disable placing parameter into register? Is it fixing 
tabstractvarsym.is_regvar, or setting varregable on the parameter, or elsewhere?

Regards,
Sergei



More information about the fpc-devel mailing list