Re:Show HN: A new stdlib for Golang focusing on platform nat...
by dolmen on Tuesday October 03, 2023 @09:27AM
(#37751584)
What is that `g` register that you are talking about. It seems to be a reference to some internals of the Go. Do you have some references to some existing documentation about this thing?
[ Parent
| on HN ]
Re:Show HN: A new stdlib for Golang focusing on platform nat...
by Leotard6963 on Tuesday October 03, 2023 @10:25AM
(#37752420)
I'm afraid there is no such resource, but you may find cmd/compile/abi-internal.md[1] helpful
And in brief introduction, the `g` register is a non-scratch register, and is preserved by the go compiler, it stores the poitner to current goroutine (type `g` in the official runtime, a structure serves the similar purpose of TCB), and since all general purpose registers are thread local, the goroutine may enjoy some thread-local features without any thread-local requirements to the running environment.
[1]: https://github.com/golang/go/blob/master/src/cmd/compile/abi...