]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agoRevert "encoding/json: implement Is on all errors"
Damien Neil [Mon, 14 Sep 2020 21:00:52 +0000 (21:00 +0000)]
Revert "encoding/json: implement Is on all errors"

This reverts CL 254537.

Reason for revert: Reason for revert: The recommended way to check for a type of error is errors.As. API changes should also start with a proposal.

Change-Id: I07c37428575e99c80b17525833a61831d10963bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/254857
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agotesting: fix panicking tests hang if Cleanup calls FailNow
Changkun Ou [Mon, 14 Sep 2020 08:24:59 +0000 (10:24 +0200)]
testing: fix panicking tests hang if Cleanup calls FailNow

Previously, it was impossible to call FailNow in a Cleanup.
Because it can terminate a panicking goroutine and cause its
parent hangs on t.signal channel. This CL sends the signal
in a deferred call to prevent the hang.

Fixes #41355

Change-Id: I4552d3a7ea763ef86817bf9b50c0e37fb34bf20f
Reviewed-on: https://go-review.googlesource.com/c/go/+/254637
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

4 years agocmd/api: omit outside dependencies when listing the packages in "std"
Bryan C. Mills [Mon, 14 Sep 2020 14:19:47 +0000 (10:19 -0400)]
cmd/api: omit outside dependencies when listing the packages in "std"

As of CL 251159, when 'go list -deps std' is run within GOROOT/src, it
treats the vendored external dependencies as real module dependencies,
not standard-library "vendor/" packages (which still exist in that
case, but are treated as distinct packages outside the "std" module).

Fixes #41358
Updates #30241

Change-Id: Ic23eae9829d90e74a340d49ca9052e9191597410
Reviewed-on: https://go-review.googlesource.com/c/go/+/254738
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agoruntime: add 24 byte allocation size class
Martin Möhrmann [Mon, 13 Jul 2020 16:12:20 +0000 (18:12 +0200)]
runtime: add 24 byte allocation size class

This CL introduces a 24 byte allocation size class which
fits 3 pointers on 64 bit and 6 pointers on 32 bit architectures.

Notably this new size class fits a slice header on 64 bit
architectures exactly while previously a 32 byte size class
would have been used for allocating a slice header on the heap.

The main complexity added with this CL is that heapBitsSetType
needs to handle objects that aren't 16-byte aligned but contain
more than a single pointer on 64-bit architectures.

Due to having a non 16 byte aligned size class on 32 bit a
h.shift of 2 is now possible which means a heap bitmap byte might
only be partially written. Due to this already having been
possible on 64 bit before the heap bitmap code only needed
minor adjustments for 32 bit doublecheck code paths.

Note that this CL changes the slice capacity allocated by append
for slice growth to a target capacity of 17 to 24 bytes.

On 64 bit architectures the capacity of the slice returned by
append([]byte{}, make([]byte, 24)...)) is 32 bytes before and
24 bytes after this CL. Depending on allocation patterns of the
specific Go program this can increase the number of total
alloctions as subsequent appends to the slice can trigger slice
growth earlier than before. On the other side if the slice is
never appended to again above its capacity this will lower heap
usage by 8 bytes.

This CL changes the set of size classes reported in the
runtime.MemStats.BySize array due to it being limited to a
total of 61 size classes. The new 24 byte size class is now
included and the 20480 byte size class is not included anymore.

Fixes #8885

name                      old time/op       new time/op       delta
Template                        196ms ± 3%        194ms ± 2%    ~     (p=0.247 n=10+10)
Unicode                        85.6ms ±16%       88.1ms ± 1%    ~     (p=0.165 n=10+10)
GoTypes                         673ms ± 2%        668ms ± 2%    ~     (p=0.258 n=9+9)
Compiler                        3.14s ± 6%        3.08s ± 1%    ~     (p=0.243 n=10+9)
SSA                             6.82s ± 1%        6.76s ± 1%  -0.87%  (p=0.006 n=9+10)
Flate                           128ms ± 7%        127ms ± 3%    ~     (p=0.739 n=10+10)
GoParser                        154ms ± 3%        153ms ± 4%    ~     (p=0.730 n=9+9)
Reflect                         404ms ± 1%        412ms ± 4%  +1.99%  (p=0.022 n=9+10)
Tar                             172ms ± 4%        170ms ± 4%    ~     (p=0.065 n=10+9)
XML                             231ms ± 4%        230ms ± 3%    ~     (p=0.912 n=10+10)
LinkCompiler                    341ms ± 1%        339ms ± 1%    ~     (p=0.243 n=9+10)
ExternalLinkCompiler            1.72s ± 1%        1.72s ± 1%    ~     (p=0.661 n=9+10)
LinkWithoutDebugCompiler        221ms ± 2%        221ms ± 2%    ~     (p=0.529 n=10+10)
StdCmd                          18.4s ± 3%        18.2s ± 1%    ~     (p=0.515 n=10+8)

name                      old user-time/op  new user-time/op  delta
Template                        238ms ± 4%        243ms ± 6%    ~     (p=0.661 n=9+10)
Unicode                         116ms ± 6%        113ms ± 3%  -3.37%  (p=0.035 n=9+10)
GoTypes                         854ms ± 2%        848ms ± 2%    ~     (p=0.604 n=9+10)
Compiler                        4.10s ± 1%        4.11s ± 1%    ~     (p=0.481 n=8+9)
SSA                             9.49s ± 1%        9.41s ± 1%  -0.92%  (p=0.001 n=9+10)
Flate                           149ms ± 6%        151ms ± 7%    ~     (p=0.481 n=10+10)
GoParser                        189ms ± 2%        190ms ± 2%    ~     (p=0.497 n=9+10)
Reflect                         511ms ± 2%        508ms ± 2%    ~     (p=0.211 n=9+10)
Tar                             215ms ± 4%        212ms ± 3%    ~     (p=0.105 n=10+10)
XML                             288ms ± 2%        288ms ± 2%    ~     (p=0.971 n=10+10)
LinkCompiler                    559ms ± 4%        557ms ± 1%    ~     (p=0.968 n=9+10)
ExternalLinkCompiler            1.78s ± 1%        1.77s ± 1%    ~     (p=0.055 n=8+10)
LinkWithoutDebugCompiler        245ms ± 3%        245ms ± 2%    ~     (p=0.684 n=10+10)

name                      old alloc/op      new alloc/op      delta
Template                       34.8MB ± 0%       34.4MB ± 0%  -0.95%  (p=0.000 n=9+10)
Unicode                        28.6MB ± 0%       28.3MB ± 0%  -0.95%  (p=0.000 n=10+10)
GoTypes                         115MB ± 0%        114MB ± 0%  -1.02%  (p=0.000 n=10+9)
Compiler                        554MB ± 0%        549MB ± 0%  -0.86%  (p=0.000 n=9+10)
SSA                            1.28GB ± 0%       1.27GB ± 0%  -0.83%  (p=0.000 n=10+10)
Flate                          21.8MB ± 0%       21.6MB ± 0%  -0.87%  (p=0.000 n=8+10)
GoParser                       26.7MB ± 0%       26.4MB ± 0%  -0.97%  (p=0.000 n=10+9)
Reflect                        75.0MB ± 0%       74.1MB ± 0%  -1.18%  (p=0.000 n=10+10)
Tar                            32.6MB ± 0%       32.3MB ± 0%  -0.94%  (p=0.000 n=10+7)
XML                            41.5MB ± 0%       41.2MB ± 0%  -0.90%  (p=0.000 n=10+8)
LinkCompiler                    105MB ± 0%        104MB ± 0%  -0.94%  (p=0.000 n=10+10)
ExternalLinkCompiler            153MB ± 0%        152MB ± 0%  -0.69%  (p=0.000 n=10+10)
LinkWithoutDebugCompiler       63.7MB ± 0%       63.6MB ± 0%  -0.13%  (p=0.000 n=10+10)

name                      old allocs/op     new allocs/op     delta
Template                         336k ± 0%         336k ± 0%  +0.02%  (p=0.002 n=10+10)
Unicode                          332k ± 0%         332k ± 0%    ~     (p=0.447 n=10+10)
GoTypes                         1.16M ± 0%        1.16M ± 0%  +0.01%  (p=0.001 n=10+10)
Compiler                        4.92M ± 0%        4.92M ± 0%  +0.01%  (p=0.000 n=10+10)
SSA                             11.9M ± 0%        11.9M ± 0%  +0.02%  (p=0.000 n=9+10)
Flate                            214k ± 0%         214k ± 0%  +0.02%  (p=0.032 n=10+8)
GoParser                         270k ± 0%         270k ± 0%  +0.02%  (p=0.004 n=10+9)
Reflect                          877k ± 0%         877k ± 0%  +0.01%  (p=0.000 n=10+10)
Tar                              313k ± 0%         313k ± 0%    ~     (p=0.075 n=9+10)
XML                              387k ± 0%         387k ± 0%  +0.02%  (p=0.007 n=10+10)
LinkCompiler                     455k ± 0%         456k ± 0%  +0.08%  (p=0.000 n=10+9)
ExternalLinkCompiler             670k ± 0%         671k ± 0%  +0.06%  (p=0.000 n=10+10)
LinkWithoutDebugCompiler         113k ± 0%         113k ± 0%    ~     (p=0.149 n=10+10)

name                      old maxRSS/op     new maxRSS/op     delta
Template                        34.1M ± 1%        34.1M ± 1%    ~     (p=0.853 n=10+10)
Unicode                         35.1M ± 1%        34.6M ± 1%  -1.43%  (p=0.000 n=10+10)
GoTypes                         72.8M ± 3%        73.3M ± 2%    ~     (p=0.724 n=10+10)
Compiler                         288M ± 3%         295M ± 4%    ~     (p=0.393 n=10+10)
SSA                              630M ± 1%         622M ± 1%  -1.18%  (p=0.001 n=10+10)
Flate                           26.0M ± 1%        26.2M ± 2%    ~     (p=0.493 n=10+10)
GoParser                        28.6M ± 1%        28.5M ± 2%    ~     (p=0.256 n=10+10)
Reflect                         55.5M ± 2%        55.4M ± 1%    ~     (p=0.436 n=10+10)
Tar                             33.0M ± 1%        32.8M ± 2%    ~     (p=0.075 n=10+10)
XML                             38.7M ± 1%        39.0M ± 1%    ~     (p=0.053 n=9+10)
LinkCompiler                     164M ± 1%         164M ± 1%  -0.27%  (p=0.029 n=10+10)
ExternalLinkCompiler             174M ± 0%         173M ± 0%  -0.33%  (p=0.002 n=9+10)
LinkWithoutDebugCompiler         137M ± 0%         136M ± 2%    ~     (p=0.825 n=9+10)

Change-Id: I9ecf2a10024513abef8fbfbe519e44e0b29b6167
Reviewed-on: https://go-review.googlesource.com/c/go/+/242258
Trust: Martin Möhrmann <moehrmann@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agomisc/ios: quote paths
Cherry Zhang [Sat, 12 Sep 2020 00:09:40 +0000 (20:09 -0400)]
misc/ios: quote paths

The paths may contain spaces. Quote them.

Change-Id: I1f67085a1e7c40f60282c2fea7104fb44a01e310
Reviewed-on: https://go-review.googlesource.com/c/go/+/254739
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

4 years agosyscall: fix fsync for read-only files on aix
Clément Chigot [Mon, 14 Sep 2020 11:06:40 +0000 (13:06 +0200)]
syscall: fix fsync for read-only files on aix

AIX fsync syscall doesn't work on read-only files. Using fsync_range
instead allows syscall.Fsync to work on any files.

Fixes #41372

Change-Id: I66d33e847875496af53da60828c1bddf6c2b76b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/254657
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agonet/http/cgi,net/http/fcgi: add Content-Type detection
Roberto Clapis [Wed, 26 Aug 2020 06:53:03 +0000 (08:53 +0200)]
net/http/cgi,net/http/fcgi: add Content-Type detection

This CL ensures that responses served via CGI and FastCGI
have a Content-Type header based on the content of the
response if not explicitly set by handlers.

If the implementers of the handler did not explicitly
specify a Content-Type both CGI implementations would default
to "text/html", potentially causing cross-site scripting.

Thanks to RedTeam Pentesting GmbH for reporting this.

Fixes #40928
Fixes CVE-2020-24553

Change-Id: I82cfc396309b5ab2e8d6e9a87eda8ea7e3799473
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/823217
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/252179
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
4 years agomake.bat: fix compare between GOROOT and srcdir paths, when either contains whitespace.
Dominic Della Valle [Sun, 13 Sep 2020 17:03:48 +0000 (17:03 +0000)]
make.bat: fix compare between GOROOT and srcdir paths, when either contains whitespace.

CL 96455 brings CL 57753 to Windows
However, a path comparison within it was left unquoted.
If the Go source directory resides in a path containing whitespace,
the interpreter will compare against the first portion of the path string,
and treat the remainder as an expression.
This patch amends that.

For example, consider the path
`C:\Users\Dominic Della Valle\Projects\Go\goroot\src`
Issuing `make.bat` will print out `'Della' is not recognized as an internal or external command, operable program or batch file.` before proceeding.

Change-Id: Ifcec159baeec940c29c61aa721c64c13c6fd8c14
GitHub-Last-Rev: 809ddbb4dbc80d834f8108ca44c2826016d78d1c
GitHub-Pull-Request: golang/go#41319
Reviewed-on: https://go-review.googlesource.com/c/go/+/253898
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Trust: Giovanni Bajo <rasky@develer.com>

4 years agotest: fix flaky test for issue24491
Cuong Manh Le [Sun, 13 Sep 2020 06:22:42 +0000 (13:22 +0700)]
test: fix flaky test for issue24491

runtime.GC() doesn't guarantee the finalizer has run, so use a channel
instead to make sure finalizer was run in call to "after()".

Fixes #41361

Change-Id: I69c801e29aea49757ea72c52e8db13239de19ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/254401
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>

4 years agocmd/compile: remove nodeNeedsWrapper flag
Cuong Manh Le [Sat, 12 Sep 2020 00:19:22 +0000 (07:19 +0700)]
cmd/compile: remove nodeNeedsWrapper flag

CL 254397 attached OVARLIVE nodes to OCALLxxx nodes Nbody.

The NeedsWrapper flag is now redundant with n.Nbody.Len() > 0
condition, so use that condition instead and remove the flag.

Passes toolstash-check.

Change-Id: Iebc3e674d3c0040a876ca4be05025943d2b4fb31
Reviewed-on: https://go-review.googlesource.com/c/go/+/254398
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: attach OVARLIVE nodes to OCALLxxx
Cuong Manh Le [Fri, 11 Sep 2020 18:57:27 +0000 (01:57 +0700)]
cmd/compile: attach OVARLIVE nodes to OCALLxxx

So we can insert theses OVARLIVE nodes right after OpStaticCall in SSA.

This helps fixing issue that unsafe-uintptr arguments are not kept alive
during return statement, or can be kept alive longer than expected.

Fixes #24491

Change-Id: Ic04a5d1bbb5c90dcfae65bd95cdd1da393a66800
Reviewed-on: https://go-review.googlesource.com/c/go/+/254397
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoencoding/json: implement Is on all errors
Carlos Alexandro Becker [Sun, 13 Sep 2020 02:12:02 +0000 (02:12 +0000)]
encoding/json: implement Is on all errors

Allows users to check:

      errors.Is(err, &UnmarshalTypeError{})
      errors.Is(err, &UnmarshalFieldError{})
      errors.Is(err, &InvalidUnmarshalError{})
      errors.Is(err, &UnsupportedValueError{})
      errors.Is(err, &MarshalerError{})

which is the recommended way of checking for kinds of errors.

SyntaxError.Is was implemented in CL 253037.
As and Unwrap relevant methods will be added in future CLs.

Change-Id: I1f8a503b8fdc0f3afdfe9669a91f3af8d960e028
GitHub-Last-Rev: 930cda5384c987a0b31f277ba3b4ab690ea74ac3
GitHub-Pull-Request: golang/go#41360
Reviewed-on: https://go-review.googlesource.com/c/go/+/254537
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

4 years agoencoding/json: implement Is on SyntaxError
Carlos Alexandro Becker [Fri, 11 Sep 2020 22:16:47 +0000 (22:16 +0000)]
encoding/json: implement Is on SyntaxError

Allows users to check:

      errors.Is(err, &json.SyntaxError{})

which is the recommended way of checking for kinds of errors.

Change-Id: I20dc805f20212765e9936a82d9cb7822e73ec4ef
GitHub-Last-Rev: e2627ccf8e2a00cc3459bb9fee86c3c8675a33af
GitHub-Pull-Request: golang/go#41210
Reviewed-on: https://go-review.googlesource.com/c/go/+/253037
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go: avoid flag.FlagSet.VisitAll at init time
Daniel Martí [Sat, 15 Aug 2020 14:20:50 +0000 (16:20 +0200)]
cmd/go: avoid flag.FlagSet.VisitAll at init time

We want to error early if GOFLAGS contains any flag that isn't known to
any cmd/go command. Thus, at init time we would recursively use VisitAll
on each of the flagsets to populate a map of all registered flags.

This was unfortunate, as populating said map constituted a whole 5% of
the run-time of 'go env GOARCH'. This is because VisitAll is pretty
expensive; it copies all the maps from the flagset's map to a slice,
sorts the slice, then does one callback per flag.

First, this was a bit wasteful. We only ever needed to query the
knownFlag map if GOFLAGS wasn't empty. If it's empty, there's no work to
do, thus we can skip the map populating work.

Second and most important, we don't actually need the map at all. A
flag.FlagSet already has a Lookup method, so we can simply recursively
call those methods for each flag in GOFLAGS. Add a hasFlag func to make
that evident.

This mechanism is different; its upfront cost is none, but it will
likely mean a handful of map lookups for each flag in GOFLAGS. However,
that tradeoff is worth it; we don't expect GOFLAGS to contain thousands
of flags. The most likely scenario is less than a dozen flags, in which
case constructing a "unified" map is not at all a net win.

One possible reason the previous mechanism was that way could be
AddKnownFlag. Thankfully, the one and only use of that API was removed
last year when Bryan cleaned up flag parsing in cmd/go.

The wins for the existing benchmark with an empty GOFLAGS are
significant:

name         old time/op       new time/op       delta
ExecGoEnv-8        575µs ± 1%        549µs ± 2%  -4.44%  (p=0.000 n=7+8)

name         old sys-time/op   new sys-time/op   delta
ExecGoEnv-8       1.69ms ± 1%       1.68ms ± 2%    ~     (p=0.281 n=7+8)

name         old user-time/op  new user-time/op  delta
ExecGoEnv-8       1.80ms ± 1%       1.66ms ± 2%  -8.09%  (p=0.000 n=7+8)

To prove that a relatively large number of GOFLAGS isn't getting
noticeably slower, we measured that as well, via benchcmd and GOFLAGS
containing 50 valid flags:

GOFLAGS=$(yes -- -race | sed 50q) benchcmd -n 500 GoEnvGOFLAGS go env GOARCH

And the result, while noisy, shows no noticeable difference (note that
it measures 3ms instead of 0.6ms since it's sequential):

name          old time/op         new time/op         delta
GoEnvGOFLAGS         3.04ms ±32%         3.03ms ±35%    ~     (p=0.156 n=487+481)

Finally, we've improved the existing Go benchmark. Now it's parallel,
and it also reports sys-time and user-time, which are useful metrics.

Change-Id: I9b4551415cedf2f819eb184a02324b8bd919e2bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/248757
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: don't report not enough args error if call is undefined
Cuong Manh Le [Wed, 9 Sep 2020 09:25:48 +0000 (16:25 +0700)]
cmd/compile: don't report not enough args error if call is undefined

Fixes #38745

Change-Id: I2fbd8b512a8cf911b81a087162c74416116efea5
Reviewed-on: https://go-review.googlesource.com/c/go/+/253678
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: use clearer error message for stuct literal
Cuong Manh Le [Wed, 9 Sep 2020 04:09:01 +0000 (11:09 +0700)]
cmd/compile: use clearer error message for stuct literal

This CL changes "T literal.M" error message to "T{...}.M". It's clearer
expression and focusing user on actual issue.

Updates #38745

Change-Id: I84b455a86742f37e0bde5bf390aa02984eecc3c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/253677
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoos: implement File.Chmod on Windows
Constantin Konstantinidis [Sun, 16 Aug 2020 11:48:09 +0000 (13:48 +0200)]
os: implement File.Chmod on Windows

Fixes: #39606
Change-Id: I4def67ef18bd3ff866b140f6e76cdabe5d51a1c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/250077
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agocmd/go: move repository resolution from internal/get to internal/vcs
Jay Conrod [Wed, 2 Sep 2020 18:53:02 +0000 (14:53 -0400)]
cmd/go: move repository resolution from internal/get to internal/vcs

This is a refactoring intended to break the dependency from
internal/modfetch to internal/get. No change in functionality is intended.

Change-Id: If51aba7139cc0b62ecc9ba454c055c99e8f36f0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/254364
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go: move get.Insecure to cfg.Insecure to break dependency cycle
Jay Conrod [Wed, 2 Sep 2020 17:25:11 +0000 (13:25 -0400)]
cmd/go: move get.Insecure to cfg.Insecure to break dependency cycle

Change-Id: If9c73ff5adc7e080a48ecc6b35ce40822193d66f
Reviewed-on: https://go-review.googlesource.com/c/go/+/254363
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go: make 'go mod download' update go.sum after downloads are complete
Jay Conrod [Fri, 11 Sep 2020 13:31:30 +0000 (09:31 -0400)]
cmd/go: make 'go mod download' update go.sum after downloads are complete

'go mod download' calls WriteGoMod once via modload.ListModules when
it loads the build list. This saves sums for go.mod files needed by
MVS, but the write occurs before any zip files are downloaded.

With this change, 'go mod download' calls WriteGoMod again (and thus,
modfetch.WriteGoSum) after downloading and verifying module zip files,
so the sums of the zip files will be saved, too.

Fixes #41341

Change-Id: I7d56754aa255256ed45fd93cb154c2e6ea5f45a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/254357
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/link: add a test to test RODATA is indeed read-only
Cherry Zhang [Thu, 10 Sep 2020 15:14:27 +0000 (11:14 -0400)]
cmd/link: add a test to test RODATA is indeed read-only

Updates #38830.

Change-Id: Ie1f6ccef40a773f038aac587dfc26bf70a1a8536
Reviewed-on: https://go-review.googlesource.com/c/go/+/253921
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/link: put read-only data in __DATA_CONST segment
Cherry Zhang [Thu, 3 Sep 2020 16:59:09 +0000 (12:59 -0400)]
cmd/link: put read-only data in __DATA_CONST segment

On darwin, we put read-only data in __TEXT segment on AMD64 in
exe (non-PIE) buildmode, and in __DATA on everywhere else. This
is not ideal: things in __DATA segment are not read-only, and
being mapped R/W may use more run-time resources.

In fact, newer darwin systems support a __DATA_CONST segment,
which the dynamic linker will map it read-only after applying
relocations. Use that.

Fixes #38830.

Change-Id: Ic281e6c6ca8ef5fec4bb7c5b71c50dd5393e78ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/253919
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/internal/objfile: recognize Mach-O __DATA_CONST segment as read-only data
Cherry Zhang [Wed, 9 Sep 2020 00:41:51 +0000 (20:41 -0400)]
cmd/internal/objfile: recognize Mach-O __DATA_CONST segment as read-only data

Updates #38830.

Change-Id: I826c6b0a42bc8e48fcda556250ca4a95c73987eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/253918
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/go: refactor modload.Import for better -mod=readonly errors
Jay Conrod [Wed, 9 Sep 2020 20:41:55 +0000 (16:41 -0400)]
cmd/go: refactor modload.Import for better -mod=readonly errors

When -mod=readonly is set, Import will now allow imports from
replacements without explicit requirements. With -mod=mod, this would
add a new requirement but does not trigger a module lookup, so it's
determinisitic.

Before reporting an error for an unknown import with -mod=readonly,
check whether the import is valid. If there's a typo in the import,
that's more relevant.

For #40728

Change-Id: I05e138ff76ba3d0eb2e3010c15589fa363deb8d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/253745
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: refactor -mod flag parsing
Jay Conrod [Wed, 9 Sep 2020 20:35:56 +0000 (16:35 -0400)]
cmd/go: refactor -mod flag parsing

Keep track of whether the -mod flag was set explicitly. When
-mod=readonly is the default, we'll want to adjust our error messages
if it's set explicitly.

Also, register the -mod, -modcacherw, and -modfile flags in functions
in internal/base instead of internal/work. 'go mod' commands that
don't load packages shouldn't depend on internal/work.

For #40728

Change-Id: I272aea9e19908ba37e151baac4ea8630e90f241f
Reviewed-on: https://go-review.googlesource.com/c/go/+/253744
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/link: record only the first occurance in Reachparent graph
Cherry Zhang [Fri, 11 Sep 2020 02:41:29 +0000 (22:41 -0400)]
cmd/link: record only the first occurance in Reachparent graph

In the deadcode pass, a type symbol may be marked twice, one
without UsedInIface, one with. For the second time, don't
update the Reachparent graph, so it only records the path of
the first time the symbol is reached. This ensures the
Reachparent graph is acyclic.

TODO: add a test. (This only affects GOEXPERIMENT=fieldtrack)

Change-Id: I68e8a1a69c3830bc8aee5df946151dc22dcb2b29
Reviewed-on: https://go-review.googlesource.com/c/go/+/254297
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/go: update tests to work with -mod=readonly on by default
Jay Conrod [Wed, 9 Sep 2020 19:58:05 +0000 (15:58 -0400)]
cmd/go: update tests to work with -mod=readonly on by default

For #40728

Change-Id: Ic2b025ff75c6e73c0cb58c1737e44e2a41c71571
Reviewed-on: https://go-review.googlesource.com/c/go/+/253837
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agoruntime: remove darwin/arm specifc code
Cherry Zhang [Thu, 10 Sep 2020 21:18:57 +0000 (17:18 -0400)]
runtime: remove darwin/arm specifc code

That port is gone.

Change-Id: I212d435e290d1890d6cd5531be98bb692650595e
Reviewed-on: https://go-review.googlesource.com/c/go/+/254077
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agounicode/utf8: refactor benchmarks for FullRune function
eric fang [Wed, 13 May 2020 06:38:39 +0000 (06:38 +0000)]
unicode/utf8: refactor benchmarks for FullRune function

BenchmarkFullASCIIRune tests the performance of function utf8.FullRune,
which will be inlined in BenchmarkFullASCIIRune. Since the return value
of FullRune is not referenced, it will be removed as dead code.

This CL makes the FullRune functions return value referenced by a global
variable to avoid this point. In addition, this CL adds one more benchmark
to cover more code paths, and puts them together as sub benchmarks of
BenchmarkFullRune.

Change-Id: I6e79f4c087adf70e351498a4b58d7482dcd1ec4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/233979
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/asm: add more SIMD instructions on arm64
Junchen Li [Mon, 31 Aug 2020 05:32:33 +0000 (13:32 +0800)]
cmd/asm: add more SIMD instructions on arm64

This CL adds USHLL, USHLL2, UZP1, UZP2, and BIF instructions requested
by #40725. And since UXTL* are aliases of USHLL*, this CL also merges
them into one case.

Updates #40725

Change-Id: I404a4fdaf953319f72eea548175bec1097a2a816
Reviewed-on: https://go-review.googlesource.com/c/go/+/253659
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/link: add copyright header
Cherry Zhang [Thu, 10 Sep 2020 15:07:48 +0000 (11:07 -0400)]
cmd/link: add copyright header

Change-Id: I44f57019bb8e659d4aa3da8b13e8bd9a20b9d2e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/253920
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime: update docs for GOMAXPROCS
ipriver [Thu, 10 Sep 2020 10:08:21 +0000 (10:08 +0000)]
runtime: update docs for GOMAXPROCS

https://github.com/golang/go/blob/master/doc/effective_go.html#L3211 is used to update the docs comment for `GOMAXPROCS` function.

Fixes #41275

Change-Id: I39f58e93a267c6e9f3ac6638ed51acbe5284ada2
GitHub-Last-Rev: e45c8ac5873979397d747838fd8d41e252aec489
GitHub-Pull-Request: golang/go#41276
Reviewed-on: https://go-review.googlesource.com/c/go/+/253537
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoall: check GOROOT_BOOTSTRAP executable before bootsrappping
Cuong Manh Le [Thu, 10 Sep 2020 06:21:41 +0000 (13:21 +0700)]
all: check GOROOT_BOOTSTRAP executable before bootsrappping

Otherwise we’d still be writing that we're building cmd/dist
even if GOROOT_BOOTSTRAP we’re wrongly set.

Change-Id: I940e18c3cebae5664f85babc9919e9eb215d5093
Reviewed-on: https://go-review.googlesource.com/c/go/+/253877
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agocmd/internal/obj/arm64: enable some SIMD instructions
fanzha02 [Thu, 20 Aug 2020 09:02:18 +0000 (17:02 +0800)]
cmd/internal/obj/arm64: enable some SIMD instructions

Enable VBSL, VBIT, VCMTST, VUXTL VUXTL2 and FMOVQ SIMD
instructions required by the issue #40725. And FMOVQ
instrucion is used to move a large constant to a Vn
register.

Add test cases.

Fixes #40725

Change-Id: I1cac1922a0a0165d698a4b73a41f7a5f0a0ad549
Reviewed-on: https://go-review.googlesource.com/c/go/+/249758
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go/internal/modload: refactor pathInModuleCache
Bryan C. Mills [Tue, 1 Sep 2020 04:34:03 +0000 (00:34 -0400)]
cmd/go/internal/modload: refactor pathInModuleCache

I found the control flow of this function a bit tricky to reason about
due to nesting and interaction between conditions and iteration. This
change factors out a helper function that can return early instead of
mixing conditionals and 'continue' statements.

Also remove the (unused) ModuleUsedDirectly function.

For #36460

Change-Id: I60a2a5a1b32989e5a17a14e1a8c858b280cda8f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/251998
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/go/internal/modload: rename LoadBuildList and BuildList
Bryan C. Mills [Mon, 27 Jul 2020 16:57:36 +0000 (12:57 -0400)]
cmd/go/internal/modload: rename LoadBuildList and BuildList

With lazy loading, the “build list” can be refined as packages are loaded.
Rename functions that return the build list to more precisely describe
the set of modules returned by the call.

Also eliminate a redundant call to LoadBuildList (right before
ListModules, which itself begins with the same call).

For #36460

Change-Id: I0fc4f9dd7602e0df5e166e329ee5d516d810ca53
Reviewed-on: https://go-review.googlesource.com/c/go/+/249878
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/go/internal/modget: move MVS code to a separate file
Bryan C. Mills [Mon, 27 Jul 2020 17:57:12 +0000 (13:57 -0400)]
cmd/go/internal/modget: move MVS code to a separate file

For #36460

Change-Id: Ie81c03df18c6987527da765d5f6575556340cb01
Reviewed-on: https://go-review.googlesource.com/c/go/+/249877
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal/modload: consolidate buildList and associated functions into one...
Bryan C. Mills [Thu, 2 Jul 2020 02:38:45 +0000 (22:38 -0400)]
cmd/go/internal/modload: consolidate buildList and associated functions into one file

Change-Id: I310c37c7f0ce5581f07cf6e27d1f6361d03b92ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/244077
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal/modload: implement the "all" pattern for lazy loading
Bryan C. Mills [Fri, 13 Mar 2020 20:32:37 +0000 (16:32 -0400)]
cmd/go/internal/modload: implement the "all" pattern for lazy loading

The new semantics of the "all" package pattern can be implemented
without actually changing module loading per se. This change
implements those semantics, so that the change can be decoupled from
the changes to the module requirement graph.

For #36460

Change-Id: I0ee8b17afa8b728dc470a42a540fcc01764a4442
Reviewed-on: https://go-review.googlesource.com/c/go/+/240623
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd: update golang.org/x/tools to v0.0.0-20200901153117-6e59e24738da
Tzu-Chiao Yeh [Sun, 6 Sep 2020 01:43:34 +0000 (09:43 +0800)]
cmd: update golang.org/x/tools to v0.0.0-20200901153117-6e59e24738da

Includes the latest fix on vet to warn unused context.WithValue result.

Fixes #41149

Change-Id: I06c204f40ef12b0f62f59b1bbdf1fe06ccd6565d
Reviewed-on: https://go-review.googlesource.com/c/go/+/252941
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go/internal/modload: fix spurious import resolution error
Bryan C. Mills [Sat, 29 Aug 2020 01:32:05 +0000 (21:32 -0400)]
cmd/go/internal/modload: fix spurious import resolution error

Due to a bug in CL 173017, if QueryPackages found multiple candidates
for the given package and *at least* one of those candidates was not
available to add, we would reject *all* such candidates — even those
that were still viable.

Now, we return the first viable candidate, and only return an error if
*no* candidate is viable given the current build list.

Fixes #41113

Change-Id: Idb2e77244be7c0f5dd511efb142c3059925d7336
Reviewed-on: https://go-review.googlesource.com/c/go/+/251446
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agonet/http: fix data race due to writeLoop goroutine left running
Steven Hartland [Mon, 31 Aug 2020 20:37:40 +0000 (21:37 +0100)]
net/http: fix data race due to writeLoop goroutine left running

Fix a data race for clients that mutate requests after receiving a
response error which is caused by the writeLoop goroutine left
running, this can be seen on cancelled requests.

Fixes #37669

Change-Id: Ia4743c6b8abde3a7503de362cc6a3782e19e7f60
Reviewed-on: https://go-review.googlesource.com/c/go/+/251858
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go/internal/modload: rework import resolution
Bryan C. Mills [Fri, 28 Aug 2020 22:19:22 +0000 (18:19 -0400)]
cmd/go/internal/modload: rework import resolution

modload.Import previously performed two otherwise-separable tasks:

1. Identify which module in the build list contains the requested
   package.

2. If no such module exists, search available modules to try to find
   the missing package.

This change splits those two tasks into two separate unexported
functions, and reports import-resolution errors by attaching them to
the package rather than emitting them directly to stderr. That allows
'list' to report the errors, but 'list -e' to ignore them.

With the two tasks now separate, it will be easier to avoid the
overhead of resolving missing packages during lazy loading if we
discover that some existing dependency needs to be promoted to the top
level (potentially altering the main module's selected versions, and
thus suppling packages that were previously missing).

For #36460
Updates #26909

Change-Id: I32bd853b266d7cd231d1f45f92b0650d95c4bcbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/251445
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/go/internal/modload: remove (*loader).forceStdVendor
Bryan C. Mills [Thu, 27 Aug 2020 20:34:59 +0000 (16:34 -0400)]
cmd/go/internal/modload: remove (*loader).forceStdVendor

forceStdVendor was a special-case mechanism to allow Go contributors
to use vendored dependencies by default when working in GOROOT/src.

As of Go 1.14,¹ the 'go' command uses vendored dependencies by default
within all modules, so the 'std' and 'cmd' modules no longer need to
be special cases, and we can remove this special-case code.

¹ https://golang.org/doc/go1.14#vendor

Updates #33848
Updates #30241

Change-Id: Ib2fb5841c253113b17fa86a086ce85a22ac3d121
Reviewed-on: https://go-review.googlesource.com/c/go/+/251159
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/go/internal/modload: track which packages are in 'all' during loading
Bryan C. Mills [Wed, 1 Jul 2020 04:45:34 +0000 (00:45 -0400)]
cmd/go/internal/modload: track which packages are in 'all' during loading

If the user requests the 'all' pattern in addition to explicit roots
outside of 'all', we should not load the transitive dependencies of
those explicit roots as if they were *in* 'all'. Without the '-test'
flag, we should not load test dependencies of any package outside of
'all'. Even *with* the '-test' flag, we should only load test
dependencies of the requested roots, not test dependencies of other
packages that happen to be imported by those roots.

More precise tracking of membership in 'all' will be important when we
implement lazy loading, because membership in 'all' determines which
module dependencies we will record in the main module's go.mod file.

This change also reduces reliance on global state, factors out the
loading process into several smaller functions, and sets us up to
reuse the 'go mod vendor' version of the 'all' pattern for lazy
loading.

For #36460
Fixes #40799

Change-Id: I5ca21c86a860daee1316f732cea131a331d8ddf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/240505
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agoruntime: ignore SIGPROF if profiling disable for thread
Ian Lance Taylor [Wed, 9 Sep 2020 17:40:11 +0000 (10:40 -0700)]
runtime: ignore SIGPROF if profiling disable for thread

This avoids a deadlock on prof.signalLock between setcpuprofilerate
and cpuprof.add if a SIGPROF is delivered to the thread between the
call to setThreadCPUProfiler and acquiring prof.signalLock.

Fixes #41014

Change-Id: Ie825e8594f93a19fb1a6320ed640f4e631553596
Reviewed-on: https://go-review.googlesource.com/c/go/+/253758
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoruntime: fix ReadMemStatsSlow's and CheckScavengedBits' chunk iteration
Michael Anthony Knyszek [Wed, 9 Sep 2020 16:52:18 +0000 (16:52 +0000)]
runtime: fix ReadMemStatsSlow's and CheckScavengedBits' chunk iteration

Both ReadMemStatsSlow and CheckScavengedBits iterate over the page
allocator's chunks but don't actually check if they exist. During the
development process the chunks index became sparse, so now this was a
possibility. If the runtime tests' heap is sparse we might end up
segfaulting in either one of these functions, though this will generally
be very rare.

The pattern here to return nil for a nonexistent chunk is also useful
elsewhere, so this change introduces tryChunkOf which won't throw, but
might return nil. It also updates the documentation of chunkOf.

Fixes #41296.

Change-Id: Id5ae0ca3234480de1724fdf2e3677eeedcf76fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/253777
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/link: remove unnecessary type conversion for nitablinks
Cuong Manh Le [Wed, 9 Sep 2020 16:47:41 +0000 (23:47 +0700)]
cmd/link: remove unnecessary type conversion for nitablinks

It's already an uint64.

Change-Id: Ic4cdb957aa4f9245c1ea3f946bcb740f116dd04b
Reviewed-on: https://go-review.googlesource.com/c/go/+/253679
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/link: pre-resolve package reference
Cherry Zhang [Tue, 11 Aug 2020 23:57:50 +0000 (19:57 -0400)]
cmd/link: pre-resolve package reference

Pre-resolve package index references, so it doesn't need to do a
map lookup in every cross-package symbol reference resolution. It
increases the memory usage very slightly (O(# imported packages)).

Change-Id: Ia76c97ac51f1c2c2d5ea7ae34853850ec69ef0a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/253604
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go: make 'go get' preserve sums for content of new requirements
Jay Conrod [Fri, 28 Aug 2020 19:05:44 +0000 (15:05 -0400)]
cmd/go: make 'go get' preserve sums for content of new requirements

This preserves zip sums when 'go get' is run on a module that does not
have a package in the root directory. The zip must be fetched to
determine whether the package should be loaded, so we already load and
verify the sum.

Note that 'go mod tidy' may still remove these sums, since they
aren't needed to load packages.

Fixes #41103

Change-Id: I78f10a25f0392461fdc98518a7c92a38ee3233c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/251880
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/compile: add Type.IsUintptr() to detect type is an uintptr
Cuong Manh Le [Wed, 9 Sep 2020 05:09:26 +0000 (12:09 +0700)]
cmd/compile: add Type.IsUintptr() to detect type is an uintptr

Passes toolstash-check.

Change-Id: I7051d45eafbfd4dea73a3d4b5ea6cff39d76cbc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/253658
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: consistently use Type.IsUnsafePtr()
Cuong Manh Le [Wed, 9 Sep 2020 05:06:18 +0000 (12:06 +0700)]
cmd/compile: consistently use Type.IsUnsafePtr()

Passes toolstash-check.

Change-Id: Iaeae7cc20e26af733642c7c8c7ca0a059e5b07b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/253657
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: fix mishandling of unsafe-uintptr arguments in go/defer
Cuong Manh Le [Tue, 8 Sep 2020 08:28:43 +0000 (15:28 +0700)]
cmd/compile: fix mishandling of unsafe-uintptr arguments in go/defer

Currently, the statement:

go g(uintptr(f()))

gets rewritten into:

tmp := f()
newproc(8, g, uintptr(tmp))
runtime.KeepAlive(tmp)

which doesn't guarantee that tmp is still alive by time the g call is
scheduled to run.

This CL fixes the issue, by wrapping g call in a closure:

go func(p unsafe.Pointer) {
g(uintptr(p))
}(f())

then this will be rewritten into:

tmp := f()
go func(p unsafe.Pointer) {
g(uintptr(p))
runtime.KeepAlive(p)
}(tmp)
runtime.KeepAlive(tmp)  // superfluous, but harmless

So the unsafe.Pointer p will be kept alive at the time g call runs.

Updates #24491

Change-Id: Ic10821251cbb1b0073daec92b82a866c6ebaf567
Reviewed-on: https://go-review.googlesource.com/c/go/+/253457
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/link: enable DWARF combining on macOS ARM64
Cherry Zhang [Fri, 4 Sep 2020 18:35:57 +0000 (14:35 -0400)]
cmd/link: enable DWARF combining on macOS ARM64

It appears the machoCalcStart function is meant to align the
segment, but it doesn't. Replace it with an actual alignment
calculation. Also, use the alignment from the configuration,
instead of hardcode.

With this fix we could enable DWARF combining on macOS ARM64.

Change-Id: I19ec771b77d752b83a54c53b6ee65af78a31b8ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/253558
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: mark ELF PLT sections executable
Cherry Zhang [Thu, 3 Sep 2020 21:51:01 +0000 (17:51 -0400)]
cmd/link: mark ELF PLT sections executable

Change-Id: Ie0316a06c30485f783c2175590d7e9fc4fa3e0cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/253021
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: rewrite some code without using reflection
Cherry Zhang [Fri, 4 Sep 2020 17:01:08 +0000 (13:01 -0400)]
cmd/link: rewrite some code without using reflection

In Mach-O DWARF combining, some code was written using reflection,
so it could support both 32-bit and 64-bit Mach-O files without
duplicating code. We no longer support 32-bit darwin platforms
now. 32-bit support can go. Rewrite it with direct field access,
for 64-bit only.

Change-Id: If1338c3cd37cecf603f4df0c6eb0c890eaebfe5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/253557
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: strip STAB (symbolic debugging) symbols on darwin
Cherry Zhang [Wed, 26 Aug 2020 22:19:03 +0000 (18:19 -0400)]
cmd/link: strip STAB (symbolic debugging) symbols on darwin

On darwin, with external linking, the system linker produces STAB
(symbolic debugging) symbols in the binary's symbol table. These
include paths of the intermediate object files, like
<tmpdir>/go.o, which changes from run to run, making the build
non-reproducible.

Since we run dsymutil to produce debug info and combine them
back into the binary, we don't need those STAB symbols anymore.
Strip them after running dsymutil.

If DWARF is not enabled, we don't run dsymutil. We can pass
"-Wl,-S" to let the system linker not generate those symbols.

While here, also make it more consistent about DWARF combining.
Currently we only do DWARF combining on macOS/AMD64, when DWARF
is enabled. On ARM64, we run dsymutil, but then throw the result
away. This CL changes it to not run dsymutil (and strip) on
ARM64.

TODO: add a test. We don't do it here as it fails on some
(non-darwin) platforms.

Fixes #40979.

Change-Id: If770f7828cdb858857d6079e0585bf067f8f7a92
Reviewed-on: https://go-review.googlesource.com/c/go/+/250944
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime: make PCDATA_RegMapUnsafe more clear and remove magic number
chainhelen [Tue, 8 Sep 2020 03:36:19 +0000 (03:36 +0000)]
runtime: make PCDATA_RegMapUnsafe more clear and remove magic number

Change-Id: Ibf3ee755c3fbec03a9396840dc92ce148c49d9f7
GitHub-Last-Rev: 945d8aaa136003dc381c6aa48bff9ea7ca2c6991
GitHub-Pull-Request: golang/go#41262
Reviewed-on: https://go-review.googlesource.com/c/go/+/253377
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoruntime: remove outdated comment in mkduff.go about usage of STOSQ
Martin Möhrmann [Mon, 7 Sep 2020 18:39:48 +0000 (20:39 +0200)]
runtime: remove outdated comment in mkduff.go about usage of STOSQ

Change-Id: I71966cc5def4615d64876165872e5e7f2956b270
Reviewed-on: https://go-review.googlesource.com/c/go/+/253397
Run-TryBot: Martin Möhrmann <martisch@uos.de>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: handle ODDD in exprformat
Cuong Manh Le [Mon, 7 Sep 2020 05:14:30 +0000 (12:14 +0700)]
cmd/compile: handle ODDD in exprformat

Fixes #41247

Change-Id: Iaa9502cc610e2cc64be5dfd91ba3187f86f87cbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/252942
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agocmd/asm: fix the error of checking the post-index offset of VLD[1-4]R instructions...
fanzha02 [Thu, 20 Aug 2020 10:39:46 +0000 (18:39 +0800)]
cmd/asm: fix the error of checking the post-index offset of VLD[1-4]R instructions of arm64

The post-index offset of VLD[1-4]R instructions is decided by the
"size" field not "Q" field, the current assembler uses "Q" fileld
to check the correctness of post-index offset which is not correct.
This patch fixes it.

Fixes #40725

Change-Id: If1cde7f21c6b3ee0e491649eb567700bd1475c84
Reviewed-on: https://go-review.googlesource.com/c/go/+/249757
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: rotate map key seed on clearing up maps
Cuong Manh Le [Fri, 4 Sep 2020 10:47:44 +0000 (17:47 +0700)]
runtime: rotate map key seed on clearing up maps

Same thing as CL 253020 did for map clear idiom.

name                        old time/op  new time/op  delta
MapDelete/Int32/100-12      30.0ns ± 1%  30.7ns ± 3%   ~     (p=0.400 n=3+3)
MapDelete/Int32/1000-12     26.6ns ± 2%  28.1ns ± 3%   ~     (p=0.100 n=3+3)
MapDelete/Int32/10000-12    28.6ns ± 1%  31.9ns ± 1%   ~     (p=0.100 n=3+3)
MapDelete/Int64/100-12      30.2ns ± 0%  32.1ns ± 3%   ~     (p=0.100 n=3+3)
MapDelete/Int64/1000-12     26.5ns ± 1%  27.5ns ± 3%   ~     (p=0.100 n=3+3)
MapDelete/Int64/10000-12    29.6ns ± 1%  29.3ns ± 1%   ~     (p=0.300 n=3+3)
MapDelete/Str/100-12        19.5ns ± 3%  19.6ns ± 2%   ~     (p=0.800 n=3+3)
MapDelete/Str/1000-12       31.6ns ± 1%  31.4ns ± 1%   ~     (p=0.500 n=3+3)
MapDelete/Str/10000-12      37.8ns ± 1%  37.1ns ± 1%   ~     (p=0.100 n=3+3)
MapDelete/Pointer/100-12    15.9ns ± 1%  16.8ns ± 9%   ~     (p=0.200 n=3+3)
MapDelete/Pointer/1000-12   26.9ns ± 1%  26.2ns ± 2%   ~     (p=0.200 n=3+3)
MapDelete/Pointer/10000-12  30.6ns ± 1%  30.7ns ± 4%   ~     (p=0.700 n=3+3)

Fixes #25237

Change-Id: I353cf44a2f6158549f0ef563d867f0844fec7095
Reviewed-on: https://go-review.googlesource.com/c/go/+/252940
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agogo/ast: note that in BasicLit CHARs and STRINGs are quoted
Alberto Donizetti [Mon, 27 Jul 2020 12:42:06 +0000 (14:42 +0200)]
go/ast: note that in BasicLit CHARs and STRINGs are quoted

The Value field of ast.BasicLit is a string field holding the literal
string. For CHARs and STRINGs, the BasicLit.Value literal includes
quotes, so to use the value in practise one will often need to Unquote
it.

Since this is a common gotcha (I've been bitten by this a few times),
document it, and suggest the use of the strconv.Unquote functions.

Fixes #39590

Change-Id: Ie3e13f5a2a71bb1b59e03bc5b3a16d8e2e7c01d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/244960
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agonet/http: mark http/2 connections active
Michael Fraenkel [Sat, 27 Jun 2020 19:31:34 +0000 (13:31 -0600)]
net/http: mark http/2 connections active

On Server.Shutdown, all idle connections are closed.
A caveat for new connections is that they are marked idle
after 5 seconds.
Previously new HTTP/2 connections were marked New, and after 5 seconds,
they would then become idle. With this change, we now mark HTTP/2
connections as Active to allow the proper shutdown sequence to occur.

Fixes #36946
Fixes #39776

Change-Id: I31efbf64b9a2850ca544da797f86d7e1b3378e8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/240278
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agomime: add examples for FormatMediaType and ParseMediaType
Ainar Garipov [Sat, 5 Sep 2020 11:24:28 +0000 (14:24 +0300)]
mime: add examples for FormatMediaType and ParseMediaType

Change-Id: Ic129c58784ad1f0b8b90fc9d33e52bee61bdf0eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/253237
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agodoc/go1.16: reformat the minor changes section as a definition list
Ainar Garipov [Wed, 26 Aug 2020 20:55:09 +0000 (23:55 +0300)]
doc/go1.16: reformat the minor changes section as a definition list

Change the section to use <dl>, <dt>, and <dd> tags to match
previous documents.

Change-Id: Ide0bea698a84ed6b61b364ef9e2f3801ebb8d4d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/250897
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agosrc/go.mod, net/http: update bundled and latest golang.org/x/net
Paschalis Tsilias [Sat, 5 Sep 2020 12:01:19 +0000 (15:01 +0300)]
src/go.mod, net/http: update bundled and latest golang.org/x/net

Updates x/net/http2 to git rev 62affa334b73ec65ed44a326519ac12c421905e3

    x/net/http2: reject HTTP/2 Content-Length headers containing a sign
    https://go-review.googlesource.com/c/net/+/236098/ (fixes #39017)

also updates the vendored version of golang.org/x/net by running

go get golang.org/x/net@62affa334b73ec65ed44a326519ac12c421905e3
go mod tidy
go mod vendor
go generate -run bundle net/http

Change-Id: I7ecfdb7644574c44c3616e3b47664eefd4c926f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/253238
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: ensure that ssa.Func constant cache is consistent
David Chase [Fri, 28 Aug 2020 18:32:15 +0000 (14:32 -0400)]
cmd/compile: ensure that ssa.Func constant cache is consistent

It was not necessarily consistent before, we were just lucky.

Change-Id: I3a92dc724e0af7b4d810a6a0b7b1d58844eb8f87
Reviewed-on: https://go-review.googlesource.com/c/go/+/251440
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotesting: make TempDir idempotent for both Cleanup and Benchmark
Changkun Ou [Fri, 28 Aug 2020 10:13:37 +0000 (12:13 +0200)]
testing: make TempDir idempotent for both Cleanup and Benchmark

Ensures that calling TempDir() in either of Cleanup or Benchmark
doesn't cause test failures which were previously caused by the
created directory having been deleted after the first run, yet
we prevented the recreation of the directory due to our selection
of concurrency primitive sync.Once. This change recreates the
temporary directory if it doesn't exist, regardless of how
many times Cleanup and Benchmark are invoked.

Fixes #41062

Change-Id: I925d9f7207d7c369a193d1e17da7a59a586244a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/251297
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoruntime: opportunistically rotate map key seed
Benjamin Barenblat [Thu, 3 Sep 2020 20:36:38 +0000 (16:36 -0400)]
runtime: opportunistically rotate map key seed

When clearing a map, reinitialize the hash seed with random data. This
makes it more difficult for attackers to trigger pathological
performance via repeated hash collisions.

The extra reinitialization causes no statistically significant slowdown:

name                              old time/op  new time/op  delta
GoMapClear/Reflexive/1-12         18.3ns ± 0%  20.0ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/Reflexive/10-12        18.2ns ± 0%  19.8ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/Reflexive/100-12       44.6ns ± 0%  46.1ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/Reflexive/1000-12       592ns ± 0%   592ns ± 0%   ~     (all samples are equal)
GoMapClear/Reflexive/10000-12     3.88µs ± 0%  3.88µs ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/NonReflexive/1-12      62.7ns ± 0%  63.9ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/NonReflexive/10-12     75.0ns ± 0%  76.1ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/NonReflexive/100-12     203ns ± 0%   206ns ± 0%   ~             (p=1.000 n=1+1)
GoMapClear/NonReflexive/1000-12   2.33µs ± 0%  2.33µs ± 0%   ~     (all samples are equal)
GoMapClear/NonReflexive/10000-12  18.1µs ± 0%  18.1µs ± 0%   ~             (p=1.000 n=1+1)

Fixes #25237

Change-Id: I629a79dd7c562ba18bd94159673c3b9b653da643
Reviewed-on: https://go-review.googlesource.com/c/go/+/253020
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/link: pass darwin/amd64-specific flags only on AMD64
Cherry Zhang [Thu, 3 Sep 2020 01:04:12 +0000 (21:04 -0400)]
cmd/link: pass darwin/amd64-specific flags only on AMD64

The linker assumed macOS is AMD64 (and 386 in the past). It
passes darwin/amd64-specific flags to the external linker when
building for macOS. They don't work for ARM64-based macOS. So
only pass them on AMD64.

Disable DWARF combining for macOS ARM64 for now. The generated
binary doesn't run. (TODO: fix.)

For macOS ARM64 port. External linking now works.

Change-Id: Iab53bc48f4fadd9b91de8898b4b450ea442667a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/253019
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: MACHOPLT is executable
Cherry Zhang [Thu, 3 Sep 2020 16:26:10 +0000 (12:26 -0400)]
cmd/link: MACHOPLT is executable

The PLT stubs are executable. Put it together with executable
sections, instead of read-only data sections.

Change-Id: I3818414aa0b87c6968c6c7eccce19b0db7c43193
Reviewed-on: https://go-review.googlesource.com/c/go/+/253018
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: store the comparison pseudo-ops of arm64 conditional instructions in...
fanzha02 [Thu, 27 Aug 2020 09:34:59 +0000 (17:34 +0800)]
cmd/compile: store the comparison pseudo-ops of arm64 conditional instructions in AuxInt

The current implementation stores the comparison pseudo-ops of arm64
conditional instructions (CSEL/CSEL0) in Aux, this patch modifies it
and stores it in AuxInt, which can avoid the allocation.

Change-Id: I0b69e51f63acd84c6878c6a59ccf6417501a8cfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/252517
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/go: define an asm macro for GOEXPERIMENT=regabi
Austin Clements [Tue, 1 Sep 2020 15:21:50 +0000 (11:21 -0400)]
cmd/go: define an asm macro for GOEXPERIMENT=regabi

This defines a macro for the regabi GOEXPERIMENT when assembling
runtime assembly code.

In general, assembly code will be shielded from the calling convention
change, but there is a small amount of runtime assembly that is going
to have to change. By defining a macro, we can easily make the small
necessary changes. The other option is to use build tags, but that
would require duplicating nontrivial amounts of unaffected code,
leading to potential divergence issues. (And unlike Go code, assembly
code can't depend on the compiler optimizing away branches on a
feature constant.) We consider the macro preferable, especially since
this is expected to be temporary as we transition to the new calling
convention.

Updates #40724.

Change-Id: I73984065123968337ec10b47bb12c4a1cbc07dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/252258
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/objabi: add regabi GOEXPERIMENT
Austin Clements [Tue, 1 Sep 2020 15:16:33 +0000 (11:16 -0400)]
cmd/internal/objabi: add regabi GOEXPERIMENT

This is the "feature flag" for the register calling convention work
(though since this work is expected to extend over a few releases,
it's not version-prefixed). This will let us develop the register
calling convention on the main branch while maintaining an easy toggle
between the old and new ABIs.

Updates #40724.

Change-Id: I129c8d87d34e6fa0910b6fa43efb35b706021637
Reviewed-on: https://go-review.googlesource.com/c/go/+/252257
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoimage/gif: have BenchmarkEncodeRealisticRGBA convert to RGBA
Nigel Tao [Wed, 2 Sep 2020 11:49:30 +0000 (21:49 +1000)]
image/gif: have BenchmarkEncodeRealisticRGBA convert to RGBA

Change-Id: I98f5d987b92a29dcff06ae23b92f293cc7d6c02f
Reviewed-on: https://go-review.googlesource.com/c/go/+/252597
Reviewed-by: David Symonds <dsymonds@golang.org>
4 years agocmd/compile: do not declare func nodes
Cuong Manh Le [Wed, 19 Aug 2020 09:05:02 +0000 (16:05 +0700)]
cmd/compile: do not declare func nodes

The primary responsibility of declare() to associate a symbol (Sym) with
a declaration (Node), so "oldname" will work. Function literals are
anonymous, so their symbols does not need to be declared.

Passes toolstash-check.

Change-Id: I739b1054e3953e85fbd74a99148b9cfd7e5a57eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/249078
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: do not push functions literal node to Func.Dcl
Cuong Manh Le [Wed, 2 Sep 2020 05:45:07 +0000 (12:45 +0700)]
cmd/compile: do not push functions literal node to Func.Dcl

They are skipped while processing Func.Dcl anyway.

This CL does not pass toolstash-check, because it reduces the length
of Func.Dcl length, while that length is used to generate autotmp
variables name.

Change-Id: I408183e62ce6c34e5f04c89814ebb9570957e37b
Reviewed-on: https://go-review.googlesource.com/c/go/+/252418
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/go: add -Wl,-Bsymbolic-functions to cgo flags whitelist
Dan Kortschak [Wed, 2 Sep 2020 22:57:34 +0000 (08:27 +0930)]
cmd/go: add -Wl,-Bsymbolic-functions to cgo flags whitelist

Closes #41199

Change-Id: Iab69358e8c39e6d2b2797c7ce750df63aa7e96b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/252698
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agonet/http: reject negative suffix-length Range:bytes=--N with 416 status code
Emmanuel T Odeke [Wed, 2 Sep 2020 08:08:02 +0000 (01:08 -0700)]
net/http: reject negative suffix-length Range:bytes=--N with 416 status code

Fixes the file server to reject requests of the form:
    "Range": "bytes=--N"
where "-N" is a negative suffix-length as designated by the
grammar in RFC 7233 Section 2.1, "Byte-Ranges", which specifies
that suffix-length MUST be of the form 1*DIGIT aka a non-negative digit.

Thus requests such as:
    "Range": "bytes=--2"
will be rejected with a "416 Range Not Satisfiable" response.

Fixes #40940

Change-Id: I3e89f8326c14af30d8bdb126998a50e02ba002d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/252497
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/compile/internal/gc: remove unparen
Cuong Manh Le [Wed, 2 Sep 2020 15:10:15 +0000 (22:10 +0700)]
cmd/compile/internal/gc: remove unparen

CL 197120 removed the last use of it.

Change-Id: I5fe4f57a47acc712208d831e72cd79205a534c28
Reviewed-on: https://go-review.googlesource.com/c/go/+/252697
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agotesting: flush test summaries to stdout atomically when streaming output
Bryan C. Mills [Wed, 19 Aug 2020 02:47:12 +0000 (22:47 -0400)]
testing: flush test summaries to stdout atomically when streaming output

While debugging #40771, I realized that the chatty printer should only
ever print to a single io.Writer (normally os.Stdout). The other
Writer implementations in the chain write to local buffers, but if we
wrote a test's output to a local buffer, then we did *not* write it to
stdout and we should not store it as the most recently logged test.

Because the chatty printer should only ever print to one place, it
shouldn't receive an io.Writer as an argument — rather, it shouldn't
be used at all for destinations other than the main output stream.

On the other hand, when we flush the output buffer to stdout in the
top-level flushToParent call, it is important that we not allow some
other test's output to intrude between the test summary header and the
remainder of the test's output. cmd/test2json doesn't know how to
parse such an intrusion, and it's confusing to humans too.

No test because I couldn't reproduce the user-reported error without
modifying the testing package. (This behavior seems to be very
sensitive to output size and/or goroutine scheduling.)

Fixes #40771
Updates #38458

Change-Id: Ic19bf1d535672b096ba1c8583a3b74aab6d6d766
Reviewed-on: https://go-review.googlesource.com/c/go/+/249026
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: add file copyright header declaration
Heisenberg [Mon, 3 Aug 2020 07:33:47 +0000 (15:33 +0800)]
runtime: add file copyright header declaration

Some files have no copyright notice.
The copyright time is the earliest modification record of the file.

Change-Id: I5698bae16b6b73543e074415877a03348f792951
Reviewed-on: https://go-review.googlesource.com/c/go/+/246378
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agonet/http/fcgi: fix race in child.serve connection read
Tzu-Chiao Yeh [Wed, 2 Sep 2020 02:53:39 +0000 (10:53 +0800)]
net/http/fcgi: fix race in child.serve connection read

Guards the connection read with a mutex, because typeStdin
asynchronously and concurrently writes to the underlying conn.

Fixes #41167

Change-Id: Ia2610f4fde0bd4b108c54164095ea293980b0301
Reviewed-on: https://go-review.googlesource.com/c/go/+/252417
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agoruntime: fix panic if newstack at runtime.acquireLockRank
chainhelen [Fri, 21 Aug 2020 16:44:52 +0000 (16:44 +0000)]
runtime: fix panic if newstack at runtime.acquireLockRank

Process may crash becaues acquireLockRank and releaseLockRank may
be called in nosplit context. With optimizations and inlining
disabled, these functions won't get inlined or have their morestack
calls eliminated.
Nosplit is not strictly required for lockWithRank, unlockWithRank
and lockWithRankMayAcquire, just keep consistency with lockrank_on.go
here.

Fixes #40843

Change-Id: I5824119f98a1da66d767cdb9a60dffe768f13c81
GitHub-Last-Rev: 38fd3ccf6ea03b670c7561c060ccdbccc42fff40
GitHub-Pull-Request: golang/go#40844
Reviewed-on: https://go-review.googlesource.com/c/go/+/248878
Reviewed-by: Dan Scales <danscales@google.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/cgo: document #include <> search path behaviour
KJ Tsanaktsidis [Tue, 1 Sep 2020 00:00:23 +0000 (10:00 +1000)]
cmd/cgo: document #include <> search path behaviour

cgo effectively prepends -I${SRCDIR} to the header include path of all
preambles it processes, so when an #include <> matches a header file
both in the source directory and also another include directory, the
local copy will be used in preference.

This behaviour is surprising but unfortunately also longstanding and
relied upon by packages in the wild, so the best we can do is to
document it.

Fixes #41059

Change-Id: If6d2818294b2bd94ea0fe5fd6ce77e54b3e167a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/251758
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agonet/smtp: adds support for the SMTPUTF8 extension
Daniel Cormier [Tue, 1 Sep 2020 21:13:01 +0000 (21:13 +0000)]
net/smtp: adds support for the SMTPUTF8 extension

If the SMTP server supports the SMTPUTF8 extension,
the SMTPUTF8 parameter is added to the MAIL FROM
command by the (*Client).Mail method.

Fixes #19860

Change-Id: I3287faf114ee514e5faa815a6bbc1bf04cf60b0f
GitHub-Last-Rev: d6338bb802da7537223f1ec6eda960606febefb8
GitHub-Pull-Request: golang/go#40627
Reviewed-on: https://go-review.googlesource.com/c/go/+/247257
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/go: simplify and document lazy-loading test cases
Bryan C. Mills [Tue, 1 Sep 2020 03:15:05 +0000 (23:15 -0400)]
cmd/go: simplify and document lazy-loading test cases

I decided to add package and module diagrams to the test cases to make
them easier to follow.

While adding those diagrams, I noticed some strong similarities among
a couple of the graphs, so I consolidated those cases (and deleted the
redundant tests).

For #36460

Change-Id: Id6cd04fc871379b83851c2d1af89ea9296a0f3e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/251997
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agonet/http/cgi: don't pass nil Body to the child handler
Marco [Sun, 24 May 2020 12:58:51 +0000 (14:58 +0200)]
net/http/cgi: don't pass nil Body to the child handler

For server requests, the http.Request Body should not be nil.

Fixes #39190

Change-Id: I32de7b6c0f6ca55008fea9fd86089cda0a2dea62
Reviewed-on: https://go-review.googlesource.com/c/go/+/235137
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go: remove TestScript/get_unicode and an internal get test case
Michael Matloob [Tue, 1 Sep 2020 19:41:36 +0000 (15:41 -0400)]
cmd/go: remove TestScript/get_unicode and an internal get test case

That test tested that import paths with non-ASCII unicode paths
were allowed by the Go command. Remove this test case because
golang.org/cl/251878 removes that support.

Also rewrite a test case in TestRepoRootForImportPath in the test
for cmd/go/internal/get to reflect that unicode directory names are now
disallowed.

Updates #29101

Change-Id: I669e220facd04fc82ccd05dd08e8f1ff4d48b1fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/252297
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agotesting: fail Example tests that invoke runtime.Goexit
Changkun Ou [Mon, 31 Aug 2020 18:54:17 +0000 (20:54 +0200)]
testing: fail Example tests that invoke runtime.Goexit

Previously, if an example test invoked runtime.Goexit, it would
pass yet hang until a timeout, while regular tests that invoke
runtime.Goexit do fail. This change removes that inconsistent
behavior and makes such example tests fail, and panic with an
indication of having invoked runtime.Goexit.

Fixes #41084

Change-Id: I0ffa152204f2b1580f4d5d6961ba1ce6b13fc022
Reviewed-on: https://go-review.googlesource.com/c/go/+/251857
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go/internal/get: add GOINSECURE support
witchard [Sun, 30 Aug 2020 18:15:03 +0000 (18:15 +0000)]
cmd/go/internal/get: add GOINSECURE support

Adds support for the GOINSECURE environment variable to GOPATH mode.

Updates #37519.

Change-Id: Ibe3f52b7f30b1395edb000998905ee93abe6cada
GitHub-Last-Rev: e298c0009eb5eba537bb00185a8778d2aab696ba
GitHub-Pull-Request: golang/go#38628
Reviewed-on: https://go-review.googlesource.com/c/go/+/229758
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go/internal/get: disallow non-ASCII unicode letters from import paths
Michael Matloob [Mon, 31 Aug 2020 20:12:35 +0000 (16:12 -0400)]
cmd/go/internal/get: disallow non-ASCII unicode letters from import paths

The copy of CheckImportPath in path.go and the regular expression for github
repos in vcsPaths together allow import paths with unicode letters with import
paths. These all come from github repos with non-ASCII unicode letters
with paths in directories. This mainly shows up in GOPATH mode, but could
also show up in Module mode when getting a module in GOPROXY=direct mode.

We expect there to not be any significant affected users of this change--
an investingation of github repos that would produce import paths that
would comply with the copy CheckImportPaths that's being removed, but not
modload.CheckImportPaths only surfaced a handful of cases, all of which
seemed to be small test or demonstation repos. But this CL is being
submitted early in the cycle so that it can be backed out if need be.

Updates #29101

Change-Id: I719df4af5b318e1330e90d8a0bffe5bb8d816f4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/251878
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd: update vendored golang.org/x/mod
Michael Matloob [Mon, 31 Aug 2020 20:29:13 +0000 (16:29 -0400)]
cmd: update vendored golang.org/x/mod

This pulls in golang.org/cl/250920 which rejects Windows shortnames as
path components in module.CheckImportPath (as is already done in
cmd/go/internal/get's copy of CheckImportPath). This will allow us to replace
the copy of CheckImportPath with the original.

This also pulls in golang.org/cl/250919 which rejects + in CheckPath and
CheckImportPath, and golang.org/cl/235597, which adds methods to the zip
package for gorelease, but shouldn't affect cmd.

This change also updates the cmd/go test case TestScript/mod_bad_filenames
to reflect that golang.org/x/mod/zip error messages now include filenames
for bad file names that can't be included in zip archives.

Updates #29101

Change-Id: I7f654325dc33b19bc9c6f77a56546747add5a47f
Reviewed-on: https://go-review.googlesource.com/c/go/+/251877
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agodoc/asm: add BP is callee-save paragraph
Egon Elbre [Tue, 25 Aug 2020 07:38:50 +0000 (10:38 +0300)]
doc/asm: add BP is callee-save paragraph

Change-Id: Id38e639c66a42acf0b1c4488cdfd0b7b6cf71c78
Reviewed-on: https://go-review.googlesource.com/c/go/+/250397
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: remove remnants of signal stack workaround
Heisenberg [Mon, 31 Aug 2020 11:22:36 +0000 (19:22 +0800)]
runtime: remove remnants of signal stack workaround

Updates #35979

Change-Id: Ic3a6e1b5e9d544979a3c8d909a36a55efa3b9c9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/251757
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
4 years agonet/http: refactor ResponseWriter.ReadFrom to permit splice on Linux
Paul Forgey [Tue, 1 Sep 2020 00:38:01 +0000 (00:38 +0000)]
net/http: refactor ResponseWriter.ReadFrom to permit splice on Linux

Rather than probe and guess if sendfile will work inside ResponseWriter.ReadFrom(src),
this change fixes the underlying issue of starting to respond before src is readable
We'll no longer send a status OK if a header has not yet been written and reading
from src is destined to fail. This small change implicitly takes care of the need for
the server to sniff the response body to determine the Content-Type.

This allows splice to work on Linux when src is a socket or any non-regular file that's spliceable.

The extra read of 512 bytes may raise an objection, and that's fair, but
we're already swapping some syscall prep work for another and a read of
512 probably will not impact the overall performance. For shorter
bodies, there's likely less setup time. A little initial slop is not too
unusual in zero copy network code, and sometimes actually helps.

Fixes #40888

Change-Id: I4a8e2ad0ace1318bae66dae5671d06ea6d4838ed
GitHub-Last-Rev: 097364ea866613d103a31e2247b44f4a12077f9e
GitHub-Pull-Request: golang/go#40903
Reviewed-on: https://go-review.googlesource.com/c/go/+/249238
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agodebug/elf: support relocations relative to sections with non-zero addresses
Victor Michel [Sun, 30 Aug 2020 20:43:39 +0000 (20:43 +0000)]
debug/elf: support relocations relative to sections with non-zero addresses

commit 72ec930fa70c20ce69b21bf32a7916c04c2e9c2f added basic support for
relocations, but assumed that the symbol value would be 0, likely because
.debug_info always has address == 0 in the ELF section headers.

CL 195679 added further support for relocations, but explicitly encoded
the original assumption that section addresses would be 0.

This change removes that assumption: all relocations will now be
properly computed based on the target symbol value even when that symbol
is a section with a non-zero address.

Typically, sections that are part of a LOAD program segment have
non-zero addresses. For example, .debug_ranges relocations could be
relative to .text, which usually has an address > 0.

Fixes #40879

Change-Id: Ib0a616bb8b05d6c96d179b03ca33a10946fc5d59
GitHub-Last-Rev: 4200de732641995f3a4958a13a5c78f65b7eae50
GitHub-Pull-Request: golang/go#41038
Reviewed-on: https://go-review.googlesource.com/c/go/+/250559
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: adjust some AMD64 rewrite rules to use typed aux fields
David Finkel [Sat, 25 Apr 2020 17:32:06 +0000 (13:32 -0400)]
cmd/compile: adjust some AMD64 rewrite rules to use typed aux fields

Remove an extra int32-representable check when deciding to use an int32
constant as an immediate value.

Comment out a broken optimization that relies on MaxUint32 being
representable by a signed int32. It never triggers and when fixed, the
signedness of the auxint prevents other optimization passes from
handling it properly, thus causing segfaults in the runtime.

Remove a couple offset representable in 32-bits checks on 32-bit aux
vals.

toolstash-check clean

Change-Id: I148b53403fde523c90d692cb90e412460664b439
Reviewed-on: https://go-review.googlesource.com/c/go/+/230458
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile,cmd/asm: simplify recording of branch targets, take 2
Keith Randall [Fri, 28 Aug 2020 17:10:32 +0000 (17:10 +0000)]
cmd/compile,cmd/asm: simplify recording of branch targets, take 2

We currently use two fields to store the targets of branches.
Some phases use p.To.Val, some use p.Pcond. Rewrite so that
every branch instruction uses p.To.Val.
p.From.Val is also used in rare instances.
Introduce a Pool link for use by arm/arm64, instead of
repurposing Pcond.

This is a cleanup CL in preparation for some stack frame CLs.

Change-Id: If8239177e4b1ea2bccd0608eb39553d23210d405
Reviewed-on: https://go-review.googlesource.com/c/go/+/251437
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>