Adriaan van Os wrote:
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 !
Adriaan, I believe you're referencing the wrong section. The registers you list are the non-volitle registers which must be saved and restored for those registers the callee actually uses. The "PowerPC Stack Structure" section, http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachORuntime/2rt_powerpc_abi/chapter_9_section_4.html, is the more appropriate reference. I'll have to take a look a the disassembly for the two programs to know for sure, but the minimum stack frame possible for a recursive routine with one integer parameter is 32 bytes - the standard required 24 bytes for the linkage area plus 4 bytes for the parameter area rounded up to the next 16 byte boundary.
Notes: Even though the integer parameter is passed in a register, there still must be a slot allocated in the stack frame parameter area for it. The 16 byte boundary requirement for stack frames isn't documented very well.
Gale Paeper gpaeper@empirenet.com