1
0
mirror of https://github.com/golang/go synced 2024-11-24 13:20:15 -07:00
Commit Graph

49472 Commits

Author SHA1 Message Date
Keith Randall
9871726c72 reflect: add test for invalid conversion
Conversion between slices with different element types is not allowed.
Previously (1.8 <= goversion <= 1.16), this conversion was allowed
if the base types were from different packages and had identical names.

Update #47785

Change-Id: I359de5b6fe3ff35bdbf9ab5a13902a0f820cac66
Reviewed-on: https://go-review.googlesource.com/c/go/+/343329
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-19 15:09:47 +00:00
Robert Findley
69d8fbec7a cmd/compile/internal/types2: return an error from Instantiate
Change Instantiate to be a function (not a method) and return an error.
Introduce an ArgumentError type to report information about which type
argument led to an error during verification.

This resolves a few concerns with the current API:
 - The Checker method set was previously just Files. It is somewhat odd
   to add an additional method for instantiation. Passing the checker as
   an argument seems cleaner.
 - pos, posList, and verify were bound together. In cases where no
   verification is required, the call site was somewhat cluttered.
 - Callers will likely want to access structured information about why
   type information is invalid, and also may not have access to position
   information. Returning an argument index solves both these problems;
   if callers want to associate errors with an argument position, they
   can do this via the resulting index.

We may want to make the first argument an opaque environment rather than
a Checker.

Change-Id: I3bc56d205c13d832b538401a4c91d3917c041225
Reviewed-on: https://go-review.googlesource.com/c/go/+/342152
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-19 15:05:05 +00:00
Roger Peppe
3bdc1799d6 io: unexport internal methods
The methods on the pipe type don't need to be exported. Doing so sets
a bad precedent that it's OK to export methods to indicate an internal
public API.  That's not a good idea in general, because exported methods
increase cognitive load when reading code: the reader needs to consider
whether the exported method might be used via some external interface
or reflection.

Change-Id: Ib13f1b3f9fe0ff251628f31b776182a0953268ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/341409
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Trust: Daniel Martí <mvdan@mvdan.cc>
2021-08-19 09:11:02 +00:00
Roger Peppe
740f7d7370 archive/tar: unexport internal methods
Many of the methods inside the archive/tar package don't need to be
exported. Doing so sets a bad precedent that it's OK to export methods
to indicate an internal public API.  That's not a good idea in general,
because exported methods increase cognitive load when reading code:
the reader needs to consider whether the exported method might be used
via some external interface or reflection.

This CL should have no externally visible behaviour changes at all.

Change-Id: I94a63de5e6a28e9ac8a283325217349ebce4f308
Reviewed-on: https://go-review.googlesource.com/c/go/+/341410
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Trust: Joe Tsai <joetsai@digital-static.net>
Trust: Michael Knyszek <mknyszek@google.com>
2021-08-19 09:09:02 +00:00
Matthew Dempsky
c85695a117 cmd/compile: add support for //go:nointerface for -G=3
This is used within Google's internal code repo, so getting it working
is a pre-req for enabling -G=3 by default.

Change-Id: Icbc570948c852ca09cdb2a59f778140f620244b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/343429
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-08-19 00:26:22 +00:00
Matthew Dempsky
322879d5c9 cmd/compile/internal/dwarfgen: use src.Pos.Rel{Filename,Line,Col} consistently
It appears that this code predates golang.org/cl/96535, which added
RelCol to support /*line*/ directives.

Change-Id: Ib79cebc1be53af706e84e8799eeea81ef8c81c8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/343430
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-08-18 23:19:19 +00:00
Keith Randall
687f2acf6a cmd/compile: only use dictionaries for conversions to type parameters
Conversions to regular concrete types should not be rewritten during
stenciling.

Fixes #47740

Change-Id: I2b45e22f962dcd2e18bd6cc876ebc0f850860822
Reviewed-on: https://go-review.googlesource.com/c/go/+/342989
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-08-18 22:34:31 +00:00
Robert Findley
eda3de0f79 cmd/compile/internal/types2: change Checker.verify to return an error
In preparation for upcoming API changes, change the internal API for
verification of type arguments to return an error and argument index,
and use this to lift up error reporting into Instantiate.

Change-Id: I88b1e64dd9055c4c20c0db49c96c79c5da894450
Reviewed-on: https://go-review.googlesource.com/c/go/+/342151
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-18 22:16:57 +00:00
Robert Findley
805d38a352 cmd/compile/internal/types2: no need to validate substituted instances
When substituting a type instance, we rely on the instance being
expanded and do not call validType, so there is need to depend on
subster.pos for error reporting or to use subst.check for creating the
new Named type. Errors will be reported for the unsubstituted instance.

This is a superficial change, but justifies some later simplification
where we don't have access to pos or check.

Change-Id: I1f3f12aa245d821512c6242ad829c940f20afae4
Reviewed-on: https://go-review.googlesource.com/c/go/+/342150
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-18 22:16:08 +00:00
Matthew Dempsky
c2bd9ee2db cmd/compile: only sort methods/interfaces during export for -d=unifiedquirks
These sorts are only important for 'toolstash -cmp' testing of unified
IR against -G=0 mode, but they were added before I added
-d=unifiedquirks to allow altering small "don't care" output details
like this.

This CL should help mitigate issues with #44195 until package
objectpath is updated and deployed.

Change-Id: Ia3dcf359481ff7abad5ddfca8e673fd2bb30ae01
Reviewed-on: https://go-review.googlesource.com/c/go/+/343390
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-18 21:19:22 +00:00
Robert Findley
8f0578ef39 cmd/compile/internal/types2: consolidate verification logic
Change an internal call of instantiateLazy to call Instantiate, so that
we can consolidate the logic for invoking verification.

This made verification of signatures lazy, which is not necessary but
should be harmless.

Change-Id: I2e59b04ac859e08c2e2910ded3c183093d1e34a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/342149
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-18 20:12:37 +00:00
Robert Findley
165ebd85a7 cmd/compile/internal/types2: clean up panics in instantiation
Clean up a few issues related to panicking during invalid instantiation.
 - Panic early in instantiateLazy when check == nil and verify == true.
   Otherwise, we would panic at check.later.
 - Always panic when check == nil and verify == true, even if targs is
   of incorrect length. This is more consistent behavior.
 - Lift the check for len(posList) <= len(targs) out of
   Checker.instantiate. This is the only reason why posList is passed to
   that function, and doing this allows us to eliminate posList from
   instance. At this point instance is close to being unnecessary, so
   update a TODO to this effect.

Change-Id: Id5f44cbb1a5897aef10ce2a573aa78acd7ae4026
Reviewed-on: https://go-review.googlesource.com/c/go/+/341862
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-18 20:11:28 +00:00
Yuki Osaki
4a0fd73ead cmd/go/internal/work/exec: throw an error when buildP is negative
Fixed a problem where an error would not occur
when a negative value was specified for the p flag.

`go build -p=0`
now should throw an error.

this is my first pr to this project.
If there's anything I'm missing, please let me know 🙏
Fixes #46686

Change-Id: I3b19773ef095fad0e0419100d317727c2268699a
GitHub-Last-Rev: e5c57804d9
GitHub-Pull-Request: golang/go#47360
Reviewed-on: https://go-review.googlesource.com/c/go/+/336751
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-18 17:25:17 +00:00
Tobias Klauser
0c83e01e0c cmd/go/testdata/script: fix test script added by CL 334873
CL 334873 added the net/http import to the wrong section in
test_vet.txt. Correct this to fix the longtest builders.

Change-Id: If28409ad1c2ed3bd3a2922fc20d5e534c30fa249
Reviewed-on: https://go-review.googlesource.com/c/go/+/343169
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-08-18 15:11:52 +00:00
Yasuhiro Matsumoto
8b471db71b path/filepath: change IsAbs to treat \\host\share as an absolute path
Fixes #47123

Change-Id: I2226b8a9ea24cd88171acfbaffea2566309416de
Reviewed-on: https://go-review.googlesource.com/c/go/+/334809
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-08-18 08:26:44 +00:00
Meng Zhuo
946e2543f8 runtime: use RDCYCLE for cputicks on riscv64
Use RDCYCLE instruction instead of RDTIME emulation

Change-Id: Id7b3de42a36d2d1b163c39cc79870eee7c840ad5
Reviewed-on: https://go-review.googlesource.com/c/go/+/332954
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-08-18 02:08:09 +00:00
eric fang
8e18428e38 cmd/internal/obj/arm64: don't use REGTMP when moving C_AACON2 to a register
MOVD $C_AACON2(Rf), Rt is encoded as ADD $C_AACON2_high_12_bits, Rf, REGTMP +
ADD $C_AACON2_low_12_bits, REGTMP, Rt. Actually REGTMP is not necessary here,
we can use Rt directly, so it becomes ADD $C_AACON2_high_12_bits, Rf, Rt +
ADD $C_AACON2_low_12_bits, Rt, Rt.

Change-Id: I90b7718b5fb0ab9f3ea28511f42946a6bdccfef3
Reviewed-on: https://go-review.googlesource.com/c/go/+/329751
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
2021-08-18 02:07:22 +00:00
eric fang
aef24d8f7d cmd/internal/obj/arm64: fix the encoding error when operating with ZR
Some arm64 instructions accept ZR as its destination register, such as MOVD,
AND, ADD etc. although it doesn't seem to make much sense, but we should
make sure the encoding is correct. However there exists some encoding mistakes
in the current assembler, they are:
1, 'MOVD $1, ZR' is incorrectly encoded as 'MOVD $1, ZR' + '0x00000000'.
2, 'AND $1, R2, ZR' is incorrectly encoded as 'MOVD $1, R27' + 'AND R27, R2, ZR' +
   '0x00000000'.
3, 'AND $1, ZR' is incorrectly encoded as 'AND $1, ZR, RSP'.

Obviously the first two encoding errors can cause SIGILL, and the third one will
rewrite RSP.

At the same time, I found some weird encodings but they don't cause errors.
4, 'MOVD $0x0001000100010001, ZR' is encoded as 'MOVW $1, ZR' + 'MOVKW $(1<<16), ZR'.
5, 'AND $0x0001000100010001, R2, ZR' is encoded as 'MOVD $1, R27' + 'MOVK $(1<<16), R27' +
   'MOVK $(1<<32), R27'.

Some of these issues also apply to 32-bit versions of these instructions.

These problems are not very complicated, and are basically caused by the improper
adaptation of the class of the constant to the entry in the optab. But the relationship
between these constant classes is a bit complicated, so I don't know how to deal with
issue 4 and 5, because they won't cause errors, so this CL didn't deal with them.

This CL fixed the first three issues.
Issue 1:
  before: 'MOVD $1, ZR' => 'MOVD $1, ZR' + '0x00000000'.
  after:  'MOVD $1, ZR' => 'MOVD $1, ZR'.
Issue 2:
  before: 'AND $1, R2, ZR' => 'MOVD $1, R27' + 'AND R27, R2, ZR' + '0x00000000'.
  after:  'AND $1, R2, ZR' => 'ORR $1, ZR, R27' + 'AND R27, R2, ZR'.
Issue 3:
  before: 'AND $1, ZR' => 'AND $1, ZR, RSP'.
  after:  'AND $1, ZR' => 'ORR $1, ZR, R27' + 'AND R27, ZR, ZR'.

Change-Id: I3c889079229f847b863ad56c88966be12d947202
Reviewed-on: https://go-review.googlesource.com/c/go/+/329750
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-18 02:06:51 +00:00
Cherry Mui
ddfcc02352 cmd/link: do not use GO_LDSO when cross compile
GO_LDSO is a setting that is set when the toolchain is build. It
only makes sense to use it on the host platform. Do not use it
when targetting a different platform.

In the past it was not a problem as GO_LDSO was almost always
unset. Now, with CL 301989 it is almost always set (maybe we want
to revisit it).

Fixes #47760.

Change-Id: I2704b9968781f46e2d2f8624090db19689b1a32f
Reviewed-on: https://go-review.googlesource.com/c/go/+/343010
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-17 23:59:53 +00:00
Paschalis Tsilias
a2a9a7b513 cmd/go: make mod init disallow invalid major version suffixes
This CL reuses the SplitPathVersion function from the module package to
detect invalid major version suffixes and return a relevant error
message along with a suggested fix.

Fixes #44052
Fixes #46085

Change-Id: I6c06f31a134e864a1d9b6e00c048ca1c59b4365e
Reviewed-on: https://go-review.googlesource.com/c/go/+/288712
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-17 21:34:32 +00:00
Colin Arnott
3848488f0f cmd/go/internal/test: add an all sentinel to -vet
The vet flag either accepts a list of vets to run, or a distinguished
value, off, to disable vet during test. By default only 100% reliable
checks are run, thus there is no way to run all vets. This change adds
another distinguished value, all, that runs every vet, by passing no
flags.

During development it was discovered that parsing of the -vet flag value
is problematic, in that it accepts deprecated flags like -all. The root
cause is detailed in #47309, but for now passing distinguished values
(all, off) and anything else returns an error.

Fixes #45963

Change-Id: I39fafb7d717dad51b507d560b3f6e604510a2881
Reviewed-on: https://go-review.googlesource.com/c/go/+/334873
Trust: Than McIntosh <thanm@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-08-17 21:25:51 +00:00
kezhao
ace1730a41 cmd/go: go test flag -failfast should be cacheable
Add failfast to cacheable list and update docs

Fixes #47355

Change-Id: I75b371c45b80a3b179ff070b7b9d092a504380c0
GitHub-Last-Rev: abe61fd48c
GitHub-Pull-Request: golang/go#47371
Reviewed-on: https://go-review.googlesource.com/c/go/+/337229
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-17 21:18:41 +00:00
Robert Griesemer
0f85b0c0e1 go/types: fix method lookup for type-parameter based types
This is a clean port of CL 342990.

Fixes #47747.

Change-Id: I2e86fb8b70d42a220ac1ba25798d9e58227ba5f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/342991
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-08-17 20:57:50 +00:00
Robert Griesemer
9d9e3291fa cmd/compile/internal/types2: fix method lookup for type-parameter based types
Pointers to type parameters don't have methods, but pointers to
defined types whose underlying types are type parameters may have
methods. Fix the respective test.

For #47747.

Change-Id: I1de47be094ed9297f0e7782538011657c37c5adc
Reviewed-on: https://go-review.googlesource.com/c/go/+/342990
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-08-17 20:57:49 +00:00
Leonard Wang
cf12b0d1f9 cmd/trace: use newTaskDesc to create taskDesc
Change-Id: I9bec8e2c4a9e1b9aa2baf883504200b5674844f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/335609
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Trust: Michael Pratt <mpratt@google.com>
2021-08-17 16:22:15 +00:00
Cherry Mui
3001b0abf0 cmd/link: remove elfwritedynentsym
elfwritedynentsym and elfWriteDynEntSym are identical.

Change-Id: I893a9a65fdc496f98ba6e66c2bf1ed8dd52f52fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/342709
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-08-17 15:00:04 +00:00
Yasuhiro Matsumoto
4012fea822 all: fix typos
Change-Id: I83180c472db8795803c1b9be3a33f35959e4dcc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/336889
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2021-08-17 13:54:10 +00:00
Dan Scales
b7b790a71a cmd/compile: fix CONVIFACE case converting interface to empty interface
We need an extra case in convertToDictionary. In the case of an operand
which is an interface and converting to an empty interface, we don't
want to get the run-time type from the dictionary (which would be the
run-time type of the interface). We want to do a type-assert to the
empty interface.

Change-Id: I414247210168153151272fab198bfe82ad7b1567
Reviewed-on: https://go-review.googlesource.com/c/go/+/342009
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-08-17 13:23:13 +00:00
Robert Griesemer
a304273d74 cmd/compile/internal/types2: allow composite literals of type parameter type
Change-Id: Iaaa2a3b462da6b121f13a10595950a8502b5f271
Reviewed-on: https://go-review.googlesource.com/c/go/+/342690
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-08-17 04:37:32 +00:00
wangyuntao
d3deb2c359 cmd/compile: fix typos
Change-Id: I88a3e69e232bf94296fe97621c5d395fc1296bbb
GitHub-Last-Rev: f1cc29dc28
GitHub-Pull-Request: golang/go#47482
Reviewed-on: https://go-review.googlesource.com/c/go/+/338751
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
2021-08-17 03:47:47 +00:00
Robert Findley
29ec74fb82 go/types: check if the interface is already complete in Complete
Once Interfaces have been completed they must never be written again,
as they may be used concurrently.

Avoid writing Interface.complete unnecessarily in Complete. Also, update
documentation to reflect that Complete must be called before the
Interface may be considered safe for concurrent use.

For #47726

Change-Id: Ic9fd1395ab0dd6d3499f7a698dadf315abcddab8
Reviewed-on: https://go-review.googlesource.com/c/go/+/342749
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-17 02:50:08 +00:00
Robert Findley
91a935ea0f Revert "go/types: make Interface.Complete a no-op"
This reverts commit fda8ee8b07.

Reason for revert: Interface.Complete is still necessary for safe concurrency.

For #47726

Change-Id: I8b924ca5f4af8c7d7e2b5a27bb03a5a5ed9b1d22
Reviewed-on: https://go-review.googlesource.com/c/go/+/342710
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-17 02:49:38 +00:00
Cuong Manh Le
a8d39f151d src: simplify race.bash checking condition
By using "uname -s -m" to get the OS name and hardware name,
then using it to match supported platform in case command.

Change-Id: I5161a29c6f3fe34dcda9e7bd477fa3b772b9e041
Reviewed-on: https://go-review.googlesource.com/c/go/+/320250
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-08-17 01:49:12 +00:00
Meng Zhuo
1951afc919 cmd/compile: lowered MulUintptr on riscv64
According to RISCV instruction set manual v2.2 Sec 6.1
MULHU followed by MUL will be fused into one multiply by microarchitecture

name              old time/op  new time/op  delta
MulUintptr/small  11.2ns ±24%   9.2ns ± 0%  -17.54%  (p=0.000 n=10+9)
MulUintptr/large  15.9ns ± 0%  10.9ns ± 0%  -31.55%  (p=0.000 n=8+8)

Change-Id: I3d152218f83948cbc5c576bda29dc86e9b4206ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/338753
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
2021-08-17 01:29:37 +00:00
Josh Bleecher Snyder
2a19333716 net: reduce allocations for UDP send/recv on Windows
This brings the optimizations added in CLs 331489 and 331490 to Windows.

Updates #43451

Change-Id: I75cf520050325d9eb5c2785d6d8677cc864fcac8
Reviewed-on: https://go-review.googlesource.com/c/go/+/331511
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-08-16 23:57:10 +00:00
Josh Bleecher Snyder
9c5eb16f6c net: reduce allocation size in ReadFromUDP
Switch to concrete types. Bring your own object to fill in.

Allocate just enough for the IP byte slice.
The allocation is now just 4 bytes for IPv4,
which puts it in the tiny allocator, which is much faster.

name                  old time/op    new time/op    delta
WriteToReadFromUDP-8    13.7µs ± 1%    13.4µs ± 2%   -2.49%  (p=0.000 n=10+10)

name                  old alloc/op   new alloc/op   delta
WriteToReadFromUDP-8     32.0B ± 0%      4.0B ± 0%  -87.50%  (p=0.000 n=10+10)

name                  old allocs/op  new allocs/op  delta
WriteToReadFromUDP-8      1.00 ± 0%      1.00 ± 0%     ~     (all equal)

Windows is temporarily stubbed out.

Updates #43451

Change-Id: Ief506f891b401d28715d22dce6ebda037941924e
Reviewed-on: https://go-review.googlesource.com/c/go/+/331490
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2021-08-16 23:57:02 +00:00
Josh Bleecher Snyder
d9349175ad net: remove allocation from UDPConn.WriteTo
Duplicate some code to avoid an interface.

name                  old time/op    new time/op    delta
WriteToReadFromUDP-8    6.38µs ±20%    5.59µs ±10%  -12.38%  (p=0.001 n=10+9)

name                  old alloc/op   new alloc/op   delta
WriteToReadFromUDP-8     64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.000 n=10+10)

name                  old allocs/op  new allocs/op  delta
WriteToReadFromUDP-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)

Windows is temporarily stubbed out.

Updates #43451

Change-Id: Ied15ff92268c652cf445836e0446025eaeb60cc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/331489
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-08-16 23:54:32 +00:00
Cherry Mui
8ff16c1990 runtime: accept restartable sequence pcdata values in isAsyncSafePoint
If the pcdata value indicates a restartable sequence, it is okay
to asynchronously preempt (and resume at the restart PC). Accept
it in isAsyncSafePoint.

Fixes #47530.

Change-Id: I419225717c8eee5812f3235338262da5895aad0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/340011
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Austin Clements <austin@google.com>
2021-08-16 23:32:14 +00:00
Hans
df9c5d8f5d cmd/cgo: fix unused parameter warnings in generated _cgo_main.c
Applying -Werror compiler option to request warnings is an usual
way to discover potential errors. Go user may put a cgo directive
in preamble: `// #cgo CFLAGS: -Werror=unused-parameter`.

However, the directive also takes effect on the cgo generated files.
I cleaned _cgo_main.c to help Go user only concentrate on warnings
of their own file.

Fixes #43639

Change-Id: I9112f02ae5226f2fc87a8650d19faee59cddd588
GitHub-Last-Rev: f09d172f97
GitHub-Pull-Request: golang/go#46358
Reviewed-on: https://go-review.googlesource.com/c/go/+/322232
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
2021-08-16 23:03:03 +00:00
Josh Bleecher Snyder
213e157d3a testing/fstest: allow specifying file for "." in MapFS
Prior to this commit, specifying a file for "." in MapFS
created an invalid fs.FS and caused infinite recursion in fs.WalkDir.

Fixes #46776

Change-Id: Ia9e4ae1125355a74dba9ee6b36451b7fda75a862
Reviewed-on: https://go-review.googlesource.com/c/go/+/328409
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-08-16 22:27:47 +00:00
Andy Pan
c04a32e59a net: avoid memory copy calling absDomainName
Change-Id: I8ea9bec8bc33e29b8c265fbca40871bc23667144
Reviewed-on: https://go-review.googlesource.com/c/go/+/330470
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-16 21:38:38 +00:00
Tobias Klauser
6406227d71 runtime: skip sysmon workaround on NetBSD >= 9.2
Detect the NetBSD version in osinit and only enable the workaround for
the kernel bug identified in #42515 for NetBSD versions older than 9.2.

For #42515
For #46495

Change-Id: I808846c7f8e47e5f7cc0a2f869246f4bd90d8e22
Reviewed-on: https://go-review.googlesource.com/c/go/+/324472
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-16 21:24:44 +00:00
Jay Conrod
a05a7d49a9 cmd/go: address code review comments in test cgo_path_space_quote
For CL 334732.

Change-Id: I5cb88cd7d5e4edf6006bbaeb17723dac2cdf0fd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/339590
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>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341938
2021-08-16 20:23:26 +00:00
Jay Conrod
54ce8793a8 cmd: update x/tools and remove copy of txtar
golang.org/x/tools/txtar is the main location for this package. We
don't need our own copy.

For golang/go#47193

Change-Id: I480eb591f57a0d05b433a657653e2021e39354eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/337352
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>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341937
2021-08-16 20:23:19 +00:00
Jay Conrod
742dcba7bb cmd: support space and quotes in CC and CXX
The CC and CXX environment variables now support spaces and quotes
(both double and single). This fixes two issues: first, if CC is a
single path that contains spaces (like 'c:\Program
Files\gcc\bin\gcc.exe'), that should now work if the space is quoted
or escaped (#41400). Second, if CC or CXX has multiple arguments (like
'gcc -O2'), they are now split correctly, and the arguments are passed
before other arguments when invoking the C compiler. Previously,
strings.Fields was used to split arguments, and the arguments were
placed later in the command line. (#43078).

Fixes golang/go#41400
Fixes golang/go#43078

NOTE: This change also includes a fix (CL 341929) for a test that was
broken by the original CL. Commit message for the fix is below.

[dev.cmdgo] cmd/link: fix TestBuildForTvOS

This test was broken in CL 334732 on darwin.

The test invokes 'go build' with a CC containing the arguments
-framework CoreFoundation. Previously, the go command split CC on
whitespace, and inserted the arguments after the command line when
running CC directly. Those arguments weren't passed to cgo though,
so cgo ran CC without -framework CoreFoundation (or any of the other
flags).

In CL 334732, we pass CC through to cgo, and cgo splits arguments
using str.SplitQuotedFields. So -framework CoreFoundation actually
gets passed to the C compiler. It appears that -framework flags are
only meant to be used in linking operations, so when cgo invokes clang
with -E (run preprocessor only), clang emits an error that -framework
is unused.

This change fixes the test by moving -framework CoreFoundation out of
CC and into CGO_LDFLAGS.

Change-Id: I2d5d89ddb19c94adef65982a8137b01f037d5c11
Reviewed-on: https://go-review.googlesource.com/c/go/+/334732
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341936
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-08-16 20:23:11 +00:00
Jay Conrod
41d991e4e1 cmd/internal/str: add utilities for quoting and splitting args
JoinAndQuoteFields does the inverse of SplitQuotedFields: it joins a
list of arguments with spaces into one string, quoting arguments that
contain spaces or quotes.

QuotedStringListFlag uses SplitQuotedFields and JoinAndQuoteFields
together to define new flags that accept lists of arguments.

For golang/go#41400

Change-Id: I4986b753cb5e6fabb5b489bf26aedab889f853f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/334731
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341935
2021-08-16 20:23:03 +00:00
180909
4466141822 cmd/go: add document -json in testflag
Fixes #47628

Change-Id: I2776fbc22d8a73ca7adc2cf7ad85669d57cc7eae
GitHub-Last-Rev: 826907b079
GitHub-Pull-Request: golang/go#47683
Reviewed-on: https://go-review.googlesource.com/c/go/+/341991
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-08-16 20:22:08 +00:00
Jay Conrod
8d2066177d cmd/go/internal/modfetch/codehost: refactor gitRepo.loadRefs to be harder to misuse
Previously, callers of loadRefs were expected to always
call via gitRepo.refsOnce.Do and check r.refsErr. This hasn't always
been the case.

This change makes loadRefs cache its own result with r.refsOnce and
return refs and refsErr. Callers can use it more like a normal
function.

CL 297950 is related. Previously, a commit like 0123456789ab could be
resolved to a v0.0.0 pseudo-version when tags couldn't be fetched, but
a shorter commit like 0123456 or a branch name like "master" couldn't
be resolved the same way. With this change, tags must be fetched
successfully ('git ls-remote' must succeed).

For #42751

Change-Id: I49c9346e6c72609ee4f8b10cfe1f69781e78457e
Reviewed-on: https://go-review.googlesource.com/c/go/+/338191
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-08-16 20:21:13 +00:00
Damien Neil
ec27168712 net/http: drop headers with invalid keys in Header.Write
Don't let handlers inject unexpected headers by setting keys like:
	w.Header().Set("Evil: x\r\nSmuggle", y)

Fixes #47711.

Change-Id: I459ce1c79bc273a84230a0f5b665f81c46dbc672
Reviewed-on: https://go-review.googlesource.com/c/go/+/342530
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-16 20:02:13 +00:00
Robert Findley
d35035f84e go/types: use the orig object for Named.Obj
This is a port of CL 341858 to go/types.

Change-Id: I9fba8941069aaacd641a19e3068de3a769e14e50
Reviewed-on: https://go-review.googlesource.com/c/go/+/342482
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-16 18:52:20 +00:00