[fpc-devel] Proposal/discussion: Simple nested functions and 'outlining'

J. Gareth Moreton gareth at moreton-family.com
Thu Oct 1 18:37:16 CEST 2020


Hi everyone,

This is an idea that sprung to mind while looking at fixing an unrelated 
bug, and that's to do with nested functions.

In situations where a nested function has no parameters, is it feasible 
and beneficial to programmatically merge it into the main procedure in 
some circumstances (it wouldn't be possible if the nested routine has 
inline assembly language because RET won't behave the same, for 
example), using jumps to navigate to, from and around it? I know for one 
thing it will possibly free up a register in some calculations because 
it doesn't have to pass the base pointer (e.g. RBP) as a hidden parameter.

On a similar topic, one person mentioned that GCC and other compilers 
sometimes 'outline' conditional branches by effectively moving the 
branch into a nested procedure in order to help with caching.by giving 
the main procedure a smaller memory footprint.

Might this be something worth researching?

Gareth aka. Kit


-- 
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the fpc-devel mailing list