Commit Graph

46441 Commits

Author SHA1 Message Date
Matthew Dempsky
d9acf6f3a3 [dev.regabi] cmd/compile: remove Func.ClosureType
The closure's type always matches the corresponding function's type,
so just use one instance rather than carrying around two. Simplifies
construction of closures, rewriting them during walk, and shrinks
memory usage.

Passes toolstash -cmp.

Change-Id: I83b8b8f435b02ab25a30fb7aa15d5ec7ad97189d
Reviewed-on: https://go-review.googlesource.com/c/go/+/283152
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-01-12 23:23:14 +00:00
Matthew Dempsky
41352fd401 [dev.regabi] cmd/compile: transform closures during walk
We used to transform directly called closures in a separate pass
before walk, because we couldn't guarantee whether we'd see the
closure call or the closure itself first. As of the last CL, this
ordering is always guaranteed, so we can rewrite calls and the closure
at the same time.

Change-Id: Ia6f4d504c24795e41500108589b53395d301123b
Reviewed-on: https://go-review.googlesource.com/c/go/+/283315
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-01-12 23:23:00 +00:00
Matthew Dempsky
d6ad88b4db [dev.regabi] cmd/compile: compile functions before closures
This CL reorders function compilation to ensure that functions are
always compiled before any enclosed function literals. The primary
goal of this is to reduce the risk of race conditions that arise due
to compilation of function literals needing to inspect data from their
closure variables. However, a pleasant side effect is that it allows
skipping the redundant, separate compilation of function literals that
were inlined into their enclosing function.

Change-Id: I03ee96212988cb578c2452162b7e99cc5e92918f
Reviewed-on: https://go-review.googlesource.com/c/go/+/282892
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2021-01-12 23:22:41 +00:00
Matthew Dempsky
432f9ffb11 [dev.regabi] cmd/compile: unindent compileFunctions
No real code changes. Just splitting into a separate CL so the next
one is easier to review.

Change-Id: I428dc986b76370d8d3afc12cf19585f6384389d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/283314
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-01-12 23:22:11 +00:00
Matthew Dempsky
cc90e7a51e [dev.regabi] cmd/compile: always use the compile queue
The compiler currently has two modes for compilation: one where it
compiles each function as it sees them, and another where it enqueues
them all into a work queue. A subsequent CL is going to reorder
function compilation to ensure that functions are always compiled
before any non-trivial function literals they enclose, and this will
be easier if we always use the compile work queue.

Also, fewer compilation modes makes things simpler to reason about.

Change-Id: Ie090e81f7476c49486296f2b90911fa0a466a5dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/283313
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-01-12 23:22:04 +00:00
Matthew Dempsky
cd5b74d2df [dev.regabi] cmd/compile: call NeedFuncSym in InitLSym
InitLSym is where we're now generating ABI wrappers, so it seems as
good a place as any to make sure we're generating the degenerate
closure wrappers for declared functions and methods.

Change-Id: I097f34bbcee65dee87a97f9ed6f3f38e4cf2e2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/283312
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-01-12 23:21:58 +00:00
Bryan C. Mills
ba76567bc2 cmd/go/internal/modload: delete unused *mvsReqs.next method
For #36460
Updates #36465

Change-Id: Id818dce21d39a48cf5fc9c015b30497dce9cd1ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/278596
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-01-12 21:39:59 +00:00
Eric Chiang
665def2c11 encoding/asn1: document unmarshaling behavior for IMPLICIT string fields
Fixes #42570.

Change-Id: I73e339cdebe1720c141861a12e28a94cef13c75b
Reviewed-on: https://go-review.googlesource.com/c/go/+/269798
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Katie Hockman <katie@golang.org>
2021-01-12 18:32:48 +00:00
Matthew Dempsky
95acd8121b [dev.regabi] cmd/compile: remove Name.Typegen
Just directly set Type.Vargen when declaring defined types within a
function.

Change-Id: Idcc0007084a660ce1c39da4a3697e158a1c615b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/283212
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-01-12 04:46:22 +00:00
Matthew Dempsky
12ee55ba7b [dev.regabi] cmd/compile: stop using Vargen for import/export
Historically, inline function bodies were exported as plain Go source
code, and symbol mangling was a convenient hack because it allowed
variables to be re-imported with largely the same names as they were
originally exported as.

However, nowadays we use a binary format that's more easily extended,
so we can simply serialize all of a function's declared objects up
front, and then refer to them by index later on. This also allows us
to easily report unmangled names all the time (e.g., error message
from issue7921.go).

Fixes #43633.

Change-Id: I46c88f5a47cb921f70ab140976ba9ddce38df216
Reviewed-on: https://go-review.googlesource.com/c/go/+/283193
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
2021-01-12 03:15:18 +00:00
Matthew Dempsky
b4d2a0445b [dev.regabi] cmd/compile: refactor closure var setup/teardown
Creating closure vars is subtle and is also needed in both CL 281932
and CL 283112, so refactor out a common implementation that can be
used in all 3 places.

Passes toolstash -cmp.

Change-Id: Ib993eb90c895b52759bfbfbaad88921e391b0b4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/283194
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
2021-01-12 02:46:27 +00:00
Matthew Dempsky
f57f484053 [dev.regabi] cmd/compile: decouple escape analysis from Name.Vargen
Escape analysis needs to know the index of result parameters for
recording escape-flow information. It currently relies on Vargen for
this, but it can easily figure this out for itself. So just do that
instead, so that we can remove Vargen.

Passes toolstash -cmp.

For #43633.

Change-Id: I65dedc2d73bc25e85ff400f308e50b73dc503630
Reviewed-on: https://go-review.googlesource.com/c/go/+/283192
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-01-12 01:25:32 +00:00
Jakub Warczarek
81ea89adf3 cmd/go: fix non-script staleness checks interacting badly with GOFLAGS
Fixes #43012.

Change-Id: Idc7a64b53c411e6dadd98521a48e15e664737d42
GitHub-Last-Rev: b56c0880c3
GitHub-Pull-Request: golang/go#43155
Reviewed-on: https://go-review.googlesource.com/c/go/+/277453
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-01-11 21:34:46 +00:00
Rebecca Stambler
759309029f doc: update editors.html for Go 1.16
Rerank editor plugins based on popularity (Go 2019 survey), and remove
Atom, as it is no longer popular.

Change-Id: I06d39b67eec24a920439b9ea1198b6e2a939874e
Reviewed-on: https://go-review.googlesource.com/c/go/+/283073
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-01-11 19:45:02 +00:00
Cherry Zhang
c3b4c7093a cmd/internal/objfile: don't require runtime.symtab symbol for XCOFF
For some reason (that I didn't look into), externally linked
AIX binaries don't have runtime.symtab symbol. Since recent Go
releases (Go 1.3 maybe?), that symbol is empty and not necessary
anyway. Don't require it.

Fixes #40972.

Change-Id: I73a1f0142195ea6debdba8a4f6e12cadc3980dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/279995
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-01-11 18:19:08 +00:00
Matthew Dempsky
7fd84c6e46 [dev.regabi] cmd/compile: remove OCLOSUREREAD
After the previous CLs, all closure reads are handled during SSA
construction.

Change-Id: Iad67b01fa2d3798f50ea647be7ccf8195f189c27
Reviewed-on: https://go-review.googlesource.com/c/go/+/281512
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-01-10 08:02:23 +00:00
Matthew Dempsky
c9c26d7ffb [dev.regabi] cmd/compile: use ClosureVars for method value wrappers
Similar to with regular closures, we can change method value wrappers
to use ClosureVars and allow SSA construction to take care of wiring
it up appropriately.

Change-Id: I05c0b1bcec4e24305324755df35b7bc5b8a6ce7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/281353
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-01-10 08:02:16 +00:00
Matthew Dempsky
950cf4d46c [dev.regabi] cmd/compile: bind closure vars during SSA constructions
For function literals that aren't inlined or directly called, we need
to pass their arguments via a closure struct. This also means we need
to rewrite uses of closure variables to access from this closure
struct.

Currently we do this rewrite in a pass before walking begins. This CL
moves the code to SSA construction instead, alongside binding other
input parameters.

Change-Id: I13538ef3394e2d6f75d5b7b2d0adbb00db812dc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/281352
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-01-10 08:02:06 +00:00
Matthew Dempsky
8b2efa990b [dev.regabi] cmd/compile: deref PAUTOHEAPs during SSA construction
Currently, during walk we rewrite PAUTOHEAP uses into derefs of their
corresponding Heapaddr, but we can easily do this instead during SSA
construction. This does involve updating two test cases:

* nilptr3.go

This file had a test that we emit a "removed nil check" diagnostic for
the implicit dereference from accessing a PAUTOHEAP variable. This CL
removes this diagnostic, since it's not really useful to end users:
from the user's point of view, there's no pointer anyway, so they
needn't care about whether we check for nil or not. That's a purely
internal detail. And with the PAUTOHEAP dereference handled during SSA
construction, we can more robustly ensure this happens, rather than
relying on setting a flag in walk and hoping that SSA sees it.

* issue20780.go

Previously, when PAUTOHEAPs were dereferenced during walk, it had a
consequence that when they're passed as a function call argument, they
would first get copied to the stack before being copied to their
actual destination. Moving the dereferencing to SSA had a side-effect
of eliminating this unnecessary temporary, and copying directly to the
destination parameter.

The test is updated to instead call "g(h(), h())" where h() returns a
large value, as the first result will always need to be spilled
somewhere will calling the second function. Maybe eventually we're
smart enough to realize it can be spilled to the heap, but we don't do
that today.

Because I'm concerned that the direct copy-to-parameter optimization
could interfere with race-detector instrumentation (e.g., maybe the
copies were previously necessary to ensure they're not clobbered by
inserted raceread calls?), I've also added issue20780b.go to exercise
this in a few different ways.

Change-Id: I720598cb32b17518bc10a03e555620c0f25fd28d
Reviewed-on: https://go-review.googlesource.com/c/go/+/281293
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-01-10 08:01:49 +00:00
Jay Conrod
59bfc18e34 cmd/go: add hint to read 'go help vcs' to GOVCS errors
Fixes #43596

Change-Id: Iff925d077b5de64161e88c9471402bc7e8885fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/282713
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-01-08 22:55:41 +00:00
Robert Griesemer
6ee9b118a2 [dev.regabi] cmd/compile: remove fmt_test code; it has outlived its usefulness
With the recent compiler rewrites and cleanups to gc/fmt.go, the
"safety net" provided by fmt_test has become less important and
the test itself has become a burden (often breaks because of small
format changes elsewhere).

Eventually, the syntax and types2 packages will provide most error
and diagnostic compiler output at which point fmt.go can be further
simplified as well.

Change-Id: Ie93eefd3e1166f3548fed0199b732dbd6c81948a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282560
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-01-08 22:40:47 +00:00
Jay Conrod
cd6f3a54e4 cmd/go: revise 'go help' documentation for modules
Module-related help pages now contain a brief summary and point to the
reference documentation at golang.org/ref/mod for details.

Help pages for commands like 'go get' still describe the basic usage
and summarize flags but don't provide as much background detail.

Fixes #41427
Fixes #43419

Change-Id: Icacd38e0f33c352c447cc5a496c99674493abde2
Reviewed-on: https://go-review.googlesource.com/c/go/+/282615
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-01-08 20:21:06 +00:00
Jay Conrod
6192b98751 cmd/go: make hints in error messages more consistent
* All commands the user can run to fix the problem now appear alone on
  a separate line after a tab.
* Removed -d from 'go get' commands.
* Replaced 'go mod tidy' with 'go mod download $modpath' when a
  package might be provided by a module missing a sum.
* Errors about 'path@version' syntax are more explicit.

Fixes #29415
Fixes #42087
Fixes #43430
Fixes #43523

Change-Id: I4427c2c4506a727a2c727d652fd2d506bb134d3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/282121
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-01-08 20:19:51 +00:00
Jay Conrod
25886cf4bd cmd/go: preserve sums for indirect deps fetched by 'go mod download'
Previously, commands that wrote go.sum (except 'go mod tidy') would
retain sums for zip files of directly required modules. Sums of
indirect dependencies wouldn't be retained unless they were used to
load packages.

With this change, sums for indirect dependencies will be retained if
they're available. This allows users to add missing sums with
'go mod download example.com/mod', which previously only worked for
directly required modules.

Note that 'go mod download' without arguments now adds sums for every
module in the build list. That matches 1.15 behavior.

For #41103

Change-Id: I4cce2bf1c73578dae836bdb5adb32da071554f1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282692
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-01-08 19:48:42 +00:00
Michael Anthony Knyszek
6250833911 runtime/metrics: mark histogram metrics as cumulative
All the current histogram metrics accumulate counts from program start
to infinity, and can be reasonably used to compute rates (also to
generate windowed distributions).

Change-Id: I5196c59867de34fba41bb8552606fa315460cef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/282633
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2021-01-08 18:15:53 +00:00
Michael Anthony Knyszek
8f6a9acbb3 runtime/metrics: remove unused StopTheWorld Description field
This change removes the as-of-yet unused StopTheWorld field in the
Description struct. Adding a new field to a struct is much easier than
removing it, so let's save it for when we actually need it.

Change-Id: I8074b8569187c1a148500575fa8a661534e875d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/282632
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2021-01-08 18:15:43 +00:00
Russ Cox
6598c65646 cmd/compile: fix exponential-time init-cycle reporting
I have a real 7,000-line Go program (not so big)
that took over two minutes to report a trivial init cycle.
I thought the compiler was in an infinite loop but
it was actually just very slow.

CL 170062 rewrote init cycle reporting but replaced
a linear-time algorithm with an exponential one:
it explores all paths through the call graph of functions
involved in the cycle.

The net effect was that  Go 1.12 took 0.25 seconds to load,
typecheck, and then diagnose the cycle in my program,
while Go 1.13 takes 600X longer.

This CL makes the new reporting code run in linear time,
restoring the speed of Go 1.12 but preserving the semantic
fixes from CL 170062.

Change-Id: I7d6dc95676d577d9b96f5953b516a64db93249bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/282314
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-08 17:14:20 +00:00
Russ Cox
fefad1dc85 test: fix timeout code for invoking compiler
When running go tool compile,
go tool is running compile as a subprocess.
Killing go tool with Process.Kill leaves the subprocess behind.
Send an interrupt signal first, which it can forward on
to the compile subprocess.

Also report the timeout in errorcheck -t.

Change-Id: I7ae0029bbe543ed7e60e0fea790dd0739d10bcaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/282313
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-08 17:14:00 +00:00
Russ Cox
6728118e0a cmd/go: pass signals forward during "go tool"
This way, if a SIGINT is sent to the go command,
it is forwarded on to the underlying tool.

Otherwise trying to use os.Process.Signal to kill
"go tool compile" only kills the "go tool" not the "compile".

Change-Id: Iac7cd4f06096469f5e76164df813a379c0da3822
Reviewed-on: https://go-review.googlesource.com/c/go/+/282312
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-08 17:13:48 +00:00
Russ Cox
e65c543f3c go/build/constraint: add parser for build tag constraint expressions
This package implements a parser for the new //go:build constraint lines.
The parser also handles // +build lines, to be able to process legacy files.

This will not be used in the standard library until Go 1.17,
but it seems worth publishing in Go 1.16 so that code that
needs to process both kinds of lines once Go 1.17 comes out
will be able to build using Go 1.16 as well.

For #41184. Design in https://golang.org/design/draft-gobuild.

Change-Id: I756c0de4081c5039e8b7397200e5274f223ab111
Reviewed-on: https://go-review.googlesource.com/c/go/+/240604
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-01-08 17:08:44 +00:00
Austin Clements
0c5afc4fb7 testing/fstest,os: clarify racy behavior of TestFS
The testing.TestFS function assumes that the file system it's testing
doesn't change under it. Clarify this in the documentation and fix the
use of os.TestDirFS that's currently susceptible to this race.

Fixes #42637.

Change-Id: Ia7792380726177f8953d150ee87381b66cb01cb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/282452
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-01-08 16:34:00 +00:00
Michael Anthony Knyszek
32afcc9436 runtime/metrics: change unit on *-by-size metrics to match bucket unit
This change modifies the *-by-size metrics' units to be based off the
bucket's unit (bytes) as opposed to the unit of the counts (objects).
This convention is more in-line with distributions in other metrics
systems.

Change-Id: Id3b68a09f52f0e1ff9f4346f613ae1cbd9f52f73
Reviewed-on: https://go-review.googlesource.com/c/go/+/282352
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
2021-01-08 16:28:15 +00:00
Ian Lance Taylor
c6513bca5a io/fs: minor corrections to Glob doc
The documentation for Glob was copied from filepath.Glob, and needs a bit
of tweaking: paths are not rooted at slash; the separator is always '/'.

Fixes #43537

Change-Id: Id64daa137e2762b66a82a5b9e60bbe603f4e2f5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/282173
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-01-08 15:41:36 +00:00
Baokun Lee
b241938e04 [dev.regabi] cmd/compile: fix some methods error text
Change-Id: Ie9b034efba30d66a869c5e991b60c76198fd330f
Reviewed-on: https://go-review.googlesource.com/c/go/+/279444
Run-TryBot: Baokun Lee <bk@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-01-08 11:05:29 +00:00
Keith Randall
304f769ffc cmd/compile: don't short-circuit copies whose source is volatile
Current optimization: When we copy a->b and then b->c, we might as well
copy a->c instead of b->c (then b might be dead and go away).

*Except* if a is a volatile location (might be clobbered by a call).
In that case, we really do want to copy a immediately, because there
might be a call before we can do the a->c copy.

User calls can't happen in between, because the rule matches up the
memory states. But calls inserted for memory barriers, particularly
runtime.typedmemmove, can.

(I guess we could introduce a register-calling-convention version
of runtime.typedmemmove, but that seems a bigger change than this one.)

Fixes #43570

Change-Id: Ifa518bb1a6f3a8dd46c352d4fd54ea9713b3eb1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282492
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-01-08 05:00:06 +00:00
Michael Anthony Knyszek
ae97717133 runtime,runtime/metrics: use explicit histogram boundaries
This change modifies the semantics of
runtime/metrics.Float64Histogram.Buckets to remove implicit buckets to
that extend to positive and negative infinity and instead defines all
bucket boundaries as explicitly listed.

Bucket boundaries remain the same as before except
/gc/heap/allocs-by-size:objects and /gc/heap/frees-by-size:objects no
longer have a bucket that extends to negative infinity.

This change simplifies the Float64Histogram API, making it both easier
to understand and easier to use.

Also, add a test for allocs-by-size and frees-by-size that checks them
against MemStats.

Fixes #43443.

Change-Id: I5620f15bd084562dadf288f733c4a8cace21910c
Reviewed-on: https://go-review.googlesource.com/c/go/+/281238
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
2021-01-08 03:43:44 +00:00
Meng Zhuo
a9ccd2d795 go/build: skip string literal while findEmbed
The findEmbed function looking for comment by readbyte,
however it might have constant or variables that contains
comment.
Maybe we should use ast parser in the future.

Fixes #43373

Change-Id: I92544384fc4c11363d8b2f6b9898c8dea1602767
Reviewed-on: https://go-review.googlesource.com/c/go/+/280332
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-01-08 02:18:40 +00:00
yangwenmai
d92f8add32 archive/tar: fix typo in comment
Change-Id: Ifcc565b34b3c3bb7ee62bb0525648a5d2895bf0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/282013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2021-01-08 02:03:24 +00:00
Ian Lance Taylor
cab1202183 cmd/link: accept extra blocks in TestFallocate
For #41127

Change-Id: I794a082299c6dce4202223197ece1864bed36810
Reviewed-on: https://go-review.googlesource.com/c/go/+/282555
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2021-01-08 01:58:34 +00:00
Meng Zhuo
ee4d32249b io/fs: minor corrections to Glob release date
io/fs is introduced in 2020, not 2009 nor 2010

Change-Id: I7d63aae17b1f8c3af1ded2f639e3fb76ff2aea81
Reviewed-on: https://go-review.googlesource.com/c/go/+/282232
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-01-08 01:48:01 +00:00
Ian Lance Taylor
54bd1ccce2 cmd: update to latest golang.org/x/tools
In particular bring in CL 201973, which reverts support for multiple
keys in a struct tag.

For #40281
For #43083
For #43226

Change-Id: I66e76639cbbca55bdbff6956acdb0a97650fdd31
Reviewed-on: https://go-review.googlesource.com/c/go/+/282412
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-01-08 01:33:44 +00:00
Ian Lance Taylor
9ec21a8f34 Revert "reflect: support multiple keys in struct tags"
Proposal #40281 was initially accepted, but has now been declined.
This CL removes most of the work done to implement it.

Specifically this reverts CLs 248341, 274448, 274474, and 278392.

For #40281
For #43226

Change-Id: I5a9ebb4d9cb5fb0962434b64c59beb8343030be5
Reviewed-on: https://go-review.googlesource.com/c/go/+/281515
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-01-07 23:43:25 +00:00
Ian Lance Taylor
091414b5b7 io/fs: correct WalkDirFunc documentation
The documentation was copied from filepath.WalkFunc, and the copy was
not fully adjusted to the new circumstances.

Fixes #43536

Change-Id: I09687c7656e6938ebd9fc1e1643d34be88cf141d
Reviewed-on: https://go-review.googlesource.com/c/go/+/282172
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Marco Gazerro <gazerro@open2b.com>
2021-01-07 23:38:51 +00:00
Michael Matloob
9b55088d6b doc/go1.16: add release note for disallowing non-ASCII import paths
golang.org/cl/251878 disallowed non-ASCII characters in import paths,
in module mode. They were already disallowed in module paths, so this
change just extended the restriction to the package subdirectory of
the module. Update the release notes to alert users of this change.

Fixes #43052

Change-Id: I1caf9ef978dd3ac599a3f82c5c376ad62e6fc436
Reviewed-on: https://go-review.googlesource.com/c/go/+/282194
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-01-07 22:28:57 +00:00
Cuong Manh Le
fa90aaca7d cmd/compile: fix late expand_calls leaf type for OpStructSelect/OpArraySelect
For the example in #43551, before late call expansion, the OpArg type is
decomposed to int64. But the late call expansion is currently decompose
it to "x.Key" instead.

This CL make expand_calls decompose further for struct { 1-field type }
and array [1]elem.

This matches the previous rules for early decompose args:

(StructSelect (StructMake1 x)) => x
(ArraySelect (ArrayMake1 x)) => x

Fixes #43551

Change-Id: I2f1ebe18cb81cb967f494331c3d237535d2859e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/282332
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-01-07 19:31:03 +00:00
Michael Matloob
7cee66d4cb cmd/go: add documentation for Embed fields in go list output
This change the struct fields for EmbedPatterns and EmbedFiles
to the Package struct listed in the go list documentation that
specifies the fields available to the go list template.

Fixes #43081

Change-Id: I89c325a9d6292a6ce484ee588b172d2f84e2333a
Reviewed-on: https://go-review.googlesource.com/c/go/+/282195
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-01-07 18:56:09 +00:00
Ian Lance Taylor
e60cffa4ca html/template: attach functions to namespace
The text/template functions are stored in a data structure shared by
all related templates, so do the same with the original, unwrapped,
functions on the html/template side.

For #39807
Fixes #43295

Change-Id: I9f64a0a601f1151c863a2833b5be2baf649b6cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/279492
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-01-07 17:51:29 +00:00
Ikko Ashimine
6da2d3b7d7 cmd/link: fix typo in asm.go
targetting -> targeting

Change-Id: Ie1752b1293426fe908799731acb352408db98d85
GitHub-Last-Rev: 4cf2a211b9
GitHub-Pull-Request: golang/go#43564
Reviewed-on: https://go-review.googlesource.com/c/go/+/282272
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-01-07 17:49:47 +00:00
Meng Zhuo
df81a15819 runtime: check mips64 VDSO clock_gettime return code
We introduced VDSO feature for mips64x in Go1.14, however Linux kernel
didn't ship VDSO safe fallback until 4.13.

This CL checks vdso return code it may fix this issue.

name         old time/op  new time/op  delta
Now           174ns ± 0%   176ns ± 0%  +1.20%  (p=0.000 n=8+9)
NowUnixNano   175ns ± 0%   177ns ± 0%  +1.13%  (p=0.000 n=9+7)
FormatNow    1.01µs ± 1%  1.02µs ± 3%    ~     (p=0.181 n=10+10)

Fixes #39046

Change-Id: Ibcefe4c8334f634c7ef18fa70f3c7dbe8306f224
Reviewed-on: https://go-review.googlesource.com/c/go/+/270717
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Trust: Meng Zhuo <mzh@golangcn.org>
2021-01-07 01:55:27 +00:00
Filippo Valsorda
4787e906cf crypto/x509: rollback new CertificateRequest fields
In general, we don't want to encourage reading them from CSRs, and
applications that really want to can parse the Extensions field.

Note that this also fixes a bug where the error of
parseKeyUsageExtension was not handled in parseCertificateRequest.

Fixes #43477
Updates #37172

Change-Id: Ia5707b0e23cecc0aed57e419a1ca25e26eea6bbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/281235
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-01-06 21:24:47 +00:00