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

2020-10-03 Thread J. Gareth Moreton via fpc-devel
Useful theory.  I'll take a read.  Thank you again. Gareth aka. Kit On 03/10/2020 19:14, Jonas Maebe via fpc-devel wrote: On 03/10/2020 18:43, J. Gareth Moreton via fpc-devel wrote: Sounds like a fun thing to research, that's for sure.  Thanks Jonas. I'm under the impression that exception

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

2020-10-03 Thread Jonas Maebe via fpc-devel
On 03/10/2020 18:43, J. Gareth Moreton via fpc-devel wrote: > Sounds like a fun thing to research, that's for sure.  Thanks Jonas. > > I'm under the impression that exception code tends to be separated > anyway, so it can't easily be separated much further. Implicit exception code, yes, but

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

2020-10-03 Thread J. Gareth Moreton via fpc-devel
Sounds like a fun thing to research, that's for sure.  Thanks Jonas. I'm under the impression that exception code tends to be separated anyway, so it can't easily be separated much further. Code that checks "IOResult" though could be possibly marked as cold code, so long as it isn't too large

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

2020-10-03 Thread Jonas Maebe via fpc-devel
On 01/10/2020 18:37, J. Gareth Moreton via fpc-devel wrote: > 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

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

2020-10-02 Thread J. Gareth Moreton via fpc-devel
Ah crumbs, I thought it was too easy!  I can't believe I missed the obvious there!  Not much of a saving if it has to store the return address somewhere (mov @return(%rip),%rcx; mov %rcx, (somewhere on the stack)). The advantage would be reducing the chance of additional memory caching since

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

2020-10-01 Thread Martin Frb via fpc-devel
On 01/10/2020 23:22, J. Gareth Moreton via fpc-devel wrote: In a way, yes, but not quite the same, since multiple calls to the nested function would still redirect to the same block of code rather than being inlined at each call.  I suppose more similar to the old GOSUB; RETURN combination in

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

2020-10-01 Thread J. Gareth Moreton via fpc-devel
In a way, yes, but not quite the same, since multiple calls to the nested function would still redirect to the same block of code rather than being inlined at each call.  I suppose more similar to the old GOSUB; RETURN combination in old versions of Basic, and the nested routine slotted either

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

2020-10-01 Thread Ryan Joseph via fpc-devel
> On Oct 1, 2020, at 10:37 AM, J. Gareth Moreton via fpc-devel > wrote: > > In situations where a nested function has no parameters, is it feasible and > beneficial to programmatically merge it into the main procedure What do you mean by "merge"? Like inlining? Regards, Ryan Joseph

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

2020-10-01 Thread J. Gareth Moreton via fpc-devel
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