| The strategy in the GC for determining the stack top for hunting GC roots will not work on all architectures. On aaarch-64, the address of a local dummy variable may be above a register save area in the stack frame, and thus the scan will miss some GC roots. In TXR Lisp, I used to use a hacked constant on aarch64: STACK_TOP_EXTRA_WORDS. It wasn't large enough to straddle the area, and so operation on aarch64 was unreliable. http://www.kylheku.com/cgit/txr/commit/?id=3aa731546c4691fac... A good stack-top-getting trick occurred to me: call alloca for a small amount of memory and use that address. It has to be below everything; alloca cannot start allocating above some register save area in the frame, because then it would collide with it; alloca has not know the real stack top and work from there. Since we need to scan registers, we use alloca for the size of the register file (e.g. setjmp jmp_buf), and put that there: kill two birds with one stone. http://www.kylheku.com/cgit/txr/commit/?id=7d5f0b7e3613f8e8b... |
Then use two stack frames! Every problem can be solved by adding an additional level of indirection. ;-)