1. 11 Mar, 2016 3 commits
  2. 10 Mar, 2016 29 commits
  3. 09 Mar, 2016 8 commits
    • Andrew Gerrand's avatar
      doc: add doc.Example.Unordered to go1.7.txt · c2400e31
      Andrew Gerrand authored
      Change-Id: I142a9f97303e3bfbd9522fd061530c0a91305389
      Reviewed-on: https://go-review.googlesource.com/20500Reviewed-by: default avatarMinux Ma <minux@golang.org>
      c2400e31
    • Josh Bleecher Snyder's avatar
      cmd/compile: make alg gen prologue/epilogue match · e0032df8
      Josh Bleecher Snyder authored
      With this, the start and end of geneq and genhash
      are parallel. This removes a few rare nilchecks
      from generated hash functions, but nothing
      to write home about.
      
      Change-Id: I3b4836111d04daa6f6834a579bbec374a3f42c70
      Reviewed-on: https://go-review.googlesource.com/20456
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
      e0032df8
    • Ian Lance Taylor's avatar
      cmd/compile: remove remaining nodeSeqIterate calls · cd6619d2
      Ian Lance Taylor authored
      Mix in several other minor cleanups, including adding some new methods
      to Nodes: Index, Addr, SetIndex, SetNodes.
      
      Passes toolstash -cmp.
      
      Update #14473.
      
      Change-Id: I8bd4ae3fde7c5e20ba66e7dd1654fbc70c3ddeb8
      Reviewed-on: https://go-review.googlesource.com/20491Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      cd6619d2
    • David Crawshaw's avatar
      cmd/link: prune unused methods · 862b9ddd
      David Crawshaw authored
      Today the linker keeps all methods of reachable types. This is
      necessary if a program uses reflect.Value.Call. But while use of
      reflection is widespread in Go for encoders and decoders, using
      it to call a method is rare.
      
      This CL looks for the use of reflect.Value.Call in a program, and
      if it is absent, adopts a (reasonably conservative) method pruning
      strategy as part of dead code elimination. Any method that is
      directly called is kept, and any method that matches a used
      interface's method signature is kept.
      
      Whether or not a method body is kept is determined by the relocation
      from its receiver's *rtype to its *rtype. A small change in the
      compiler marks these relocations as R_METHOD so they can be easily
      collected and manipulated by the linker.
      
      As a bonus, this technique removes the text segment of methods that
      have been inlined. Looking at the output of building cmd/objdump with
      -ldflags=-v=2 shows that inlined methods like
      runtime.(*traceAllocBlockPtr).ptr are removed from the program.
      
      Relatively little work is necessary to do this. Linking two
      examples, jujud and cmd/objdump show no more than +2% link time.
      
      Binaries that do not use reflect.Call.Value drop 4 - 20% in size:
      
      	addr2line: -793KB (18%)
      	asm:       -346KB (8%)
      	cgo:       -490KB (10%)
      	compile:   -564KB (4%)
      	dist:      -736KB (17%)
      	fix:       -404KB (12%)
      	link:      -328KB (7%)
      	nm:        -827KB (19%)
      	objdump:   -712KB (16%)
      	pack:      -327KB (14%)
      	yacc:      -350KB (10%)
      
      Binaries that do use reflect.Call.Value see a modest size decrease
      of 2 - 6% thanks to pruning of unexported methods:
      
      	api:    -151KB (3%)
      	cover:  -222KB (4%)
      	doc:    -106KB (2.5%)
      	pprof:  -314KB (3%)
      	trace:  -357KB (4%)
      	vet:    -187KB (2.7%)
      	jujud:  -4.4MB (5.8%)
      	cmd/go: -384KB (3.4%)
      
      The trivial Hello example program goes from 2MB to 1.68MB:
      
      	package main
      
      	import "fmt"
      
      	func main() {
      		fmt.Println("Hello, 世界")
      	}
      
      Method pruning also helps when building small binaries with
      "-ldflags=-s -w". The above program goes from 1.43MB to 1.2MB.
      
      Unfortunately the linker can only tell if reflect.Value.Call has been
      statically linked, not if it is dynamically used. And while use is
      rare, it is linked into a very common standard library package,
      text/template. The result is programs like cmd/go, which don't use
      reflect.Value.Call, see limited benefit from this CL. If binary size
      is important enough it may be possible to address this in future work.
      
      For #6853.
      
      Change-Id: Iabe90e210e813b08c3f8fd605f841f0458973396
      Reviewed-on: https://go-review.googlesource.com/20483Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      862b9ddd
    • Brad Fitzpatrick's avatar
      doc: fix bogus HTML in contribute.html · f02dc513
      Brad Fitzpatrick authored
      Introduced in https://golang.org/cl/20462
      
      Change-Id: I6c55f87228f0980058a10f204b57ead7594e3492
      Reviewed-on: https://go-review.googlesource.com/20490Reviewed-by: default avatarAndrew Gerrand <adg@golang.org>
      f02dc513
    • Brad Fitzpatrick's avatar
      cmd/compile: shrink tables · 0ac0e22f
      Brad Fitzpatrick authored
      Drops cmd/binary size from 14.41 MiB to 11.42 MiB.
      
      Before:
      
         text    data     bss     dec     hex filename
      8121210 3521696  737960 12380866         bceac2 ../pkg/tool/linux_amd64/compile
      
      bradfitz@dev-bradfitz-debian2:~/go/src$ ls -l ../pkg/tool/linux_amd64/compile
      -rwxr-xr-x 1 bradfitz bradfitz 15111272 Mar  8 23:32 ../pkg/tool/linux_amd64/compile
      
        a2afc0      51312 R html.statictmp_0085
        6753f0      56592 T cmd/internal/obj/x86.doasm
        625480      58080 T cmd/compile/internal/gc.typecheck1
        f34c40      65688 D runtime.trace
        be0a20     133552 D cmd/compile/internal/ppc64.varianttable
        c013e0     265856 D cmd/compile/internal/arm.progtable
        c42260     417280 D cmd/compile/internal/amd64.progtable
        ca8060     417280 D cmd/compile/internal/x86.progtable
        f44ce0     500640 D cmd/internal/obj/arm64.oprange
        d0de60     534208 D cmd/compile/internal/ppc64.progtable
        d90520     667520 D cmd/compile/internal/arm64.progtable
        e334a0     790368 D cmd/compile/internal/mips64.progtable
        a3e8c0    1579362 r runtime.pclntab
      
      After:
      
         text    data     bss     dec     hex filename
      8128226  375954  246432 8750612  858614 ../pkg/tool/linux_amd64/compile
      
      -rwxr-xr-x 1 bradfitz bradfitz 11971432 Mar  8 23:35 ../pkg/tool/linux_amd64/compile
      
        6436d0      43936 T cmd/compile/internal/gc.walkexpr
        c13ca0      45056 D cmd/compile/internal/ssa.opcodeTable
        5d8ea0      50256 T cmd/compile/internal/gc.(*state).expr
        818c50      50448 T cmd/compile/internal/ssa.rewriteValueAMD64_OpMove
        a2d0e0      51312 R html.statictmp_0085
        6753d0      56592 T cmd/internal/obj/x86.doasm
        625460      58080 T cmd/compile/internal/gc.typecheck1
        c38fe0      65688 D runtime.trace
        a409e0    1578810 r runtime.pclntab
      
      Fixes #14703
      
      Change-Id: I2177596d5c7fd67db0a3c423cd90801cf52adb12
      Reviewed-on: https://go-review.googlesource.com/20450Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      0ac0e22f
    • Martin Möhrmann's avatar
      fmt: refactor pointer formatting and improve tests · 8e231567
      Martin Möhrmann authored
      Uses a switch statement for direct format function selection
      similar to other types verb handling in fmt.
      
      Applies padding also to nil pointers formatted with %v.
      
      Guards against "slice bounds out of range" panic in TestSprintf
      when a pointer test results in a formatted string s
      that is shorter than the index i the pointer should appear in.
      
      Adds more and rearranges tests.
      
      Fixes #14712
      Fixes #14714
      
      Change-Id: Iaf5ae37b7e6ba7d27d528d199f2b2eb9d5829b8c
      Reviewed-on: https://go-review.googlesource.com/20371
      Run-TryBot: Rob Pike <r@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRob Pike <r@golang.org>
      8e231567
    • Alexandru Moșoi's avatar
      cmd/compile: constant fold more of IsInBounds and IsSliceInBounds · bbd3ffbd
      Alexandru Moșoi authored
      Fixes #14721
      
      Change-Id: Id1d5a819e5c242b91a37c4e464ed3f00c691aff5
      Reviewed-on: https://go-review.googlesource.com/20482Reviewed-by: default avatarKeith Randall <khr@golang.org>
      Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      bbd3ffbd