A long time ago getg was written in assembly in the runtime package. These days it is implemented directly as pseudo instruction in the compiler. Search for OpGetG in $GOROOT/src/cmd/compile/internal
On Wednesday, 17 January 2018 12:40:48 UTC+11, Jiajun Huang wrote: > > Hi, all: > > I'm reading golang runtime implementation, I've got a function > definition: > > // getg returns the pointer to the current g. > // The compiler rewrites calls to this function into instructions > // that fetch the g directly (from TLS or from the dedicated register). > func getg() *g > > > So, is there any solution that I can reading what implementation does > the compiler rewrite? It seems that it's Assembly code. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.