]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agocmd/go/internal/modload: cache parsed go.mod files globally
Bryan C. Mills [Thu, 23 Jul 2020 04:45:27 +0000 (00:45 -0400)]
cmd/go/internal/modload: cache parsed go.mod files globally

Previously they were cached per mvsReqs instance. However, the
contents of the go.mod file of a given dependency version can only
vary if the 'replace' directives that apply to that version have
changed, and the only time we change 'replace' directives is in 'go
mod edit' (which does not care about the build list or MVS).

This not only simplifies the mvsReqs implementation, but also makes
more of the underlying logic independent of mvsReqs.

For #36460

Change-Id: Ieac20c2fcd56f64d847ac8a1b40f9361ece78663
Reviewed-on: https://go-review.googlesource.com/c/go/+/244774
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal/modload: cache the Go language version for each module globally
Bryan C. Mills [Tue, 21 Jul 2020 20:50:59 +0000 (16:50 -0400)]
cmd/go/internal/modload: cache the Go language version for each module globally

Previously, this cache was a member of the (ephemeral) modload.loader
struct. However, the Go language version for a given module version
does not vary based on the build list, the set of loaded packages, the
build tags in use, the meaning of the "all" pattern, or anything else
that can be configured for an instance of the package loader. The map
containing that information is therefore not appropriate as a field of
the (configurable, package-list-dependent) loader struct.

The Go language version mapping could, in theory, be read from the
go.mod file in the module cache (or replacement directory) every time
it is needed: this map is just a cache, and as such it belongs
alongside the other caches and indexes in the modload package, which
are currently found in modfile.go.

We may want to do the same sort of global caching for the mapping from
each module.Version to its list of direct requirements (which are
similarly idempotent), but for now that is left for a future change.

For #36460
For #36876

Change-Id: I90ac176ffea97f30c47d6540c3dfb874dc9cfa4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/244078
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/go/internal/mvs: indicate the actual version when printing a mismatched ModuleError
Bryan C. Mills [Wed, 5 Aug 2020 03:53:01 +0000 (23:53 -0400)]
cmd/go/internal/mvs: indicate the actual version when printing a mismatched ModuleError

Previously, we suppressed the module version annotation if the last
error in the stack was a *module.ModuleError, regardless of its path.
However, if the error is for a replacement module, that produces a
confusing error message: the error is attributed to the last module in
the error path, but actually originates in the replacement (which is
not otherwise indicated).

Now, we print both the original and the replacement modules when they
differ, which may add some unfortunate redundancy in the output but at
least doesn't drop the very relevant information about replacements.

Fixes #35039

Change-Id: I631a7398033602b1bd5656150a4fad4945a87ade
Reviewed-on: https://go-review.googlesource.com/c/go/+/247765
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal/mvs: export a NewBuildListError function
Bryan C. Mills [Wed, 5 Aug 2020 03:27:18 +0000 (23:27 -0400)]
cmd/go/internal/mvs: export a NewBuildListError function

Also factor out BuildListError to a separate file.

For #36460

Change-Id: Ibd1143893b09a2bbef659bea1e8c5dd35184a7ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/247764
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal/mvs: reverse the order of BuildListError.stack
Bryan C. Mills [Fri, 24 Jul 2020 02:24:04 +0000 (22:24 -0400)]
cmd/go/internal/mvs: reverse the order of BuildListError.stack

When we print the stack from a BuildListError, we print the main
module first and the error last. That was the opposite of the order in
which in was stored in memory, leading to (arguably) more complex code
and (definitely) my own inability to reason about the contents of the
slice.

For now, it's still more convenient to construct the stack reversed,
so we do that and then reverse it before packing it into the error.

For #36460

Change-Id: I6312fb67b2ad9bf9b64071fe829854833208bad7
Reviewed-on: https://go-review.googlesource.com/c/go/+/244759
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal/modload: drop requirements on excluded versions
Bryan C. Mills [Fri, 24 Jul 2020 21:43:55 +0000 (17:43 -0400)]
cmd/go/internal/modload: drop requirements on excluded versions

Previously, when we encountered an excluded version in any module's
requirements, we would resolve it to the next higher version.
Unfortunately, the meaning of “the next higher version” can change
over time.

Moreover, users who use 'exclude' directives normally either already
require some higher version (using the 'exclude' directive to prune
out invalid requirements from some intermediate version), or already
require some lower version (using the 'exclude' directive to prevent
'go get -u' from upgrading to a known-bad version). In both of these
cases, resolving an upgrade for the excluded version is needless work
even in the best case: it adds work for the 'go' command when there is
already a perfectly usable selected version of the module in the
requirement graph.

Instead, we now interpret the 'exclude' directive as dropping all
references to the excluded version.

This implements the approach described in
https://golang.org/issue/36465#issuecomment-572694990.

Fixes #36465
Updates #36460

Change-Id: Ibf0187daced417b4cc23b97125826778658e4b0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/244773
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: add a "v" prefix to the indexed go version
Bryan C. Mills [Fri, 13 Mar 2020 20:46:51 +0000 (16:46 -0400)]
cmd/go/internal/modload: add a "v" prefix to the indexed go version

This allows semver-based comparisons of the version without additional allocations.

Also comment on the reason for the loops that iterate over modFile instead.

(I was reading the vendor code in order to add the lazy-loading version check,
and this section was a bit unclear to me.)

For #36460

Change-Id: I11559d81ffb4eba0e4e10e6fa3c01990b11f9180
Reviewed-on: https://go-review.googlesource.com/c/go/+/240622
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 agosync: delete dirty keys inside Map.LoadAndDelete
Changkun Ou [Mon, 24 Aug 2020 11:45:27 +0000 (13:45 +0200)]
sync: delete dirty keys inside Map.LoadAndDelete

Fixes #40999

Change-Id: Ie32427e5cb5ed512b976b554850f50be156ce9f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/250197
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: populate the Module field for test packages
Bryan C. Mills [Wed, 1 Jul 2020 14:33:56 +0000 (10:33 -0400)]
cmd/go: populate the Module field for test packages

Fixes #39974

Change-Id: I52bb13e887fde52bf789198059c39fd6aacd96f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/240678
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 agonet/http: set Content-Length:0 for empty PATCH requests as with POST, PATCH
Segflow [Mon, 24 Aug 2020 13:42:45 +0000 (13:42 +0000)]
net/http: set Content-Length:0 for empty PATCH requests as with POST, PATCH

Sets Content-Length:0 for nil bodies in PATCH requests, as we already do for  POST and PUT requests.

RFC 2616 mentions that unless a method’s Content-Length is forbidden it can send one.
In the wild, we’ve found that Microsoft Azure’s DataLake Gen2 storage API https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update deliberately rejects PATCH requests without a Content-Length, yet there is no workaround for setting that header when trying to flush the content of a file which was uploaded in a previous request.

Fixes #40978

Change-Id: Ib0a623b907d827a1c5ee431dca3c41024fa291c5
GitHub-Last-Rev: 12a3903f2bc22bcc4f5f8e2abcc3922b612b8871
GitHub-Pull-Request: golang/go#40991
Reviewed-on: https://go-review.googlesource.com/c/go/+/250039
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 agogo/types: update test case to exercise mutually recursive interfaces
Rob Findley [Mon, 6 Jul 2020 20:45:46 +0000 (16:45 -0400)]
go/types: update test case to exercise mutually recursive interfaces

Due to a typo, this test case was not actually exercising the bug
described in golang/go#33656. Update it to do so. Interestingly, the
comparison is now valid (as it should be) -- I suspect #33656 is
actually fixed.

Fixes #33656

Change-Id: If50a917f6477d8eb4f82f5a2a96bf5d9123ff0d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/241263
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: add tests for AssignableTo and ConvertibleTo
Rob Findley [Wed, 1 Jul 2020 22:10:02 +0000 (18:10 -0400)]
go/types: add tests for AssignableTo and ConvertibleTo

These exported functions are mostly trivial wrappers, but do make
certain assumptions about how the underlying Checker APIs can be called.
Add some simple tests.

Change-Id: I68e9ae875353c12d118ec961a6f3834385fbbb97
Reviewed-on: https://go-review.googlesource.com/c/go/+/241262
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/compile: add more generic rewrite rules to reassociate (op (op y C) x|C)
fanzha02 [Thu, 28 May 2020 10:11:52 +0000 (18:11 +0800)]
cmd/compile: add more generic rewrite rules to reassociate (op (op y C) x|C)

With this patch, opt pass can expose more obvious constant-folding
opportunites.

Example:
func test(i int) int {return (i+8)-(i+4)}

The previous version:
  MOVD "".i(FP), R0
  ADD $8, R0, R1
  ADD $4, R0, R0
  SUB R0, R1, R0
  MOVD R0, "".~r1+8(FP)
  RET (R30)

The optimized version:
  MOVD $4, R0
  MOVD R0, "".~r1+8(FP)
  RET (R30)

This patch removes some existing reassociation rules, such as "x+(z-C)",
because the current generic rewrite rules will canonicalize "x-const"
to "x+(-const)", making "x+(z-C)" equal to "x+(z+(-C))".

This patch also adds test cases.

Change-Id: I857108ba0b5fcc18a879eeab38e2551bc4277797
Reviewed-on: https://go-review.googlesource.com/c/go/+/237137
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: complete adjust MIPS64x rewrite rules to use typed aux fields
Meng Zhuo [Thu, 7 May 2020 10:08:35 +0000 (18:08 +0800)]
cmd/compile: complete adjust MIPS64x rewrite rules to use typed aux fields

Follow CL 228937
All MIPS64x rewrite rules has been converted into =>.

toolstash-check passed for b1b67841d1..f2ad426737

Change-Id: I7eb7541ae1b86a005770003b61c555672660d2e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/230778
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: convert rest ARM64.rules lines to typed aux mode
fanzha02 [Thu, 14 May 2020 09:01:11 +0000 (17:01 +0800)]
cmd/compile: convert rest ARM64.rules lines to typed aux mode

This patch adds the ARM6464Bitfield auxInt to auxIntType() and
returns its Go type as "arm64Bitfield" type, which is defined
as int16 type.

And the Go type of SymOff auxInt is int32, but some functions
(such as min(), areAdjacentOffsets() and read16/32/64(),etc.)
use SymOff as an input parameter and treat its type as int64,
this patch adds the type conversion for these rules.

Passes toolstash-check -all.

Change-Id: Ib234b48d0a97ef244dd37878e06b5825316dd782
Reviewed-on: https://go-review.googlesource.com/c/go/+/234378
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/go: use verbose flag to log proxy activities
Constantin Konstantinidis [Sun, 12 Apr 2020 19:28:41 +0000 (21:28 +0200)]
cmd/go: use verbose flag to log proxy activities

Fixes #29515
Fixes #30604

Change-Id: Ie75a331cd6ca51806c5720443506d4fe0bec28cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/227162
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/compile: convert typed aux to CCop for ARM64 rules
fanzha02 [Tue, 12 May 2020 11:47:23 +0000 (19:47 +0800)]
cmd/compile: convert typed aux to CCop for ARM64 rules

Add a new conversion function to convert aux type to Op type.

Passes toolstash-check -all.

Change-Id: I25d649a5296f6f178d64320dfc5d291e0a597e24
Reviewed-on: https://go-review.googlesource.com/c/go/+/233739
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: convert more ARM64.rules lines to typed aux mode
fanzha02 [Tue, 12 May 2020 03:05:24 +0000 (11:05 +0800)]
cmd/compile: convert more ARM64.rules lines to typed aux mode

Add a check code for checking whether the "c" value can be
represented as a signed 32 bit integer in some rules.

Passes toolstash-check -all.

Change-Id: I84e4431dc75945985695516d34565b841c8b53e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/233738
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: add test for StorepNoWB param leaking
Cuong Manh Le [Sat, 22 Aug 2020 11:21:14 +0000 (18:21 +0700)]
runtime: add test for StorepNoWB param leaking

CL 249962 added wasm StorepNoWB implementation in assembly, it's now
like all other architectures. This CL adds a general test that the
second param of StorepNoWB must be force to escape.

Fixes #40975

Change-Id: I1eccc7e50a3ec742a1912d65f25b15f9f5ad9241
Reviewed-on: https://go-review.googlesource.com/c/go/+/249761
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: make GOSSAHASH package-sensitive, also append to log files
David Chase [Wed, 5 Aug 2020 14:26:57 +0000 (10:26 -0400)]
cmd/compile: make GOSSAHASH package-sensitive, also append to log files

Turns out if your failure is in a function with a name like "Reset()"
there will be a lot of hits on the same hashcode.  Adding package sensitivity
solves this problem.

In additionm, it turned out that in the case that a logfile was specified
for the GOSSAHASH logging, that it was opened in create mode, which meant
that multiple compiler invocations would reset the file to zero length.
Opening in append mode works better; the automated harness
(github.com/dr2chase/gossahash) takes care of truncating the file before use.

Change-Id: I5601bc280faa94cbd507d302448831849db6c842
Reviewed-on: https://go-review.googlesource.com/c/go/+/246937
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: implement StorepNoWB for wasm in assembly
Keith Randall [Sun, 23 Aug 2020 18:52:53 +0000 (11:52 -0700)]
runtime: implement StorepNoWB for wasm in assembly

The second argument of StorepNoWB must be forced to escape.
The current Go code does not explicitly enforce that property.
By implementing in assembly, and not using go:noescape, we
force the issue.

Test is in CL 249761. Issue #40975.

This CL is needed for CL 249917, which changes how go:notinheap
works and breaks the previous StorepNoWB wasm code.

I checked for other possible errors like this. This is the only
go:notinheap that isn't in the runtime itself.

Change-Id: I43400a806662655727c4a3baa8902b63bdc9fa57
Reviewed-on: https://go-review.googlesource.com/c/go/+/249962
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: make Haspointers a method instead of a function
Keith Randall [Sat, 22 Aug 2020 21:07:30 +0000 (14:07 -0700)]
cmd/compile: make Haspointers a method instead of a function

More ergonomic that way. Also change Haspointers to HasPointers
while we are here.

Change-Id: I45bedc294c1a8c2bd01dc14bd04615ae77555375
Reviewed-on: https://go-review.googlesource.com/c/go/+/249959
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agotest: remove nacl checking condition
Cuong Manh Le [Sat, 22 Aug 2020 16:26:32 +0000 (23:26 +0700)]
test: remove nacl checking condition

go1.14 drop nacl support, as go1.15 was released, go1.13 is not
supported anymore, nacl is absolutely gone.

Change-Id: I05efb46891ec875b08da8f2996751a8e9cb57d0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/249977
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/compile: optimize unsigned comparisons with 0/1 on wasm
Agniva De Sarker [Sat, 8 Aug 2020 09:49:42 +0000 (15:19 +0530)]
cmd/compile: optimize unsigned comparisons with 0/1 on wasm

Updates #21439

Change-Id: I0fbcde6e0c2fc368fe686b271670f9d8be4a7900
Reviewed-on: https://go-review.googlesource.com/c/go/+/247557
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
4 years agocmd/objdump: skip cgo test in testGoAndCgoDisasm on AIX
Alex Brainman [Sat, 22 Aug 2020 02:06:24 +0000 (12:06 +1000)]
cmd/objdump: skip cgo test in testGoAndCgoDisasm on AIX

Updates #40972.

Change-Id: Id2092f0bef4fb4bdc4178e7bc9730716136f7b8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/249760
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agocmd/internal/objfile: use pe.FileHeader.Machine to reliably determine GOARCH
Alex Brainman [Sun, 28 Jun 2020 06:28:52 +0000 (16:28 +1000)]
cmd/internal/objfile: use pe.FileHeader.Machine to reliably determine GOARCH

Current peFile.goarch looks for symbols like "_rt0_386_windows" to
determine GOARCH. But "_rt0_386_windows" is not present in executables
built with cgo.

Use pe.FileHeader.Machine instead. This should work with any Windows
executable, not just with Go built executable.

Fixes #39682

Change-Id: Ie0ffce664f4b8b8fed69b2ecc482425b042a38d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/240957
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agonet/http: use iotest.ErrReader in tests
Carlos Alexandro Becker [Fri, 21 Aug 2020 08:01:01 +0000 (08:01 +0000)]
net/http: use iotest.ErrReader in tests

Updates #38781

Change-Id: I16a66904167ca4c0e916619b4da1dd23795b3ab2
GitHub-Last-Rev: 45054235a009cf776030bc951ba9a2a2a02c13e9
GitHub-Pull-Request: golang/go#40864
Reviewed-on: https://go-review.googlesource.com/c/go/+/249037
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 agogo/doc: support examples on methods from embedded unexported types
Jonathan Amsterdam [Thu, 20 Aug 2020 15:35:17 +0000 (11:35 -0400)]
go/doc: support examples on methods from embedded unexported types

In

  type T1 struct { t2 }
  type t2 int
  func (t2) M()

T1 has method M because it embeds t2, which has M. Classify
the example

  func ExampleT1_M

with T1 instead of ignoring it, as is done currently. There is no
other way to provide an example for such a method, since its original
type is unexported.

Continue to ignore examples on methods from embedded types that are
exported, unless in AllMethods mode. Examples for those methods could
be written on the original type.

The change involves removing a check in classifyExamples. The check
isn't necessary to get the above behavior because
reader.collectEmbeddedMethods and sortedFuncs already generate the
appropriate list of methods.

For #40172.

Change-Id: Ibe7d965ecba6426466184e6e6655fc05989e9caf
Reviewed-on: https://go-review.googlesource.com/c/go/+/249557
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agocmd/go/testdata/script: make list_case_collision's behavior more clear
Michael Matloob [Thu, 23 Apr 2020 22:06:21 +0000 (18:06 -0400)]
cmd/go/testdata/script: make list_case_collision's behavior more clear

Implementing the suggestion made by bcmills on a comment on golang.org/cl/228783.

Change-Id: I314a24a002c65b582ea51610dcc1a54a69afbb8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229705
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: clarify error for invalid proxy responses
Michał Łowicki [Mon, 11 May 2020 21:57:26 +0000 (22:57 +0100)]
cmd/go: clarify error for invalid proxy responses

Add information that error comes from parsing module proxy responses.

Fixes #38680

Change-Id: Ic318b9cdbca789c1b0d983e083e692a914892fbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/233437
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agohash/maphash: adding benchmarks for maphash
Meng Zhuo [Fri, 21 Aug 2020 03:11:32 +0000 (11:11 +0800)]
hash/maphash: adding benchmarks for maphash

goos: linux
goarch: arm64
pkg: hash/maphash
BenchmarkHash8Bytes
BenchmarkHash8Bytes     22568919                46.0 ns/op       173.80 MB/s
BenchmarkHash320Bytes
BenchmarkHash320Bytes    5243858               230 ns/op        1393.30 MB/s
BenchmarkHash1K
BenchmarkHash1K          1755870               660 ns/op        1550.60 MB/s
BenchmarkHash8K
BenchmarkHash8K           225688              5313 ns/op        1541.90 MB/s
PASS
ok      hash/maphash    6.465s

Change-Id: I5a909042a542135ebc47d639fea02dc46c900c1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/249079
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agogo/types: update flag documentation for gotype command
Robert Griesemer [Thu, 20 Aug 2020 23:48:21 +0000 (16:48 -0700)]
go/types: update flag documentation for gotype command

The documentation refers to a non longer existing flag (-seq).
Remove those references.

Change-Id: I480b6259f9199b47761dc655a90911eabfe07427
Reviewed-on: https://go-review.googlesource.com/c/go/+/249738
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: fix checkptr handling of &^
Matthew Dempsky [Thu, 20 Aug 2020 04:39:12 +0000 (21:39 -0700)]
cmd/compile: fix checkptr handling of &^

checkptr has code to recognize &^ expressions, but it didn't take into
account that "p &^ x" gets rewritten to "p & ^x" during walk, which
resulted in false positive diagnostics.

This CL changes walkexpr to mark OANDNOT expressions with Implicit
when they're rewritten to OAND, so that walkCheckPtrArithmetic can
still recognize them later.

It would be slightly more idiomatic to instead mark the OBITNOT
expression as Implicit (as it's a compiler-generated Node), but the
OBITNOT expression might get constant folded. It's not worth the extra
complexity/subtlety of relying on n.Right.Orig, so we set Implicit on
the OAND node instead.

To atone for this transgression, I add documentation for nodeImplicit.

Fixes #40917.

Change-Id: I386304171ad299c530e151e5924f179e9a5fd5b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/249477
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agocmd/internal/obj: fix inline marker issue on s390x
Michael Munday [Mon, 10 Aug 2020 15:01:21 +0000 (08:01 -0700)]
cmd/internal/obj: fix inline marker issue on s390x

The optimization that replaces inline markers with pre-existing
instructions assumes that 'Prog' values produced by the compiler are
still reachable after the assembler has run. This was not true on
s390x where the assembler was removing NOP instructions from the
linked list of 'Prog' values. This led to broken inlining data
which in turn caused an infinite loop in the runtime traceback code.

Fix this by stopping the s390x assembler backend removing NOP
values. It does not make any difference to the output of the
assembler because NOP instructions are 0 bytes long anyway.

Fixes #40473.

Change-Id: I9b97c494afaae2d5ed6bca4cd428b4132b5f8133
Reviewed-on: https://go-review.googlesource.com/c/go/+/249448
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/go: add tracing for querying and downloading from the proxy
Michael Matloob [Wed, 15 Jul 2020 21:38:36 +0000 (17:38 -0400)]
cmd/go: add tracing for querying and downloading from the proxy

This CL adds tracing spans for modload.queryPattern, modload.queryProxy,
modload.QueryPattern, modload.QueryPattern.queryModule,
modload.queryPrefixModules and modfetch.Download.

Updates #38714

Change-Id: I91af3f022a6e18ab8d9c1d9b0ccf4928b6c236bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/249022
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go: do context propagation for tracing downloads
Michael Matloob [Tue, 30 Jun 2020 21:51:52 +0000 (17:51 -0400)]
cmd/go: do context propagation for tracing downloads

This change does context propagation (and only context propagation)
necessary to add context to modfetch.Download and pkg.LoadImport.
This was done by adding context to their callers, and then
adding context to all call-sites, and then repeating adding
context to callers of those enclosing functions and their
callers until none were left. In some cases the call graph expansion
was pruned by using context.TODOs.

The next CL will add a span to Download. I kept it out of this
change to avoid making it any larger (and harder to review)
than it needs to be.

Updates #38714

Change-Id: I7a03416e04a14ca71636d96f2c1bda2c4c30d348
Reviewed-on: https://go-review.googlesource.com/c/go/+/249021
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/compile: define starting block before opening html writer
Keith Randall [Thu, 20 Aug 2020 06:01:58 +0000 (23:01 -0700)]
cmd/compile: define starting block before opening html writer

Opening the html writer can fail, and the failure printer wants
to use the entry block's line number. So make sure we set up
the entry block first.

Fixes #40919

Change-Id: I4ffa2839b45a721bbaf04ff84418e8108fa1cc37
Reviewed-on: https://go-review.googlesource.com/c/go/+/249497
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agounicode: upgrade to Unicode 13.0.0
Marcel van Lohuizen [Mon, 17 Aug 2020 17:10:12 +0000 (19:10 +0200)]
unicode: upgrade to Unicode 13.0.0

Fixes #40755

Change-Id: I14b3977317994095db8ae1bd873c174641209356
Reviewed-on: https://go-review.googlesource.com/c/go/+/248765
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/internal/obj: stop removing NOPs from instruction stream
Keith Randall [Sat, 15 Aug 2020 15:08:37 +0000 (08:08 -0700)]
cmd/internal/obj: stop removing NOPs from instruction stream

This has already been done for s390x, ppc64. This CL is for
all the other architectures.

Fixes #40796

Change-Id: Idd1816e057df63022d47e99fa06617811d8c8489
Reviewed-on: https://go-review.googlesource.com/c/go/+/248684
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agointernal/poll: treat copy_file_range EPERM as not-handled
Tobias Klauser [Wed, 19 Aug 2020 14:54:36 +0000 (16:54 +0200)]
internal/poll: treat copy_file_range EPERM as not-handled

Fixes #40893

Change-Id: I938ea4796c1e1d1e136117fe78b06ad6da8e40de
Reviewed-on: https://go-review.googlesource.com/c/go/+/249257
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Antonio Troina <thoeni@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/dist: fix tipo in comment
Ian Lance Taylor [Wed, 19 Aug 2020 21:42:11 +0000 (14:42 -0700)]
cmd/dist: fix tipo in comment

Change-Id: I98fbf0dc94cf182adec5d414a56b9cc5126c38f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/249437
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoos, internal/poll: loop on EINTR for all file syscalls
Ian Lance Taylor [Tue, 18 Aug 2020 23:46:24 +0000 (16:46 -0700)]
os, internal/poll: loop on EINTR for all file syscalls

When using a FUSE file system, any system call that touches the file
system can return EINTR.

Fixes #40846

Change-Id: I25d32da22cec08dea81ab297291a85ad72db2df7
Reviewed-on: https://go-review.googlesource.com/c/go/+/249178
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go/internal: remove some users of par.Work
Michael Matloob [Thu, 25 Jun 2020 23:11:28 +0000 (19:11 -0400)]
cmd/go/internal: remove some users of par.Work

par.Work is used in a number of places as a parallel
work queue. This change replaces it with goroutines
and channels in a number of simpler places where it's
used.

This is the same CL as golang.org/cl/240062 and golang.org/cl/248326
except for the following changes in convert.go (all line numbers
from this CL), as well as fixing up imports in download.go:
- On line 44, the "*" before modules.Versions is removed (we were
trying to assign to a nil value on lines 72 and 73).
- Line 64 is new, and ensures that we receive on the semaphore
channel once the goroutine function exits. (The previous versions
of this CL only received at the end of the function, ignoring
the return point in the branch in the middle of the function.)
- The semaphore channel receive right before line 74 is gone,
replaced with the deferred receive above.
- The if block at line 83 is new, accounting for cases where
modfetch.ImportRepoRev returned an error in the goroutine,
so that versions[i] is ignored.

Change-Id: I0e33670bb2eb0a1e4d7a5fa693a471e61ffbc8b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/249020
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/asm,cmd/internal/obj/ppc64: add {l,st}xvx power9 instructions
Paul E. Murphy [Tue, 18 Aug 2020 21:26:42 +0000 (16:26 -0500)]
cmd/asm,cmd/internal/obj/ppc64: add {l,st}xvx power9 instructions

These are the indexed vsx load operations with the
same endian and alignment benefits of {l,st}vx.

Likewise, cleanup redundant comments in op{load,store}x and
fix ISA 3.0 typos nearby.

Change-Id: Ie1ace17c6150cf9168a834e435114028ff6eb07c
Reviewed-on: https://go-review.googlesource.com/c/go/+/249025
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
4 years agocmd/compile: Optimize ARM64's code with EON
diaxu01 [Fri, 5 Jun 2020 03:53:53 +0000 (03:53 +0000)]
cmd/compile: Optimize ARM64's code with EON

This patch fuses pattern '(MVN (XOR x y))' into '(EON x y)'.

Change-Id: I269c98ce198d51a4945ce8bd0e1024acbd1b7609
Reviewed-on: https://go-review.googlesource.com/c/go/+/239638
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/dist: ignore _test.s files in bootstrap
Cherry Zhang [Tue, 18 Aug 2020 16:01:41 +0000 (12:01 -0400)]
cmd/dist: ignore _test.s files in bootstrap

Ignore all _test.s files in bootstrap, not only the ARM64 one.
They are for testing only.

Fixes #40855.

Change-Id: I00e6b4ab5349e317c9ad3a503997de85aed49373
Reviewed-on: https://go-review.googlesource.com/c/go/+/249018
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agointernal/poll: treat copy_file_range EOPNOTSUPP as not-handled
Ian Lance Taylor [Wed, 12 Aug 2020 19:09:35 +0000 (12:09 -0700)]
internal/poll: treat copy_file_range EOPNOTSUPP as not-handled

Fixes #40731

Change-Id: I3e29878d597318acf5edcc38497aa2624f72be35
Reviewed-on: https://go-review.googlesource.com/c/go/+/248258
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agoruntime: don't call setitimer for each thread
Ian Lance Taylor [Thu, 25 Jun 2020 21:50:10 +0000 (14:50 -0700)]
runtime: don't call setitimer for each thread

Previously, on Unix systems, when the profiler was enabled or disabled,
we called setitimer once per thread. With this change we instead call
it once per process.

Change-Id: I90f0189b562e11232816390dc7d55ed154bd836d
Reviewed-on: https://go-review.googlesource.com/c/go/+/240003
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/internal/objfile: cache computation of goobj.Arch
Tao Qingyun [Wed, 19 Aug 2020 01:38:43 +0000 (01:38 +0000)]
cmd/internal/objfile: cache computation of goobj.Arch

Change-Id: I23774cf185e5fa6b89398001cd0655fb0c5bdb46
GitHub-Last-Rev: ca8cae2469b5fad84bd636a3305a484dfdcb0db2
GitHub-Pull-Request: golang/go#40877
Reviewed-on: https://go-review.googlesource.com/c/go/+/249180
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: don't bother to declare closure inside redeclared func
Cuong Manh Le [Fri, 14 Aug 2020 17:44:58 +0000 (00:44 +0700)]
cmd/compile: don't bother to declare closure inside redeclared func

Fixes #17758

Change-Id: I75f5dc5be85fd8a6791ac89dfc0681be759cca36
Reviewed-on: https://go-review.googlesource.com/c/go/+/248517
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 agopath,path/filepath: add Join examples with ".." components
Andrew Ekstedt [Fri, 24 Jul 2020 19:48:30 +0000 (12:48 -0700)]
path,path/filepath: add Join examples with ".." components

People sometimes expect Join to trim .. components from its arguments
before joining, and are surprised that it doesn't. This is bad if they
were relying on that assumed behaviour to prevent directory traversal
attacks.

While a careful reading of the documentation for Join and Clean
might dispel this notion, it is not obvious at first glance.

Add a case to the examples to nudge people in the right direction.

Updates #40373

Change-Id: Ib5792c12ba1000811a0c0eb77048196d0b26da60
Reviewed-on: https://go-review.googlesource.com/c/go/+/249177
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoruntime: reduce syscall when call runtime.clone
cui [Wed, 12 Aug 2020 17:33:41 +0000 (17:33 +0000)]
runtime: reduce syscall when call runtime.clone

Change-Id: I3ea398fd86aae4c86557dd6fff65d90a6f756890
GitHub-Last-Rev: 4c295388f7b5e6768ffd2530337f78b4c75a9310
GitHub-Pull-Request: golang/go#40392
Reviewed-on: https://go-review.googlesource.com/c/go/+/244626
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: remove unnecessary error condition on reading fingerprint
Cherry Zhang [Fri, 8 May 2020 21:12:45 +0000 (17:12 -0400)]
cmd/compile: remove unnecessary error condition on reading fingerprint

io.ReadFull guarantees n == len(buf) if and only if err == nil,
so the length check is redundant.

Change-Id: I15bff97868e27a65648acd791883cac8dab77630
Reviewed-on: https://go-review.googlesource.com/c/go/+/232988
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agocmd/compile: combine multiply/add into maddld on ppc64le/power9
Paul E. Murphy [Mon, 17 Aug 2020 21:14:48 +0000 (16:14 -0500)]
cmd/compile: combine multiply/add into maddld on ppc64le/power9

Add a new lowering rule to match and replace such instances
with the MADDLD instruction available on power9 where
possible.

Likewise, this plumbs in a new ppc64 ssa opcode to house
the newly generated MADDLD instructions.

When testing ed25519, this reduced binary size by 936B.
Similarly, MADDLD combination occcurs in a few other less
obvious cases such as division by constant.

Testing of golang.org/x/crypto/ed25519 shows non-trivial
speedup during keygeneration:

name           old time/op  new time/op  delta
KeyGeneration  65.2µs ± 0%  63.1µs ± 0%  -3.19%
Signing        64.3µs ± 0%  64.4µs ± 0%  +0.16%
Verification    147µs ± 0%   147µs ± 0%  +0.11%

Similarly, this test binary has shrunk by 66488B.

Change-Id: I077aeda7943119b41f07e4e62e44a648f16e4ad0
Reviewed-on: https://go-review.googlesource.com/c/go/+/248723
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
4 years agomath/big: improve performance of mulAddVWW on ppc64x
Lynn Boger [Mon, 17 Aug 2020 14:57:54 +0000 (10:57 -0400)]
math/big: improve performance of mulAddVWW on ppc64x

This changes the assembly implementation on ppc64x
to improve performance by reordering some instructions.
It also eliminates an unnecessary move by changing an
ADDZE to use the correct target register.

Improvement on power9:

MulAddVWW/1         6.89ns ± 0%    7.30ns ± 0%   +5.95%  (p=1.000 n=1+1)
MulAddVWW/2         8.04ns ± 0%    8.06ns ± 0%   +0.25%  (p=1.000 n=1+1)
MulAddVWW/3         9.39ns ± 0%    9.39ns ± 0%     ~     (all equal)
MulAddVWW/4         9.76ns ± 0%    9.48ns ± 0%   -2.87%  (p=1.000 n=1+1)
MulAddVWW/5         10.5ns ± 0%    10.3ns ± 0%   -1.90%  (p=1.000 n=1+1)
MulAddVWW/10        15.4ns ± 0%    14.9ns ± 0%   -3.25%  (p=1.000 n=1+1)
MulAddVWW/100        149ns ± 0%     125ns ± 0%  -16.11%  (p=1.000 n=1+1)
MulAddVWW/1000      1.42µs ± 0%    1.28µs ± 0%   -9.74%  (p=1.000 n=1+1)
MulAddVWW/10000     14.2µs ± 0%    12.8µs ± 0%   -9.73%  (p=1.000 n=1+1)
MulAddVWW/100000     144µs ± 0%     129µs ± 0%  -10.10%  (p=1.000 n=1+1)

Change-Id: I0ae7002a69783ca19d7a4e3e42042ae75dc60069
Reviewed-on: https://go-review.googlesource.com/c/go/+/248721
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
4 years agocmd/compile/internal/gc: cleanup walkselectcases slightly
Matthew Dempsky [Mon, 27 Jul 2020 23:45:48 +0000 (16:45 -0700)]
cmd/compile/internal/gc: cleanup walkselectcases slightly

Remove some unnecessary code. Most significantly, we can skip testing
"if ch == nil { block() }", because this is already the semantics
implied by normal send/receive operations.

Updates #40410.

Change-Id: I4acd33383cc876719fc3b998d85244d4ac1ff9d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/245126
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agoruntime: eliminate scase.kind field
Matthew Dempsky [Mon, 27 Jul 2020 23:19:15 +0000 (16:19 -0700)]
runtime: eliminate scase.kind field

Currently, we include a "kind" field on scase to distinguish the three
kinds of cases in a select statement: sends, receives, and defaults.

This commit removes by kind field by instead arranging for the
compiler to always place sends before receives, and to provide their
counts separately. It also passes an explicit "block bool" parameter
to avoid needing to include a default case in the array.

It's safe to shuffle cases like this because the runtime will
randomize the order they're polled in anyway.

Fixes #40410.

Change-Id: Iaeaed4cf7bddd576d78f2c863bd91a03a5c82df2
Reviewed-on: https://go-review.googlesource.com/c/go/+/245125
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: split PCs out of scase
Matthew Dempsky [Mon, 27 Jul 2020 22:20:18 +0000 (15:20 -0700)]
runtime: split PCs out of scase

Per-case PCs are only needed for race detector builds, so this allows
skipping allocating stack space for them for non-race builds.

It's possible to arrange the PCs and order arrays consecutively in
memory so that we could just reuse the order0 pointer to identify
both. However, there's more risk of that silently going wrong, so this
commit passes them as separate arguments for now. We can revisit this
in the future.

Updates #40410.

Change-Id: I8468bc25749e559891cb0cb007d1cc4a40fdd0f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/245124
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: omit nil-channel cases from selectgo's orders
Matthew Dempsky [Mon, 27 Jul 2020 21:47:47 +0000 (14:47 -0700)]
runtime: omit nil-channel cases from selectgo's orders

Currently, selectgo does an initial pass over the cases array to look
for entries with nil channels, so they can be easily recognized and
skipped later on. But this still involves actually visiting the cases.

This commit changes selectgo to omit cases with nil channels when
constructing pollorder, so that they'll be skipped over entirely later
on. It also checks for caseDefault up front, which will facilitate
changing it to use a "block bool" parameter instead.

Updates #40410.

Change-Id: Icaebcb8f08df03cc33b6d8087616fb5585f7fedd
Reviewed-on: https://go-review.googlesource.com/c/go/+/245123
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: remove scase.releasetime field
Matthew Dempsky [Mon, 27 Jul 2020 21:05:05 +0000 (14:05 -0700)]
runtime: remove scase.releasetime field

selectgo will report at most one block event, so there's no need to
keep a releasetime for every select case. It suffices to simply track
the releasetime of the case responsible for the wakeup.

Updates #40410.

Change-Id: I72679cd43dde80d7e6dbab21a78952a4372d1e79
Reviewed-on: https://go-review.googlesource.com/c/go/+/245122
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: add "success" field to sudog
Matthew Dempsky [Mon, 27 Jul 2020 19:40:18 +0000 (12:40 -0700)]
runtime: add "success" field to sudog

The current wakeup protocol for channel communications is that the
second goroutine sets gp.param to the sudog when a value is
successfully communicated over the channel, and to nil when the wakeup
is due to closing the channel.

Setting nil to indicate channel closure works okay for chansend and
chanrecv, because they're only communicating with one channel, so they
know it must be the channel that was closed. However, it means
selectgo has to re-poll all of the channels to figure out which one
was closed.

This commit adds a "success" field to sudog, and changes the wakeup
protocol to always set gp.param to sg, and to use sg.success to
indicate successful communication vs channel closure.

While here, this also reorganizes the chansend code slightly so that
the sudog is still released to the pool if the send blocks and then is
awoken because the channel closed.

Updates #40410.

Change-Id: I6cd9a20ebf9febe370a15af1b8afe24c5539efc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/245019
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoencoding/asn1: speed up marshal by reducing allocations
Martin Möhrmann [Sun, 3 May 2020 17:58:10 +0000 (19:58 +0200)]
encoding/asn1: speed up marshal by reducing allocations

Replace strings.Split by strings.IndexByte and explicit
slicing to avoid the allocation of the return slice
of strings.Split.

name     old time/op    new time/op    delta
Marshal    43.3µs ± 1%    36.7µs ± 1%  -15.23%  (p=0.000 n=9+9)

name     old alloc/op   new alloc/op   delta
Marshal    10.7kB ± 0%     9.2kB ± 0%  -13.96%  (p=0.000 n=10+10)

name     old allocs/op  new allocs/op  delta
Marshal       444 ± 0%       366 ± 0%  -17.57%  (p=0.000 n=10+10)

Change-Id: I9e727defa23f7e5fc684f246de0136fe28cf8d25
Reviewed-on: https://go-review.googlesource.com/c/go/+/231738
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agotesting: treat PAUSE lines as changing the active test name
Bryan C. Mills [Mon, 17 Aug 2020 21:31:21 +0000 (17:31 -0400)]
testing: treat PAUSE lines as changing the active test name

We could instead fix cmd/test2json to treat PAUSE lines as *not*
changing the active test name, but that seems like it would be more
confusing to humans, and also wouldn't fix tools that parse output
using existing builds of cmd/test2json.

Fixes #40657

Change-Id: I937611778f5b1e7dd1d6e9f44424d7e725a589ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/248727
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jean de Klerk <deklerk@google.com>
4 years agocmd/asm: Add SHA512 hardware instructions for ARM64
Meng Zhuo [Mon, 8 Jun 2020 05:58:53 +0000 (13:58 +0800)]
cmd/asm: Add SHA512 hardware instructions for ARM64

ARMv8.2-SHA add SHA512 intructions:

1. SHA512H Vm.D2, Vn, Vd
2. SHA512H2 Vm.D2, Vn, Vd
3. SHA512SU0 Vn.D2, Vd.D2
4. SHA512SU1 Vm.D2, Vn.D2, Vd.D2

ARMv8 Architecture Reference Manual C7.2.234-C7.2.234

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

4 years agocmd/dist: use GO_TEST_SHORT value more consistently
Dmitri Shuralyov [Wed, 13 May 2020 17:57:36 +0000 (13:57 -0400)]
cmd/dist: use GO_TEST_SHORT value more consistently

There were two places where the -short flag was added in order to
speed up tests when run in short mode, in CL 178399 and CL 177417.

It appears viable to re-use the GO_TEST_SHORT value so that -short
flag is not used when the tests are executed on a longtest builder,
where it is not a goal to skip slow tests for improved performance.

Do so, in order to make the testing configurations simpler and more
predictable.

Factor out the flag name out of the string returned by short, so that
it can be used in context of 'go test' which can accept a -short flag,
and a test binary which requires the use of a longer -test.short flag.

For #39054.
For #29252.

Change-Id: I52dfbef73cc8307735c52e2ebaa609305fb05933
Reviewed-on: https://go-review.googlesource.com/c/go/+/233898
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile, runtime: mark R12 clobbered for write barrier call on PPC64
Cherry Zhang [Mon, 17 Aug 2020 23:06:19 +0000 (19:06 -0400)]
cmd/compile, runtime: mark R12 clobbered for write barrier call on PPC64

When external linking, for large binaries, the external linker
may insert a trampoline for the write barrier call, which looks

0000000005a98cc8 <__long_branch_runtime.gcWriteBarrier>:
 5a98cc8:       86 01 82 3d     addis   r12,r2,390
 5a98ccc:       d8 bd 8c e9     ld      r12,-16936(r12)
 5a98cd0:       a6 03 89 7d     mtctr   r12
 5a98cd4:       20 04 80 4e     bctr

It clobbers R12 (and CTR, which is never live across a call).

As at compile time we don't know whether the binary is big and
what link mode will be used, I think we need to mark R12 as
clobbered for write barrier call. For extra safety (future-proof)
we mark caller-saved register that cannot be used for function
arguments, which includes R11, as potentially clobbered as well.

Fixes #40851.

Change-Id: Iedd901c5072f1127cc59b0a48cfeb4aaec81b519
Reviewed-on: https://go-review.googlesource.com/c/go/+/248917
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/go: revert 3 CLs affecting par.Work, context propagation, tracing
Dmitri Shuralyov [Tue, 18 Aug 2020 14:54:11 +0000 (10:54 -0400)]
cmd/go: revert 3 CLs affecting par.Work, context propagation, tracing

This reverts the following changes:

• cmd/go: add tracing for querying and downloading from the proxy
CL 242786, commit 1a3558341860357c2400e37773e5076bb3a51628

• cmd/go: do context propagation for tracing downloads
CL 248327, commit c0cf190d226cc3defb71d17c01d0b45bf49a8a85

• cmd/go/internal: remove some users of par.Work
CL 248326, commit f30044a03bc7cf107dbec03c02fb6d0072878252

Reason for revert: broke linux 386 and amd64 longtest builders.

The problem started with CL 248326, but CL 248327 and CL 242786
are reverted as well due to conflicts.

Updates #38714.
Fixes #40861.

Change-Id: I68496b4e5a27e47a42183553c3a645b288edac83
Reviewed-on: https://go-review.googlesource.com/c/go/+/249017
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: clean up and optimize s390x multiplication rules
Michael Munday [Thu, 4 Jun 2020 17:55:01 +0000 (10:55 -0700)]
cmd/compile: clean up and optimize s390x multiplication rules

Some of the existing optimizations aren't triggered because they
are handled by the generic rules so this CL removes them. Also
some constraints were copied without much thought from the amd64
rules and they don't make sense on s390x, so we remove those
constraints.

Finally, add a 'multiply by the sum of two powers of two'
optimization. This makes sense on s390x as shifts are low latency
and can also sometimes be optimized further (especially if we add
support for RISBG instructions).

name                   old time/op  new time/op  delta
IntMulByConst/3-8      1.70ns ±11%  1.10ns ± 5%  -35.26%  (p=0.000 n=10+10)
IntMulByConst/5-8      1.64ns ± 7%  1.10ns ± 4%  -32.94%  (p=0.000 n=10+9)
IntMulByConst/12-8     1.65ns ± 6%  1.20ns ± 4%  -27.16%  (p=0.000 n=10+9)
IntMulByConst/120-8    1.66ns ± 4%  1.22ns ±13%  -26.43%  (p=0.000 n=10+10)
IntMulByConst/-120-8   1.65ns ± 7%  1.19ns ± 4%  -28.06%  (p=0.000 n=9+10)
IntMulByConst/65537-8  0.86ns ± 9%  1.12ns ±12%  +30.41%  (p=0.000 n=10+10)
IntMulByConst/65538-8  1.65ns ± 5%  1.23ns ± 5%  -25.11%  (p=0.000 n=10+10)

Change-Id: Ib196e6bff1e97febfd266134d0a2b2a62897989f
Reviewed-on: https://go-review.googlesource.com/c/go/+/248937
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: move startupRandomData declaration to os_linux.go
Tobias Klauser [Mon, 17 Aug 2020 14:32:33 +0000 (16:32 +0200)]
runtime: move startupRandomData declaration to os_linux.go

startupRandomData is only used in sysauxv and getRandomData on linux,
thus move it closer to where it is used. Also adjust its godoc comment.

Change-Id: Ice51d579ec33436adbfdf247caf4ba00bae865e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/248761
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agonet: simplify error return in *RawConn test helpers
Tobias Klauser [Thu, 7 May 2020 18:48:37 +0000 (20:48 +0200)]
net: simplify error return in *RawConn test helpers

No need to check operr before returning.

Change-Id: I64b849f7c102de01180823e3f0123d438ce7608a
Reviewed-on: https://go-review.googlesource.com/c/go/+/232797
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: fix SSA type comparison
Keith Randall [Tue, 18 Aug 2020 04:59:07 +0000 (21:59 -0700)]
cmd/compile: fix SSA type comparison

A typo in the conversion code caused comparisons of SSA types to
report CMPeq when they were not in fact equal.

Fixes #40837

Change-Id: I0627eee51d524a585908b34a4590bc533c8415fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/248781
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agoruntime: reduce critical path in injectglist
Cholerae Hu [Mon, 11 May 2020 03:18:57 +0000 (11:18 +0800)]
runtime: reduce critical path in injectglist

Change-Id: Ia3fb30ac9add39c803f11f69d967c6604fdeacf8
Reviewed-on: https://go-review.googlesource.com/c/go/+/233217
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/cgo: close file
alex-semenyuk [Sun, 17 May 2020 16:05:05 +0000 (16:05 +0000)]
cmd/cgo: close file

Change-Id: Ia70edc8ba22e31e498fe07946db41882804bd39f
GitHub-Last-Rev: 280232e879965b34fae3aa02e6215eff5bd7be46
GitHub-Pull-Request: golang/go#39120
Reviewed-on: https://go-review.googlesource.com/c/go/+/234317
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: optimize unsigned comparisons to 0/1 on arm64
Junchen Li [Fri, 10 Jul 2020 03:39:23 +0000 (11:39 +0800)]
cmd/compile: optimize unsigned comparisons to 0/1 on arm64

For an unsigned integer, it's useful to convert its order test with 0/1
to its equality test with 0. We can save a comparison instruction that
followed by a conditional branch on arm64 since it supports
compare-with-zero-and-branch instructions. For example,

  if x > 0 { ... } else { ... }

the original version:
  CMP $0, R0
  BLS 9

the optimized version:
  CBZ R0, 8

Updates #21439

Change-Id: Id1de6f865f6aa72c5d45b29f7894818857288425
Reviewed-on: https://go-review.googlesource.com/c/go/+/246857
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoall: fix spelling mistakes
lihaowei [Fri, 14 Aug 2020 10:35:46 +0000 (10:35 +0000)]
all: fix spelling mistakes

Change-Id: I7d512281d8442d306594b57b5deaecd132b5ea9e
GitHub-Last-Rev: 251e1d6857516b21fd71f654133f81f23ffec654
GitHub-Pull-Request: golang/go#40793
Reviewed-on: https://go-review.googlesource.com/c/go/+/248441
Reviewed-by: Dave Cheney <dave@cheney.net>
4 years agotesting/iotest: correct ErrReader signature and remove exported error
Emmanuel T Odeke [Mon, 17 Aug 2020 19:25:49 +0000 (12:25 -0700)]
testing/iotest: correct ErrReader signature and remove exported error

Corrects ErrReader's signature to what was accepted in the approved
proposal, and also removes an exported ErrIO which wasn't part of
the proposal and is unnecessary.

The new signature allows users to customize their own errors.

While here, started examples, with ErrReader leading the way.

Updates #38781

Change-Id: Ia7f84721f11061343cfef8b1adc2b7b69bc3f43c
Reviewed-on: https://go-review.googlesource.com/c/go/+/248898
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
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 agoreflect: remove depth from deepequal recursion
Keith Randall [Thu, 18 Jun 2020 01:22:38 +0000 (18:22 -0700)]
reflect: remove depth from deepequal recursion

We aren't using it for anything. The visited map will terminate
any recursion for us.

Change-Id: I36e6bd8e34952123c2ed46323067e42928ec7168
Reviewed-on: https://go-review.googlesource.com/c/go/+/238759
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agocmd/compile: don't rewrite (CMP (AND x y) 0) to TEST if AND has other uses
Keith Randall [Tue, 7 Jul 2020 16:32:12 +0000 (09:32 -0700)]
cmd/compile: don't rewrite (CMP (AND x y) 0) to TEST if AND has other uses

If the AND has other uses, we end up saving an argument to the AND
in another register, so we can use it for the TEST. No point in doing that.

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

4 years agoruntime: bit parallel implementation of findBitRange64
Keith Randall [Tue, 7 Jul 2020 03:46:31 +0000 (20:46 -0700)]
runtime: bit parallel implementation of findBitRange64

Use a bit-parallel implementation of findBitRange64.
It uses a repeated shift-'N-and technique to erase all the
free marks that are too small for the allocation.

Also some small improvements to find1.

name                                             old time/op  new time/op  delta
FindBitRange64/Pattern00Size2-16                 4.19ns ± 0%  2.26ns ± 0%   -46.04%  (p=0.000 n=10+8)
FindBitRange64/Pattern00Size8-16                 4.19ns ± 0%  2.12ns ± 0%   -49.35%  (p=0.000 n=9+10)
FindBitRange64/Pattern00Size32-16                4.20ns ± 0%  2.12ns ± 0%   -49.49%  (p=0.000 n=10+8)
FindBitRange64/PatternFFFFFFFFFFFFFFFFSize2-16   2.13ns ± 0%  2.27ns ± 0%    +6.28%  (p=0.000 n=10+10)
FindBitRange64/PatternFFFFFFFFFFFFFFFFSize8-16   2.13ns ± 0%  4.46ns ± 0%  +109.39%  (p=0.000 n=10+9)
FindBitRange64/PatternFFFFFFFFFFFFFFFFSize32-16  2.13ns ± 1%  5.58ns ± 0%  +162.37%  (p=0.000 n=10+9)
FindBitRange64/PatternAASize2-16                 22.2ns ± 0%   2.3ns ± 0%   -89.82%  (p=0.000 n=9+8)
FindBitRange64/PatternAASize8-16                 22.2ns ± 0%   2.1ns ± 1%   -90.41%  (p=0.000 n=9+10)
FindBitRange64/PatternAASize32-16                22.2ns ± 0%   2.1ns ± 1%   -90.43%  (p=0.000 n=10+10)
FindBitRange64/PatternAAAAAAAAAAAAAAAASize2-16    156ns ± 1%     2ns ± 0%   -98.54%  (p=0.000 n=10+10)
FindBitRange64/PatternAAAAAAAAAAAAAAAASize8-16    155ns ± 1%     2ns ± 0%   -98.63%  (p=0.000 n=10+8)
FindBitRange64/PatternAAAAAAAAAAAAAAAASize32-16   155ns ± 0%     2ns ± 1%   -98.63%  (p=0.000 n=8+10)
FindBitRange64/Pattern80000000AAAAAAAASize2-16   81.2ns ± 0%   2.3ns ± 1%   -97.21%  (p=0.000 n=10+10)
FindBitRange64/Pattern80000000AAAAAAAASize8-16   81.1ns ± 0%   2.1ns ± 0%   -97.39%  (p=0.000 n=10+9)
FindBitRange64/Pattern80000000AAAAAAAASize32-16  81.1ns ± 0%   2.1ns ± 0%   -97.38%  (p=0.000 n=10+10)
FindBitRange64/PatternAAAAAAAA00000001Size2-16   76.8ns ± 1%   2.3ns ± 0%   -97.05%  (p=0.000 n=10+10)
FindBitRange64/PatternAAAAAAAA00000001Size8-16   76.6ns ± 0%   2.1ns ± 0%   -97.23%  (p=0.000 n=8+10)
FindBitRange64/PatternAAAAAAAA00000001Size32-16  76.7ns ± 0%   2.1ns ± 0%   -97.23%  (p=0.000 n=9+9)
FindBitRange64/PatternBBBBBBBBBBBBBBBBSize2-16   2.13ns ± 0%  2.27ns ± 0%    +6.57%  (p=0.000 n=8+8)
FindBitRange64/PatternBBBBBBBBBBBBBBBBSize8-16   76.7ns ± 0%   2.9ns ± 0%   -96.20%  (p=0.000 n=9+10)
FindBitRange64/PatternBBBBBBBBBBBBBBBBSize32-16  76.7ns ± 0%   2.9ns ± 0%   -96.20%  (p=0.000 n=10+10)
FindBitRange64/Pattern80000000BBBBBBBBSize2-16   2.12ns ± 0%  2.27ns ± 1%    +6.74%  (p=0.000 n=10+10)
FindBitRange64/Pattern80000000BBBBBBBBSize8-16   44.8ns ± 0%   2.9ns ± 0%   -93.49%  (p=0.000 n=9+10)
FindBitRange64/Pattern80000000BBBBBBBBSize32-16  44.9ns ± 0%   2.9ns ± 0%   -93.49%  (p=0.000 n=10+8)
FindBitRange64/PatternBBBBBBBB00000001Size2-16   4.20ns ± 1%  2.27ns ± 1%   -46.02%  (p=0.000 n=10+10)
FindBitRange64/PatternBBBBBBBB00000001Size8-16   44.9ns ± 0%   2.9ns ± 1%   -93.51%  (p=0.000 n=10+9)
FindBitRange64/PatternBBBBBBBB00000001Size32-16  44.9ns ± 0%   2.9ns ± 0%   -93.51%  (p=0.000 n=10+9)
FindBitRange64/PatternCCCCCCCCCCCCCCCCSize2-16   4.19ns ± 0%  2.26ns ± 0%   -46.10%  (p=0.000 n=10+10)
FindBitRange64/PatternCCCCCCCCCCCCCCCCSize8-16   76.5ns ± 0%   2.9ns ± 0%   -96.19%  (p=0.000 n=8+7)
FindBitRange64/PatternCCCCCCCCCCCCCCCCSize32-16  76.5ns ± 0%   2.9ns ± 0%   -96.19%  (p=0.000 n=10+8)
FindBitRange64/Pattern4444444444444444Size2-16   76.4ns ± 0%   2.3ns ± 0%   -97.04%  (p=0.000 n=8+10)
FindBitRange64/Pattern4444444444444444Size8-16   76.5ns ± 0%   2.1ns ± 0%   -97.23%  (p=0.000 n=9+10)
FindBitRange64/Pattern4444444444444444Size32-16  76.5ns ± 0%   2.1ns ± 0%   -97.23%  (p=0.000 n=8+10)
FindBitRange64/Pattern4040404040404040Size2-16   40.3ns ± 0%   2.3ns ± 0%   -94.38%  (p=0.000 n=7+10)
FindBitRange64/Pattern4040404040404040Size8-16   40.2ns ± 0%   2.1ns ± 0%   -94.75%  (p=0.000 n=10+10)
FindBitRange64/Pattern4040404040404040Size32-16  40.2ns ± 0%   2.1ns ± 0%   -94.76%  (p=0.000 n=10+6)
FindBitRange64/Pattern4000400040004000Size2-16   22.2ns ± 0%   2.2ns ± 0%   -89.86%  (p=0.001 n=8+9)
FindBitRange64/Pattern4000400040004000Size8-16   22.2ns ± 0%   2.1ns ± 0%   -90.52%  (p=0.000 n=8+10)
FindBitRange64/Pattern4000400040004000Size32-16  22.2ns ± 1%   2.1ns ± 0%   -90.50%  (p=0.000 n=10+10)

The cases that slow down aren't really that slow, and those inputs
never actually occur (there's a short circuit before the call to
findBitRange64 for that case).

Change-Id: I50fae62915098032d8ce7fa57ef29eee9deb01ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/241279
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agoruntime: use bit-parallel operations to compute heap bit summaries
Keith Randall [Fri, 3 Jul 2020 18:28:50 +0000 (11:28 -0700)]
runtime: use bit-parallel operations to compute heap bit summaries

The new implementation is much faster in all cases.

name                                             old time/op  new time/op  delta
PallocBitsSummarize/Unpacked00-16                 142ns ± 1%     7ns ± 2%  -94.75%  (p=0.000 n=10+9)
PallocBitsSummarize/UnpackedFFFFFFFFFFFFFFFF-16   172ns ± 0%    24ns ± 0%  -86.02%  (p=0.000 n=9+9)
PallocBitsSummarize/UnpackedAA-16                 145ns ± 0%    32ns ± 0%  -78.16%  (p=0.000 n=8+10)
PallocBitsSummarize/UnpackedAAAAAAAAAAAAAAAA-16   172ns ± 0%    33ns ± 0%  -80.95%  (p=0.000 n=9+9)
PallocBitsSummarize/Unpacked80000000AAAAAAAA-16   162ns ± 1%    60ns ± 0%  -62.69%  (p=0.000 n=10+9)
PallocBitsSummarize/UnpackedAAAAAAAA00000001-16   163ns ± 0%    68ns ± 1%  -58.47%  (p=0.000 n=8+10)
PallocBitsSummarize/UnpackedBBBBBBBBBBBBBBBB-16   172ns ± 0%    35ns ± 0%  -79.70%  (p=0.000 n=9+9)
PallocBitsSummarize/Unpacked80000000BBBBBBBB-16   161ns ± 0%    63ns ± 0%  -60.61%  (p=0.000 n=8+10)
PallocBitsSummarize/UnpackedBBBBBBBB00000001-16   163ns ± 0%    60ns ± 0%  -63.14%  (p=0.000 n=9+10)
PallocBitsSummarize/UnpackedCCCCCCCCCCCCCCCC-16   172ns ± 0%    39ns ± 0%  -77.41%  (p=0.000 n=7+10)
PallocBitsSummarize/Unpacked4444444444444444-16   172ns ± 0%    39ns ± 0%  -77.42%  (p=0.000 n=7+10)
PallocBitsSummarize/Unpacked4040404040404040-16   173ns ± 2%    51ns ± 1%  -70.55%  (p=0.000 n=10+10)
PallocBitsSummarize/Unpacked4000400040004000-16   160ns ± 1%    53ns ± 0%  -66.78%  (p=0.000 n=10+10)
PallocBitsSummarize/Unpacked1000404044CCAAFF-16   169ns ± 1%    59ns ± 1%  -65.28%  (p=0.000 n=10+10)

Change-Id: I94daa645b76a9cf9c93edeb2058d7132216fcb72
Reviewed-on: https://go-review.googlesource.com/c/go/+/240900
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agoruntime: print faulting instruction on a SIGFPE
Keith Randall [Thu, 25 Jun 2020 16:10:23 +0000 (09:10 -0700)]
runtime: print faulting instruction on a SIGFPE

Just like SIGILL, it might be useful to see what the instruction
that generated the SIGFPE is.

Update #39816

Change-Id: I8b2ff692998f0b770289339537dceab96b09d1ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/239999
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: remove tracebackinit and unused skipPC
liu-xuewen [Mon, 13 Jul 2020 09:15:38 +0000 (09:15 +0000)]
runtime: remove tracebackinit and unused skipPC

CL [152537](https://go-review.googlesource.com/c/go/+/152537/) changed the way inlined frames are represented in tracebacks to no longer use skipPC

Change-Id: I42386fdcc5cf72f3c122e789b6af9cbd0c6bed4b
GitHub-Last-Rev: 79c26dcd532907eda4ffc30951845c1c01243501
GitHub-Pull-Request: golang/go#39829
Reviewed-on: https://go-review.googlesource.com/c/go/+/239701
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: move dumpFileSeq
surechen [Mon, 27 Jul 2020 04:00:19 +0000 (12:00 +0800)]
cmd/compile: move dumpFileSeq

I noticed that there is a Todo comment here. This variable is only used for filename when dump a function's ssa passes result in details. It is no problem to print a function alone, but may be edited by not only one goroutine if dump multiple functions at the same time. Although it looks only dump one function's ssa passes now. As far as I am concerned this variable can be a member variable of the struct Func. I'm not sure if this change is necessary. Looking forward to your advices, thank you very much.

Change-Id: I35dd7247889e0cc7f19c0b400b597206592dee75
Reviewed-on: https://go-review.googlesource.com/c/go/+/244918
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

4 years agointernal/bytealg: use CBZ instructions
Heisenberg [Thu, 11 Jun 2020 02:16:33 +0000 (10:16 +0800)]
internal/bytealg: use CBZ instructions

Use CBZ to replace the comparison and jump to the zero instruction in the arm64 assembly file.

Change-Id: Ie16fb52e27b4d327343e119ebc0f0ca756437bc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/237477
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoruntime: use the CBZ instruction in the assembler
Heisenberg [Thu, 11 Jun 2020 03:17:20 +0000 (11:17 +0800)]
runtime: use the CBZ instruction in the assembler

Use CBZ to replace the comparison and branch of arm64 and the zero instruction in the assembly file.

Change-Id: Id6c03e9af13aadafc3ad3953f82d2ffa29c12926
Reviewed-on: https://go-review.googlesource.com/c/go/+/237497
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoruntime: clean up old mcentral code
Michael Anthony Knyszek [Wed, 19 Feb 2020 16:37:48 +0000 (16:37 +0000)]
runtime: clean up old mcentral code

This change deletes the old mcentral implementation from the code base
and the newMCentralImpl feature flag along with it.

Updates #37487.

Change-Id: Ibca8f722665f0865051f649ffe699cbdbfdcfcf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/221184
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agoruntime: clean up old markrootSpans
Michael Anthony Knyszek [Wed, 19 Feb 2020 19:45:57 +0000 (19:45 +0000)]
runtime: clean up old markrootSpans

This change removes the old markrootSpans implementation and deletes the
feature flag.

Updates #37487.

Change-Id: Idb5a2559abcc3be5a7da6f2ccce1a86e1d7634e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/221183
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/compile: optimize unsigned comparisons to 0
Junchen Li [Fri, 10 Jul 2020 03:39:23 +0000 (11:39 +0800)]
cmd/compile: optimize unsigned comparisons to 0

There are some architecture-independent rules in #21439, since an
unsigned integer >= 0 is always true and < 0 is always false. This CL
adds these optimizations to generic rules.

Updates #21439

Change-Id: Iec7e3040b761ecb1e60908f764815fdd9bc62495
Reviewed-on: https://go-review.googlesource.com/c/go/+/246617
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go: add tracing for querying and downloading from the proxy
Michael Matloob [Wed, 15 Jul 2020 21:38:36 +0000 (17:38 -0400)]
cmd/go: add tracing for querying and downloading from the proxy

This CL adds tracing spans for modload.queryPattern, modload.queryProxy,
modload.QueryPattern, modload.QueryPattern.queryModule,
modload.queryPrefixModules and modfetch.Download.

Updates #38714

Change-Id: I537c7fa4f466c691c1b60ec73ef8a2277af49cd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/242786
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/go: do context propagation for tracing downloads
Michael Matloob [Tue, 30 Jun 2020 21:51:52 +0000 (17:51 -0400)]
cmd/go: do context propagation for tracing downloads

This change does context propagation (and only context propagation)
necessary to add context to modfetch.Download and pkg.LoadImport.
This was done by adding context to their callers, and then
adding context to all call-sites, and then repeating adding
context to callers of those enclosing functions and their
callers until none were left. In some cases the call graph expansion
was pruned by using context.TODOs.

The next CL will add a span to Download. I kept it out of this
change to avoid making it any larger (and harder to review)
than it needs to be.

Updates #38714

Change-Id: I5bf2d599aafef67334c384dfccd5e255198c85b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/248327
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go/internal/test: keep looking for go command flags after ambiguous test flag
Bryan C. Mills [Fri, 14 Aug 2020 19:47:49 +0000 (15:47 -0400)]
cmd/go/internal/test: keep looking for go command flags after ambiguous test flag

Fixes #40763

Change-Id: I275970d1f8561414571a5b93e368d68fa052c60f
Reviewed-on: https://go-review.googlesource.com/c/go/+/248618
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/test2json: do not emit a final Action if the result is not known
Bryan C. Mills [Fri, 14 Aug 2020 21:44:22 +0000 (17:44 -0400)]
cmd/test2json: do not emit a final Action if the result is not known

If we are parsing a test output, and the test does not end in the
usual PASS or FAIL line (say, because it panicked), then we need the
exit status of the test binary in order to determine whether the test
passed or failed. If we don't have that status available, we shouldn't
guess arbitrarily — instead, we should omit the final "pass" or "fail"
action entirely.

(In practice, we nearly always DO have the final status, such as when
running 'go test' or 'go tool test2json some.exe'.)

Fixes #40132

Change-Id: Iae482577361a6033395fe4a05d746b980e18c3de
Reviewed-on: https://go-review.googlesource.com/c/go/+/248624
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal: remove some users of par.Work
Michael Matloob [Thu, 25 Jun 2020 23:11:28 +0000 (19:11 -0400)]
cmd/go/internal: remove some users of par.Work

par.Work is used in a number of places as a parallel
work queue. This change replaces it with goroutines
and channels in a number of simpler places where it's
used.

Change-Id: I0620eda46ec7b2c0599a8b9361639af7bb73a05a
Reviewed-on: https://go-review.googlesource.com/c/go/+/248326
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: add span for modload.LoadBuildList
Michael Matloob [Wed, 24 Jun 2020 19:58:47 +0000 (15:58 -0400)]
cmd/go: add span for modload.LoadBuildList

This change adds context, and a span to modload.LoadBuildList and
propagates context into modload.BuildList. It's the start
of a run of CLs to add trace spans for module operations.

Updates #38714

Change-Id: I0d58dd394051526338092dc9a5ec29a9e087e4e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/248325
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: process -debug-trace flag for cmd/test and cmd/vet
Michael Matloob [Mon, 22 Jun 2020 23:02:00 +0000 (19:02 -0400)]
cmd/go: process -debug-trace flag for cmd/test and cmd/vet

These commands are build-like commands that do their own flag
processing, so the value of debug-trace isn't available until
the command starts running. Start tracing in the cmd's run
function.

Updates #38714

Change-Id: I4d633e6ee907bf09feac52c2aff3daceb9b20e12
Reviewed-on: https://go-review.googlesource.com/c/go/+/248324
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: add tracing instrumentation to load.TestPackagesFor
Michael Matloob [Mon, 22 Jun 2020 22:39:10 +0000 (18:39 -0400)]
cmd/go: add tracing instrumentation to load.TestPackagesFor

This change adds tracing instrumentation into load.TestPackagesFor,
propagating context through its callers.

Updates #38714

Change-Id: I80fefaf3116ccccffaa8bb7613a656bda867394c
Reviewed-on: https://go-review.googlesource.com/c/go/+/248323
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: mark trace flows between actions
Michael Matloob [Thu, 18 Jun 2020 15:58:46 +0000 (11:58 -0400)]
cmd/go: mark trace flows between actions

This could help make it easier to identify blocking
dependencies when examining traces. Flows can be turned
off when viewing traces to remove potential distractions.

Updates #38714

Change-Id: Ibfd3f1a1861e3cac31addb053a2fca7ee796c4d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/248322
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: propagate context into Action.Func calls
Michael Matloob [Wed, 17 Jun 2020 22:18:23 +0000 (18:18 -0400)]
cmd/go: propagate context into Action.Func calls

Action.Func is now a func(*Builder, context.Context, *Action), so that
contexts can be propagated into the action funcs. While context
is traditionally the first parameter of a function, it's the second
parameter of Action.Func's type to continue to allow for methods
on Builder to be used as functions taking a *Builder as the first
parameter. context.Context is instead the first parameter on
those functions.

Change-Id: I5f058d6a99a1e96fe2025f2e8ce30a033d12e935
Reviewed-on: https://go-review.googlesource.com/c/go/+/248321
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: add trace events for each action
Michael Matloob [Wed, 17 Jun 2020 22:05:16 +0000 (18:05 -0400)]
cmd/go: add trace events for each action

This change adds a trace event for each action and also
annotates each of the action execution goroutines with trace.Goroutine
so that the actions eaxecuted by each goroutine appear on different threads in
the chrome trace viewer.

Updates #38714

Change-Id: I2e58dc5606b2e3f7f87076a61e1cc6a2014255c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/248320
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go/internal/trace: add function to distinguish goroutines
Michael Matloob [Wed, 17 Jun 2020 21:40:35 +0000 (17:40 -0400)]
cmd/go/internal/trace: add function to distinguish goroutines

trace.StartGoroutine will associate the trace information on the context
with a new chrome profiler thread id. The chrome profiler doesn't
expect multiple trace events to have the same thread id, so this
will allow us to display concurrent events on the trace.

Updates #38714

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