How to store Go pointers from assembly
10 months ago
- #Assembly
- #Garbage Collection
- #Go
- The Go toolchain includes an assembler with Plan 9 syntax and custom names for platform-specific instructions.
- Go's garbage collector is concurrent, minimizing pauses by running alongside application code.
- Pointer stores are instrumented with write barriers to inform the GC of new references.
- Go avoids instrumenting stack pointer stores for performance, previously requiring a final stack rescan.
- Go 1.8 introduced a broader write barrier, reducing stop-the-world pauses significantly.
- Handling pointer stores in assembly requires manual write barrier implementation.
- Linking to runtime symbols for write barriers is restricted but possible with specific build tags.
- Allocating 128-bit aligned slots for concurrent hash tables is tricky in Go, requiring creative solutions.
- A workaround for alignment involves manipulating slice types and unsafe pointers.