Re: [go-nuts] Re: where is the implementation of `getg`?
thanks Ian Lance Taylor于2018年1月17日周三 上午9:53写道: > On Tue, Jan 16, 2018 at 5:51 PM, Dave Cheney wrote: > > 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 > > Yes. The simplest way to see the generated instructions is to > disassemble the runtime package and look for a place that you know is > a call to getg. > > Ian > > > > 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. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "golang-nuts" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/golang-nuts/KgPOzaMylHo/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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.
Re: [go-nuts] Re: where is the implementation of `getg`?
On Tue, Jan 16, 2018 at 5:51 PM, Dave Cheneywrote: > 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 Yes. The simplest way to see the generated instructions is to disassemble the runtime package and look for a place that you know is a call to getg. Ian > 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. -- 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.
[go-nuts] Re: where is the implementation of `getg`?
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.