Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

GP comment said it's not used for FFI, not that it's not used.


You're both stating things that are a bit beside the point.

Pure Go code uses registers to pass function arguments whenever possible. Large structs and/or numerous arguments can still spill onto the stack, though.

FFI (cgo) uses whatever the platform's calling convention requires. These conventions also usually favor registers.

Go has its own assembly language, which is neither of those two things. Go assembly technically supports two ABIs, one called "ABI0" and the other called "ABIInternal" [1]. The former passes all arguments on the stack and is stable while the latter passes some arguments through registers but is unstable and subject to change. Accordingly, people writing Go code outside of the Go toolchain almost always use ABI0, so that the code keeps working even when new versions of Go are released.

[1]: https://go.googlesource.com/go/+/refs/heads/dev.regabi/src/c...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: