5 ms·
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 as
by fl0ki 2y ago
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 https://github.com/klauspost/compress
- jhoechtl 2y agoPusha popa and never yield back in between should suffice?
- fl0ki 2y agoNon-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.
- yencabulator 2y agoGenerally the inline assembly is hand-written and must follow the platform rules, see "Architecture-specific details" in https://go.dev/doc/asm https://go.dev/doc/asm The few tools that generate that asm, such as https://github.com/mmcloughlin/avo 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 https://www.youtube.com/watch?v=KINIAgRpkDA