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

I didn't know Go reserved some registers for its own use. For libraries that don't use cgo but do use assembly [1], does this mean they have to generate that assembly with a compiler flag that avoids reserved registers?

[1] A common optimization technique, like in the superb https://github.com/klauspost/compress



Generally the inline assembly is hand-written and must follow the platform rules, see "Architecture-specific details" in https://go.dev/doc/asm

The few tools that generate that asm, such as https://github.com/mmcloughlin/avo , would also have follow the rules.

You're not meant to take C source, crank it through GCC, and slurp that in as inline asm in Go.

Background: https://www.youtube.com/watch?v=KINIAgRpkDA


Pusha popa and never yield back in between should suffice?


Non-CGO goroutines are preemptible via signals so there may still be more to it than that. If anyone knows the precise mechanism used I'd be very keen to hear it.




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

Search: