On Thursday, April 17, 2025 at 11:50:18 AM UTC-7 Wojciech Kaczmarek wrote:

Hi Gophers,

I am experimenting with assembler, ABI0 and stuff. 
While I was learning the ABI0 frame structure from disassembled code, I 
noticed that the stack check happens before subtracting from RSP (I'm on 
arm64, but the same applies to SP on amd64, I mean the hardware register 
ofc). 
Then, what if the frame being allocated is big enough to cause trouble?


Do you mean, what if the stack check fails? It calls into 
runtime.morestack. morestack will allocate a new, larger stack and copy the 
existing contents over.
 

Also, after the CALL runtime.morestack*, what is the safe amount to 
subtract from RSP?


There's no specific amount. Probably the frame that didn't fit at the start 
will fit after calling morestack. But not necessarily, if the frame is 
really large it will call into morestack again. (That's why after calling 
morestack we jump to the top of the function and redo the stack check.)
 

cheers,
Wojciech

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/88d49550-644b-4df9-91d9-885db2ff8011n%40googlegroups.com.

Reply via email to