On Tue, Aug 20, 2019 at 6:42 PM Gert <gert.cuyk...@gmail.com> wrote: > > https://golang.org/doc/asm > > $ cat x.go > package main > > func main() { > println(3) > } > $ GOOS=linux GOARCH=amd64 go tool compile -S x.go # or: go build > -gcflags -S x.go > > --- prog list "main" --- > 0000 (x.go:3) TEXT main+0(SB),$8-0 > 0001 (x.go:3) FUNCDATA $0,gcargs·0+0(SB) > 0002 (x.go:3) FUNCDATA $1,gclocals·0+0(SB) > 0003 (x.go:4) MOVQ $3,(SP) > 0004 (x.go:4) PCDATA $0,$8 > 0005 (x.go:4) CALL ,runtime.printint+0(SB) > 0006 (x.go:4) PCDATA $0,$-1 > 0007 (x.go:4) PCDATA $0,$0 > 0008 (x.go:4) CALL ,runtime.printnl+0(SB) > 0009 (x.go:4) PCDATA $0,$-1 > 0010 (x.go:5) RET , > ... > > > The FUNCDATA and PCDATA directives contain information for use by the garbage > collector; they are introduced by the compiler. > > > 1) funcdata What is this .0 which is not a dot :)
Note that the current compiler emits different data. I think the ·0 was just used to distinguish the GC information for different functions. The second function would use ·1, and so forth. > 2) pcdata what does $-1 mean here I'm not sure. > 3) Is there some more information on funcdata and pcdata? Doesn't have to be > in detail, because i know its a can of worms, but just enough so I can tell > what the garbage collector will be doing :) I don't know of any real documentation. You can see some basic stuff in cmd/internal/objabi and runtime/symtab.go. You can see the garbage collector using the information in the runtime function getStackMap and its callers. > When defining a TEXT, specifying frame size $-4 tells the linker that this is > a leaf function that does not need to save LR on entry. > > > 4) What is LR? The Link Register used on architectures like ARM. > 5) Leaf as in closure function? No, leaf as in a function that does not call any other functions. Ian -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcW9m9FokcK1V2tdu%2B1g2nTw%2BwawZp%2BtcybUhKPBZMuAiA%40mail.gmail.com.