]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agotext/template: only unwrap final and/or value
Ian Lance Taylor [Tue, 5 Oct 2021 18:41:40 +0000 (11:41 -0700)]
text/template: only unwrap final and/or value

In the last CL I missed the fact that except for the final value the
code already unwraps the argument.

For #31103

Change-Id: Ic9099aeb50c6b3322fc14a90ac8026c1d8cb1698
Reviewed-on: https://go-review.googlesource.com/c/go/+/354091
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile: fix problem with methods of instantiated types which are nointerface
Dan Scales [Thu, 30 Sep 2021 00:47:19 +0000 (17:47 -0700)]
cmd/compile: fix problem with methods of instantiated types which are nointerface

In the case of a nointerface method on an instantiated type, we still
have to call methodWrapper, because methodWrapper generates the actual
generic method on the type as well. Currently, we don't call
methodWrapper, so the method on the instantiated type never gets filled
in.

Adjusted the code to still call methodWrapper, but not use the result,
in the case of a nointerface method on an instantiated type.

Change-Id: I34bca58de2861aa772be04eb8dd7695c5b7f3a77
Reviewed-on: https://go-review.googlesource.com/c/go/+/353369
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>

3 years agotest: add test for export/import of recover & defer
Dan Scales [Mon, 4 Oct 2021 23:15:17 +0000 (16:15 -0700)]
test: add test for export/import of recover & defer

Add a simple test with an exported generic function that does
recover/defer, to test that recover/defer are exported/imported
properly (and a generic function with recover/defer works fine).

Change-Id: Idc3af101cbb78fc96bf945f1f5eab2740dd8994b
Reviewed-on: https://go-review.googlesource.com/c/go/+/353883
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>

3 years agocmd/go: do not check for a built binary in TestScript/mod_get_fossil
Bryan C. Mills [Tue, 5 Oct 2021 20:11:17 +0000 (16:11 -0400)]
cmd/go: do not check for a built binary in TestScript/mod_get_fossil

This test hasn't passed since CL 349997, but the failure was not
detected because the Go project's builders do not have a 'fossil'
binary installed (#48802).

For #43684

Change-Id: I25544574ab48f4f146ae3795e541179e78815758
Reviewed-on: https://go-review.googlesource.com/c/go/+/354149
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoRevert "runtime: use unsafe.Slice in getStackMap"
Josh Bleecher Snyder [Tue, 5 Oct 2021 18:31:57 +0000 (11:31 -0700)]
Revert "runtime: use unsafe.Slice in getStackMap"

This reverts commit golang.org/cl/352953.

Reason for revert: unsafe.Slice is considerably slower.
Part of this is extra safety checks (good), but most of it
is the function call overhead. We should consider open-coding it (#48798).

Impact of this change:

name                   old time/op  new time/op  delta
StackCopyWithStkobj-8  12.1ms ± 5%  11.6ms ± 3%  -4.03%  (p=0.009 n=10+8)

Change-Id: Ib2448e3edac25afd8fb55ffbea073b8b11521bde
Reviewed-on: https://go-review.googlesource.com/c/go/+/354090
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agoruntime: remove a branch from funcdata
Josh Bleecher Snyder [Tue, 5 Oct 2021 17:21:54 +0000 (10:21 -0700)]
runtime: remove a branch from funcdata

name                   old time/op  new time/op  delta
StackCopyWithStkobj-8  12.1ms ± 7%  11.6ms ± 8%  -3.88%  (p=0.002 n=19+19)

Change-Id: Idf810017d541eba70bcf9c736267de9efae916d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/354072
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: add BenchmarkStackCopyWithStkobj
Josh Bleecher Snyder [Tue, 5 Oct 2021 16:40:15 +0000 (09:40 -0700)]
runtime: add BenchmarkStackCopyWithStkobj

For benchmarking and improving recent stkobj-related changes.

Co-Authored-By: Cherry Mui <cherryyz@google.com>
Change-Id: I34c8b1a09e4cf98547460882b0d3908158269f57
Reviewed-on: https://go-review.googlesource.com/c/go/+/354071
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agotesting: document f.Fuzz requirement to not change underlying data
Katie Hockman [Tue, 5 Oct 2021 17:05:09 +0000 (13:05 -0400)]
testing: document f.Fuzz requirement to not change underlying data

Updates #48606

Change-Id: I6d555fdefccd842fb65ec8d630b4808bcb54a825
Reviewed-on: https://go-review.googlesource.com/c/go/+/353977
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agogo/types: implement generic slice expressions
Robert Griesemer [Tue, 5 Oct 2021 18:45:22 +0000 (11:45 -0700)]
go/types: implement generic slice expressions

This is a clean port of CL 354070 from types2 to go/types.

Change-Id: I44de1b8e6c0177e2a33e7f36a82465dc520c35aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/354092
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: make stkobj symbols content-addressable
Josh Bleecher Snyder [Mon, 4 Oct 2021 22:51:22 +0000 (15:51 -0700)]
cmd/compile: make stkobj symbols content-addressable

Shrinks binaries a little bit.

size    before    after     Δ       %
api     4892370   4875858   -16512  -0.338%
asm     4711218   4694706   -16512  -0.350%
cgo     4164770   4148258   -16512  -0.396%
compile 21875922  21826386  -49536  -0.226%
cover   4358370   4341858   -16512  -0.379%
doc     3532562   3516050   -16512  -0.467%
link    6110786   6094274   -16512  -0.270%
objdump 3982914   3966402   -16512  -0.415%
pprof   12869986  12836962  -33024  -0.257%
trace   9614626   9598114   -16512  -0.172%
vet     6580322   6563810   -16512  -0.251%
total   102897284 102666116 -231168 -0.225%

Change-Id: Idf4ba3c05e35ec1d1ae957d6ded00ae79cc0fd2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/172198
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/link,runtime: remove relocations from stkobjs
Josh Bleecher Snyder [Mon, 27 Sep 2021 21:27:20 +0000 (14:27 -0700)]
cmd/link,runtime: remove relocations from stkobjs

Use an offset from go.func.* instead.
This removes the last relocation from funcdata symbols,
which lets us simplify that code.

size      before    after     Δ       %
addr2line 3683218   3680706   -2512   -0.068%
api       4951074   4944850   -6224   -0.126%
asm       4744258   4757586   +13328  +0.281%
buildid   2419986   2418546   -1440   -0.060%
cgo       4218306   4197346   -20960  -0.497%
compile   22132066  22076882  -55184  -0.249%
cover     4432834   4411362   -21472  -0.484%
dist      3111202   3091346   -19856  -0.638%
doc       3583602   3563234   -20368  -0.568%
fix       3023922   3020658   -3264   -0.108%
link      6188034   6164642   -23392  -0.378%
nm        3665826   3646818   -19008  -0.519%
objdump   4015234   4012450   -2784   -0.069%
pack      2155010   2153554   -1456   -0.068%
pprof     13044178  13011522  -32656  -0.250%
test2json 2402146   2383906   -18240  -0.759%
trace     9765410   9736514   -28896  -0.296%
vet       6681250   6655058   -26192  -0.392%
total     104217556 103926980 -290576 -0.279%

relocs    before  after   Δ       %
addr2line 25563   25066   -497    -1.944%
api       18409   17176   -1233   -6.698%
asm       18903   18271   -632    -3.343%
buildid   9513    9233    -280    -2.943%
cgo       17103   16222   -881    -5.151%
compile   64825   60421   -4404   -6.794%
cover     19464   18479   -985    -5.061%
dist      10798   10135   -663    -6.140%
doc       13503   12735   -768    -5.688%
fix       11465   10820   -645    -5.626%
link      23214   21849   -1365   -5.880%
nm        25480   24987   -493    -1.935%
objdump   26610   26057   -553    -2.078%
pack      7951    7665    -286    -3.597%
pprof     63964   60761   -3203   -5.008%
test2json 8735    8389    -346    -3.961%
trace     39639   37180   -2459   -6.203%
vet       25970   24044   -1926   -7.416%
total     431108  409489  -21619  -5.015%

Change-Id: I43c26196a008da6d1cb3a782eea2f428778bd569
Reviewed-on: https://go-review.googlesource.com/c/go/+/353138
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agointernal/buildcfg: enable register ABI for PPC64
Lynn Boger [Mon, 4 Oct 2021 17:13:41 +0000 (12:13 -0500)]
internal/buildcfg: enable register ABI for PPC64

This enables the new register ABI for all PPC64 targets
by default including linux/ppc64, linux/ppc64le, and aix/ppc64.

Improvements with the new register ABI on a power9:

name old time/op (ns/op) new time/op (ns/op) delta
BinaryTree17     3882070000 3274900000 -15.64%
Fannkuch11         3787620000 3614740000 -4.56%
FmtFprintfEmpty         58.705         51.1875  -12.81%
FmtFprintfString 101.675         94.4725  -7.08%
FmtFprintfInt         112.725  104.075  -7.67%
FmtFprintfIntInt 166.475  158.05   -5.06%
FmtFprintfPrefixedInt 183.7         178.975  -2.57%
FmtFprintfFloat         246.55         258.8         +4.97%
FmtManyArgs         648.325  665.875  +2.71%
GobDecode         8004660         6802210  -15.02%
GobEncode        7289780  5675710  -22.14%
Gzip             326931000 323586000 -1.02%
Gunzip           47544700 37808000 -20.48%
HTTPClientServer     46927.2  42357.8  -9.74%
JSONEncode         12098300 9621450         -20.47%
JSONDecode       62305300 55410200 -11.07%
Mandelbrot200         5841540  5934590  +1.59%
GoParse          5594880  4003360  -28.45%
RegexpMatchEasy0_32 96.185         89.6325  -6.81%
RegexpMatchEasy0_1K 255.775  210.45   -17.72%
RegexpMatchEasy1_32 102.95   93.8825  -8.81%
RegexpMatchEasy1_1K 511.65   385.075  -24.74%
RegexpMatchMedium_32 1414.75  1236.75  -12.58%
RegexpMatchMedium_1K 42114.5  37022.5  -12.09%
RegexpMatchHard_32 2110.5   1901.5   -9.90%
RegexpMatchHard_1K 63559.5  59494    -6.40%
Revcomp          532981000 480640000 -9.82%
Template         81903600 65743300 -19.73%
TimeParse        310.75         276.525  -11.01%
TimeFormat         483.4    355.475   -26.46%

Change-Id: Ib7c5dfe8ddc2f17050943912048f55667dabde39
Reviewed-on: https://go-review.googlesource.com/c/go/+/353969
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile/internal/types2: implement generic slice expressions
Robert Griesemer [Tue, 5 Oct 2021 17:29:21 +0000 (10:29 -0700)]
cmd/compile/internal/types2: implement generic slice expressions

For now, the constraint's underlying type set must be a single
type that is sliceable.

Change-Id: I08b6a2e88fe35e8238a95b3f40dc969689021a0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/354070
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: don't emit unnecessary amd64 extension checks
nimelehin [Wed, 15 Sep 2021 07:31:05 +0000 (10:31 +0300)]
cmd/compile: don't emit unnecessary amd64 extension checks

In case of amd64 the compiler issues checks if extensions are
available on a platform. With GOAMD64 microarchitecture levels
provided, some of the checks could be eliminated.

Change-Id: If15c178bcae273b2ce7d3673415cb8849292e087
Reviewed-on: https://go-review.googlesource.com/c/go/+/352010
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: add remaining >v1 instructions to v1-only test
Keith Randall [Tue, 5 Oct 2021 17:21:09 +0000 (10:21 -0700)]
cmd/compile: add remaining >v1 instructions to v1-only test

roundsd and FMA (vfmadd231sd).

Change-Id: I2d91332667e577bd9bb903ac58904f62b8454128
Reviewed-on: https://go-review.googlesource.com/c/go/+/354069
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/compile/internal/types2: update the recorded function type after inference
Robert Griesemer [Tue, 5 Oct 2021 00:44:56 +0000 (17:44 -0700)]
cmd/compile/internal/types2: update the recorded function type after inference

This is a clean port of CL 353831 from go/types to types2.

For #47916.

Change-Id: I2c2b9c7bbcd416fb21f3032c55a06406bad9334a
Reviewed-on: https://go-review.googlesource.com/c/go/+/353934
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>
3 years agocmd/compile: test to ensure we guard GOAMD64>v1 instructions
Keith Randall [Tue, 28 Sep 2021 20:23:08 +0000 (13:23 -0700)]
cmd/compile: test to ensure we guard GOAMD64>v1 instructions

When compiling with GOAMD64=v1, clobber all the >v1 instructions
with faulting instructions. Run the binary with the corresponding
feature flags off. We shouldn't try to execute any of the clobbered
instructions.

Change-Id: I295acaf9fd0eafd037192aa6f933365c794cc76e
Reviewed-on: https://go-review.googlesource.com/c/go/+/352831
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/compile: use TZCNT instruction for GOAMD64>=v3
wdvxdr [Thu, 30 Sep 2021 01:57:04 +0000 (09:57 +0800)]
cmd/compile: use TZCNT instruction for GOAMD64>=v3

on my Intel CoffeeLake CPU:
name               old time/op  new time/op  delta
TrailingZeros-8    0.68ns ± 1%  0.64ns ± 1%  -6.26%  (p=0.000 n=10+10)
TrailingZeros8-8   0.70ns ± 1%  0.70ns ± 1%    ~     (p=0.697 n=10+10)
TrailingZeros16-8  0.70ns ± 1%  0.70ns ± 1%  +0.57%  (p=0.043 n=10+10)
TrailingZeros32-8  0.66ns ± 1%  0.64ns ± 1%  -3.35%  (p=0.000 n=10+10)
TrailingZeros64-8  0.68ns ± 1%  0.64ns ± 1%  -5.84%  (p=0.000 n=9+10)

Updates #45453

Change-Id: I228ff2d51df24b1306136f061432f8a12bb1d6fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/353249
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/link: mangle function name with ABI on XCOFF
Cherry Mui [Tue, 5 Oct 2021 14:48:24 +0000 (10:48 -0400)]
cmd/link: mangle function name with ABI on XCOFF

This is like CL 304432 and CL 307229, for XCOFF.

With this, GOEXPERIMENT=regabi works on AIX/PPC64.

Change-Id: I8cf00681df5c93f397913febd78f38099d91e7c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/353972
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>
3 years agocmd/link, runtime: convert FUNCDATA relocations to offsets
Josh Bleecher Snyder [Fri, 1 Oct 2021 23:35:43 +0000 (16:35 -0700)]
cmd/link, runtime: convert FUNCDATA relocations to offsets

Every function has associated numbered extra funcdata to another symbol.
Prior to this change, a funcdata pointer was stored as a relocation.

This change alters this to be an offset relative to go.func.* or go.funcrel.*.

This reduces the number of relocations on darwin/arm64 by about 40%.
It also shrinks externally linked binaries. On darwin/arm64:

size      before    after     Δ        %
addr2line 3788498   3699730   -88768   -2.343%
api       5100018   4951074   -148944  -2.920%
asm       4855234   4744274   -110960  -2.285%
buildid   2500162   2419986   -80176   -3.207%
cgo       4338258   4218306   -119952  -2.765%
compile   22764418  22132226  -632192  -2.777%
cover     4583186   4432770   -150416  -3.282%
dist      3200962   3094626   -106336  -3.322%
doc       3680402   3583602   -96800   -2.630%
fix       3114914   3023922   -90992   -2.921%
link      6308578   6154786   -153792  -2.438%
nm        3754338   3665826   -88512   -2.358%
objdump   4124738   4015234   -109504  -2.655%
pack      2232626   2155010   -77616   -3.476%
pprof     13497474  13044066  -453408  -3.359%
test2json 2483810   2402146   -81664   -3.288%
trace     10108898  9748802   -360096  -3.562%
vet       6884322   6681314   -203008  -2.949%
total     107320836 104167700 -3153136 -2.938%

relocs    before  after   Δ       %
addr2line 33357   25563   -7794   -23.365%
api       31589   18409   -13180  -41.723%
asm       27825   18904   -8921   -32.061%
buildid   15603   9513    -6090   -39.031%
cgo       27809   17103   -10706  -38.498%
compile   114769  64829   -49940  -43.513%
cover     32932   19462   -13470  -40.902%
dist      18797   10796   -8001   -42.565%
doc       22891   13503   -9388   -41.012%
fix       19700   11465   -8235   -41.802%
link      37324   23198   -14126  -37.847%
nm        33226   25480   -7746   -23.313%
objdump   35237   26610   -8627   -24.483%
pack      13535   7951    -5584   -41.256%
pprof     97986   63961   -34025  -34.724%
test2json 15113   8735    -6378   -42.202%
trace     66786   39636   -27150  -40.652%
vet       43328   25971   -17357  -40.060%
total     687806  431088  -256718 -37.324%

It should also incrementally speed up binary launching
and may reduce linker memory use.

This is another step towards removing relocations so
that pages that were previously dirtied by the loader may remain clean,
which will offer memory savings useful in constrained environments like iOS.

Removing the relocations in .stkobj symbols will allow some simplifications.
There will be no references into go.funcrel.*,
so we will no longer need to use the bottom bit to distinguish offset bases.

Change-Id: I83d34c1701d6f3f515b9905941477d522441019d
Reviewed-on: https://go-review.googlesource.com/c/go/+/352110
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/link: move all FUNCDATA refs into go.func.*
Josh Bleecher Snyder [Fri, 24 Sep 2021 20:50:22 +0000 (13:50 -0700)]
cmd/link: move all FUNCDATA refs into go.func.*

This change moves all symbols referred to by FUNCDATA
into go.func.* and go.funcrel.*.

Surprisingly (because it inhibits some content-addressability),
it shrinks binaries by a little bit, about 0.1%.

This paves the way for a subsequent change to change
FUNCDATA relocations to offsets.

Change-Id: I70e487205073699f442192b0791cc92da5663057
Reviewed-on: https://go-review.googlesource.com/c/go/+/352189
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: add ABIInternal to strhash and memhash on ppc64x
Lynn Boger [Mon, 4 Oct 2021 21:27:56 +0000 (16:27 -0500)]
runtime: add ABIInternal to strhash and memhash on ppc64x

In testing the register ABI changes I found that the benchmarks
for strhash and memhash degraded unless I marked them as
ABIInternal. This fixes that.

Change-Id: I9c7a04eaa6a66b888877f43454c51277c07e638a
Reviewed-on: https://go-review.googlesource.com/c/go/+/353832
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

3 years agocrypto/rand: document additional getrandom/getentropy support in Reader
Tobias Klauser [Mon, 4 Oct 2021 21:55:52 +0000 (23:55 +0200)]
crypto/rand: document additional getrandom/getentropy support in Reader

CL 269999 added support for getrandom on Dragonfly.
CL 299134 added support for getrandom on Solaris.
CL 302489 added support for getentropy on macOS.

Update the godoc for Reader accordingly.

Change-Id: Ice39e5e62f052f21b664db6abbfd97f03944586e
Reviewed-on: https://go-review.googlesource.com/c/go/+/353190
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/go: enable test build concurrent backend on darwin/arm64
Cuong Manh Le [Tue, 5 Oct 2021 00:42:48 +0000 (07:42 +0700)]
cmd/go: enable test build concurrent backend on darwin/arm64

After CL 353871, darwin/arm64 now do concurrent build, so enable the
test for it.

Updates #48490

Change-Id: I29336f6fc7d7d2f463d8ad2a620534bd7f048d2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/353949
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: Bryan C. Mills <bcmills@google.com>
3 years agocmd/dist: omit cmd/cgo from toolchain1
Matthew Dempsky [Mon, 4 Oct 2021 23:42:13 +0000 (16:42 -0700)]
cmd/dist: omit cmd/cgo from toolchain1

We don't need cmd/cgo for building go_bootstrap or toolchain2, so skip
building it as part of toolchain1.

This allows cmd/cgo to assume a current go/ast; e.g., that
ast.IndexListExpr exists (needed for next CL).

Change-Id: I642bba780bf273e6ea9c6e7c5d5d7ccfe86bf462
Reviewed-on: https://go-review.googlesource.com/c/go/+/353884
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/internal/obj: reduce alignment for gcbits
Cherry Mui [Fri, 1 Oct 2021 21:02:50 +0000 (17:02 -0400)]
cmd/internal/obj: reduce alignment for gcbits

runtime.gcbits symbols are pointer masks, which are just bytes.

Change-Id: I6e86359451c7da69da435e1928e55712dd904047
Reviewed-on: https://go-review.googlesource.com/c/go/+/353571
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>
3 years agodebug/gosym: add funcTab abstraction
Josh Bleecher Snyder [Mon, 4 Oct 2021 21:49:42 +0000 (14:49 -0700)]
debug/gosym: add funcTab abstraction

This clarifies the existing code and makes modifications easier.

name            old time/op    new time/op    delta
115/LineToPC-8    58.6µs ± 3%    56.4µs ± 3%  -3.80%  (p=0.000 n=15+15)
115/PCToLine-8     194ns ± 2%     188ns ± 2%  -3.31%  (p=0.000 n=15+15)

Change-Id: Iafdf57af93d5e3c145965c32e0227e37c69ab017
Reviewed-on: https://go-review.googlesource.com/c/go/+/353880
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agodebug/gosym: use sort.Search in findFunc
Josh Bleecher Snyder [Mon, 4 Oct 2021 21:08:05 +0000 (14:08 -0700)]
debug/gosym: use sort.Search in findFunc

Use sort.Search instead of open-coding the binary search.
This makes the code a lot easier to work on.

As a bonus, it speeds it up.

name            old time/op    new time/op    delta
115/LineToPC-8    57.4µs ± 5%    59.2µs ± 8%   +3.19%  (p=0.003 n=15+13)
115/PCToLine-8     255ns ± 1%     192ns ± 3%  -24.63%  (p=0.000 n=15+15)

Change-Id: I41da18bfb0e745c40d24e5b96e50dfdd0c3b79f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/353879
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agocmd/objdump: print full disassembly when testing with -v
Josh Bleecher Snyder [Mon, 4 Oct 2021 21:06:37 +0000 (14:06 -0700)]
cmd/objdump: print full disassembly when testing with -v

It is helpful for debugging.

Change-Id: Idd566d312037420f8341fcf502a45410a8497798
Reviewed-on: https://go-review.googlesource.com/c/go/+/353878
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agocmd/internal/obj, cmd/link: move symbol alignment logic to object file writer
Cherry Mui [Fri, 1 Oct 2021 16:21:36 +0000 (12:21 -0400)]
cmd/internal/obj, cmd/link: move symbol alignment logic to object file writer

Change-Id: I827a9702dfa01b712b88331668434f8db94df249
Reviewed-on: https://go-review.googlesource.com/c/go/+/353569
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>
3 years agocmd, runtime: eliminate runtime.no_pointers_stackmap
Josh Bleecher Snyder [Fri, 1 Oct 2021 23:25:32 +0000 (16:25 -0700)]
cmd, runtime: eliminate runtime.no_pointers_stackmap

runtime.no_pointers_stackmap is an odd beast.
It is defined in a Go file, populated by assembly,
used by the GC, and its address is magic used
by async pre-emption to ascertain whether a
routine was implemented in assembly.

A subsequent change will force all GC data into the go.func.* linker symbol.
runtime.no_pointers_stackmap is GC data, so it must go there.
Yet it also needs to go into rodata, for the runtime address trick.

This change eliminates it entirely.

Replace the runtime address check with the newly introduced asm funcflag.

Handle the assembly macro as magic, similarly to our handling of go_args_stackmap.
This allows the no_pointers_stackmap to be identical in all ways
to other gclocals stackmaps, including content-addressability.

Change-Id: Id2f20a262cfab0719beb88e6342984ec4b196268
Reviewed-on: https://go-review.googlesource.com/c/go/+/353672
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile: refactor gclocals sym creation
Josh Bleecher Snyder [Fri, 1 Oct 2021 22:39:21 +0000 (15:39 -0700)]
cmd/compile: refactor gclocals sym creation

It'll be used in second place in a subsequent change.
No functional changes.

Change-Id: I58dd12d7dde45b36995d031fc7fbb27d6eaf48d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/353670
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
3 years agocmd, runtime: mark assembly routines in FuncFlags
Josh Bleecher Snyder [Fri, 1 Oct 2021 23:19:27 +0000 (16:19 -0700)]
cmd, runtime: mark assembly routines in FuncFlags

There's no good way to ascertain at runtime whether
a function was implemented in assembly.
The existing workaround doesn't play nicely
with some upcoming linker changes.

This change introduces an explicit marker for routines
implemented in assembly.

This change doesn't use the new bit anywhere,
it only introduces it.

Change-Id: I4051dc0afc15b260724a04b9d18aeeb94911bb29
Reviewed-on: https://go-review.googlesource.com/c/go/+/353671
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoRevert "runtime: add padding to Linux kernel structures"
Michael Pratt [Mon, 4 Oct 2021 21:44:08 +0000 (21:44 +0000)]
Revert "runtime: add padding to Linux kernel structures"

This reverts commit f0db7eae74ea235e9fbc2598252bfd46c1cc5510.

Reason for revert: Breaks linux-386 tests

Change-Id: Ia51fbf97460ab52920b67d6db6177ac2d6b0058e
Reviewed-on: https://go-review.googlesource.com/c/go/+/353432
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile: set opendefer info symbol as content-addressable
Cherry Mui [Mon, 4 Oct 2021 16:51:06 +0000 (12:51 -0400)]
cmd/compile: set opendefer info symbol as content-addressable

Also move the logic of setting arginfo symbols content-addressable
to the place of symbol creation.

Change-Id: Ia5c3d77b1cec988c42c84d573170120948575c07
Reviewed-on: https://go-review.googlesource.com/c/go/+/353830
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>
3 years agocmd/compile: intrinsify publicationBarrier
Ruslan Andreev [Fri, 11 Jun 2021 09:27:09 +0000 (09:27 +0000)]
cmd/compile: intrinsify publicationBarrier

This CL intrinsify asm call for publicationBarrier on ARM64. As for x86
we may completly removes any instructions due to strong memory
oredering, but decided to leave it as is for compiler barrier.

Benchmarks Go1 ARM64:
name                     old time/op    new time/op    delta
BinaryTree17-8              3.38s ± 1%     3.36s ± 1%    ~     (p=0.095 n=5+5)
Fannkuch11-8                2.93s ± 0%     2.84s ± 0%  -3.26%  (p=0.008 n=5+5)
FmtFprintfEmpty-8          54.2ns ± 1%    54.0ns ± 1%    ~     (p=0.690 n=5+5)
FmtFprintfString-8          111ns ± 0%     109ns ± 0%  -1.48%  (p=0.008 n=5+5)
FmtFprintfInt-8             140ns ± 0%     138ns ± 0%  -1.10%  (p=0.000 n=4+5)
FmtFprintfIntInt-8          168ns ± 0%     169ns ± 0%  +0.66%  (p=0.008 n=5+5)
FmtFprintfPrefixedInt-8     206ns ± 1%     195ns ± 0%  -5.12%  (p=0.008 n=5+5)
FmtFprintfFloat-8           270ns ± 0%     269ns ± 0%  -0.20%  (p=0.024 n=5+5)
FmtManyArgs-8               721ns ± 0%     733ns ± 0%  +1.69%  (p=0.008 n=5+5)
GobDecode-8                9.75ms ± 1%    9.28ms ± 3%  -4.88%  (p=0.008 n=5+5)
GobEncode-8                6.38ms ± 1%    6.34ms ± 1%    ~     (p=0.095 n=5+5)
Gzip-8                      255ms ± 0%     254ms ± 0%  -0.44%  (p=0.008 n=5+5)
Gunzip-8                   41.8ms ± 1%    40.8ms ± 0%  -2.40%  (p=0.008 n=5+5)
HTTPClientServer-8         65.1µs ± 1%    65.1µs ± 1%    ~     (p=0.690 n=5+5)
JSONEncode-8               11.7ms ± 0%    11.7ms ± 1%    ~     (p=0.841 n=5+5)
JSONDecode-8               60.2ms ± 1%    60.0ms ± 0%    ~     (p=0.841 n=5+5)
Mandelbrot200-8            5.85ms ± 0%    5.86ms ± 0%  +0.22%  (p=0.016 n=4+5)
GoParse-8                  4.38ms ± 0%    4.35ms ± 0%  -0.60%  (p=0.008 n=5+5)
RegexpMatchEasy0_32-8      87.1ns ± 2%    88.3ns ± 1%    ~     (p=0.151 n=5+5)
RegexpMatchEasy0_1K-8       306ns ± 0%     306ns ± 1%    ~     (p=0.143 n=5+5)
RegexpMatchEasy1_32-8      86.3ns ± 0%    84.8ns ± 0%  -1.81%  (p=0.008 n=5+5)
RegexpMatchEasy1_1K-8       491ns ± 2%     487ns ± 1%    ~     (p=0.548 n=5+5)
RegexpMatchMedium_32-8     7.50ns ± 0%    7.49ns ± 1%    ~     (p=0.817 n=5+5)
RegexpMatchMedium_1K-8     40.3µs ± 1%    39.9µs ± 0%  -1.02%  (p=0.008 n=5+5)
RegexpMatchHard_32-8       2.10µs ± 1%    2.10µs ± 1%    ~     (p=0.548 n=5+5)
RegexpMatchHard_1K-8       62.4µs ± 1%    62.5µs ± 2%    ~     (p=0.690 n=5+5)
Revcomp-8                   504ms ± 1%     502ms ± 1%    ~     (p=0.095 n=5+5)
Template-8                 86.8ms ± 1%    86.5ms ± 1%    ~     (p=0.222 n=5+5)
TimeParse-8                 330ns ± 0%     327ns ± 0%  -0.84%  (p=0.008 n=5+5)
TimeFormat-8                383ns ± 1%     392ns ± 1%  +2.42%  (p=0.008 n=5+5)
[Geo mean]                 54.3µs         53.9µs       -0.67%

name                     old speed      new speed      delta
GobDecode-8              78.7MB/s ± 1%  82.8MB/s ± 4%  +5.16%  (p=0.008 n=5+5)
GobEncode-8               120MB/s ± 1%   121MB/s ± 1%    ~     (p=0.095 n=5+5)
Gzip-8                   76.2MB/s ± 0%  76.5MB/s ± 0%  +0.44%  (p=0.008 n=5+5)
Gunzip-8                  464MB/s ± 1%   475MB/s ± 0%  +2.45%  (p=0.008 n=5+5)
JSONEncode-8              166MB/s ± 0%   166MB/s ± 1%    ~     (p=0.841 n=5+5)
JSONDecode-8             32.2MB/s ± 1%  32.3MB/s ± 0%    ~     (p=0.714 n=5+5)
GoParse-8                13.2MB/s ± 0%  13.3MB/s ± 0%  +0.59%  (p=0.008 n=5+5)
RegexpMatchEasy0_32-8     368MB/s ± 2%   362MB/s ± 1%    ~     (p=0.151 n=5+5)
RegexpMatchEasy0_1K-8    3.34GB/s ± 0%  3.34GB/s ± 1%    ~     (p=0.127 n=5+5)
RegexpMatchEasy1_32-8     371MB/s ± 0%   378MB/s ± 0%  +1.84%  (p=0.008 n=5+5)
RegexpMatchEasy1_1K-8    2.09GB/s ± 2%  2.10GB/s ± 1%    ~     (p=0.548 n=5+5)
RegexpMatchMedium_32-8    133MB/s ± 0%   134MB/s ± 1%    ~     (p=0.952 n=5+5)
RegexpMatchMedium_1K-8   25.4MB/s ± 1%  25.6MB/s ± 0%  +1.04%  (p=0.008 n=5+5)
RegexpMatchHard_32-8     15.3MB/s ± 1%  15.2MB/s ± 1%    ~     (p=0.500 n=5+5)
RegexpMatchHard_1K-8     16.4MB/s ± 1%  16.4MB/s ± 2%    ~     (p=0.595 n=5+5)
Revcomp-8                 504MB/s ± 1%   506MB/s ± 1%    ~     (p=0.095 n=5+5)
Template-8               22.4MB/s ± 1%  22.4MB/s ± 1%    ~     (p=0.206 n=5+5)
[Geo mean]                120MB/s        121MB/s       +0.71%

Change-Id: I9cc10840b5c0d6bf759150f052c79f4c499e35e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/328290
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: David Chase <drchase@google.com>

3 years agogo/types: update the recorded function type after inference
Robert Findley [Mon, 4 Oct 2021 18:17:50 +0000 (14:17 -0400)]
go/types: update the recorded function type after inference

This change preserves the observable invariant that for an *ast.CallExpr
'call', Info.Types[call.Fun] is the signature being called.

Updates #47916

Change-Id: I3e97c712a7ee33a4f29e8cf4c18dc7c946b66cc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/353831
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>
3 years agoruntime: add padding to Linux kernel structures
Rhys Hiltner [Thu, 30 Sep 2021 00:35:27 +0000 (17:35 -0700)]
runtime: add padding to Linux kernel structures

Go exchanges siginfo and sigevent structures with the kernel. They
contain unions, but Go's use is limited to the first few fields. Pad out
the rest so the size Go sees is the same as what the Linux kernel sees.

This is a follow-up to CL 342052 which added the sigevent struct without
padding. It updates the siginfo struct as well so there are no bad
examples in the defs_linux_*.go files.

Change-Id: Id991d4a57826677dd7e6cc30ad113fa3b321cddf
Reviewed-on: https://go-review.googlesource.com/c/go/+/353136
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agointernal/fuzz: print size of interesting cache
Amelia Downs [Thu, 30 Sep 2021 15:35:30 +0000 (11:35 -0400)]
internal/fuzz: print size of interesting cache

This change updates the log lines to clarify that the printed
interesting count is only for newly discovered cache entries, and prints
the total cache size. It only prints information about interesting
entries when coverageEnabled is true.

Fixes #48669

Change-Id: I2045afc204764c1842d323e8ae42016fb21b6fb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/353172
Trust: Michael Knyszek <mknyszek@google.com>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/api: set architecture sizes when type checking
Michael Pratt [Thu, 30 Sep 2021 17:26:19 +0000 (13:26 -0400)]
cmd/api: set architecture sizes when type checking

Otherwise the type checker defaults to amd64, which can break
type-checking for definitions using unsafe.Sizeof.

This has the side effect of changing the API output: constants with
different values across architectures (e.g., MaxInt) are now
individually listed per-arch. This actually makes the API file more
accurate, but does introduce a one-time discontinuity. These changes
have been integrated into the API files where the constants were added.

Change-Id: I4bbb0b7a7f405d3adda2d83869475c8bacdeb6a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/353331
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
3 years agocmd/go,cmd/compile: re-enable concurrent compilation on darwin/arm64
Josh Bleecher Snyder [Mon, 4 Oct 2021 19:14:10 +0000 (12:14 -0700)]
cmd/go,cmd/compile: re-enable concurrent compilation on darwin/arm64

I've manually reviewed all uses of ctxt.Flag_shared for concurrency safety.
And I manually tested with the race detector and found no issues.
Allow -shared to be used with compiler concurrency,
thereby re-enabling concurrent compilation on darwin/arm64.

Fixes #48496

Change-Id: I8a084cb08e6050950e404ceb9bd7e3a20e07e9c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/353871
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go/internal/cfg: improve error message when GOPATH is unset
siddharth [Mon, 28 Jun 2021 23:36:53 +0000 (19:36 -0400)]
cmd/go/internal/cfg: improve error message when GOPATH is unset

Add GoPathError variable. This variable gets set when GOPATH is not
set in the environment and in build.Default.GOPATH. GoPathError may
be used in "GOPATH unset" error messages to explain why GOPATH is not
set.

This CL improves upon CL 158257.

Fixes #29341

Change-Id: Ib42b42fb442c8297d58da4ca556be55e21a034e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/331529
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agogo/types: remove 1.18 APIs that have been replaced
Robert Findley [Fri, 1 Oct 2021 18:22:34 +0000 (14:22 -0400)]
go/types: remove 1.18 APIs that have been replaced

Remove the Interface.IsConstraint, Signature.SetTypeParams, and
Signature.SetRecvTypeParams methods, as they have been replaced and
usage removed from x/tools.

Change-Id: I8786c3cf34e96ab5211cd8e7e6348e9ee792b843
Reviewed-on: https://go-review.googlesource.com/c/go/+/353570
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>
3 years agocrypto/tls: use cryptobyte.NewFixedBuilder
Filippo Valsorda [Sat, 8 May 2021 05:07:30 +0000 (01:07 -0400)]
crypto/tls: use cryptobyte.NewFixedBuilder

Change-Id: Ia2a9465680e766336dae34f5d2b3cb412185bf1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/318131
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>
3 years agocmd/compile: fix PPC64.rules to correct failure in issue45344.go with regabi
Lynn Boger [Mon, 4 Oct 2021 13:00:20 +0000 (08:00 -0500)]
cmd/compile: fix PPC64.rules to correct failure in issue45344.go with regabi

This changes a rule in PPC64.rules to fix a failure in
test/issue45344.go when regabi is enabled.

Change-Id: I98baf2ae92c766b7276b0f3167b2e6fef37dfe84
Reviewed-on: https://go-review.googlesource.com/c/go/+/353789
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

3 years agocmd/internal/obj/riscv,cmd/link/internal/riscv64: add call trampolines for riscv64
Joel Sing [Wed, 25 Aug 2021 15:33:29 +0000 (01:33 +1000)]
cmd/internal/obj/riscv,cmd/link/internal/riscv64: add call trampolines for riscv64

CALL and JMP on riscv64 are currently implemented as an AUIPC+JALR pair. This means
that every call requires two instructions and makes use of the REG_TMP register,
even when the symbol would be directly reachable via a single JAL instruction.

Add support for call trampolines - CALL and JMP are now implemented as a single JAL
instruction, with the linker generating trampolines in the case where the symbol is
not reachable (more than +/-1MiB from the JAL instruction), is an unknown symbol or
does not yet have an address assigned. Each trampoline contains an AUIPC+JALR pair,
which the relocation is applied to.

Due to the limited reachability of the JAL instruction, combined with the way that
the Go linker currently assigns symbol addresses, there are cases where a call is to
a symbol that has no address currently assigned. In this situation we have to assume
that a trampoline will be required, however we can patch this up during relocation,
potentially calling directly instead. This means that we will end up with trampolines
that are unused. In the case of the Go binary, there are around 3,500 trampolines of
which approximately 2,300 are unused (around 9200 bytes of machine instructions).

Overall, this removes over 72,000 AUIPC instructions from the Go binary.

Change-Id: I2d9ecfb85dfc285c7729a3cd0b3a77b6f6c98be0
Reviewed-on: https://go-review.googlesource.com/c/go/+/345051
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agonet: don't use syscall.NET_RT_IFLISTL on FreeBSD
Damien Neil [Sat, 2 Oct 2021 00:45:09 +0000 (17:45 -0700)]
net: don't use syscall.NET_RT_IFLISTL on FreeBSD

The golang.org/x/net/route package can't parse the RIB returned
by NET_RT_IFLISTL. Use the route.RIBTypeInterface constant
instead, leaving the choice of syscall up to the route package.

Fixes #48553.

Change-Id: Ida4bd6e332c0dc6dc871d3a93cfb56c0fbc93e1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/353611
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agotest/typeparam: require -G=3 for issue48424.go (fix build)
Robert Griesemer [Sat, 2 Oct 2021 04:02:43 +0000 (21:02 -0700)]
test/typeparam: require -G=3 for issue48424.go (fix build)

Change-Id: Icabef5cf75770ffde012b1fc785a72f53f9b2c46
Reviewed-on: https://go-review.googlesource.com/c/go/+/353669
Trust: Robert Griesemer <gri@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
3 years agocmd/go: remove double parallelism from "go fmt"
Daniel Martí [Sat, 16 Jan 2021 18:03:31 +0000 (18:03 +0000)]
cmd/go: remove double parallelism from "go fmt"

Now that gofmt knows how to format many files in parallel,
there's no need for "go fmt" to have its own parallelism.
Instead of running "gofmt -l -w $file" in parallel with GOMAXPROCS,
simply collect a large list of files and hand it to "gofmt -l -w $files".

The benchmark below was obtained via:

benchcmd -n 10 FmtGorootCmd go fmt cmd

We can see a drastic improvement in system time per call.
This makes sense, as we used to fork+exec one gofmt program per file,
and now we only do that for every thousand or so files.

We also see an increase in peak memory usage and user CPU time.
This seems to be because each gofmt process was very short lived before.
This meant that there was a limit to the total amount of allocations
produced by go/parser and go/printer before the process stopped,
and thus the GC probably didn't kick in most of the time.

Now that each gofmt process formats hundreds or thousands of files,
a lot of those allocations pile up in the same process,
making peak-RSS go higher and piling on garbage for the GC to clean up.

Finally, note that time/op seems largely unchanged.
I did many benchmark runs; some ended up in noise like the one below,
and others gave small wall time speed-ups of 3-4%.
It seems like we get very little wall time benefit,
possibly due to the factors mentioned earlier cancelling each other out.

Overall, it seems worthwhile to not let "go fmt" do its own parallelism,
to keep the tool simpler to understand and maintain going forward.
Plus, the sys-time savings do seem to be the biggest change here.

name          old time/op         new time/op         delta
FmtGorootCmd          850ms ± 4%          842ms ± 6%      ~     (p=0.529 n=10+10)

name          old user-time/op    new user-time/op    delta
FmtGorootCmd          7.30s ± 4%          7.67s ± 3%    +5.07%  (p=0.000 n=10+10)

name          old sys-time/op     new sys-time/op     delta
FmtGorootCmd          1.66s ± 7%          0.43s ±24%   -74.08%  (p=0.000 n=10+10)

name          old peak-RSS-bytes  new peak-RSS-bytes  delta
FmtGorootCmd         30.1MB ± 4%        199.4MB ±21%  +563.03%  (p=0.000 n=10+10)

To make use of the already-present "maximum exec arg length limit"
constant in cmd/go/internal, move it to cmd/internal.

Fixes #43566.

Change-Id: If864151d0c851a40bf7138f9864640f15a066d48
Reviewed-on: https://go-review.googlesource.com/c/go/+/353309
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocontext: implement Context.Value using iteration rather than recursion
roudkerk [Mon, 19 Jul 2021 11:49:57 +0000 (12:49 +0100)]
context: implement Context.Value using iteration rather than recursion

In profiles of a production server, 2.3% of CPU time is spent in
runtime.newstack for stacks with 12 or more chained Context.Value
calls. Using iteration will avoid some needless stack resizes.

When calling Context.Value in the same goroutine (see
DeepValueSameGoRoutine) , no stack resizing is needed (after warming
up), and this change reduces time/op by around 10%.

The time to start a new goroutine and call Context.Value (see
DeepValueNewGoRoutine) is reduced by over 75% if a stack resize is
needed. If you factor out the overhead of starting the goroutine
(about 960ns) then, avoiding the stack resize saves about 95%.

```
name                                          old time/op  new time/op  delta
CommonParentCancel-12                          960ns ± 1%   958ns ± 1%     ~     (p=0.561 n=9+9)
WithTimeout/concurrency=40-12                 1.31µs ± 2%  1.29µs ± 6%     ~     (p=0.305 n=9+10)
WithTimeout/concurrency=4000-12               1.30µs ± 2%  1.30µs ± 2%     ~     (p=0.343 n=10+10)
WithTimeout/concurrency=400000-12             1.03µs ± 1%  1.02µs ± 2%     ~     (p=0.213 n=9+9)
CancelTree/depth=1/Root=Background-12          123ns ± 5%   126ns ± 2%   +2.61%  (p=0.023 n=10+9)
CancelTree/depth=1/Root=OpenCanceler-12        781ns ± 4%   806ns ± 4%   +3.20%  (p=0.022 n=9+10)
CancelTree/depth=1/Root=ClosedCanceler-12      370ns ± 4%   369ns ± 3%     ~     (p=0.497 n=9+10)
CancelTree/depth=10/Root=Background-12        4.74µs ± 4%  4.78µs ± 3%     ~     (p=0.516 n=10+10)
CancelTree/depth=10/Root=OpenCanceler-12      6.31µs ± 4%  6.29µs ± 4%     ~     (p=1.000 n=10+10)
CancelTree/depth=10/Root=ClosedCanceler-12    2.10µs ± 5%  2.09µs ± 5%     ~     (p=0.839 n=10+10)
CancelTree/depth=100/Root=Background-12       51.0µs ± 3%  51.2µs ± 2%     ~     (p=0.631 n=10+10)
CancelTree/depth=100/Root=OpenCanceler-12     60.8µs ± 1%  61.6µs ± 4%     ~     (p=0.274 n=8+10)
CancelTree/depth=100/Root=ClosedCanceler-12   19.3µs ± 2%  19.0µs ± 3%     ~     (p=0.123 n=10+10)
CancelTree/depth=1000/Root=Background-12       504µs ± 4%   512µs ± 4%     ~     (p=0.123 n=10+10)
CancelTree/depth=1000/Root=OpenCanceler-12     615µs ± 6%   619µs ± 4%     ~     (p=1.000 n=10+10)
CancelTree/depth=1000/Root=ClosedCanceler-12   190µs ± 2%   192µs ± 3%     ~     (p=0.190 n=9+9)
CheckCanceled/Err-12                          12.1ns ± 2%  12.1ns ± 2%     ~     (p=0.615 n=10+10)
CheckCanceled/Done-12                         7.27ns ± 1%  7.26ns ± 1%     ~     (p=0.698 n=10+10)
ContextCancelDone-12                          1.03ns ± 1%  1.03ns ± 1%     ~     (p=0.474 n=9+9)
DeepValueNewGoRoutine/depth=10-12             1.02µs ± 3%  0.99µs ± 2%   -3.41%  (p=0.000 n=10+10)
DeepValueNewGoRoutine/depth=20-12             1.11µs ± 3%  1.08µs ± 2%   -2.51%  (p=0.004 n=10+10)
DeepValueNewGoRoutine/depth=30-12             5.55µs ±10%  1.17µs ± 4%  -78.91%  (p=0.000 n=10+10)
DeepValueNewGoRoutine/depth=50-12             5.70µs ±13%  1.35µs ± 2%  -76.31%  (p=0.000 n=10+10)
DeepValueNewGoRoutine/depth=100-12            9.69µs ± 4%  1.82µs ± 2%  -81.18%  (p=0.000 n=10+10)
DeepValueSameGoRoutine/depth=10-12            54.2ns ± 2%  46.8ns ± 2%  -13.71%  (p=0.000 n=9+9)
DeepValueSameGoRoutine/depth=20-12             109ns ± 2%    97ns ± 2%  -11.11%  (p=0.000 n=10+10)
DeepValueSameGoRoutine/depth=30-12             155ns ± 3%   140ns ± 1%   -9.49%  (p=0.000 n=10+10)
DeepValueSameGoRoutine/depth=50-12             256ns ± 2%   226ns ± 2%  -11.83%  (p=0.000 n=10+10)
DeepValueSameGoRoutine/depth=100-12            492ns ± 3%   442ns ± 1%  -10.15%  (p=0.000 n=10+10)
```

Fixes #47292

Change-Id: I6bdeb234c979fb8fd6bfb91fd345cb5038f52c75
Reviewed-on: https://go-review.googlesource.com/c/go/+/335790
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Damien Neil <dneil@google.com>

3 years agonet/http/pprof: use "curl" instead of "wget" in usage example
Leon Klingele [Fri, 1 Oct 2021 09:05:13 +0000 (09:05 +0000)]
net/http/pprof: use "curl" instead of "wget" in usage example

The "curl" binary is already used at several other places inside
the code base, whereas this was the only occurrence of "wget".

Change-Id: I2b9c5c353d08b3ba8289819b4a602c51f1ebd593
GitHub-Last-Rev: abf94855223c4ceac08dd0d18c5a2b97d1abcca9
GitHub-Pull-Request: golang/go#48718
Reviewed-on: https://go-review.googlesource.com/c/go/+/353401
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agonet: consistently return DNSError on lookup failure
Ian Lance Taylor [Thu, 30 Sep 2021 23:35:52 +0000 (16:35 -0700)]
net: consistently return DNSError on lookup failure

Previously if we failed because the context timed out or was canceled,
we returned errCanceled or errTimeout.

Fixes #39178

Change-Id: I11bd7ebfaa7e5775fb05dfbb6b67f8307c8d8697
Reviewed-on: https://go-review.googlesource.com/c/go/+/353400
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 years agotext/template: undo reflect.Value wrapping for short-circuit and/or
Ian Lance Taylor [Fri, 1 Oct 2021 19:32:41 +0000 (12:32 -0700)]
text/template: undo reflect.Value wrapping for short-circuit and/or

For #31103

Change-Id: I9c0aa64f95f564de31a4c178e3930584d41316bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/353610
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile: remove typeparam subscripts, use func/type prefix for uniqueness
Dan Scales [Wed, 29 Sep 2021 17:54:27 +0000 (10:54 -0700)]
cmd/compile: remove typeparam subscripts, use func/type prefix for uniqueness

In types1 and for the export format, we were using type param subscripts
coming from types2 (originally for debugging) to provide unique names.
We need unique full-names for type params in types1 to ensure consistent
references to type params in function/method bodies and type params
derived from translation from types2. We also currently need unique
names for type params in importer/iimport.go and gcimporter/iimport.go,
because there are no levels of scoping in the package symbol lookup and
pkgIndex table.

As a step to eliminate the typeparam subscripts (which have no
relation to the source code), we change so that the typeparams' unique
name is just prefixing the type param name with the name of the
enclosing generic function, type, or method.

We now no longer use types2.TypeString in types2-to-types1 translation,
so Typestring can be changed to eliminate the subscript, as needed.
Also, types2.TypeParam.SetId() is no longer needed and is eliminated.

We can decide later if we want to do the further step of adding scoping
to the importer/iimport.go and gcimporter/iimport.go, which could be
used to eliminate the type param "path" prefix from the export format.

Change-Id: I0e37795664be2c2e1869b8f9e93393b83fc56409
Reviewed-on: https://go-review.googlesource.com/c/go/+/353135
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agobufio: reject UnreadByte or UnreadRune after a Discard or WriteTo
Bryan C. Mills [Thu, 23 Sep 2021 15:56:16 +0000 (11:56 -0400)]
bufio: reject UnreadByte or UnreadRune after a Discard or WriteTo

Discard is not really a read operation, and in theory it could
Seek the underlying Reader without actually reading anything,
so an UnreadByte following a Discard is disallowed.

Similarly, although WriteTo usually does end up calling Read on the
underlying buffer, if the underlying Reader implements io.WriterTo it
may instead terminate in a call to WriteTo, without ever buffering or
even seeing the last byte written. (It is conceptually read-like, but
not strictly “a read operation”.)

Fixes #48446

Change-Id: Ide6f2b157332b423486810399f66140c914144e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/351810
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
3 years agocmd/compile/internal/types2: mark implicit interfaces as such
Robert Griesemer [Thu, 30 Sep 2021 20:37:30 +0000 (13:37 -0700)]
cmd/compile/internal/types2: mark implicit interfaces as such

Provide an accessor for clients, and don't print the interface
around implicitly wrapped embedded types.

For #48424.

Change-Id: Ib2c76315508fc749ea4337d52e13d17de80e04da
Reviewed-on: https://go-review.googlesource.com/c/go/+/353396
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>
3 years agocmd/compile: accept constraint literals with elided interfaces
Robert Griesemer [Thu, 30 Sep 2021 17:04:46 +0000 (10:04 -0700)]
cmd/compile: accept constraint literals with elided interfaces

This change enables the relaxed syntax for constraint literals
as proposed in issue #48424 and adds a simple smoke test for
the compiler. (Most of the relevant changes are in the syntax
and types2 package which have more extensive tests for this.)

This makes it possible to experiment with the new syntax while
we contemplate the fate of #48424.

If #48424 is accepted, this change can remain. If #48424 is
not accepted, reverting this CL will remove this feature in
the compiler.

For #48424.

Change-Id: I624fbb37c2f616ee9ad692e17e4fc75c9d5b06e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/353389
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/compile/internal/types2: accept constraint literals with elided interfaces
Robert Griesemer [Thu, 30 Sep 2021 03:56:36 +0000 (20:56 -0700)]
cmd/compile/internal/types2: accept constraint literals with elided interfaces

When collecting type parameters, wrap constraint literals of the
form ~T or A|B into interfaces so the type checker doesn't have
to deal with these type set expressions syntactically anywhere
else but in interfaces (i.e., union types continue to appear
only as embedded elements in interfaces).

Since a type constraint doesn't need to be an interface anymore,
we can remove the respective restriction. Instead, when accessing
the constraint interface via TypeParam.iface, wrap non-interface
constraints at that point and update the constraint so it happens
only once. By computing the types sets of all type parameters at
before the end of type-checking, we ensure that type constraints
are in their final form when accessed through the API.

For #48424.

Change-Id: I3a47a644ad4ab20f91d93ee39fcf3214bb5a81f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/353139
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>
3 years agocmd/compile/internal/syntax: allow eliding interface in constraint literals
Robert Griesemer [Wed, 29 Sep 2021 18:14:05 +0000 (11:14 -0700)]
cmd/compile/internal/syntax: allow eliding interface in constraint literals

This CL permits an arbitrary type as well as the type sets  ~T and A|B
in constraint position, without the need of a surrrounding interface.
For instance, the type parameter list

[P interface{ ~map[K]V }, K comparable, V interface{ ~string }]

may be written as

[P ~map[K]V, K comparable, V ~string]

The feature must be enabled explicitly with the AllowTypeSets mode
and is only available if AllowGenerics is set as well.

For #48424.

Change-Id: Ic70bb97a49ff75e67e040853eac10e6aed0fef1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/353133
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>
3 years agogo/types: remove Environment type
jiahua wang [Fri, 1 Oct 2021 13:58:51 +0000 (21:58 +0800)]
go/types: remove Environment type

Change-Id: Id53633477d1c07bce0c5fcbcab079da51076cdf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/353351
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/link: correct type..importpath symbol handling
Cherry Mui [Thu, 30 Sep 2021 22:09:24 +0000 (18:09 -0400)]
cmd/link: correct type..importpath symbol handling

The linker specially handles go.importpath symbols. But the
compiler doesn't actually generate such symbols. Instead, it
generates type..importpath symbols. It is already in the type
section as the name starts with "type.". Also set its alignment
to 1, as it is string data.

Change-Id: I771f5529a0ff41a5bb476b3a02c8cc75729792de
Reviewed-on: https://go-review.googlesource.com/c/go/+/353489
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>
3 years agocmd/link: set alignment for string symbols in symtab pass
Cherry Mui [Thu, 30 Sep 2021 21:42:15 +0000 (17:42 -0400)]
cmd/link: set alignment for string symbols in symtab pass

Set alignment for string symbols in symtab pass, so we don't need
to look at symbol name in symalign in dodata pass. (Ideally we
should not use symbol name like this in symtab pass either, but
we already use the names there anyway.)

Change-Id: I9fd61e0dd0824c50e3d0d7c07f75b967c8654796
Reviewed-on: https://go-review.googlesource.com/c/go/+/353470
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>
3 years agocmd/link: reduce alignment for some funcdata symbols
Cherry Mui [Thu, 30 Sep 2021 15:46:00 +0000 (11:46 -0400)]
cmd/link: reduce alignment for some funcdata symbols

Funcdata like opendefer info and traceback arginfo are varints or
bytes. There is no need to align them.

GC liveness map and inline tree have 32-bit fields, so continue
align them to 4 bytes.

Change-Id: I9d5dd750a926c65a910efe5817f9f5c473019bc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/353469
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile/internal/types2: removed deprecated API entry points
Robert Griesemer [Thu, 30 Sep 2021 21:21:18 +0000 (14:21 -0700)]
cmd/compile/internal/types2: removed deprecated API entry points

We don't need to keep them around in types2.
Switched a couple of uses of NewSignature to NewSignatureType.

Change-Id: I62880c2b49ec82caa9362ed8a798cfc3bcea300e
Reviewed-on: https://go-review.googlesource.com/c/go/+/353397
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types: switch uses of NewSignature to NewSignatureType (cleanup)
Robert Griesemer [Thu, 30 Sep 2021 21:39:52 +0000 (14:39 -0700)]
go/types: switch uses of NewSignature to NewSignatureType (cleanup)

Change-Id: I05ed5806e2a35a57ef3e8c9275a157574abcb0ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/353399
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/internal/gccgoimporter: change all .gox files to text
Ian Lance Taylor [Mon, 27 Sep 2021 15:59:46 +0000 (08:59 -0700)]
go/internal/gccgoimporter: change all .gox files to text

Avoid problems with distro scanning by not using files that look like
object files.

For #48548

Change-Id: I4a06d5690d0870d6253f176e510faa5eebf2d057
Reviewed-on: https://go-review.googlesource.com/c/go/+/352450
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
3 years agocmd/dist: consistently set PWD when executing a command in a different directory
Bryan C. Mills [Thu, 30 Sep 2021 19:15:45 +0000 (15:15 -0400)]
cmd/dist: consistently set PWD when executing a command in a different directory

For #33598

Change-Id: If0de906ffa2fcc83bb2a90f9e80a5b29d7667398
Reviewed-on: https://go-review.googlesource.com/c/go/+/353449
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: correct comment: walkSwitch -> walkSelect
wangyuntao [Sat, 10 Jul 2021 04:11:22 +0000 (04:11 +0000)]
cmd/compile: correct comment: walkSwitch -> walkSelect

fix typo

Change-Id: Ie2470e494ba95eed067ad42677520b35b383555f
GitHub-Last-Rev: 831f1973194f55b435dcdc6ef30290848228a114
GitHub-Pull-Request: golang/go#47117
Reviewed-on: https://go-review.googlesource.com/c/go/+/333789
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Keith Randall <khr@golang.org>

3 years ago.github: update IRC server
Sean Liao [Fri, 23 Jul 2021 18:14:14 +0000 (20:14 +0200)]
.github: update IRC server

Updates #46281

Change-Id: I1c70ad72a155a39138f120df5b71de61bb01e20c
Reviewed-on: https://go-review.googlesource.com/c/go/+/336931
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>

3 years agocmd/link: use "CC --print-prog-name" to locate tools
Cherry Mui [Thu, 22 Jul 2021 22:57:52 +0000 (18:57 -0400)]
cmd/link: use "CC --print-prog-name" to locate tools

When building for macOS with external linking, we currently use
"xcrun" to invoke "dsymutil" and "strip" tools. That doesn't work
well for cross compilation. Use "CC --print-prog-name" to find the
tool path instead.

Fixes #47316.

Change-Id: Ib30c6494c48bfb6a505dc26fe644ef543d777076
Reviewed-on: https://go-review.googlesource.com/c/go/+/336769
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>
3 years agoruntime: avoid run TestSyscallN in parallel
Changkun Ou [Fri, 27 Aug 2021 15:08:23 +0000 (17:08 +0200)]
runtime: avoid run TestSyscallN in parallel

Fixes #48012

Change-Id: Ie27eb864ac387ecf5155a3aefa81661f1448ace5
Reviewed-on: https://go-review.googlesource.com/c/go/+/345670
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/link: add runtime.text.N symbols to Mach-O symbol table
Cherry Mui [Wed, 29 Sep 2021 20:47:12 +0000 (16:47 -0400)]
cmd/link: add runtime.text.N symbols to Mach-O symbol table

On Darwin/ARM64 when external linking, for very large text we
split it into multiple sections. For each section (other than the
first) we create runtime.text.N marker symbols. In CL 316050 I
forgot to add those symbols to the symbol table. This CL does it.

It doesn't actually matter for program execution. But we add them
on ELF when splitting text sections, so we do it here as well.
Also, this makes it easier to tell if we split text sections.

Change-Id: Ida7f8e9431867881e5ee2bc1a2129eeaf83cb878
Reviewed-on: https://go-review.googlesource.com/c/go/+/353209
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agodebug/gosym: run TestPCLine on Linux/AMD64 in short mode
Cherry Mui [Thu, 30 Sep 2021 16:02:56 +0000 (12:02 -0400)]
debug/gosym: run TestPCLine on Linux/AMD64 in short mode

Currently TestPCLine is skipped in short mode. The test builds a
Linux/AMD64 binary, so it makes sense to skip it if we're cross
compiling, as building the runtime takes a while. But if we are
on Linux/AMD64, it will only build a small amount of code, which
isn't really slow. The test runs in 0.14 second on my machine.
I think it is acceptable to run in short mode. Then we'll have
trybot coverage for this test.

Change-Id: If682f88c28050f7daafde35b4f9e59c03b764a35
Reviewed-on: https://go-review.googlesource.com/c/go/+/353330
Trust: Cherry Mui <cherryyz@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
3 years agodebug/gosym: fix version check in file table access
Cherry Mui [Thu, 30 Sep 2021 15:46:41 +0000 (11:46 -0400)]
debug/gosym: fix version check in file table access

Go 1.16 and 1.18 table are the same for that part. Accept 1.18
version number in that code.

Fixes #48699.

Change-Id: I44eafa279a94bd06444f61518aedd541b25390fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/353329
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocrypto: document the extended key interfaces
Filippo Valsorda [Wed, 29 Sep 2021 11:09:34 +0000 (13:09 +0200)]
crypto: document the extended key interfaces

Change-Id: Iaff3f77b0a168e8bde981c791035a6451b3a49ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/353049
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
3 years agotime: add doc comment about tzdata package
Leigh McCulloch [Wed, 29 Sep 2021 02:19:34 +0000 (02:19 +0000)]
time: add doc comment about tzdata package

Add doc comment about the time/tzdata package to the time.LoadLocation
function. The time.LoadLocation function was changed in Go 1.15 to add an extra
source that it considers for the time zone database. That location is the
time/tzdata package. It is not easy to discover this behavior because the
documentation for the time package doesn't mention it in the discussion on the
time.LoadLocation function when discussing the different sources. It would be helpful to
describe all possible sources that time.LoadLocation considers when loading the
time zone database, and so I think it would be worthwhile to mention
time/tzdata.

Change-Id: I408fbe188bf9d4ba797e59ec17eb677136d6a9c2
GitHub-Last-Rev: 3dac204326960a18c4e44d3ea24fd428e91e9fcb
GitHub-Pull-Request: golang/go#48673
Reviewed-on: https://go-review.googlesource.com/c/go/+/352830
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Heschi Kreinick <heschi@google.com>

3 years agoREADME.md: update contribute URL
180909 [Tue, 31 Aug 2021 17:57:33 +0000 (17:57 +0000)]
README.md: update contribute URL

/doc/contribute.html now redirects to /doc/contribute.

Change-Id: Ib342d515bf6e74bb5807ce21f8df3d985bc7e490
GitHub-Last-Rev: c491a060da22d1bb456283f5ed0ae2894f0365ca
GitHub-Pull-Request: golang/go#48005
Reviewed-on: https://go-review.googlesource.com/c/go/+/345590
Trust: Cherry Mui <cherryyz@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
3 years agocmd/asm: add error check for move constant instructions on arm64
fanzha02 [Tue, 28 Sep 2021 05:46:14 +0000 (13:46 +0800)]
cmd/asm: add error check for move constant instructions on arm64

The current Go assembler encodes "MOVK $(0<<16|32|48), Rd" as the
same binary with "MOVK $0, Rd", but for arm64 move constant instructions
MOVK, MOVN and MOVZ, "op $0, Rd" and "op $(0<<16|32|48), Rd" have
different semantics. In order not to change the way the assembler
frontend parses constants, this patch adds a check for the zero shifts.

Change-Id: Ia844c419ce49f63605b549e3a2e98d9075dd1cf1
Reviewed-on: https://go-review.googlesource.com/c/go/+/275812
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/link: make funcSize a constant
Josh Bleecher Snyder [Wed, 29 Sep 2021 00:26:24 +0000 (17:26 -0700)]
cmd/link: make funcSize a constant

Now that it no longer depends on the size of a pointer,
we can make it a constant, which simplifies a bit of code.

Change-Id: I1b7c3b1b648da5c8960378a02b9263e2cc902441
Reviewed-on: https://go-review.googlesource.com/c/go/+/352952
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/link, runtime: use offset for _func.entry
Josh Bleecher Snyder [Wed, 29 Sep 2021 00:06:56 +0000 (17:06 -0700)]
cmd/link, runtime: use offset for _func.entry

The first field of the func data stored by the linker is the
entry PC for the function. Prior to this change, this was stored
as a relocation to the function. Change this to be an offset
relative to runtime.text.

This reduces the number of relocations on darwin/arm64 by about 10%.
It also slightly shrinks binaries:

file      before    after     Δ       %
addr2line 3803058   3791298   -11760  -0.309%
api       5140114   5104242   -35872  -0.698%
asm       4886850   4840626   -46224  -0.946%
buildid   2512466   2503042   -9424   -0.375%
cgo       4374770   4342274   -32496  -0.743%
compile   22920530  22769202  -151328 -0.660%
cover     4624626   4588242   -36384  -0.787%
dist      3217570   3205522   -12048  -0.374%
doc       3715026   3684498   -30528  -0.822%
fix       3148226   3119266   -28960  -0.920%
link      6350226   6313362   -36864  -0.581%
nm        3768850   3757106   -11744  -0.312%
objdump   4140594   4127618   -12976  -0.313%
pack      2227474   2218818   -8656   -0.389%
pprof     13598706  13506786  -91920  -0.676%
test2json 2497234   2487426   -9808   -0.393%
trace     10198066  10118498  -79568  -0.780%
vet       6930658   6889074   -41584  -0.600%
total     108055044 107366900 -688144 -0.637%

It should also incrementally speed up binary launching.

This is the first step towards removing enough relocations
that pages that were previously dirtied by the loader may remain clean,
which will offer memory savings useful in constrained environments.

Change-Id: Icfba55e696ba2f9c99c4f179125ba5a3ba4369c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/351463
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: extract text address calculation into a separate method
Josh Bleecher Snyder [Wed, 29 Sep 2021 16:49:54 +0000 (09:49 -0700)]
runtime: extract text address calculation into a separate method

Pure code movement.

Change-Id: I7216e50fe14afa3d19c5047c92e515c90838f834
Reviewed-on: https://go-review.googlesource.com/c/go/+/353129
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agodebug/gosym: refactor handling of funcdata
Josh Bleecher Snyder [Thu, 23 Sep 2021 20:11:04 +0000 (13:11 -0700)]
debug/gosym: refactor handling of funcdata

We do a bunch of manual offset calculations everywhere.
Add a bit of type safety and some helpers.
In addition to making the code clearer and providing a place
to hang some documentation, it also makes upcoming changes easier.

name                old time/op    new time/op    delta
115/NewLineTable-8    79.9ns ± 1%    90.2ns ±23%    ~     (p=0.234 n=9+10)
115/NewTable-8        72.0µs ± 1%    73.4µs ± 1%  +1.96%  (p=0.000 n=8+8)
115/LineToPC-8        53.3µs ± 1%    54.4µs ± 1%  +2.02%  (p=0.000 n=10+10)
115/PCToLine-8         249ns ± 0%     249ns ± 2%    ~     (p=0.147 n=9+10)

name                old alloc/op   new alloc/op   delta
115/NewLineTable-8      384B ± 0%      384B ± 0%    ~     (all equal)
115/NewTable-8         164kB ± 0%     164kB ± 0%    ~     (p=0.610 n=10+10)
115/LineToPC-8         0.00B          0.00B         ~     (all equal)
115/PCToLine-8         0.00B          0.00B         ~     (all equal)

name                old allocs/op  new allocs/op  delta
115/NewLineTable-8      3.00 ± 0%      3.00 ± 0%    ~     (all equal)
115/NewTable-8         1.04k ± 0%     1.04k ± 0%    ~     (all equal)
115/LineToPC-8          0.00           0.00         ~     (all equal)
115/PCToLine-8          0.00           0.00         ~     (all equal)

Change-Id: If357dce5ae4277e6ddc6d90ba6b5b83e470b9121
Reviewed-on: https://go-review.googlesource.com/c/go/+/352951
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go/internal/modcmd: fix "go mod editwork" error text
citizen233 [Tue, 28 Sep 2021 06:05:20 +0000 (14:05 +0800)]
cmd/go/internal/modcmd: fix "go mod editwork" error text

Fixes #48583

Change-Id: I863ece5c546c383a2f46b8b1a36cbf9f2526d3ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/352709
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agodebug/gosym: add benchmark
Josh Bleecher Snyder [Wed, 29 Sep 2021 17:16:47 +0000 (10:16 -0700)]
debug/gosym: add benchmark

Use a Go 1.15 executable for the benchmark, because it is handy.
Most of the code paths are shared for Go 1.2+.

Change-Id: Id7ddc76a05d76335108c58ff9f1ab2ff837b7227
Reviewed-on: https://go-review.googlesource.com/c/go/+/353131
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agointernal/fuzz: disconnect stdout and stderr from the worker
Katie Hockman [Tue, 28 Sep 2021 19:59:34 +0000 (15:59 -0400)]
internal/fuzz: disconnect stdout and stderr from the worker

This was useful for debugging while we were developing
the feature, but is now causing extraneous prints that
make the command output difficult to read.

This change also prevents the go command from printing
an extraneous "FAIL" when fuzzing is enabled.

Fixes #48633
Fixes #46631

Change-Id: I636e65f305a20f6dcd843e62090ae228741a3725
Reviewed-on: https://go-review.googlesource.com/c/go/+/352892
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agotext/template: check final value for short-circuit and/or
Ian Lance Taylor [Wed, 29 Sep 2021 17:50:18 +0000 (10:50 -0700)]
text/template: check final value for short-circuit and/or

There was a bug in the short-circuit code for and/or added in CL 321490:
it ignored the value passed in by an earlier pipeline.

For #31103

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

3 years agocmd/compile: rename some types2.Context variables from env to ctxt
Robert Findley [Wed, 29 Sep 2021 17:05:37 +0000 (13:05 -0400)]
cmd/compile: rename some types2.Context variables from env to ctxt

Rename some variables in the compiler that were missed in CL 353089.

Change-Id: Ie748fe9b64e584a841d08ff60c439c93aae412d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/353149
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoruntime: use unsafe.Slice in getStackMap
Josh Bleecher Snyder [Wed, 29 Sep 2021 00:42:05 +0000 (17:42 -0700)]
runtime: use unsafe.Slice in getStackMap

It's not less code, but it is clearer code.

Change-Id: I32239baf92487a56900a4edd8a2593014f37d093
Reviewed-on: https://go-review.googlesource.com/c/go/+/352953
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agotest: update test/codegen/noextend.go to work with either ABI on ppc64x
Lynn Boger [Wed, 29 Sep 2021 14:24:50 +0000 (09:24 -0500)]
test: update test/codegen/noextend.go to work with either ABI on ppc64x

This updates the codegen tests in noextend.go so they are not
dependent on the ABI.

Change-Id: I8433bea9dc78830c143290a7e0cf901b2397d38a
Reviewed-on: https://go-review.googlesource.com/c/go/+/353070
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/go: prevent necessary GCFlag from being removed
Katie Hockman [Mon, 27 Sep 2021 20:12:05 +0000 (16:12 -0400)]
cmd/go: prevent necessary GCFlag from being removed

There are special flags that must be passed to the
compiler at build time in order to instrument the
testing binary for fuzzing.
One potential option would be to add these flags to
p.Internal.Gcflags inside cmd/go/internal/test. However,
future calls to setToolFlags can cause these flags to
get cleared about before the build starts, removing
virtually all coverage guidance. This change moves the
logic to add the flag deeper down the call stack,
preventing it from being cleared.

Change-Id: I40eadb0cacc18f29cee75379cd9380f9e73bb8da
Reviewed-on: https://go-review.googlesource.com/c/go/+/352511
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types, types2: rename Environment to Context
Robert Findley [Wed, 29 Sep 2021 13:35:02 +0000 (09:35 -0400)]
go/types, types2: rename Environment to Context

Replace the name Environment with Context, as discussed in #47916. Along
the way, fix some stale or inaccurate comments.

The Environment type remains temporarily as an alias for Context, to
allow the x/tools Trybot to pass until dependency on types.Environment
can be removed.

Updates #47916

Change-Id: Iffd069ab0e8adebf4207c8f8891468a64d32b7cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/353089
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>

3 years agocmd/compile: add PPC64-specific inlining for runtime.memmove
Archana R [Fri, 24 Sep 2021 15:31:20 +0000 (10:31 -0500)]
cmd/compile: add PPC64-specific inlining for runtime.memmove

Add rule to PPC64.rules to inline runtime.memmove in more cases, as is
done for other target architectures
Updated tests in codegen/copy.go to verify changes are done on
ppc64/ppc64le

Updates #41662

Change-Id: Id937ce21f9b4f4047b3e66dfa3c960128ee16a2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/352054
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

3 years agodebug/gosym: adjust go12* method comments
Josh Bleecher Snyder [Tue, 28 Sep 2021 22:57:09 +0000 (15:57 -0700)]
debug/gosym: adjust go12* method comments

These methods are for use with Go 1.2 _and later_ pcln tables.
Make that clearer.

Change-Id: Iee06e0828fd5895639b654363b6d91bf9151d224
Reviewed-on: https://go-review.googlesource.com/c/go/+/352950
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agodebug/gosym: add hook to disable recovers
Josh Bleecher Snyder [Tue, 28 Sep 2021 20:13:49 +0000 (13:13 -0700)]
debug/gosym: add hook to disable recovers

debug/gosym assumes throughout that bogus input means a malformed file.
That's generally true, but not when you're changing the package.
In that case, the panic usually indicates a newly introduced bug,
and seeing the panic is really useful.

Add a manually-enabled way to make panics panic.

Change-Id: I07af6c7b982c4cf61180db29f07aa63576ba7837
Reviewed-on: https://go-review.googlesource.com/c/go/+/352949
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile: make sure shapes have proper indexes for sub-instantiation
Dan Scales [Wed, 29 Sep 2021 04:14:17 +0000 (21:14 -0700)]
cmd/compile: make sure shapes have proper indexes for sub-instantiation

The computation for determining the shapes to use at the top of
getInstantation was not always creating shapes with the proper indexes.
If an instantiation is being called from another instantiated function,
we cannot just copy the shape types unchanged, because their indexes may
have changed. So, for type args that already shapes, we still call
Shapify() with the correct index.

Fixes #48645

Change-Id: Ibb61c6f9a3c317220fb85135ca87eb5ad4dcff9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/353030
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agoruntime: drop nowritebarrier from gcParkAssist
Michael Pratt [Tue, 28 Sep 2021 18:35:03 +0000 (14:35 -0400)]
runtime: drop nowritebarrier from gcParkAssist

Nothing in this function is at odds with having write barriers. It
originally inherited the annotation from gcAssistAlloc
http://golang.org/cl/30700, which subsequently dropped the annotation in
http://golang.org/cl/32431 as it was unnecessary.

Change-Id: Ie464e6b4ed957f57e922ec043728ff4e15bf35ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/352811
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 years agogo/types: avoid infinite recursion in unification
Robert Griesemer [Wed, 29 Sep 2021 03:42:45 +0000 (20:42 -0700)]
go/types: avoid infinite recursion in unification

This is an almost clean port of CL 352832 from types2 to go/types:
The nest files and unify.go where copied verbatim; unify.go was
adjusted with correct package name, a slightly different comment
was restored to what it was. The test files got adjustments for
error position. infer.go got a missing _Todo error code.

For #48619.
For #48656.

Change-Id: Ia1a2d09e8bb37a85032b4b7e7c7a0b08e8c793a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/353029
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/internal/goobj, cmd/link: remove funcdataoff
Cherry Mui [Tue, 28 Sep 2021 21:07:01 +0000 (17:07 -0400)]
cmd/internal/goobj, cmd/link: remove funcdataoff

FUNCDATA is always a symbol reference with 0 offset. Assert the
offset is 0 and remove funcdataoff.

Change-Id: I326815365c9db5aeef6b869df5d78a9957bc16a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/352894
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/link: access pcdata via aux symbols
Cherry Mui [Tue, 28 Sep 2021 20:20:29 +0000 (16:20 -0400)]
cmd/link: access pcdata via aux symbols

Pcdata are now separate aux symbols. Read them from aux, instead
of using funcinfo.

Now we can remove pcdata fields from funcinfo.

Change-Id: Ie65e3962edecc0f39127a5f6963dc59d1f141e67
Reviewed-on: https://go-review.googlesource.com/c/go/+/352893
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>
3 years agocmd/compile/internal/types2: avoid infinite recursion in unification
Robert Griesemer [Tue, 28 Sep 2021 20:50:15 +0000 (13:50 -0700)]
cmd/compile/internal/types2: avoid infinite recursion in unification

If the type T inferred for a type parameter P is P itself (or a derived
type containing P), a subsequent unification step leads to infinite
recursion: at each encounter of P with the already inferred type T
(which is or contains P), P stands for that T and the recursive matching
process continues with T, which inevitably contains P again and recursion
never terminates.

This CL introduces a set of masks, one for each type parameter.
When a type parameter is encountered for which a type has already
been inferred, the type parameter is "masked" for the recursive
matching of the inferred type. Masking makes the type parameter
"invisible" such that it will be handled like any other type and
not unpacked further.

Fixes #48619.
For #48656.

Change-Id: Ic1d938322be51fd44323ea14f925303f58b27c97
Reviewed-on: https://go-review.googlesource.com/c/go/+/352832
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>