mirror of
https://github.com/golang/go
synced 2024-11-12 04:50:21 -07:00
The Go programming language
0184081eb9
Given the following Go program: func sum(s []int) int { ret := 0 for _, x := range s { ret += x } return ret } 6g would previously generate: --- prog list "sum" --- 0000 (main.go:3) TEXT sum+0(SB),$0-24 0001 (main.go:5) MOVQ s+0(FP),CX 0002 (main.go:5) MOVL s+8(FP),DI 0003 (main.go:5) MOVL s+12(FP),BX 0004 (main.go:4) MOVL $0,SI 0005 (main.go:5) MOVL $0,AX 0006 (main.go:5) JMP ,8 0007 (main.go:5) INCL ,AX 0008 (main.go:5) CMPL AX,DI 0009 (main.go:5) JGE $0,16 0010 (main.go:5) MOVL (CX),DX 0011 (main.go:5) MOVQ $4,BX 0012 (main.go:5) ADDQ CX,BX 0013 (main.go:5) MOVQ BX,CX 0014 (main.go:6) ADDL DX,SI 0015 (main.go:5) JMP ,7 0016 (main.go:8) MOVL SI,.noname+16(FP) 0017 (main.go:8) RET , and now generates: --- prog list "sum" --- 0000 (main.go:3) TEXT sum+0(SB),$0-24 0001 (main.go:5) MOVQ s+0(FP),CX 0002 (main.go:5) MOVL s+8(FP),DI 0003 (main.go:5) MOVL s+12(FP),BX 0004 (main.go:4) MOVL $0,SI 0005 (main.go:5) MOVL $0,AX 0006 (main.go:5) JMP ,8 0007 (main.go:5) INCL ,AX 0008 (main.go:5) CMPL AX,DI 0009 (main.go:5) JGE $0,14 0010 (main.go:5) MOVL (CX),BP 0011 (main.go:5) ADDQ $4,CX 0012 (main.go:6) ADDL BP,SI 0013 (main.go:5) JMP ,7 0014 (main.go:8) MOVL SI,.noname+16(FP) 0015 (main.go:8) RET , The key difference is that 0011 (main.go:5) MOVQ $4,BX 0012 (main.go:5) ADDQ CX,BX 0013 (main.go:5) MOVQ BX,CX has changed to 0011 (main.go:5) ADDQ $4,CX R=rsc, dave, remyoudompheng CC=golang-dev https://golang.org/cl/6506089 |
||
---|---|---|
api | ||
doc | ||
include | ||
lib | ||
misc | ||
src | ||
test | ||
.hgignore | ||
.hgtags | ||
AUTHORS | ||
CONTRIBUTORS | ||
favicon.ico | ||
LICENSE | ||
PATENTS | ||
README | ||
robots.txt | ||
VERSION |
This is the source code repository for the Go programming language. For documentation about how to install and use Go, visit http://golang.org/ or load doc/install.html in your web browser. After installing Go, you can view a nicely formatted doc/install.html by running godoc --http=:6060 and then visiting http://localhost:6060/doc/install.html. Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file. -- Binary Distribution Notes If you have just untarred a binary Go distribution, you need to set the environment variable $GOROOT to the full path of the go directory (the one containing this README). You can omit the variable if you unpack it into /usr/local/go, or if you rebuild from sources by running all.bash (see doc/install.html). You should also add the Go binary directory $GOROOT/bin to your shell's path. For example, if you extracted the tar file into $HOME/go, you might put the following in your .profile: export GOROOT=$HOME/go export PATH=$PATH:$GOROOT/bin See doc/install.html for more details.