Frank Heckenbach wrote:
Adriaan van Os wrote:
The failures in nonloc2goto.pas and nonloc4goto.pas go away when increasing the stacksize limit. We might reduce the recursion depth somewhat in these tests, in order to run them in the default Mac OS X stacksize limit of 512 KB.
I'm a bit surprised. Depth 10000 with only one integer parameter shouldn't take much stack -- 16 bytes per recursion on my system. Is the procedure call overhead (WRT stack usage) so big on the Mac?
This is probably due to register preservation, see <http://developer.apple.com/documentation/DeveloperTools/Conceptual/ MachORuntime/2rt_powerpc_abi/chapter_9_section_5.html>. With Mach-O PowerPC calling conventions GPR1, GPR13-31, FPR14-31, VRSAVE and CR2-CR4 are saved, that's 24 registers or 96 bytes ! A waste of stack space, of course, not to mention slow execution due to memory stalls on the stack !
Actually the point is to use up some amount of stack, something like 32-64 KB is more than sufficient.
With 16 bytes per recursion and a depth of 10000 that would be 160 Kbytes. Did you try on Linux (IA-32) ?
So perhaps they should be rewritten to use fewer recursions with more parameters to reduce the overhead, so the minimum stack usage (as given by parameter sizes alone) is still >= 32 KB, and the usage on the Mac is acceptable. Feel free to experiment and send me the results.
OK, I will look into it.
Please note that nonloc4goto.pas does some useless computations in order to avoid tail call optimization. Also, make sure that all parameters are actually used (non-trivially), so they can't possibly be optimized away.
OK.
Regards,
Adriaan van Os