Skip to content

Instantly share code, notes, and snippets.

@peterbourgon
Created February 27, 2014 14:45
Show Gist options
  • Save peterbourgon/9251445 to your computer and use it in GitHub Desktop.
Save peterbourgon/9251445 to your computer and use it in GitHub Desktop.
$ cat inline.go ; go build -gcflags=-S inline.go
package main
func do() {
type foo struct {
i int
}
s := foo{i: 123}
println(s.i)
}
func main() {
do()
}
# command-line-arguments
--- prog list "do" ---
0000 (/Users/peter/src/tmp/struct/inline.go:3) TEXT do+0(SB),$8-0
0001 (/Users/peter/src/tmp/struct/inline.go:3) FUNCDATA $0,gcargs·0+0(SB)
0002 (/Users/peter/src/tmp/struct/inline.go:3) FUNCDATA $1,gclocals·0+0(SB)
0003 (/Users/peter/src/tmp/struct/inline.go:7) MOVQ statictmp_0000+0(SB),BX
0004 (/Users/peter/src/tmp/struct/inline.go:8) MOVQ BX,(SP)
0005 (/Users/peter/src/tmp/struct/inline.go:8) PCDATA $0,$8
0006 (/Users/peter/src/tmp/struct/inline.go:8) CALL ,runtime.printint+0(SB)
0007 (/Users/peter/src/tmp/struct/inline.go:8) PCDATA $0,$-1
0008 (/Users/peter/src/tmp/struct/inline.go:8) PCDATA $0,$0
0009 (/Users/peter/src/tmp/struct/inline.go:8) CALL ,runtime.printnl+0(SB)
0010 (/Users/peter/src/tmp/struct/inline.go:8) PCDATA $0,$-1
0011 (/Users/peter/src/tmp/struct/inline.go:9) RET ,
--- prog list "main" ---
0012 (/Users/peter/src/tmp/struct/inline.go:11) TEXT main+0(SB),$0-0
0013 (/Users/peter/src/tmp/struct/inline.go:11) FUNCDATA $0,gcargs·1+0(SB)
0014 (/Users/peter/src/tmp/struct/inline.go:11) FUNCDATA $1,gclocals·1+0(SB)
0015 (/Users/peter/src/tmp/struct/inline.go:12) CALL ,do+0(SB)
0016 (/Users/peter/src/tmp/struct/inline.go:13) RET ,
--- prog list "init" ---
0017 (/Users/peter/src/tmp/struct/inline.go:13) TEXT init+0(SB),$0-0
0018 (/Users/peter/src/tmp/struct/inline.go:13) MOVBQZX initdone·+0(SB),AX
0019 (/Users/peter/src/tmp/struct/inline.go:13) FUNCDATA $0,gcargs·2+0(SB)
0020 (/Users/peter/src/tmp/struct/inline.go:13) FUNCDATA $1,gclocals·2+0(SB)
0021 (/Users/peter/src/tmp/struct/inline.go:13) CMPB AX,$0
0022 (/Users/peter/src/tmp/struct/inline.go:13) JEQ ,29
0023 (/Users/peter/src/tmp/struct/inline.go:13) CMPB AX,$2
0024 (/Users/peter/src/tmp/struct/inline.go:13) JNE ,26
0025 (/Users/peter/src/tmp/struct/inline.go:13) RET ,
0026 (/Users/peter/src/tmp/struct/inline.go:13) PCDATA $0,$0
0027 (/Users/peter/src/tmp/struct/inline.go:13) CALL ,runtime.throwinit+0(SB)
0028 (/Users/peter/src/tmp/struct/inline.go:13) UNDEF ,
0029 (/Users/peter/src/tmp/struct/inline.go:13) MOVB $2,initdone·+0(SB)
0030 (/Users/peter/src/tmp/struct/inline.go:13) RET ,
$ cat toplevel.go ; go build -gcflags=-S toplevel.go
package main
type foo struct {
i int
}
func do() {
s := foo{i: 123}
println(s.i)
}
func main() {
do()
}
# command-line-arguments
--- prog list "do" ---
0000 (/Users/peter/src/tmp/struct/toplevel.go:7) TEXT do+0(SB),$8-0
0001 (/Users/peter/src/tmp/struct/toplevel.go:7) FUNCDATA $0,gcargs·0+0(SB)
0002 (/Users/peter/src/tmp/struct/toplevel.go:7) FUNCDATA $1,gclocals·0+0(SB)
0003 (/Users/peter/src/tmp/struct/toplevel.go:8) MOVQ statictmp_0000+0(SB),BX
0004 (/Users/peter/src/tmp/struct/toplevel.go:9) MOVQ BX,(SP)
0005 (/Users/peter/src/tmp/struct/toplevel.go:9) PCDATA $0,$8
0006 (/Users/peter/src/tmp/struct/toplevel.go:9) CALL ,runtime.printint+0(SB)
0007 (/Users/peter/src/tmp/struct/toplevel.go:9) PCDATA $0,$-1
0008 (/Users/peter/src/tmp/struct/toplevel.go:9) PCDATA $0,$0
0009 (/Users/peter/src/tmp/struct/toplevel.go:9) CALL ,runtime.printnl+0(SB)
0010 (/Users/peter/src/tmp/struct/toplevel.go:9) PCDATA $0,$-1
0011 (/Users/peter/src/tmp/struct/toplevel.go:10) RET ,
--- prog list "main" ---
0012 (/Users/peter/src/tmp/struct/toplevel.go:12) TEXT main+0(SB),$8-0
0013 (/Users/peter/src/tmp/struct/toplevel.go:12) FUNCDATA $0,gcargs·1+0(SB)
0014 (/Users/peter/src/tmp/struct/toplevel.go:12) FUNCDATA $1,gclocals·1+0(SB)
0015 (/Users/peter/src/tmp/struct/toplevel.go:13) MOVQ statictmp_0001+0(SB),BX
0016 (/Users/peter/src/tmp/struct/toplevel.go:13) MOVQ BX,(SP)
0017 (/Users/peter/src/tmp/struct/toplevel.go:13) PCDATA $0,$8
0018 (/Users/peter/src/tmp/struct/toplevel.go:13) CALL ,runtime.printint+0(SB)
0019 (/Users/peter/src/tmp/struct/toplevel.go:13) PCDATA $0,$-1
0020 (/Users/peter/src/tmp/struct/toplevel.go:13) PCDATA $0,$0
0021 (/Users/peter/src/tmp/struct/toplevel.go:13) CALL ,runtime.printnl+0(SB)
0022 (/Users/peter/src/tmp/struct/toplevel.go:13) PCDATA $0,$-1
0023 (/Users/peter/src/tmp/struct/toplevel.go:14) RET ,
--- prog list "init" ---
0024 (/Users/peter/src/tmp/struct/toplevel.go:14) TEXT init+0(SB),$0-0
0025 (/Users/peter/src/tmp/struct/toplevel.go:14) MOVBQZX initdone·+0(SB),AX
0026 (/Users/peter/src/tmp/struct/toplevel.go:14) FUNCDATA $0,gcargs·2+0(SB)
0027 (/Users/peter/src/tmp/struct/toplevel.go:14) FUNCDATA $1,gclocals·2+0(SB)
0028 (/Users/peter/src/tmp/struct/toplevel.go:14) CMPB AX,$0
0029 (/Users/peter/src/tmp/struct/toplevel.go:14) JEQ ,36
0030 (/Users/peter/src/tmp/struct/toplevel.go:14) CMPB AX,$2
0031 (/Users/peter/src/tmp/struct/toplevel.go:14) JNE ,33
0032 (/Users/peter/src/tmp/struct/toplevel.go:14) RET ,
0033 (/Users/peter/src/tmp/struct/toplevel.go:14) PCDATA $0,$0
0034 (/Users/peter/src/tmp/struct/toplevel.go:14) CALL ,runtime.throwinit+0(SB)
0035 (/Users/peter/src/tmp/struct/toplevel.go:14) UNDEF ,
0036 (/Users/peter/src/tmp/struct/toplevel.go:14) MOVB $2,initdone·+0(SB)
0037 (/Users/peter/src/tmp/struct/toplevel.go:14) RET ,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment