]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
7 years ago*.bash: always use the same string equality operator
Daniel Martí [Fri, 10 Mar 2017 17:15:46 +0000 (17:15 +0000)]
*.bash: always use the same string equality operator

POSIX Shell only supports = to compare variables inside '[' tests. But
this is Bash, where == is an alias for =. In practice they're the same,
but the current form is inconsisnent and breaks POSIX for no good
reason.

Change-Id: I38fa7a5a90658dc51acc2acd143049e510424ed8
Reviewed-on: https://go-review.googlesource.com/38031
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile: eliminate fmtmode and fmtpkgpfx globals
Josh Bleecher Snyder [Tue, 8 Nov 2016 00:14:32 +0000 (16:14 -0800)]
cmd/compile: eliminate fmtmode and fmtpkgpfx globals

The fmtmode and fmtpkgpfx globals stand in the
way of making the compiler more concurrent (#15756).
This CL removes them.

The natural way to eliminate a global is to explicitly
thread it as a parameter through all function calls.
However, most of the functions in gc/fmt.go
get called indirectly, by way of fmt format strings,
so there's nowhere natural to add a parameter.

Since there are only a few fmtmode modes,
use named types to distinguish between modes.
For example, fmtNodeErr, fmtNodeDbg, and fmtNodeTypeId
are all gc.Node, but they print in different modes.
Varying the type allows us to thread mode through fmt.
Handle fmtpkgpfx by converting it to a printing mode,
FTypeIdName, and using the same type-based approach.

To avoid a loss of readability and danger of bugs
from introducing conversions at all call sites,
instead add a helper that systematically modifies the args.

The only remaining gc/fmt.go global is dumpdepth.
Since that is used for debugging only,
it that can be handled with a global mutex,
or some similarly basic, if inefficient, protection.

Passes toolstash -cmp. No compiler performance impact.

For future reference, other options for threading state
that were considered and rejected:

* Wrapping values in structs, such as:

  type fmtNode struct {
   n *Node
   mode fmtMode
  }

  This reduces the proliferation of types, and supports
  easily adding extra local parameters.
  However, putting such a struct into an interface{} allocates.
  This is unacceptable in this particular area of code.

* Passing state via precision, such as:

  fmt.Fprintf("%*v", mode, n)

  where mode is the state encoded as an integer.
  This avoids extra allocations, but it is out of keeping
  with the intended semantics of precision, and is less readable.

* Modify the fmt package to support setting/getting context
  via fmt.State. Unavailable due to Go 1 compatibility,
  and probably the wrong solution anyway.

* Give up on package fmt. This would be a huge readability
  regression and cause high code churn.

* Attempt a de-novo rewrite that circumvents these problems.
  Too high a risk of bugs, with insufficient reward for the effort,
  particularly since long term plans call for elimination
  of gc.Node.

Change-Id: Iea2440d5a34a938e64273707de27e3a897cb41d1
Reviewed-on: https://go-review.googlesource.com/38147
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agocmd/compile: improve assignment count mismatch error message
Michael Stapelberg [Tue, 29 Nov 2016 10:45:11 +0000 (02:45 -0800)]
cmd/compile: improve assignment count mismatch error message

Given the following test cases:

    $ cat left_too_many.go
    package main

    func main() {
     a, err := make([]int, 1)
    }

    $ cat right_too_many.go
    package main

    func main() {
     a := "foo", "bar"
    }

Before this change, the error messages are:

    ./left_too_many.go:4: assignment count mismatch: 2 = 1

    ./right_too_many.go:4: assignment count mismatch: 1 = 2

After this change, the error messages are:

    ./left_too_many.go:4: assignment count mismatch: want 2 values, got 1

    ./right_too_many.go:4: assignment count mismatch: want 1 values, got 2

Change-Id: I9ad346f122406bc9a785bf690ed7b3de76a422da
Reviewed-on: https://go-review.googlesource.com/33616
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile/internal/ssa: remove unused OpFunc
Matthew Dempsky [Tue, 14 Mar 2017 19:18:10 +0000 (12:18 -0700)]
cmd/compile/internal/ssa: remove unused OpFunc

Change-Id: I0f7eec2e0c15a355422d5ae7289508a5bd33b971
Reviewed-on: https://go-review.googlesource.com/38171
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: de-virtualize interface calls
philhofer [Mon, 13 Mar 2017 22:03:17 +0000 (15:03 -0700)]
cmd/compile: de-virtualize interface calls

With this change, code like

    h := sha1.New()
    h.Write(buf)
    sum := h.Sum()

gets compiled into static calls rather than
interface calls, because the compiler is able
to prove that 'h' is really a *sha1.digest.

The InterCall re-write rule hits a few dozen times
during make.bash, and hundreds of times during all.bash.

The most common pattern identified by the compiler
is a constructor like

    func New() Interface { return &impl{...} }

where the constructor gets inlined into the caller,
and the result is used immediately. Examples include
{sha1,md5,crc32,crc64,...}.New, base64.NewEncoder,
base64.NewDecoder, errors.New, net.Pipe, and so on.

Some existing benchmarks that change on darwin/amd64:

Crc64/ISO4KB-8        2.67µs ± 1%    2.66µs ± 0%  -0.36%  (p=0.015 n=10+10)
Crc64/ISO1KB-8         694ns ± 0%     690ns ± 1%  -0.59%  (p=0.001 n=10+10)
Adler32KB-8            473ns ± 1%     471ns ± 0%  -0.39%  (p=0.010 n=10+9)

On architectures like amd64, the reduction in code size
appears to contribute more to benchmark improvements than just
removing the indirect call, since that branch gets predicted
accurately when called in a loop.

Updates #19361

Change-Id: I57d4dc21ef40a05ec0fbd55a9bb0eb74cdc67a3d
Reviewed-on: https://go-review.googlesource.com/38139
Run-TryBot: Philip Hofer <phofer@umich.edu>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agocmd/compile/internal/ssa: populate SymEffects for SSA Ops
Matthew Dempsky [Thu, 9 Mar 2017 22:46:43 +0000 (14:46 -0800)]
cmd/compile/internal/ssa: populate SymEffects for SSA Ops

Changes to ${GOARCH}Ops.go files were mechanically produced using
github.com/mdempsky/ssa-symops, a one-off tool that inserts
"SymEffect: X" elements by pattern matching against the Op names.

Change-Id: Ibf3e481ffd588647f2a31662d72114b740ccbfcf
Reviewed-on: https://go-review.googlesource.com/38084
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile/internal/ssa: add SymEffect attribute to SSA Ops
Matthew Dempsky [Thu, 9 Mar 2017 22:45:37 +0000 (14:45 -0800)]
cmd/compile/internal/ssa: add SymEffect attribute to SSA Ops

To replace the progeffects tables for liveness analysis.

Change-Id: Idc4b990665cb0a9aa300d62cdf8ad12e51c5b991
Reviewed-on: https://go-review.googlesource.com/38083
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile: catch bad pragma combination earlier
Josh Bleecher Snyder [Tue, 14 Mar 2017 16:29:23 +0000 (09:29 -0700)]
cmd/compile: catch bad pragma combination earlier

Bad pragmas should never make it to the backend.
I've confirmed manually that the error position is unchanged.

Updates #15756
Updates #19250

Change-Id: If14f7ce868334f809e337edc270a49680b26f48e
Reviewed-on: https://go-review.googlesource.com/38152
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agonet/http: deflake TestServerTimeouts
Brad Fitzpatrick [Tue, 14 Mar 2017 17:43:50 +0000 (17:43 +0000)]
net/http: deflake TestServerTimeouts

Retry the test several times with increasingly long timeouts.

Fixes #19538 (hopefully)

Change-Id: Ia3bf2b63b4298a6ee1e4082e14d9bfd5922c293a
Reviewed-on: https://go-review.googlesource.com/38154
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
7 years agocmd/compile: use Fatalf for more internal errors
Josh Bleecher Snyder [Tue, 14 Mar 2017 16:46:45 +0000 (09:46 -0700)]
cmd/compile: use Fatalf for more internal errors

There were a surprising number of places
in the tree that used yyerror for failed internal
consistency checks. Switch them to Fatalf.

Updates #15756
Updates #19250

Change-Id: Ie4278148185795a28ff3c27dacffc211cda5bbdd
Reviewed-on: https://go-review.googlesource.com/38153
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile: use local fn variable in compile
Josh Bleecher Snyder [Tue, 14 Mar 2017 16:12:55 +0000 (09:12 -0700)]
cmd/compile: use local fn variable in compile

fn == Curfn in this context. Prefer the local variable.

Passes toolstash -cmp. Updates #15756.

Change-Id: I75b589c682d0c1b524cac2bbf2bba368a6027b06
Reviewed-on: https://go-review.googlesource.com/38151
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile/internal/gc: better loop var names in esc.go
Matthew Dempsky [Tue, 14 Mar 2017 15:18:11 +0000 (08:18 -0700)]
cmd/compile/internal/gc: better loop var names in esc.go

Used gorename.

Change-Id: Ib33305dc95876ec18e2473ad2999788a32eb21c0
Reviewed-on: https://go-review.googlesource.com/38146
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agocmd/compile: remove FmtFlag save and restore
Josh Bleecher Snyder [Mon, 7 Nov 2016 23:50:16 +0000 (15:50 -0800)]
cmd/compile: remove FmtFlag save and restore

It is unnecessary.

Passes toolstash -cmp.

Change-Id: I7c03523b6110c3d9bd5ba2b37d9a1e17a7ae570e
Reviewed-on: https://go-review.googlesource.com/38145
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile: eliminate format string FmtUnsigned support
Josh Bleecher Snyder [Mon, 7 Nov 2016 19:52:21 +0000 (11:52 -0800)]
cmd/compile: eliminate format string FmtUnsigned support

Passes toolstash -cmp.

Change-Id: I678fc40c0f2a6e9a434bcdd4ea17bb7f319a6063
Reviewed-on: https://go-review.googlesource.com/38144
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile: add Type.LongString and Type.ShortString
Josh Bleecher Snyder [Sun, 6 Nov 2016 19:08:08 +0000 (11:08 -0800)]
cmd/compile: add Type.LongString and Type.ShortString

Reduces duplication and centralizes documentation.
Moves all uses of FmtUnsigned and tconv inside fmt.go.

Passes toolstash -cmp.

Change-Id: If6d906e7e839de05f36423523a3a1d596e29807d
Reviewed-on: https://go-review.googlesource.com/38141
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agocmd/compile: rename Nconv to nconv
Josh Bleecher Snyder [Sun, 6 Nov 2016 19:09:09 +0000 (11:09 -0800)]
cmd/compile: rename Nconv to nconv

For consistency.

Change-Id: Ic687fea95f7a4a3be576945af3e9c97086309b07
Reviewed-on: https://go-review.googlesource.com/38142
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: simplify printing of constant bools
Josh Bleecher Snyder [Mon, 7 Nov 2016 18:28:46 +0000 (10:28 -0800)]
cmd/compile: simplify printing of constant bools

Change-Id: I9339e83e39075826bf5819e55804a94208fe84ae
Reviewed-on: https://go-review.googlesource.com/38140
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: add mapassign_fast*
Hugues Bruant [Sun, 12 Mar 2017 21:47:59 +0000 (14:47 -0700)]
runtime: add mapassign_fast*

Add benchmarks for map assignment with int32/int64/string key

Benchmark results on darwin/amd64

name                  old time/op  new time/op  delta
MapAssignInt32_255-8  24.7ns ± 3%  17.4ns ± 2%  -29.75%  (p=0.000 n=10+10)
MapAssignInt32_64k-8  45.5ns ± 4%  37.6ns ± 4%  -17.18%  (p=0.000 n=10+10)
MapAssignInt64_255-8  26.0ns ± 3%  17.9ns ± 4%  -31.03%  (p=0.000 n=10+10)
MapAssignInt64_64k-8  46.9ns ± 5%  38.7ns ± 2%  -17.53%  (p=0.000 n=9+10)
MapAssignStr_255-8    47.8ns ± 3%  24.8ns ± 4%  -48.01%  (p=0.000 n=10+10)
MapAssignStr_64k-8    83.0ns ± 3%  51.9ns ± 3%  -37.45%  (p=0.000 n=10+9)

name                     old time/op    new time/op    delta
BinaryTree17-8              3.11s ±19%     2.78s ± 3%    ~     (p=0.095 n=5+5)
Fannkuch11-8                3.26s ± 1%     3.21s ± 2%    ~     (p=0.056 n=5+5)
FmtFprintfEmpty-8          50.3ns ± 1%    50.8ns ± 2%    ~     (p=0.246 n=5+5)
FmtFprintfString-8         82.7ns ± 4%    80.1ns ± 5%    ~     (p=0.238 n=5+5)
FmtFprintfInt-8            82.6ns ± 2%    81.9ns ± 3%    ~     (p=0.508 n=5+5)
FmtFprintfIntInt-8          124ns ± 4%     121ns ± 3%    ~     (p=0.111 n=5+5)
FmtFprintfPrefixedInt-8     158ns ± 6%     160ns ± 2%    ~     (p=0.341 n=5+5)
FmtFprintfFloat-8           249ns ± 2%     245ns ± 2%    ~     (p=0.095 n=5+5)
FmtManyArgs-8               513ns ± 2%     519ns ± 3%    ~     (p=0.151 n=5+5)
GobDecode-8                7.48ms ±12%    7.11ms ± 2%    ~     (p=0.222 n=5+5)
GobEncode-8                6.25ms ± 1%    6.03ms ± 2%  -3.56%  (p=0.008 n=5+5)
Gzip-8                      252ms ± 4%     252ms ± 4%    ~     (p=1.000 n=5+5)
Gunzip-8                   38.4ms ± 3%    38.6ms ± 2%    ~     (p=0.690 n=5+5)
HTTPClientServer-8         76.9µs ±41%    66.4µs ± 6%    ~     (p=0.310 n=5+5)
JSONEncode-8               16.5ms ± 3%    16.7ms ± 3%    ~     (p=0.421 n=5+5)
JSONDecode-8               54.6ms ± 1%    54.3ms ± 2%    ~     (p=0.548 n=5+5)
Mandelbrot200-8            4.45ms ± 3%    4.47ms ± 1%    ~     (p=0.841 n=5+5)
GoParse-8                  3.43ms ± 1%    3.32ms ± 2%  -3.28%  (p=0.008 n=5+5)
RegexpMatchEasy0_32-8      88.2ns ± 3%    89.4ns ± 2%    ~     (p=0.333 n=5+5)
RegexpMatchEasy0_1K-8       205ns ± 1%     206ns ± 1%    ~     (p=0.905 n=5+5)
RegexpMatchEasy1_32-8      85.1ns ± 1%    85.5ns ± 5%    ~     (p=0.690 n=5+5)
RegexpMatchEasy1_1K-8       365ns ± 1%     371ns ± 9%    ~     (p=1.000 n=5+5)
RegexpMatchMedium_32-8      129ns ± 2%     128ns ± 3%    ~     (p=0.730 n=5+5)
RegexpMatchMedium_1K-8     39.8µs ± 0%    39.7µs ± 4%    ~     (p=0.730 n=4+5)
RegexpMatchHard_32-8       1.99µs ± 3%    2.05µs ±16%    ~     (p=0.794 n=5+5)
RegexpMatchHard_1K-8       59.3µs ± 1%    60.3µs ± 7%    ~     (p=1.000 n=5+5)
Revcomp-8                   1.36s ±63%     0.52s ± 5%    ~     (p=0.095 n=5+5)
Template-8                 62.6ms ±14%    60.5ms ± 5%    ~     (p=0.690 n=5+5)
TimeParse-8                 330ns ± 2%     324ns ± 2%    ~     (p=0.087 n=5+5)
TimeFormat-8                350ns ± 3%     340ns ± 1%  -2.86%  (p=0.008 n=5+5)

name                     old speed      new speed      delta
GobDecode-8               103MB/s ±11%   108MB/s ± 2%    ~     (p=0.222 n=5+5)
GobEncode-8               123MB/s ± 1%   127MB/s ± 2%  +3.71%  (p=0.008 n=5+5)
Gzip-8                   77.1MB/s ± 4%  76.9MB/s ± 3%    ~     (p=1.000 n=5+5)
Gunzip-8                  505MB/s ± 3%   503MB/s ± 2%    ~     (p=0.690 n=5+5)
JSONEncode-8              118MB/s ± 3%   116MB/s ± 3%    ~     (p=0.421 n=5+5)
JSONDecode-8             35.5MB/s ± 1%  35.8MB/s ± 2%    ~     (p=0.397 n=5+5)
GoParse-8                16.9MB/s ± 1%  17.4MB/s ± 2%  +3.45%  (p=0.008 n=5+5)
RegexpMatchEasy0_32-8     363MB/s ± 3%   358MB/s ± 2%    ~     (p=0.421 n=5+5)
RegexpMatchEasy0_1K-8    4.98GB/s ± 1%  4.97GB/s ± 1%    ~     (p=0.548 n=5+5)
RegexpMatchEasy1_32-8     376MB/s ± 1%   375MB/s ± 5%    ~     (p=0.690 n=5+5)
RegexpMatchEasy1_1K-8    2.80GB/s ± 1%  2.76GB/s ± 9%    ~     (p=0.841 n=5+5)
RegexpMatchMedium_32-8   7.73MB/s ± 1%  7.76MB/s ± 3%    ~     (p=0.730 n=5+5)
RegexpMatchMedium_1K-8   25.8MB/s ± 0%  25.8MB/s ± 4%    ~     (p=0.651 n=4+5)
RegexpMatchHard_32-8     16.1MB/s ± 3%  15.7MB/s ±14%    ~     (p=0.794 n=5+5)
RegexpMatchHard_1K-8     17.3MB/s ± 1%  17.0MB/s ± 7%    ~     (p=0.984 n=5+5)
Revcomp-8                 273MB/s ±83%   488MB/s ± 5%    ~     (p=0.095 n=5+5)
Template-8               31.1MB/s ±13%  32.1MB/s ± 5%    ~     (p=0.690 n=5+5)

Updates #19495

Change-Id: I116e9a2a4594769318b22d736464de8a98499909
Reviewed-on: https://go-review.googlesource.com/38091
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/vet: check shift calculations with "unsafe" package
Aliaksandr Valialkin [Mon, 13 Mar 2017 16:29:46 +0000 (18:29 +0200)]
cmd/vet: check shift calculations with "unsafe" package

vet should properly handle shift calculations via "unsafe"
package after the CL 37950.

Change-Id: I7737f2e656a5166337a17b92db46a0997f2a4e0e
Reviewed-on: https://go-review.googlesource.com/38064
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile/internal/ssa: make ARM's udiv like other calls
Matthew Dempsky [Sat, 11 Mar 2017 06:09:43 +0000 (22:09 -0800)]
cmd/compile/internal/ssa: make ARM's udiv like other calls

Passes toolstash-check -all.

Change-Id: Id389f8158cf33a3c0fcef373615b5351e7c74b5b
Reviewed-on: https://go-review.googlesource.com/38082
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agoRevert "cmd/compile: de-virtualize interface calls"
David Chase [Mon, 13 Mar 2017 21:09:27 +0000 (21:09 +0000)]
Revert "cmd/compile: de-virtualize interface calls"

This reverts commit 4e0c7c3f61475116c4ae8d11ef796819d9c404f0.

Reason for revert: The presence-of-optimization test program is fragile, breaks under noopt, and might break if the Go libraries are tweaked.  It needs to be (re)written without reference to other packages.

Change-Id: I3aaf1ab006a1a255f961a978e9c984341740e3c7
Reviewed-on: https://go-review.googlesource.com/38097
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile/internal/gc: refactor ACALL Prog creation
Matthew Dempsky [Sat, 11 Mar 2017 02:34:41 +0000 (18:34 -0800)]
cmd/compile/internal/gc: refactor ACALL Prog creation

This abstracts creation of ACALL Progs into package gc. The main
benefit of this today is we can refactor away a lot of common
boilerplate code.

Later, once liveness analysis happens on the SSA graph, this will also
provide an easy insertion point for emitting the PCDATA Progs
immediately before call instructions.

Passes toolstash-check -all.

Change-Id: Ia15108ace97201cd84314f1ca916dfeb4f09d61c
Reviewed-on: https://go-review.googlesource.com/38081
Reviewed-by: Keith Randall <khr@golang.org>
7 years agoencoding/gob: add Encode-Decode Int slices tests
Alberto Donizetti [Mon, 13 Mar 2017 19:35:07 +0000 (20:35 +0100)]
encoding/gob: add Encode-Decode Int slices tests

Tinkering with the gob package shows that is currently possible to
*completely destroy* Int slices encoding without triggering a single
test failure.

The various encInt{8,16,32,64}Slice methods are only called during the
execution of the GobMapInterfaceEncode test, which only encodes a few
slices of length exactly 1 and then just checks that the error
returned by Encode is nil (without trying to Decode back the data).

This patch adds a few tests for signed integer slices encoding.

Change-Id: Ifaaee2f32132873118b241f79aa8203e4ad31416
Reviewed-on: https://go-review.googlesource.com/38066
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile/internal/ssa: replace {Defer,Go}Call with StaticCall
Matthew Dempsky [Sat, 11 Mar 2017 01:42:02 +0000 (17:42 -0800)]
cmd/compile/internal/ssa: replace {Defer,Go}Call with StaticCall

Passes toolstash-check -all.

Change-Id: Icf8b75364e4761a5e56567f503b2c1cb17382ed2
Reviewed-on: https://go-review.googlesource.com/38080
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile: zero return parameters earlier
khr [Thu, 9 Mar 2017 18:38:45 +0000 (10:38 -0800)]
cmd/compile: zero return parameters earlier

Move the zeroing of results earlier.  In particular, they need to
come before any move-to-heap operations, as those require allocation.
Those allocations are points at which the GC can see the uninitialized
result slots.

For the function:

func f() (x, y, z *int) {
  defer(){}()
  escape(&y)
  return
}

We used to generate code like this:

x = nil
y = nil
&y = new(int)
z = nil

Now we will generate:

x = nil
y = nil
z = nil
&y = new(int)

Since the fix for #18860, the return slots are always live if there
is a defer, so the former ordering allowed the GC to see junk
in the z slot.

Fixes #19078

Change-Id: I71554ae437549725bb79e13b2c100b2911d47ed4
Reviewed-on: https://go-review.googlesource.com/38133
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/internal/obj/x86: remove unused const
Ilya Tocar [Mon, 13 Mar 2017 18:56:41 +0000 (13:56 -0500)]
cmd/internal/obj/x86: remove unused const

Since https://go-review.googlesource.com/24040 we no longer pad functions
in asm6, so funcAlign is unused. Delete it.

Change-Id: Id710e545a76b1797398f2171fe7e0928811fcb31
Reviewed-on: https://go-review.googlesource.com/38134
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile: eliminate more nil checks of phis
Josh Bleecher Snyder [Thu, 9 Mar 2017 21:30:20 +0000 (13:30 -0800)]
cmd/compile: eliminate more nil checks of phis

The existing implementation started by eliminating
nil checks for OpAddr, OpAddPtr, and OpPhis with
all non-nil args.

However, some OpPhis had all non-nil args,
but their args had not been processed yet.

Pull the OpPhi checks into their own loop,
and repeat until stabilization.

Eliminates a dozen additional nilchecks during make.bash.

Negligible compiler performance impact.

Change-Id: If7b803c3ad7582af7d9867d05ca13e03e109d864
Reviewed-on: https://go-review.googlesource.com/37999
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
7 years agocmd/compile: de-virtualize interface calls
Philip Hofer [Fri, 3 Mar 2017 18:57:53 +0000 (10:57 -0800)]
cmd/compile: de-virtualize interface calls

With this change, code like

    h := sha1.New()
    h.Write(buf)
    sum := h.Sum()

gets compiled into static calls rather than
interface calls, because the compiler is able
to prove that 'h' is really a *sha1.digest.

The InterCall re-write rule hits a few dozen times
during make.bash, and hundreds of times during all.bash.

The most common pattern identified by the compiler
is a constructor like

    func New() Interface { return &impl{...} }

where the constructor gets inlined into the caller,
and the result is used immediately. Examples include
{sha1,md5,crc32,crc64,...}.New, base64.NewEncoder,
base64.NewDecoder, errors.New, net.Pipe, and so on.

Some existing benchmarks that change on darwin/amd64:

Crc64/ISO4KB-8        2.67µs ± 1%    2.66µs ± 0%  -0.36%  (p=0.015 n=10+10)
Crc64/ISO1KB-8         694ns ± 0%     690ns ± 1%  -0.59%  (p=0.001 n=10+10)
Adler32KB-8            473ns ± 1%     471ns ± 0%  -0.39%  (p=0.010 n=10+9)

On architectures like amd64, the reduction in code size
appears to contribute more to benchmark improvements than just
removing the indirect call, since that branch gets predicted
accurately when called in a loop.

Updates #19361

Change-Id: Ia9d30afdd5f6b4d38d38b14b88f308acae8ce7ed
Reviewed-on: https://go-review.googlesource.com/37751
Run-TryBot: Philip Hofer <phofer@umich.edu>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agospec: remove superfluous terms "delimiter" and "special tokens"
Robert Griesemer [Sat, 11 Mar 2017 01:17:23 +0000 (17:17 -0800)]
spec: remove superfluous terms "delimiter" and "special tokens"

The (original) section on "Operators and Delimiters" introduced
superfluous terminology ("delimiter", "special token") which
didn't matter and was used inconsistently.

Removed any mention of "delimiter" or "special token" and now
simply group the special character tokens into "operators"
(clearly defined via links), and "punctuation" (everything else).

Fixes #19450.

Change-Id: Ife31b24b95167ace096f93ed180b7eae41c66808
Reviewed-on: https://go-review.googlesource.com/38073
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
7 years agonet/http: unset proxy environment after test
Chew Choon Keat [Mon, 13 Mar 2017 03:21:21 +0000 (03:21 +0000)]
net/http: unset proxy environment after test

Fix last proxy in TestProxyFromEnvironment bleeds into other tests
Change ResetProxyEnv to use the newer os.Unsetenv, instead of hard
coding as ""

Change-Id: I67cf833dbcf4bec2e10ea73c354334160cf05f84
Reviewed-on: https://go-review.googlesource.com/38115
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile/internal/gc: remove unused exportsize variable
Dave Cheney [Mon, 13 Mar 2017 03:30:44 +0000 (14:30 +1100)]
cmd/compile/internal/gc: remove unused exportsize variable

In Go 1.7 and earlier, gc.exportsize tracked the number of bytes
written through exportf. With the removal of the old exporter in Go 1.8
exportf is only used for printing the build id, and the header and
trailer of the binary export format. The size of the export data is
now returned directly from the exporter and exportsize is never
referenced. Remove it.

Change-Id: Id301144b3c26c9004c722d0c55c45b0e0801a88c
Reviewed-on: https://go-review.googlesource.com/38116
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/go/internal/get: remove unused tag selection code
Dave Cheney [Mon, 13 Mar 2017 00:19:47 +0000 (11:19 +1100)]
cmd/go/internal/get: remove unused tag selection code

selectTag has been hard coded to only understand the tag `go1` since
CL 6112060 which landed in 2012. The commit message asserted;

  Right now (before go1.0.1) there is only one possible tag,
  "go1", and I'd like to keep it that way.

Remove goTag and the unused matching code in selectTag.

Change-Id: I85f7c10f95704e22f8e8681266afd72bbcbe8fbd
Reviewed-on: https://go-review.googlesource.com/38112
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: remove sizeToClass
Dave Cheney [Mon, 13 Mar 2017 00:35:39 +0000 (11:35 +1100)]
runtime: remove sizeToClass

CL 32219 added precomputed sizeclass tables.

Remove the unused sizeToClass method which was previously only
called from initSizes.

Change-Id: I907bf9ed78430ecfaabbec7fca77ef2375010081
Reviewed-on: https://go-review.googlesource.com/38113
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet/http: fix body close statement is missing
Marcel Edmund Franke [Sun, 12 Mar 2017 11:19:32 +0000 (12:19 +0100)]
net/http: fix body close statement is missing

Call body close after ioutil.ReadAll is done

Change-Id: Ieceb1965a6a8f2dbc024e983acdfe22df17d07d1
Reviewed-on: https://go-review.googlesource.com/38059
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agostrconv: fix performance regression in integer formatting on 32bit platforms
Martin Möhrmann [Sat, 11 Mar 2017 07:48:56 +0000 (08:48 +0100)]
strconv: fix performance regression in integer formatting on 32bit platforms

Some of the changes in CL golang.org/cl/38071/ assumed that / and %
could always be combined to use only one DIV instruction. However,
this is not the case for 64bit operands on a 32bit platform which use
seperate runtime functions to calculate division and modulo.

This CL restores the original optimizations that help on 32bit platforms
with negligible impact on 64bit platforms.

386:
name          old time/op  new time/op  delta
FormatInt-2   6.06µs ± 0%  6.02µs ± 0%  -0.70%  (p=0.000 n=20+20)
AppendInt-2   4.98µs ± 0%  4.98µs ± 0%    ~     (p=0.747 n=18+18)
FormatUint-2  1.93µs ± 0%  1.85µs ± 0%  -4.19%  (p=0.000 n=20+20)
AppendUint-2  1.71µs ± 0%  1.64µs ± 0%  -3.68%  (p=0.000 n=20+20)

amd64:
name          old time/op  new time/op  delta
FormatInt-2   2.41µs ± 0%  2.41µs ± 0%  -0.09%  (p=0.010 n=18+18)
AppendInt-2   1.77µs ± 0%  1.77µs ± 0%  +0.08%  (p=0.000 n=18+18)
FormatUint-2   653ns ± 1%   653ns ± 0%    ~     (p=0.178 n=20+20)
AppendUint-2   514ns ± 0%   513ns ± 0%  -0.13%  (p=0.000 n=20+17)

Change-Id: I574a18e54fb41b25fbe51ce696e7a8765abc79a6
Reviewed-on: https://go-review.googlesource.com/38051
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agocmd/link: eliminate markextra
Matthew Dempsky [Sat, 11 Mar 2017 06:22:11 +0000 (22:22 -0800)]
cmd/link: eliminate markextra

This appears to be leftover from when instruction selection happened
in the linker. Many of the morestackX functions listed don't even
exist anymore.

Now that we select instructions within the compiler and assembler,
normal deadcode elimination mechanisms should suffice for these
symbols.

Change-Id: I2cb1e435101392e7c983957c4acfbbcc87a5ca7d
Reviewed-on: https://go-review.googlesource.com/38077
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/vet: eliminate "might be too small for shift" warnings
Aliaksandr Valialkin [Wed, 8 Mar 2017 09:36:30 +0000 (11:36 +0200)]
cmd/vet: eliminate "might be too small for shift" warnings

Determine int, uint and uintptr bit sizes from GOARCH environment
variable if it is set. Otherwise use host-specific sizes.

Fixes #19321

Change-Id: I494b8e4b49b59d32794f50ff2ce06ba040cb8460
Reviewed-on: https://go-review.googlesource.com/37950
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
7 years agocmd/go: if we get a C compiler dwarf2 warning, try without -g
Ian Lance Taylor [Sat, 11 Mar 2017 01:03:52 +0000 (17:03 -0800)]
cmd/go: if we get a C compiler dwarf2 warning, try without -g

This avoids a problem that occurs on FreeBSD 11, in which the clang
3.8 assembler issues a pointless warning when invoked with -g on a
file that contains an empty .note.GNU-stack section.

No test because there is no reasonable way to write one, but should
fix the build on FreeBSD 11.

Fixes #14705.

Change-Id: I8c49bbf79a2c715c0e75495da19045fc92280e81
Reviewed-on: https://go-review.googlesource.com/38072
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agomath/big: make nat.setUint64 vet-friendly
Josh Bleecher Snyder [Fri, 10 Mar 2017 23:09:05 +0000 (15:09 -0800)]
math/big: make nat.setUint64 vet-friendly

nat.setUint64 is nicely generic.
By assuming 32- or 64-bit words, however,
we can write simpler code,
and eliminate some shifts
in dead code that vet complains about.

Generated code for 64 bit systems is unaltered.
Generated code for 32 bit systems is much better.
For 386, the routine length drops from 325
bytes of code to 271 bytes of code, with fewer loops.

Change-Id: I1bc14c06272dee37a7fcb48d33dd1e621eba945d
Reviewed-on: https://go-review.googlesource.com/38070
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agostrconv: use % instead of computing the remainder from the quotient
Robert Griesemer [Fri, 10 Mar 2017 23:14:54 +0000 (15:14 -0800)]
strconv: use % instead of computing the remainder from the quotient

The compiler recognizes that in a sequence q = x/y; r = x%y only
one division is required. Remove prior work-arounds and write
more readable straight-line code (this also results in fewer
instructions, though it doesn't appear to affect the benchmarks
significantly).

name          old time/op  new time/op  delta
FormatInt-8   2.95µs ± 1%  2.92µs ± 5%   ~     (p=0.952 n=5+5)
AppendInt-8   1.91µs ± 1%  1.89µs ± 2%   ~     (p=0.421 n=5+5)
FormatUint-8   795ns ± 2%   782ns ± 4%   ~     (p=0.444 n=5+5)
AppendUint-8   557ns ± 1%   557ns ± 2%   ~     (p=0.548 n=5+5)

https://perf.golang.org/search?q=upload:20170310.1

Also:
- use uint instead of uintptr where we want to guarantee single-
  register operations
- remove some unnecessary conversions (before indexing)
- add more comments and fix some comments

Change-Id: I04858dc2d798a6495879d9c7cfec2fdc2957b704
Reviewed-on: https://go-review.googlesource.com/38071
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: use cpuset_getaffinity for runtime.NumCPU() on FreeBSD
David NewHamlet [Fri, 10 Mar 2017 20:13:20 +0000 (09:13 +1300)]
runtime: use cpuset_getaffinity for runtime.NumCPU() on FreeBSD

In FreeBSD when run Go proc under a given sub-list of
processors(e.g. 'cpuset -l 0 ./a.out' in multi-core system),
runtime.NumCPU() still return all physical CPUs from sysctl
hw.ncpu instead of account from sub-list.

Fix by use syscall cpuset_getaffinity to account the number of sub-list.

Fixes #15206

Change-Id: If87c4b620e870486efa100685db5debbf1210a5b
Reviewed-on: https://go-review.googlesource.com/29341
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

7 years agocmd/go: when expanding "cmd", skip vendored main packages
Ian Lance Taylor [Fri, 10 Mar 2017 18:04:42 +0000 (10:04 -0800)]
cmd/go: when expanding "cmd", skip vendored main packages

We are vendoring pprof from github.com/google/pprof, which comes with
a main package. If we don't explicitly skip that main package, then
`go install cmd` will install the compiled program in $GOROOT/bin.

Fixes #19441.

Change-Id: Ib268ffd16d4be65f7d80e4f8d9dc6e71523a94de
Reviewed-on: https://go-review.googlesource.com/38007
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Raul Silvera <rsilvera@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: remove unused ratep parameter
Daniel Martí [Fri, 10 Mar 2017 17:07:42 +0000 (17:07 +0000)]
runtime: remove unused ratep parameter

Found by github.com/mvdan/unparam.

Change-Id: Iabcdfec2ae42c735aa23210b7183080d750682ca
Reviewed-on: https://go-review.googlesource.com/38030
Reviewed-by: Peter Weinberger <pjw@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoexpvar: add benchmark for (*Map).Set with per-goroutine keys
Bryan C. Mills [Thu, 9 Mar 2017 21:45:14 +0000 (16:45 -0500)]
expvar: add benchmark for (*Map).Set with per-goroutine keys

Change-Id: I0fa68ca9812fe5e82ffb9d0b9598e95b47183eb8
Reviewed-on: https://go-review.googlesource.com/38011
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agonet/http: change TestServerAllowsBlockingRemoteAddr to non-parallel
Josh Bleecher Snyder [Fri, 10 Mar 2017 06:02:13 +0000 (22:02 -0800)]
net/http: change TestServerAllowsBlockingRemoteAddr to non-parallel

It appears that this test is particularly
sensitive to resource starvation.
Returning it to non-parallel should reduce flakiness,
by giving it the full system resources to run.

Fixes #19161

Change-Id: I6e8906516629badaa0cffeb5712af649dc197f39
Reviewed-on: https://go-review.googlesource.com/38005
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: add 32 bit (AddPtr (Const)) rule
Josh Bleecher Snyder [Thu, 9 Mar 2017 22:28:32 +0000 (14:28 -0800)]
cmd/compile: add 32 bit (AddPtr (Const)) rule

This triggers about 50k times during 32 bit make.bash.

Change-Id: Ia0c2b1a8246b92173b4b0d94a4037626f76b6e73
Reviewed-on: https://go-review.googlesource.com/37998
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/compile: add OpOffPtr [c] SP to constant cache
Josh Bleecher Snyder [Wed, 8 Mar 2017 20:50:00 +0000 (12:50 -0800)]
cmd/compile: add OpOffPtr [c] SP to constant cache

They accounted for almost 30% of all CSE'd values.

By never creating the duplicates in the first place,
we reduce the high water mark of Value IDs,
which in turn makes all SSA phases cheaper,
particularly regalloc.

name       old time/op     new time/op     delta
Template       200ms ± 3%      198ms ± 4%  -0.87%  (p=0.016 n=50+49)
Unicode       86.9ms ± 2%     85.5ms ± 3%  -1.56%  (p=0.000 n=49+50)
GoTypes        553ms ± 4%      551ms ± 4%    ~     (p=0.183 n=50+49)
SSA            3.97s ± 3%      3.93s ± 2%  -1.06%  (p=0.000 n=48+48)
Flate          124ms ± 4%      124ms ± 3%    ~     (p=0.545 n=48+50)
GoParser       146ms ± 4%      146ms ± 4%    ~     (p=0.810 n=49+49)
Reflect        357ms ± 3%      355ms ± 3%  -0.59%  (p=0.049 n=50+48)
Tar            106ms ± 4%      107ms ± 5%    ~     (p=0.454 n=49+50)
XML            203ms ± 4%      203ms ± 4%    ~     (p=0.726 n=48+50)

name       old user-ns/op  new user-ns/op  delta
Template        237M ± 3%       235M ± 4%    ~     (p=0.208 n=47+48)
Unicode         111M ± 4%       108M ± 9%  -2.50%  (p=0.000 n=47+50)
GoTypes         736M ± 5%       729M ± 4%  -0.95%  (p=0.017 n=50+46)
SSA            5.73G ± 4%      5.74G ± 4%    ~     (p=0.765 n=50+50)
Flate           150M ± 5%       148M ± 6%  -0.89%  (p=0.045 n=48+47)
GoParser        180M ± 5%       178M ± 7%  -1.34%  (p=0.012 n=50+50)
Reflect         450M ± 4%       444M ± 4%  -1.40%  (p=0.000 n=50+49)
Tar             124M ± 7%       123M ± 7%    ~     (p=0.092 n=50+50)
XML             248M ± 6%       245M ± 5%    ~     (p=0.057 n=50+50)

name       old alloc/op    new alloc/op    delta
Template      39.4MB ± 0%     39.3MB ± 0%  -0.37%  (p=0.000 n=50+50)
Unicode       30.9MB ± 0%     30.9MB ± 0%  -0.27%  (p=0.000 n=48+50)
GoTypes        114MB ± 0%      113MB ± 0%  -1.03%  (p=0.000 n=50+49)
SSA            882MB ± 0%      865MB ± 0%  -1.95%  (p=0.000 n=49+49)
Flate         25.8MB ± 0%     25.7MB ± 0%  -0.21%  (p=0.000 n=50+50)
GoParser      31.7MB ± 0%     31.6MB ± 0%  -0.33%  (p=0.000 n=50+50)
Reflect       79.7MB ± 0%     79.3MB ± 0%  -0.49%  (p=0.000 n=44+49)
Tar           27.2MB ± 0%     27.1MB ± 0%  -0.31%  (p=0.000 n=50+50)
XML           42.7MB ± 0%     42.3MB ± 0%  -1.05%  (p=0.000 n=48+49)

name       old allocs/op   new allocs/op   delta
Template        379k ± 1%       380k ± 1%  +0.26%  (p=0.000 n=50+50)
Unicode         324k ± 1%       324k ± 1%    ~     (p=0.964 n=49+50)
GoTypes        1.14M ± 0%      1.15M ± 0%  +0.14%  (p=0.000 n=50+49)
SSA            7.89M ± 0%      7.89M ± 0%  -0.05%  (p=0.000 n=49+49)
Flate           240k ± 1%       241k ± 1%  +0.27%  (p=0.001 n=50+50)
GoParser        310k ± 1%       311k ± 1%  +0.48%  (p=0.000 n=50+49)
Reflect        1.00M ± 0%      1.00M ± 0%  +0.17%  (p=0.000 n=48+50)
Tar             254k ± 1%       255k ± 1%  +0.23%  (p=0.005 n=50+50)
XML             395k ± 1%       395k ± 1%  +0.19%  (p=0.002 n=49+47)

Change-Id: Iaa8f5f37e23bd81983409f7359f9dcd4dfe2961f
Reviewed-on: https://go-review.googlesource.com/38003
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/compile: allow earlier GC of freed constant value
Josh Bleecher Snyder [Wed, 8 Mar 2017 22:48:43 +0000 (14:48 -0800)]
cmd/compile: allow earlier GC of freed constant value

Minor fix, because it's the right thing to do.
No significant impact.

Change-Id: I2138285d397494daa9a88c414149c2a7860edd7e
Reviewed-on: https://go-review.googlesource.com/38001
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: fix SSA type for first runtime call arg/result
Josh Bleecher Snyder [Wed, 8 Mar 2017 20:48:04 +0000 (12:48 -0800)]
cmd/compile: fix SSA type for first runtime call arg/result

CLs 37254 and 37869 contained similar fixes.

Change-Id: I0cbf01c691b54d82acef398489df6e9c89ebb83f
Reviewed-on: https://go-review.googlesource.com/38000
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Michael Munday <munday@ca.ibm.com>
7 years agocmd/compile: rename Func.constVal arg for clarity
Josh Bleecher Snyder [Wed, 8 Mar 2017 20:45:12 +0000 (12:45 -0800)]
cmd/compile: rename Func.constVal arg for clarity

Values have an Aux and an AuxInt.
We're setting AuxInt, not Aux.
Say so.

Change-Id: I41aa783273bb7e1ba47c941aa4233f818e37dadd
Reviewed-on: https://go-review.googlesource.com/37997
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: print columns (not just lines) in error messages
Robert Griesemer [Wed, 8 Mar 2017 22:26:23 +0000 (14:26 -0800)]
cmd/compile: print columns (not just lines) in error messages

Compiler errors now show the exact line and line byte offset (sometimes
called "column") of where an error occured. For `go tool compile x.go`:

package p
const c int = false
//line foo.go:123
type t intg

reports

x.go:2:7: cannot convert false to type int
foo.go:123[x.go:4:8]: undefined: intg

(Some errors use the "wrong" position for the error message; arguably
the byte offset for the first error should be 15, the position of 'false',
rathen than 7, the position of 'c'. But that is an indepedent issue.)

The byte offset (column) values are measured in bytes; they start at 1,
matching the convention used by editors and IDEs.

Positions modified by //line directives show the line offset only for the
actual source location (in square brackets), not for the "virtual" file and
line number because that code is likely generated and the //line directive
only provides line information.

Because the new format might break existing tools or scripts, printing
of line offsets can be disabled with the new compiler flag -C. We plan
to remove this flag eventually.

Fixes #10324.

Change-Id: I493f5ee6e78457cf7b00025aba6b6e28e50bb740
Reviewed-on: https://go-review.googlesource.com/37970
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile/internal/syntax: start line offset (column) numbers at 1
Robert Griesemer [Thu, 9 Mar 2017 21:38:10 +0000 (13:38 -0800)]
cmd/compile/internal/syntax: start line offset (column) numbers at 1

We could leave it alone and fix line offset (column) numbers when
reporting errors, but that is likely to cause confusion (internal
numbers don't match reported numbers). Instead, switch to default
numbering starting at 1.

For package syntax-internal use only, introduced constants defining
the line and column bases, and use them throughout the code and its
tests. It is possible to change these constants and package syntax
will continue to work. But changing them is going to break any client
that makes explicit assumptions about line and column numbers (which
is "all of them").

Change-Id: Ia3d136a8ec8d9372ed9c05ca47d3dff222cf030e
Reviewed-on: https://go-review.googlesource.com/37996
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agonet: add Resolver.StrictErrors
Paul Marks [Wed, 2 Nov 2016 04:01:08 +0000 (21:01 -0700)]
net: add Resolver.StrictErrors

When LookupIP is performing multiple subqueries, this option causes a
timeout/servfail affecting a single query to abort the whole operation,
instead of returning a partial (IPv4/IPv6-only) result.

Similarly, operations that walk the DNS search list will also abort when
encountering one of these errors.

Fixes #17448

Change-Id: Ice22e4aceb555c5a80d19bd1fde8b8fe87ac9517
Reviewed-on: https://go-review.googlesource.com/32572
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile: clean up ssa.Value memory arg usage
Philip Hofer [Fri, 3 Mar 2017 21:44:18 +0000 (13:44 -0800)]
cmd/compile: clean up ssa.Value memory arg usage

This change adds a method to replace expressions
of the form

   v.Args[len(v.Args)-1]

so that the code's intention to walk memory arguments
is explicit.

Passes toolstash-check.

Change-Id: I0c80d73bc00989dd3cdf72b4f2c8e1075a2515e0
Reviewed-on: https://go-review.googlesource.com/37757
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile: remove duplicated zeroing of outgoing args
Cherry Zhang [Wed, 8 Mar 2017 11:56:40 +0000 (06:56 -0500)]
cmd/compile: remove duplicated zeroing of outgoing args

Outgoing arg zeroing code is inserted at walk.go:paramstoheap.
Don't do it twice.

Change-Id: I70afac6af9e39b3efce0a6a79d6193428d922708
Reviewed-on: https://go-review.googlesource.com/37863
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agosrc/*.bash: use tabs consistently
Daniel Martí [Thu, 9 Mar 2017 20:50:24 +0000 (20:50 +0000)]
src/*.bash: use tabs consistently

make.bash used mostly tabs and buildall.bash used mostly spaces, but
they were both mixing them. Be consistent and use tabs, as that's what's
more common and what the Go code uses.

Change-Id: Ia6affbfccfe64fda800c1ac400965df364d2c545
Reviewed-on: https://go-review.googlesource.com/37967
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile: fix OffPtr type in 2-field struct Store rule
Michael Munday [Thu, 9 Mar 2017 18:03:07 +0000 (13:03 -0500)]
cmd/compile: fix OffPtr type in 2-field struct Store rule

The type of the OffPtr for the first field was incorrect. It should
have been a pointer to the field type, rather than the field
type itself.

Fixes #19475.

Change-Id: I3960b404da0f4bee759331126cce6140d2ce1df7
Reviewed-on: https://go-review.googlesource.com/37869
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agoruntime/cgo: return correct sa_flags
Bryan C. Mills [Tue, 7 Mar 2017 23:50:52 +0000 (18:50 -0500)]
runtime/cgo: return correct sa_flags

A typo in the previous revision ("act" instead of "oldact") caused us
to return the sa_flags from the new (or zeroed) sigaction rather than
the old one.

In the presence of a signal handler registered before
runtime.libpreinit, this caused setsigstack to erroneously zero out
important sa_flags (such as SA_SIGINFO) in its attempt to re-register
the existing handler with SA_ONSTACK.

Change-Id: I3cd5152a38ec0d44ae611f183bc1651d65b8a115
Reviewed-on: https://go-review.googlesource.com/37852
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: fix _cgo_yield usage with sysmon and on BSD
Bryan C. Mills [Wed, 8 Mar 2017 20:40:28 +0000 (15:40 -0500)]
runtime: fix _cgo_yield usage with sysmon and on BSD

There are a few problems from change 35494, discovered during testing
of change 37852.

1. I was confused about the usage of n.key in the sema variant, so we
   were looping on the wrong condition. The error was not caught by
   the TryBots (presumably due to missing TSAN coverage in the BSD and
   darwin builders?).

2. The sysmon goroutine sometimes skips notetsleep entirely, using
   direct usleep syscalls instead. In that case, we were not calling
   _cgo_yield, leading to missed signals under TSAN.

3. Some notetsleep calls have long finite timeouts. They should be
   broken up into smaller chunks with a yield at the end of each
   chunk.

updates #18717

Change-Id: I91175af5dea3857deebc686f51a8a40f9d690bcc
Reviewed-on: https://go-review.googlesource.com/37867
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agotime: make the ParseInLocation test more robust
Alberto Donizetti [Thu, 9 Mar 2017 12:20:54 +0000 (13:20 +0100)]
time: make the ParseInLocation test more robust

The tzdata 2017a update (2017-02-28) changed the abbreviation of the
Asia/Baghdad time zone (used in TestParseInLocation) from 'AST' to the
numeric '+03'.

Update the test so that it skips the checks if we're using a recent
tzdata release.

Fixes #19457

Change-Id: I45d705a5520743a611bdd194dc8f8d618679980c
Reviewed-on: https://go-review.googlesource.com/37964
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agomisc/cgo/testcarchive: add missing header
Elias Naur [Thu, 9 Mar 2017 09:23:10 +0000 (10:23 +0100)]
misc/cgo/testcarchive: add missing header

write(2) is defined in unistd.h.

For the iOS builder.

Change-Id: I411ffe81988d8fbafffde89e4732a20af1a63325
Reviewed-on: https://go-review.googlesource.com/37962
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile/internal/gc: shrink Sym by 8 bytes on amd64
Aliaksandr Valialkin [Mon, 6 Mar 2017 18:39:24 +0000 (20:39 +0200)]
cmd/compile/internal/gc: shrink Sym by 8 bytes on amd64

Move 8-bit flags field after 32-bit Block field

Change-Id: I8e5e9a2285477aac2402a839a105e710d5340224
Reviewed-on: https://go-review.googlesource.com/37848
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: set base register of spill/restore to SP
Keith Randall [Thu, 9 Mar 2017 00:31:02 +0000 (16:31 -0800)]
cmd/compile: set base register of spill/restore to SP

Previously the base register was unset, which lead to the disassembler
using "FP" instead of "SP" as the base register.  That lead to some
confusion as to what the difference betweeen the two was.
Be consistent and always use SP.

Fixes #19458

Change-Id: Ie8f8ee54653bd202c0cf6fbf1d350e3c8c8b67a0
Reviewed-on: https://go-review.googlesource.com/37971
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agogo/internal/srcimporter: skip tests on iOS
Elias Naur [Wed, 8 Mar 2017 21:54:52 +0000 (22:54 +0100)]
go/internal/srcimporter: skip tests on iOS

The iOS test harness only includes the current test directory in its
app bundles, but the tests need access to all source code.

Change-Id: I8a902b183bc2745b4fbfffef867002d573abb1f5
Reviewed-on: https://go-review.googlesource.com/37961
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: optimize slicebytestostring
Josh Bleecher Snyder [Sun, 5 Mar 2017 00:54:50 +0000 (16:54 -0800)]
runtime: optimize slicebytestostring

Inline rawstringtmp and simplify.
Use memmove instead of copy.

name                     old time/op  new time/op  delta
SliceByteToString/1-8    19.4ns ± 2%  14.1ns ± 1%  -27.04%  (p=0.000 n=20+17)
SliceByteToString/2-8    20.8ns ± 2%  15.5ns ± 2%  -25.46%  (p=0.000 n=20+20)
SliceByteToString/4-8    20.7ns ± 1%  14.9ns ± 1%  -28.30%  (p=0.000 n=20+20)
SliceByteToString/8-8    23.2ns ± 1%  17.1ns ± 1%  -26.22%  (p=0.000 n=19+19)
SliceByteToString/16-8   29.4ns ± 1%  23.6ns ± 1%  -19.76%  (p=0.000 n=17+20)
SliceByteToString/32-8   31.4ns ± 1%  26.0ns ± 1%  -17.11%  (p=0.000 n=16+19)
SliceByteToString/64-8   36.1ns ± 0%  30.0ns ± 0%  -16.96%  (p=0.000 n=16+16)
SliceByteToString/128-8  46.9ns ± 0%  38.9ns ± 0%  -17.15%  (p=0.000 n=17+19)

Change-Id: I422e688830e4a9bd21897d1f74964625b735f436
Reviewed-on: https://go-review.googlesource.com/37791
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agoos/user: fake Current on Android
Elias Naur [Wed, 8 Mar 2017 20:56:57 +0000 (21:56 +0100)]
os/user: fake Current on Android

On Android devices where the stub fallback for Current fails to
extract a User from the environment, return a dummy fallback instead
of failing.

While we're here, use / instead of /home/nacl for the NaCL fallback.

Hopefully fixes the Android builder.

Change-Id: Ia29304fbc224ee5f9c0f4e706d1756f765a7eae5
Reviewed-on: https://go-review.googlesource.com/37960
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime: poll libc to deliver signals under TSAN
Bryan C. Mills [Thu, 19 Jan 2017 21:09:10 +0000 (16:09 -0500)]
runtime: poll libc to deliver signals under TSAN

fixes #18717

Change-Id: I7244463d2e7489e0b0fe3b74c4b782e71210beb2
Reviewed-on: https://go-review.googlesource.com/35494
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/compile: check loop rescheduling with stack bound, not counter
David Chase [Thu, 2 Feb 2017 16:53:41 +0000 (11:53 -0500)]
cmd/compile: check loop rescheduling with stack bound, not counter

After benchmarking with a compiler modified to have better
spill location, it became clear that this method of checking
was actually faster on (at least) two different architectures
(ppc64 and amd64) and it also provides more timely interruption
of loops.

This change adds a modified FOR loop node "FORUNTIL" that
checks after executing the loop body instead of before (i.e.,
always at least once).  This ensures that a pointer past the
end of a slice or array is not made visible to the garbage
collector.

Without the rescheduling checks inserted, the restructured
loop from this  change apparently provides a 1% geomean
improvement on PPC64 running the go1 benchmarks; the
improvement on AMD64 is only 0.12%.

Inserting the rescheduling check exposed some peculiar bug
with the ssa test code for s390x; this was updated based on
initial code actually generated for GOARCH=s390x to use
appropriate OpArg, OpAddr, and OpVarDef.

NaCl is disabled in testing.

Change-Id: Ieafaa9a61d2a583ad00968110ef3e7a441abca50
Reviewed-on: https://go-review.googlesource.com/36206
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agodatabase/sql: fix spelling mistake in tests
Kevin Burke [Wed, 8 Mar 2017 18:22:00 +0000 (10:22 -0800)]
database/sql: fix spelling mistake in tests

Change-Id: I04e150d4e4123aad2f277e5c6e9f2abd15628a28
Reviewed-on: https://go-review.googlesource.com/37941
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: fix recorded export data position info
Robert Griesemer [Tue, 7 Mar 2017 23:58:28 +0000 (15:58 -0800)]
cmd/compile: fix recorded export data position info

The position information recorded now consists of the line-
directive relative filename and line number. It would be
relatively easy to also encode absolute position information
as necessary (by serializing src.PosBase data).

For example, given $GOROOT/src/tmp/x.go:

package p

const C0 = 0

//line c.go:10
const C1 = 1

//line t.go:20
type T int

//line v.go:30
var V T

//line f.go:40
func F() {}

The recorded positions for the exported entities are:

C0 $GOROOT/src/tmp/x.go 3
C1 c.go 10
T t.go 20
V v.go 30
F f.go 40

Fix verified by manual inspection. There's currently no easy way
to test this, but it will eventually be tested when we fix #7311.

Fixes #19391.

Change-Id: I6269067ea58358250fe6dd1f73bdf9e5d2adfe3d
Reviewed-on: https://go-review.googlesource.com/37936
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agodatabase/sql: proper prepared statement support in transactions
Sarah Adams [Thu, 19 Jan 2017 22:17:10 +0000 (14:17 -0800)]
database/sql: proper prepared statement support in transactions

This change was originally written by Marko Tiikkaja <marko@joh.to>.
https://go-review.googlesource.com/#/c/2035/

Previously *Tx.Stmt always prepared a new statement, even if an
existing one was available on the connection the transaction was on.
Now we first see if the statement is already available on the
connection and only prepare if it isn't. Additionally, when we do
need to prepare one, we store it in the parent *Stmt to allow it to be
later reused by other calls to *Tx.Stmt on that statement or just
straight up by *Stmt.Exec et al.

To make sure that the statement doesn't disappear unexpectedly, we
record a dependency from the statement returned by *Tx.Stmt to the
*Stmt it came from and set a new field, parentStmt, to point to the
originating *Stmt. When the transaction's *Stmt is closed, we remove
the dependency. This way the "parent" *Stmt can be closed by the user
without her having to know whether any transactions are still using it
or not.

Fixes #15606

Change-Id: I41b5056847e117ac61130328b0239d1e000a4a08
Reviewed-on: https://go-review.googlesource.com/35476
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
7 years agonet/http: use httptest.Server Client in tests
Johan Brandhorst [Sat, 4 Mar 2017 18:24:44 +0000 (18:24 +0000)]
net/http: use httptest.Server Client in tests

After merging https://go-review.googlesource.com/c/34639/,
it was pointed out to me that a lot of tests under net/http
could use the new functionality to simplify and unify testing.

Using the httptest.Server provided Client removes the need to
call CloseIdleConnections() on all Transports created, as it
is automatically called on the Transport associated with the
client when Server.Close() is called.

Change the transport used by the non-TLS
httptest.Server to a new *http.Transport rather than using
http.DefaultTransport implicitly. The TLS version already
used its own *http.Transport. This change is to prevent
concurrency problems with using DefaultTransport implicitly
across several httptest.Server's.

Add tests to ensure the httptest.Server.Client().Transport
RoundTripper interface is implemented by a *http.Transport,
as is now assumed across large parts of net/http tests.

Change-Id: I9f9d15f59d72893deead5678d314388718c91821
Reviewed-on: https://go-review.googlesource.com/37771
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agonet/mail: fix wrong error message in consumePhrase
Hiroshi Ioka [Tue, 7 Mar 2017 22:47:31 +0000 (07:47 +0900)]
net/mail: fix wrong error message in consumePhrase

Fixes #19415

Change-Id: I6414f82e42bd09f1793156befce326aeac919ea2
Reviewed-on: https://go-review.googlesource.com/37911
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime/pprof: add GNU build IDs to Mappings recorded from /proc/self/maps
Russ Cox [Tue, 7 Mar 2017 01:39:57 +0000 (20:39 -0500)]
runtime/pprof: add GNU build IDs to Mappings recorded from /proc/self/maps

This helps systems that maintain an external database mapping
build ID to symbol information for the given binary, especially
in the case where /proc/self/maps lists many different files
(for example, many shared libraries).

Avoid importing debug/elf to avoid dragging in that whole
package (and its dependencies like debug/dwarf) into the
build of every program that generates a profile.

Fixes #19431.

Change-Id: I6d4362a79fe23e4f1726dffb0661d20bb57f766f
Reviewed-on: https://go-review.googlesource.com/37855
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/internal/src: fix Pos.String() for positions after line directives
Robert Griesemer [Tue, 7 Mar 2017 22:53:56 +0000 (14:53 -0800)]
cmd/internal/src: fix Pos.String() for positions after line directives

The old code simply printed the position of the line directive in
square brackets for a position modified by a line directive. Now
we print the corresponding actual source file position instead.

Fixes #19392.

Change-Id: I933f3e435d03a6ee8269df36ae35f9202b7b2e76
Reviewed-on: https://go-review.googlesource.com/37932
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agointernal/poll: code cleanup
Mikio Hara [Mon, 6 Mar 2017 09:39:02 +0000 (18:39 +0900)]
internal/poll: code cleanup

This change adds missing docs, collapses single-line import paths,
removes unsed method placeholders and renames str.go to strconv.go.

Change-Id: I2d155c838935cd8427abd142a462ff4c56829703
Reviewed-on: https://go-review.googlesource.com/37814
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: join selectgo and selectgoImpl
Austin Clements [Tue, 7 Mar 2017 20:36:49 +0000 (15:36 -0500)]
runtime: join selectgo and selectgoImpl

Currently selectgo is just a wrapper around selectgoImpl. This keeps
the hard-coded frame skip counts for tracing the same between the
channel implementation and the select implementation.

However, this is fragile and confusing, so pass a skip parameter to
send and recv, join selectgo and selectgoImpl into one function, and
use decrease all of the skips in selectgo by one.

Change-Id: I11b8cbb7d805b55f5dc6ab4875ac7dde79412ff2
Reviewed-on: https://go-review.googlesource.com/37860
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile: refactor portable SSA Op handling
Matthew Dempsky [Tue, 7 Mar 2017 20:31:59 +0000 (12:31 -0800)]
cmd/compile: refactor portable SSA Op handling

Several SSA ops will always behave identically regardless of target
architecture, so handle those within gc/ssa.go instead.

Passes toolstash-check -all.

Change-Id: I54d514e80ab86723e44332a5a38e3054cbca8c5d
Reviewed-on: https://go-review.googlesource.com/37931
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: print SP/FP on bad pointer crashes
Austin Clements [Tue, 7 Mar 2017 20:20:40 +0000 (15:20 -0500)]
runtime: print SP/FP on bad pointer crashes

If the bad pointer is on a stack, this makes it possible to find the
frame containing the bad pointer.

Change-Id: Ieda44e054aa9ebf22d15d184457c7610b056dded
Reviewed-on: https://go-review.googlesource.com/37858
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: honor GOTRACEBACK=crash even if _g_.m.traceback != 0
Austin Clements [Tue, 7 Mar 2017 20:24:02 +0000 (15:24 -0500)]
runtime: honor GOTRACEBACK=crash even if _g_.m.traceback != 0

Change-Id: I6de1ef8f67bde044b8706c01e98400e266e1f8f0
Reviewed-on: https://go-review.googlesource.com/37857
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agocmd/compile, runtime: simplify multiway select implementation
Matthew Dempsky [Wed, 1 Mar 2017 23:50:57 +0000 (15:50 -0800)]
cmd/compile, runtime: simplify multiway select implementation

This commit reworks multiway select statements to use normal control
flow primitives instead of the previous setjmp/longjmp-like behavior.
This simplifies liveness analysis and should prevent issues around
"returns twice" function calls within SSA passes.

test/live.go is updated because liveness analysis's CFG is more
representative of actual control flow. The case bodies are the only
real successors of the selectgo call, but previously the selectsend,
selectrecv, etc. calls were included in the successors list too.

Updates #19331.

Change-Id: I7f879b103a4b85e62fc36a270d812f54c0aa3e83
Reviewed-on: https://go-review.googlesource.com/37661
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
7 years agoruntime/pprof: actually use tag parameter
Daniel Martí [Tue, 7 Mar 2017 16:05:40 +0000 (16:05 +0000)]
runtime/pprof: actually use tag parameter

It's only ever called with the value it was using, but the code was
counterintuitive. Use the parameter instead, like the other funcs near
it.

Found by github.com/mvdan/unparam.

Change-Id: I45855e11d749380b9b2a28e6dd1d5dedf119a19b
Reviewed-on: https://go-review.googlesource.com/37893
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoos/user: use the stubs fallback for Android
Elias Naur [Sat, 4 Mar 2017 03:55:56 +0000 (04:55 +0100)]
os/user: use the stubs fallback for Android

Using the stubs, user.Current will no longer fail on Android, fixing
the os/exec.TestCredentialNoSetGroups test.

Change-Id: I8b9842aa6704c0cde383c549a614bab0a0ed7695
Reviewed-on: https://go-review.googlesource.com/37765
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: fix misleading "truncated to int" messages
Alberto Donizetti [Wed, 18 Jan 2017 10:48:14 +0000 (11:48 +0100)]
cmd/compile: fix misleading "truncated to int" messages

When defining an int const, the compiler tries to cast the RHS
expression to int. The cast may fail for three reasons:

  1. expr is an integer constant that overflows int
  2. expr is a floating point constant
  3. expr is a complex constant, or not a number

In the second case, in order to print a sensible error message, we
must distinguish between a floating point constant that should be
included in the error message and a floating point constant that
cannot be reasonably formatted for inclusion in an error message.

For example, in:

  const a int = 1.1
  const b int = 1 + 1e-100

a is in the former group, while b is in the latter, since the floating
point value resulting from the evaluation of the rhs of the assignment
(1.00...01) is too long to be fully printed in an error message, and
cannot be shortened without making the error message misleading
(rounding or truncating it would result in a "1", which looks like an
integer constant, and it makes little sense in an error message about
an invalid floating point expression).

To fix this problem, we try to format the float value using fconv
(which is used by the error reporting mechanism to format float
arguments), and then parse the resulting string back to a
big.Float. If the result is an integer, we assume that expr is a float
value that cannot be reasonably be formatted as a string, and we emit
an error message that does not include its string representation.

Also, change the error message for overflows to a more conservative
"integer too large", which does not mention overflows that are only
caused by an internal implementation restriction.

Also, change (*Mpint) SetFloat so that it returns a bool (instead of
0/-1 for success/failure).

Fixes #11371

Change-Id: Ibbc73e2ed2eaf41f07827b0649d0eb637150ecaa
Reviewed-on: https://go-review.googlesource.com/35411
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agocmd/compile/internal/gc: skip autotmp vars in gc again
Matthew Dempsky [Tue, 7 Mar 2017 18:57:55 +0000 (10:57 -0800)]
cmd/compile/internal/gc: skip autotmp vars in gc again

Instead of skipping them based on string matching much later in the
compilation process, skip them up front using the proper API.

Passes toolstash-check.

Change-Id: Ibd4c0448a0701ba0de3235d4689ef300235fa1d9
Reviewed-on: https://go-review.googlesource.com/37930
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/internal/obj: change started to bool
Matthew Dempsky [Tue, 7 Mar 2017 18:44:12 +0000 (10:44 -0800)]
cmd/internal/obj: change started to bool

Change-Id: I90143e3c6e95a1495f300ffeb10de554aa41f56a
Reviewed-on: https://go-review.googlesource.com/37889
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agoruntime/pprof: fix the protobuf tests on Android
Elias Naur [Tue, 7 Mar 2017 19:04:23 +0000 (20:04 +0100)]
runtime/pprof: fix the protobuf tests on Android

Change-Id: I5f85a7980b9a18d3641c4ee8b0992671a8421bb0
Reviewed-on: https://go-review.googlesource.com/37896
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoencoding/base64, html/template: fix grammar mistakes
Kevin Burke [Tue, 7 Mar 2017 17:03:40 +0000 (09:03 -0800)]
encoding/base64, html/template: fix grammar mistakes

Replace 'does not contains' with 'does not contain' where it appears
in the source code.

Change-Id: Ie7266347c429512c8a41a7e19142afca7ead3922
Reviewed-on: https://go-review.googlesource.com/37887
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agomime: fix panic parsing 'encoded-word', be stricter
Hiroshi Ioka [Mon, 6 Mar 2017 00:59:32 +0000 (09:59 +0900)]
mime: fix panic parsing 'encoded-word', be stricter

Fixes #19416

Change-Id: I23c69ff637abaa202909f1cba6ed41b3cfe3d117
Reviewed-on: https://go-review.googlesource.com/37812
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/internal/obj: move dwarf.Var generation into compiler
Matthew Dempsky [Mon, 6 Mar 2017 15:32:37 +0000 (07:32 -0800)]
cmd/internal/obj: move dwarf.Var generation into compiler

Passes toolstash -cmp.

Change-Id: I4bd60f7ebba5457e7b3ece688fee2351bfeeb59a
Reviewed-on: https://go-review.googlesource.com/37874
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
7 years agocmd/compile: change signatlist to []*Type
Matthew Dempsky [Tue, 7 Mar 2017 07:49:49 +0000 (23:49 -0800)]
cmd/compile: change signatlist to []*Type

No need to keep as Nodes when they're all Types anyway.

Change-Id: I8157914ba5b09cadf2263247844680a60233a0f2
Reviewed-on: https://go-review.googlesource.com/37886
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocrypto/x509: rename and reposition rsaPublicKey struct declaration
Andrew Benton [Tue, 7 Mar 2017 07:17:58 +0000 (23:17 -0800)]
crypto/x509: rename and reposition rsaPublicKey struct declaration

For consistency with the other named types in this package, this
change renames the unexported rsaPublicKey struct to pkcs1PublicKey
and positions the declaration up with the other similarly-named
types in pkcs1.go.

See the final comment of #19355 for discussion.

Change-Id: I1fa0366a8efa01602b81bc69287ef747abce84f5
Reviewed-on: https://go-review.googlesource.com/37885
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agonet: remove unused Interface parameter
Daniel Martí [Tue, 7 Mar 2017 13:09:05 +0000 (13:09 +0000)]
net: remove unused Interface parameter

Found by github.com/mvdan/unparam.

Change-Id: I4795dd0221784d10cf7c9f7b84ea00787d5789f2
Reviewed-on: https://go-review.googlesource.com/37892
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/link: use IMAGE_SYM_CLASS_STATIC for local symbols
Alex Brainman [Sun, 5 Mar 2017 08:57:26 +0000 (19:57 +1100)]
cmd/link: use IMAGE_SYM_CLASS_STATIC for local symbols

Sometimes asm code in 2 different packages name its global
symbols with the same name. When these symbols are passed
to gcc, it refuses to link them thinking they are duplicate.
Mark these symbols with IMAGE_SYM_CLASS_STATIC.

Fixes #19198.

Change-Id: Ia5f59ede47354a2b48ce60b7d406c9f097ff2000
Reviewed-on: https://go-review.googlesource.com/37810
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agonet/mail: ignore whitespace between adjacent 'encoded-word's
Hiroshi Ioka [Sat, 4 Mar 2017 10:47:19 +0000 (19:47 +0900)]
net/mail: ignore whitespace between adjacent 'encoded-word's

rfc2047 says:
  White space between adjacent 'encoded-word's is not displayed.

Although, mime package already have that feature,
we cannot simply reuse that code,
because there is a subtle difference in quoted-string handling.

Fixes #19363

Change-Id: I754201aa3c6b701074ad78fe46818af5b96cbd00
Reviewed-on: https://go-review.googlesource.com/37811
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoencoding/base64: add alphabet and padding restrictions
Josselin Costanzi [Sun, 5 Mar 2017 17:55:18 +0000 (18:55 +0100)]
encoding/base64: add alphabet and padding restrictions

Document and check that the alphabet cannot contain '\n' or '\r'.
Document that the alphabet cannot contain the padding character.
Document that the padding character must be equal or bellow '\xff'.
Document that the padding character must not be '\n' or '\r'.

Fixes #19343
Fixes #19318

Change-Id: I6de0034d347ffdf317d7ea55d6fe38b01c2c4c03
Reviewed-on: https://go-review.googlesource.com/37838
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/compile: regenerate knownFormats
Michael Munday [Tue, 7 Mar 2017 00:43:21 +0000 (19:43 -0500)]
cmd/compile: regenerate knownFormats

Should fix the build dashboard.

Change-Id: Id4c8a996d9f689e1fa865a9cff9a7f52c700c691
Reviewed-on: https://go-review.googlesource.com/37877
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: add link to the setting GOPATH guide
Jaana Burcu Dogan [Thu, 2 Feb 2017 19:48:22 +0000 (11:48 -0800)]
doc: add link to the setting GOPATH guide

Change-Id: I4718c82540ef214728393824b89c8c7f6656823b
Reviewed-on: https://go-review.googlesource.com/36210
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agoRevert "cmd/compile: improve error message if init is directly invoked"
Robert Griesemer [Mon, 6 Mar 2017 23:41:56 +0000 (15:41 -0800)]
Revert "cmd/compile: improve error message if init is directly invoked"

This reverts commit cb6e0639fb090ea0e129b1ddb956a7e645cff285.

The fix is incorrect as it's perfectly fine to refer to an
identifier 'init' inside a function, and 'init' may even be
a variable of function value. Misspelling 'init' in that
context would lead to an incorrect error message.

Reopened #8481.

Change-Id: I49787fdf7738213370ae6f0cab54013e9e3394a8
Reviewed-on: https://go-review.googlesource.com/37876
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile: emit OffPtr for first field in SSA'd structs
philhofer [Sun, 5 Mar 2017 00:17:12 +0000 (16:17 -0800)]
cmd/compile: emit OffPtr for first field in SSA'd structs

Given

  (Store [c] (OffPtr <T1> [0] (Addr <T> _)) _
    (Store [c] (Addr <T> _) _ _))

dead store elimination doesn't eliminate the inner
Store, because it addresses a type of a different width
than the first store.

When decomposing StructMake operations, always generate
an OffPtr to address struct fields so that dead stores to
the first field of the struct can be optimized away.

benchmarks affected on darwin/amd64:
HTTPClientServer-8        73.2µs ± 1%    72.7µs ± 1%  -0.69%  (p=0.022 n=9+10)
TimeParse-8                304ns ± 1%     300ns ± 0%  -1.61%  (p=0.000 n=9+9)
RegexpMatchEasy1_32-8     80.1ns ± 0%    79.5ns ± 1%  -0.84%  (p=0.000 n=8+9)
GobDecode-8               6.78ms ± 0%    6.81ms ± 1%  +0.46%  (p=0.000 n=9+10)
Gunzip-8                  36.1ms ± 1%    36.2ms ± 0%  +0.37%  (p=0.019 n=10+10)
JSONEncode-8              15.6ms ± 0%    15.7ms ± 0%  +0.69%  (p=0.000 n=9+10)

Change-Id: Ia80d73fd047f9400c616ca64fdee4f438a0e7f21
Reviewed-on: https://go-review.googlesource.com/37769
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>