1. 14 Mar, 2019 21 commits
  2. 13 Mar, 2019 19 commits
    • Matthew Dempsky's avatar
      cmd/compile: cleanup OREAL/OIMAG constant folding · 2d21bf42
      Matthew Dempsky authored
      Based on suggestion from gri@ on golang.org/cl/166980.
      
      Passes toolstash-check.
      
      Change-Id: I79b66bb09b5635f3a9daecaa5d605b661a0ab108
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167501
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      2d21bf42
    • Josh Bleecher Snyder's avatar
      test/codegen: gofmt · 870cfe64
      Josh Bleecher Snyder authored
      Change-Id: I33f5b5051e5f75aa264ec656926223c5a3c09c1b
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167498
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      Reviewed-by: default avatarMatt Layher <mdlayher@gmail.com>
      870cfe64
    • Bryan C. Mills's avatar
      cmd/dist: add a test in misc/reboot to verify that the toolchain can self-bootstrap · 2989abc9
      Bryan C. Mills authored
      Fixes #30758
      
      Change-Id: I8e49958602de9caa47bb5710828158e51744f375
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167478
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      2989abc9
    • Daniel Martí's avatar
      builtin: make len's godoc less ambiguous · 1a24bf10
      Daniel Martí authored
      The len godoc uses a blockquote to list the rules for its semantics.
      
      The item that describes channels is a bit long, so it's split in two
      lines. However, the first line ends with a semicolon, and the second
      line can be read as a sentence of its own, so it's easy to misinterpret
      that the two lines are separate.
      
      Making that easy mistake would lead to an incorrect understanding of
      len:
      
      	if v is nil, len(v) is zero.
      
      This could lead us to think that len(nil) is valid and should return
      zero. When in fact, that statement only applies to nil channels.
      
      To make this less ambiguous, add a bit of indentation to the follow-up
      line, to align with the channel body. If lists are added to godoc in the
      future via #7873, perhaps this text can be simplified.
      
      Fixes #30349.
      
      Change-Id: I84226edc812d429493137bcc65c332e92d4e6c87
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167403
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      1a24bf10
    • Brad Fitzpatrick's avatar
      cmd/go/internal/work: remove commented-out import · 6aa710f7
      Brad Fitzpatrick authored
      Somebody wasn't using goimports. :)
      
      Change-Id: Ibad3c0781ea70d538592b2e90d8b578e4fae8173
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167385Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
      6aa710f7
    • Hana Kim's avatar
      cmd/go: fix the default build output name for versioned binaries · bf94fc3a
      Hana Kim authored
      `go build` has chosen the last element of the package import path
      as the default output name when -o option is given. That caused
      the output of a package build when the module root is the major
      version component such as 'v2'.
      
      A similar issue involving `go install` was fixed in
      https://golang.org/cl/128900. This CL refactors the logic added
      with the change and makes it available as
      internal/load.DefaultExecName.
      
      This CL makes 'go test' to choose the right default test binary
      name when the tested package is in the module root. (E.g.,
      instead of v2.test, choose pkg.test for the test of 'path/pkg/v2')
      
      Fixes #27283.
      
      Change-Id: I6905754f0906db46e3ce069552715f45356913ae
      Reviewed-on: https://go-review.googlesource.com/c/go/+/140863Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
      bf94fc3a
    • Matthew Dempsky's avatar
      cmd/compile: restore constant folding optimization within OADDSTR · 0a04c043
      Matthew Dempsky authored
      Change-Id: Ib55f2458c75aee49302f0dd4e2a819f9931a5ed3
      Reviewed-on: https://go-review.googlesource.com/c/go/+/166982
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
      0a04c043
    • Matthew Dempsky's avatar
      cmd/compile: simplify isGoConst · a1b5cb1d
      Matthew Dempsky authored
      The only ways to construct an OLITERAL node are (1) a basic literal
      from the source package, (2) constant folding within evconst (which
      only folds Go language constants), (3) the universal "nil" constant,
      and (4) implicit conversions of nil to some concrete type.
      
      Passes toolstash-check.
      
      Change-Id: I30fc6b07ebede7adbdfa4ed562436cbb7078a2ff
      Reviewed-on: https://go-review.googlesource.com/c/go/+/166981
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
      a1b5cb1d
    • Matthew Dempsky's avatar
      cmd/compile: move all constant folding logic into evconst · 3def15cd
      Matthew Dempsky authored
      All setconst calls now happen within evconst. While here, get rid of
      callrecv, which (incompletely) duplicates the logic of hascallchan.
      
      Passes toolstash-check.
      
      Change-Id: Ic67b9dd2a1b397d4bc25e8c8b6f81daf4f6cfb75
      Reviewed-on: https://go-review.googlesource.com/c/go/+/166980
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
      3def15cd
    • Ilya Tocar's avatar
      runtime: simplify readUnaligned · 3aa7bbdb
      Ilya Tocar authored
      We already have a pure go code sequence that is compiled into single load.
      Just use it everywhere, instead of pointer hackery.
      Passes toolstash-check.
      
      Change-Id: I0c42b5532fa9a5665da3385913609c6d42aaff27
      Reviewed-on: https://go-review.googlesource.com/c/go/+/118568
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarAustin Clements <austin@google.com>
      3aa7bbdb
    • Clément Chigot's avatar
      syscall: add Chroot and Dup2 for aix/ppc64 · 82bd9399
      Clément Chigot authored
      Change-Id: Ib98c7ad91d83ce68811f5c671200462c5fee0fca
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167398
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarTobias Klauser <tobias.klauser@gmail.com>
      82bd9399
    • Michael Munday's avatar
      cmd/compile: try and access last argument first in rulegen · 04f1b65c
      Michael Munday authored
      This reduces the number of extra bounds check hints we need to
      insert. For example, rather than producing:
      
      	_ = v.Args[2]
      	x := v.Args[0]
      	y := v.Args[1]
      	z := v.Args[2]
      
      We now produce:
      
      	z := v.Args[2]
      	x := v.Args[0]
      	y := v.Args[1]
      
      This gets rid of about 7000 lines of code from the rewrite rules.
      
      Change-Id: I1291cf0f82e8d035a6d65bce7dee6cedee04cbcd
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167397Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      04f1b65c
    • Bryan C. Mills's avatar
      cmd/go/internal/modload: remove unused InitGoMod function · 5d4fa147
      Bryan C. Mills authored
      Change-Id: I0223d935184017e841d56abe114d78b670457c5a
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167437
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      5d4fa147
    • Carlos Eduardo Seo's avatar
      cmd/compile: add processor level selection support to ppc64{,le} · 4ba69a9a
      Carlos Eduardo Seo authored
      ppc64{,le} processor level selection allows the compiler to generate instructions
      targeting newer processors and processor-specific optimizations without breaking
      compatibility with our current baseline. This feature introduces a new environment
      variable, GOPPC64.
      
      GOPPC64 is a GOARCH=ppc64{,le} specific option, for a choice between different
      processor levels (i.e. Instruction Set Architecture versions) for which the
      compiler will target. The default is 'power8'.
      
      Change-Id: Ic152e283ae1c47084ece4346fa002a3eabb3bb9e
      Reviewed-on: https://go-review.googlesource.com/c/go/+/163758
      Run-TryBot: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDavid Chase <drchase@google.com>
      4ba69a9a
    • David Chase's avatar
      cmd/compile: move statement marks from jumps to targets · 82af9e67
      David Chase authored
      When a jump at the end of a block is about to be marked as
      a statement, if the first real instruction in the target
      block is also a statement for the same line, remove the
      mark from the jump.
      
      This is a first effort at a minimal-harm heuristic.
      A better heuristic might skip over any "not-statement"
      values preceding a definitely marked value.
      
      Fixes #29443.
      
      Change-Id: Ibd52783713b4936e0c2dfda8d708bf186f33b00a
      Reviewed-on: https://go-review.googlesource.com/c/go/+/159977
      Run-TryBot: David Chase <drchase@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarAlessandro Arzilli <alessandro.arzilli@gmail.com>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      82af9e67
    • Bryan C. Mills's avatar
      cmd/go/internal/{modconv,modfetch,modload}: set modfetch proxy URL in tests · bd680d94
      Bryan C. Mills authored
      Fixes #30571
      
      Change-Id: Id4c74e83ee58a080d1c2894ae5ebdbf4aeb1ce42
      Reviewed-on: https://go-review.googlesource.com/c/go/+/167084
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      bd680d94
    • Daniel Martí's avatar
      cmd/go/internal/base: remove MergeEnvLists · 2f02daaa
      Daniel Martí authored
      This internally exported function allowed merging environment variable
      lists, and was mostly a convenience for the rest of cmd/go/internal.
      It seems to date all the way back to 2013.
      
      However, since CL 37586 in early 2017, os/exec has already taken care of
      deduplicating environment variable lists. Thus, it's unnecessary for
      cmd/go to take care of that before calling exec.Cmd.Start.
      
      Moreover, because os/exec will deduplicate the list in any case, we're
      adding extra work in all these scenarios.
      
      Finally, remove an unnecessary addition of GOROOT= in internal/tool.
      cfg.OrigEnv may not have the correct GOROOT set up, but os.Environ does;
      cmd/go's main function makes sure of that.
      
      Change-Id: I1f92f65fb927dc15bc7b0397cfd1a572b6337bb3
      Reviewed-on: https://go-review.googlesource.com/c/go/+/164703
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      2f02daaa
    • Daniel Martí's avatar
      encoding/base64: speed up the decoder · 5f403517
      Daniel Martí authored
      Most of the decoding time is spent in the first Decode loop, since the
      rest of the function only deals with the few remaining bytes. Any
      unnecessary work done in that loop body matters tremendously.
      
      One such unnecessary bottleneck was the use of the enc.decodeMap table.
      Since enc is a pointer receiver, and the field is used within the
      non-inlineable function decode64, the decoder must perform a nil check
      at every iteration.
      
      To fix that, move the enc.decodeMap uses to the parent function, where
      we can lift the nil check outside the loop. That gives roughly a 15%
      speed-up. The function no longer performs decoding per se, so rename it.
      While at it, remove the now unnecessary receivers.
      
      An unfortunate side effect of this change is that the loop now contains
      eight bounds checks on src instead of just one. However, not having to
      slice src plus the nil check removal well outweigh the added cost.
      
      The other piece that made decode64 slow was that it wasn't inlined, and
      had multiple branches. Use a simple bitwise-or trick suggested by Roger
      Peppe, and collapse the rest of the bitwise logic into a single
      expression. Inlinability and the reduced branching give a further 10%
      speed-up.
      
      Finally, add these two functions to TestIntendedInlining, since we want
      them to stay inlinable.
      
      Apply the same refactor to decode32 for consistency, and to let 32-bit
      architectures see a similar performance gain for large inputs.
      
      name                 old time/op    new time/op    delta
      DecodeString/2-8       47.3ns ± 1%    45.8ns ± 0%   -3.28%  (p=0.002 n=6+6)
      DecodeString/4-8       55.8ns ± 2%    51.5ns ± 0%   -7.71%  (p=0.004 n=5+6)
      DecodeString/8-8       64.9ns ± 0%    61.7ns ± 0%   -4.99%  (p=0.004 n=5+6)
      DecodeString/64-8       238ns ± 0%     198ns ± 0%  -16.54%  (p=0.002 n=6+6)
      DecodeString/8192-8    19.5µs ± 0%    14.6µs ± 0%  -24.96%  (p=0.004 n=6+5)
      
      name                 old speed      new speed      delta
      DecodeString/2-8     84.6MB/s ± 1%  87.4MB/s ± 0%   +3.38%  (p=0.002 n=6+6)
      DecodeString/4-8      143MB/s ± 2%   155MB/s ± 0%   +8.41%  (p=0.004 n=5+6)
      DecodeString/8-8      185MB/s ± 0%   195MB/s ± 0%   +5.29%  (p=0.004 n=5+6)
      DecodeString/64-8     369MB/s ± 0%   442MB/s ± 0%  +19.78%  (p=0.002 n=6+6)
      DecodeString/8192-8   560MB/s ± 0%   746MB/s ± 0%  +33.27%  (p=0.004 n=6+5)
      
      Updates #19636.
      
      Change-Id: Ib839577b0e3f5a2bb201f5cae580c61365d92894
      Reviewed-on: https://go-review.googlesource.com/c/go/+/151177
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarroger peppe <rogpeppe@gmail.com>
      5f403517
    • Mikio Hara's avatar
      runtime, internal/poll, net: report event scanning error on read event · a5fdd58c
      Mikio Hara authored
      This change makes it possible the runtime-integrated network poller and
      APIs in the package internal/poll to report an event scanning error on a
      read event.
      
      The latest Go releases open up the way of the manipulation of the poller
      for users. On the other hand, it starts misleading users into believing
      that the poller accepts any user-configured file or socket perfectly
      because of not reporting any error on event scanning, as mentioned in
      issue 30426. The initial implementation of the poller was designed for
      just well-configured, validated sockets produced by the package net.
      However, the assumption is now obsolete.
      
      Fixes #30624.
      
      Benchmark results on linux/amd64:
      
      benchmark                              old ns/op     new ns/op     delta
      BenchmarkTCP4OneShot-4                 24649         23979         -2.72%
      BenchmarkTCP4OneShotTimeout-4          25742         24411         -5.17%
      BenchmarkTCP4Persistent-4              5139          5222          +1.62%
      BenchmarkTCP4PersistentTimeout-4       4919          4892          -0.55%
      BenchmarkTCP6OneShot-4                 21182         20767         -1.96%
      BenchmarkTCP6OneShotTimeout-4          23364         22305         -4.53%
      BenchmarkTCP6Persistent-4              4351          4366          +0.34%
      BenchmarkTCP6PersistentTimeout-4       4227          4255          +0.66%
      BenchmarkTCP4ConcurrentReadWrite-4     2309          1839          -20.36%
      BenchmarkTCP6ConcurrentReadWrite-4     2180          1791          -17.84%
      
      benchmark                              old allocs     new allocs   delta
      BenchmarkTCP4OneShot-4                 26             26           +0.00%
      BenchmarkTCP4OneShotTimeout-4          26             26           +0.00%
      BenchmarkTCP4Persistent-4              0              0            +0.00%
      BenchmarkTCP4PersistentTimeout-4       0              0            +0.00%
      BenchmarkTCP6OneShot-4                 26             26           +0.00%
      BenchmarkTCP6OneShotTimeout-4          26             26           +0.00%
      BenchmarkTCP6Persistent-4              0              0            +0.00%
      BenchmarkTCP6PersistentTimeout-4       0              0            +0.00%
      BenchmarkTCP4ConcurrentReadWrite-4     0              0            +0.00%
      BenchmarkTCP6ConcurrentReadWrite-4     0              0            +0.00%
      
      benchmark                              old bytes     new bytes     delta
      BenchmarkTCP4OneShot-4                 2000          2000          +0.00%
      BenchmarkTCP4OneShotTimeout-4          2000          2000          +0.00%
      BenchmarkTCP4Persistent-4              0             0             +0.00%
      BenchmarkTCP4PersistentTimeout-4       0             0             +0.00%
      BenchmarkTCP6OneShot-4                 2144          2144          +0.00%
      BenchmarkTCP6OneShotTimeout-4          2144          2145          +0.05%
      BenchmarkTCP6Persistent-4              0             0             +0.00%
      BenchmarkTCP6PersistentTimeout-4       0             0             +0.00%
      BenchmarkTCP4ConcurrentReadWrite-4     0             0             +0.00%
      BenchmarkTCP6ConcurrentReadWrite-4     0             0             +0.00%
      
      Change-Id: Iab60e504dff5639e688dc5420d852f336508c0af
      Reviewed-on: https://go-review.googlesource.com/c/go/+/166497
      Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      a5fdd58c