]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
20 months agomisc/cgo: replace ioutil.ReadFile with os.ReadFile
hopehook [Fri, 16 Sep 2022 01:21:59 +0000 (09:21 +0800)]
misc/cgo: replace ioutil.ReadFile with os.ReadFile

For #45557

Change-Id: I25be5b437fa1c9b0e0c46802a9b37efc2d47bca0
Reviewed-on: https://go-review.googlesource.com/c/go/+/431097
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
20 months agomisc/cgo: replace os.SEEK_SET with io.SeekStart
hopehook [Fri, 16 Sep 2022 00:13:23 +0000 (08:13 +0800)]
misc/cgo: replace os.SEEK_SET with io.SeekStart

Since os.SEEK_SET was deprecated, use io.SeekStart instead.

Change-Id: I11ae496b071ab35412403ff73e52f3da73d5b120
Reviewed-on: https://go-review.googlesource.com/c/go/+/431096
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

20 months agointernal/syscall/unix: reuse existing {Fstat,Open,Unlink}at on freebsd
Tobias Klauser [Thu, 15 Sep 2022 21:28:49 +0000 (23:28 +0200)]
internal/syscall/unix: reuse existing {Fstat,Open,Unlink}at on freebsd

Change-Id: I517e75faca18bf0fdcd4e6c837f50f824aa6348c
Reviewed-on: https://go-review.googlesource.com/c/go/+/431236
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
20 months agoRevert "runtime: treat SI_TKILL like SI_USER on Linux"
Cuong Manh Le [Mon, 19 Sep 2022 05:48:35 +0000 (05:48 +0000)]
Revert "runtime: treat SI_TKILL like SI_USER on Linux"

This reverts CL 431255.

Reason for revert: breaks darwin-arm and linux-noopt builders.

Change-Id: I29332b935cc1e35fa039af3d70465e496361fcc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/431715
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
20 months agocmd/compile/internal/typebits: relax alignment check
Cuong Manh Le [Fri, 16 Sep 2022 03:41:15 +0000 (10:41 +0700)]
cmd/compile/internal/typebits: relax alignment check

Now we have 8-byte alignment types on 32-bit system, so in some rare
case, e.g, generated wrapper for embedded interface, the function
argument may need more than 4 byte alignment. We could pad somehow, but
this is a rare case which makes it hard to ensure that we've got it right.

So relaxing the check for argument and return value region of the stack.

Fixes #54991

Change-Id: I34986e17a920254392a39439ad3dcb323da2ea8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/431098
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
20 months agocmd/compile,sync: make accessing address of zero offset struct field inline cost 0
Cuong Manh Le [Thu, 15 Sep 2022 16:04:53 +0000 (23:04 +0700)]
cmd/compile,sync: make accessing address of zero offset struct field inline cost 0

Accessing the address of something often needs the same (or even less)
number of instructions as accessing the content of the thing. That would
help us rolling back the hack of CL 429766 to lower sync atomic types
inline cost.

Compiled objects size increase a bit:

file      before    after     Δ       %
addr2line 3729827   3733958   +4131   +0.111%
api       5457224   5456267   -957    -0.018%
asm       4806486   4808993   +2507   +0.052%
buildid   2480271   2480562   +291    +0.012%
cgo       4593496   4593947   +451    +0.010%
compile   23906958  23910086  +3128   +0.013%
cover     4680870   4681461   +591    +0.013%
dist      3341333   3341692   +359    +0.011%
doc       3879927   3880409   +482    +0.012%
fix       3298081   3298979   +898    +0.027%
link      6500098   6499873   -225    -0.003%
nm        3654362   3656997   +2635   +0.072%
objdump   4108300   4108671   +371    +0.009%
pack      2255445   2256391   +946    +0.042%
pprof     14364561  14379475  +14914  +0.104%
test2json 2550942   2555333   +4391   +0.172%
trace     13573199  13578409  +5210   +0.038%
vet       7430923   7430094   -829    -0.011%
total     114612303 114651597 +39294  +0.034%

file                                                                     before    after     Δ       %
archive/tar.a                                                            905032    905560    +528    +0.058%
archive/zip.a                                                            853464    853916    +452    +0.053%
cmd/asm/internal/lex.a                                                   359388    367418    +8030   +2.234%
cmd/compile/internal/importer.a                                          947206    947734    +528    +0.056%
cmd/compile/internal/inline.a                                            563390    566828    +3438   +0.610%
cmd/compile/internal/types2.a                                            5761990   5764274   +2284   +0.040%
cmd/go/internal/cfg.a                                                    234892    235342    +450    +0.192%
cmd/go/internal/envcmd.a                                                 257166    257694    +528    +0.205%
cmd/go/internal/fix.a                                                    93522     94052     +530    +0.567%
cmd/go/internal/generate.a                                               201308    201838    +530    +0.263%
cmd/go/internal/get.a                                                    207862    208390    +528    +0.254%
cmd/go/internal/imports.a                                                230266    230794    +528    +0.229%
cmd/go/internal/list.a                                                   385044    386632    +1588   +0.412%
cmd/go/internal/load.a                                                   1164508   1165566   +1058   +0.091%
cmd/go/internal/modcmd.a                                                 627582    629168    +1586   +0.253%
cmd/go/internal/modfetch/codehost.a                                      1031962   1032490   +528    +0.051%
cmd/go/internal/modfetch.a                                               1289294   1289822   +528    +0.041%
cmd/go/internal/modget.a                                                 674566    675624    +1058   +0.157%
cmd/go/internal/modindex.a                                               935598    936576    +978    +0.105%
cmd/go/internal/modload.a                                                2640784   2642058   +1274   +0.048%
cmd/go/internal/par.a                                                    135858    136476    +618    +0.455%
cmd/go/internal/run.a                                                    127158    127688    +530    +0.417%
cmd/go/internal/search.a                                                 242918    243446    +528    +0.217%
cmd/go/internal/trace.a                                                  113216    113188    -28     -0.025%
cmd/go/internal/vcs.a                                                    517280    517810    +530    +0.102%
cmd/go/internal/work.a                                                   2389522   2390580   +1058   +0.044%
cmd/go/internal/workcmd.a                                                311118    311452    +334    +0.107%
cmd/vendor/github.com/google/pprof/internal/driver.a                     1714950   1715478   +528    +0.031%
cmd/vendor/golang.org/x/mod/sumdb.a                                      453840    454290    +450    +0.099%
cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags.a       326162    326610    +448    +0.137%
cmd/vendor/golang.org/x/tools/go/analysis/internal/facts.a               302476    303006    +530    +0.175%
cmd/vendor/golang.org/x/tools/go/analysis/passes/asmdecl.a               366580    367030    +450    +0.123%
cmd/vendor/golang.org/x/tools/go/analysis/passes/assign.a                129556    130006    +450    +0.347%
cmd/vendor/golang.org/x/tools/go/analysis/passes/atomic.a                133466    133916    +450    +0.337%
cmd/vendor/golang.org/x/tools/go/analysis/passes/bools.a                 193558    194006    +448    +0.231%
cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag.a              177984    178434    +450    +0.253%
cmd/vendor/golang.org/x/tools/go/analysis/passes/cgocall.a               221226    221674    +448    +0.203%
cmd/vendor/golang.org/x/tools/go/analysis/passes/composite.a             168572    169022    +450    +0.267%
cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock.a              227040    227490    +450    +0.198%
cmd/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow.a              204650    205098    +448    +0.219%
cmd/vendor/golang.org/x/tools/go/analysis/passes/errorsas.a              138020    138468    +448    +0.325%
cmd/vendor/golang.org/x/tools/go/analysis/passes/framepointer.a          119030    119480    +450    +0.378%
cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse.a          165006    165454    +448    +0.272%
cmd/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert.a           180850    181300    +450    +0.249%
cmd/vendor/golang.org/x/tools/go/analysis/passes/inspect.a               103876    104326    +450    +0.433%
cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil.a 116070    116516    +446    +0.384%
cmd/vendor/golang.org/x/tools/go/analysis/passes/loopclosure.a           153068    153518    +450    +0.294%
cmd/vendor/golang.org/x/tools/go/analysis/passes/lostcancel.a            244936    245384    +448    +0.183%
cmd/vendor/golang.org/x/tools/go/analysis/passes/nilfunc.a               135720    136168    +448    +0.330%
cmd/vendor/golang.org/x/tools/go/analysis/passes/printf.a                527134    527584    +450    +0.085%
cmd/vendor/golang.org/x/tools/go/analysis/passes/shift.a                 172026    172476    +450    +0.262%
cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer.a           151690    152138    +448    +0.295%
cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods.a            187494    187944    +450    +0.240%
cmd/vendor/golang.org/x/tools/go/analysis/passes/stringintconv.a         164752    165200    +448    +0.272%
cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag.a             200144    200594    +450    +0.225%
cmd/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine.a      161146    161596    +450    +0.279%
cmd/vendor/golang.org/x/tools/go/analysis/passes/tests.a                 270252    270702    +450    +0.167%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal.a             130646    131094    +448    +0.343%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable.a           182130    182580    +450    +0.247%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr.a             153646    154094    +448    +0.292%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult.a          179800    180248    +448    +0.249%
cmd/vendor/golang.org/x/tools/go/analysis/unitchecker.a                  303838    304286    +448    +0.147%
cmd/vendor/golang.org/x/tools/go/analysis.a                              217930    218380    +450    +0.206%
cmd/vendor/golang.org/x/tools/go/ast/astutil.a                           539428    539874    +446    +0.083%
cmd/vendor/golang.org/x/tools/go/cfg.a                                   286820    287270    +450    +0.157%
cmd/vendor/golang.org/x/tools/go/types/objectpath.a                      236144    236674    +530    +0.224%
cmd/vendor/golang.org/x/tools/go/types/typeutil.a                        412728    413176    +448    +0.109%
cmd/vendor/golang.org/x/tools/internal/analysisinternal.a                223256    223704    +448    +0.201%
cmd/vendor/golang.org/x/tools/internal/typeparams.a                      419498    419946    +448    +0.107%
context.a                                                                210000    209972    -28     -0.013%
crypto/internal/boring/bcache.a                                          8652      8568      -84     -0.971%
crypto/tls.a                                                             3295282   3295202   -80     -0.002%
database/sql.a                                                           1365892   1365762   -130    -0.010%
encoding/base64.a                                                        131572    136228    +4656   +3.539%
encoding/binary.a                                                        452546    453076    +530    +0.117%
encoding/gob.a                                                           1690728   1691672   +944    +0.056%
encoding/json.a                                                          1198834   1199276   +442    +0.037%
encoding/xml.a                                                           1035784   1036314   +530    +0.051%
expvar.a                                                                 285282    285678    +396    +0.139%
go/ast.a                                                                 1175212   1175662   +450    +0.038%
go/build.a                                                               657802    658252    +450    +0.068%
go/doc.a                                                                 808002    808452    +450    +0.056%
go/format.a                                                              101378    101824    +446    +0.440%
go/importer.a                                                            101816    102266    +450    +0.442%
go/internal/gccgoimporter.a                                              593828    594358    +530    +0.089%
go/internal/gcimporter.a                                                 974178    974626    +448    +0.046%
go/internal/srcimporter.a                                                196600    197050    +450    +0.229%
go/parser.a                                                              1152502   1152946   +444    +0.039%
go/printer.a                                                             910744    911194    +450    +0.049%
go/token.a                                                               299624    299768    +144    +0.048%
go/types.a                                                               5763222   5766118   +2896   +0.050%
hash/crc32.a                                                             128130    128098    -32     -0.025%
internal/fuzz.a                                                          1058644   1059174   +530    +0.050%
internal/poll.a                                                          660412    660382    -30     -0.005%
internal/testenv.a                                                       212792    213320    +528    +0.248%
log/syslog.a                                                             128718    128654    -64     -0.050%
log.a                                                                    157330    157274    -56     -0.036%
mime.a                                                                   383058    383588    +530    +0.138%
net/http/httptest.a                                                      430550    431000    +450    +0.105%
net/http/pprof.a                                                         306918    307448    +530    +0.173%
net/http.a                                                               7413852   7414074   +222    +0.003%
net/internal/socktest.a                                                  258934    258900    -34     -0.013%
net/rpc/jsonrpc.a                                                        173158    172962    -196    -0.113%
net/rpc.a                                                                634464    634914    +450    +0.071%
net.a                                                                    3539574   3541348   +1774   +0.050%
os.a                                                                     891416    891390    -26     -0.003%
reflect.a                                                                3956224   3956666   +442    +0.011%
runtime/cgo.a                                                            187406    187852    +446    +0.238%
runtime/trace.a                                                          85720     85616     -104    -0.121%
runtime.a                                                                9357520   9371302   +13782  +0.147%
sync/atomic.a                                                            232512    232376    -136    -0.058%
sync.a                                                                   353112    355068    +1956   +0.554%
syscall.a                                                                1660308   1660222   -86     -0.005%
testing.a                                                                1399348   1399198   -150    -0.011%
text/template.a                                                          1384750   1384726   -24     -0.002%
total                                                                    265209524 265294628 +85104  +0.032%

Change-Id: I21114dcddeb4fc2c56e781ea2f6e732fe3da2b01
Reviewed-on: https://go-review.googlesource.com/c/go/+/431095
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

21 months agodebug/pe: be careful to avoid potential uint32 overflow
Dan Kortschak [Sat, 27 Aug 2022 03:19:25 +0000 (12:49 +0930)]
debug/pe: be careful to avoid potential uint32 overflow

Change-Id: Ic3c1c972bec39e14ea1af50ab2b5d887dac29eab
Reviewed-on: https://go-review.googlesource.com/c/go/+/426114
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Dan Kortschak <dan@kortschak.io>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
21 months agocmd/compile: resolve known outcomes for SLTI/SLTIU on riscv64
Joel Sing [Thu, 1 Sep 2022 10:36:34 +0000 (20:36 +1000)]
cmd/compile: resolve known outcomes for SLTI/SLTIU on riscv64

When SLTI/SLTIU is used with ANDI/ORI, it may be possible to determine the
outcome based on the values of the immediates. Resolve these cases.

Improves code generation for various shift operations.

While here, sort tests by architecture to improve readability and ease
future maintenance.

Change-Id: I87e71e016a0e396a928e7d6389a2df61583dfd8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/428217
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>

21 months agoruntime/internal/sys: make Len64 nosplit
Michael Anthony Knyszek [Sat, 17 Sep 2022 02:21:12 +0000 (02:21 +0000)]
runtime/internal/sys: make Len64 nosplit

CL 427615 causes failures when Len64 can't be inlined. It's unclear to
me why this wasn't a problem before, but it is used in sensitive
contexts and therefore really should be marked. Confirmed that the
failures in question reproduce without this change, and don't reproduce
with it.

Fixes #55117.

Change-Id: Ic3aa96af1420cc0c39551908d83f954725c712f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/431058
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agocmd/dist: add old style build tags
Cherry Mui [Fri, 16 Sep 2022 23:54:51 +0000 (19:54 -0400)]
cmd/dist: add old style build tags

If one (accidentally) uses Go 1.16 as bootstrap toolchain, we
want it to print the error

found packages main (build.go) and building_Go_requires_Go_1_17_or_later (notgo117.go)

But because some files lack old style build tags, Go 1.16 instead
prints

//go:build comment without // +build comment

Add the build tags to make the error message work.

Change-Id: Iaa9b3c12e71842bb40f8687b2fda2cc4cb15b113
Reviewed-on: https://go-review.googlesource.com/c/go/+/431057
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
21 months agoruntime: treat SI_TKILL like SI_USER on Linux
Ian Lance Taylor [Thu, 15 Sep 2022 18:33:58 +0000 (11:33 -0700)]
runtime: treat SI_TKILL like SI_USER on Linux

On Linux a signal sent using tgkill will have si_code == SI_TKILL,
not SI_USER. Treat the two cases the same. Add a Linux-specific test.

Change the test to use the C pause function rather than sleeping
for a second, as that achieves the same effect.

Change-Id: I2a36646aecabcab9ec42ed9a048b07c2ff0a3987
Reviewed-on: https://go-review.googlesource.com/c/go/+/431255
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

21 months agonet/http: deflake TestServerCancelsReadHeaderTimeoutWhenIdle
Bryan C. Mills [Wed, 14 Sep 2022 18:21:23 +0000 (14:21 -0400)]
net/http: deflake TestServerCancelsReadHeaderTimeoutWhenIdle

Return errors instead of calling t.Fatalf for timing-sensitive failure
modes. Scale the Sleep call to the timeout (so that it isn't too short
for the longer durations).

Fixes #54891.

Change-Id: I574e85e121becdda9ab8ee6bfd37c18a549d366d
Reviewed-on: https://go-review.googlesource.com/c/go/+/430955
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agocmd/compile: make isConstDelta compute delta for 8 and 16 bit arithmetic
Jakub Ciolek [Fri, 16 Sep 2022 10:16:00 +0000 (12:16 +0200)]
cmd/compile: make isConstDelta compute delta for 8 and 16 bit arithmetic

Use the delta for computing min and max values. This elides a few bounds checks:

compilecmp linux/amd64:

regexp/syntax
regexp/syntax.Op.String 271 -> 249  (-8.12%)

compress/bzip2
compress/bzip2.(*reader).readBlock 2991 -> 2973  (-0.60%)

cmd/internal/objabi
cmd/internal/objabi.RelocType.String 240 -> 220  (-8.33%)

cmd/vendor/golang.org/x/arch/ppc64/ppc64asm
cmd/vendor/golang.org/x/arch/ppc64/ppc64asm.CondReg.String 421 -> 400  (-4.99%)
cmd/vendor/golang.org/x/arch/ppc64/ppc64asm.gnuArg changed
cmd/vendor/golang.org/x/arch/ppc64/ppc64asm.plan9Arg 1868 -> 1836  (-1.71%)

cmd/internal/objfile
cmd/internal/objfile.(*machoFile).symbols 1457 -> 1423  (-2.33%)
cmd/internal/objfile.loadPETable changed

cmd/internal/obj/wasm
cmd/internal/obj/wasm.assemble changed

cmd/internal/obj/ppc64
cmd/internal/obj/ppc64.type_vsrdbi changed
cmd/internal/obj/ppc64.type_vmsumcud changed

cmd/link/internal/loadpe
cmd/link/internal/loadpe.Load 10634 -> 10602  (-0.30%)
cmd/link/internal/loadpe.(*peLoaderState).readpesym changed

Change-Id: I439facd13e3d2695abadfe1d3f7faebfd0d7df74
Reviewed-on: https://go-review.googlesource.com/c/go/+/431237
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
21 months agonet: set AD bit in DNS queries when trust-ad in resolv.conf
Mateusz Poliwczak [Fri, 9 Sep 2022 06:40:57 +0000 (06:40 +0000)]
net: set AD bit in DNS queries when trust-ad in resolv.conf

Fixes #51152

Change-Id: Ib366e733434b4bb60ac93e6e622d9ba50bfe4e26
GitHub-Last-Rev: e98220d62fc4f5b60aa3e4839f46ecf8f8f75485
GitHub-Pull-Request: golang/go#54921
Reviewed-on: https://go-review.googlesource.com/c/go/+/428955
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agonet/http/httputil: remove duplicated code block
Damien Neil [Fri, 16 Sep 2022 17:28:42 +0000 (10:28 -0700)]
net/http/httputil: remove duplicated code block

Remove a harmless but redundant section of code introduced
in CL 407214.

Change-Id: Id6522e6ff13a283d726b3b97dfc72f101884f733
Reviewed-on: https://go-review.googlesource.com/c/go/+/431395
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>

21 months agoruntime: tweak bgsweep "low-priority" heuristic
Michael Anthony Knyszek [Thu, 8 Sep 2022 20:59:02 +0000 (20:59 +0000)]
runtime: tweak bgsweep "low-priority" heuristic

Currently bgsweep attempts to be a low-priority background goroutine
that runs mainly when the application is mostly idle. To avoid
complicating the scheduler further, it achieves this with a simple
heuristic: call Gosched after each span swept. While this is somewhat
inefficient as there's scheduling overhead on each iteration, it's
mostly fine because it tends to just come out of idle time anyway. In a
busy system, the call to Gosched quickly puts bgsweep at the back of
scheduler queues.

However, what's problematic about this heuristic is the number of
tracing events it produces. Average span sweeping latencies have been
measured as low as 30 ns, so every 30 ns in the sweep phase, with
available idle time, there would be a few trace events emitted. This
could result in an overwhelming number, making traces much larger than
they need to be. It also pollutes other observability tools, like the
scheduling latencies runtime metric, because bgsweep stays runnable the
whole time.

This change fixes these problems with two modifications to the
heursitic:

1. Check if there are any idle Ps before yielding. If there are, don't
   yield.
2. Sweep at least 10 spans before trying to yield.

(1) is doing most of the work here. This change assumes that the
presence of idle Ps means that there is available CPU time, so bgsweep
is already making use of idle time and there's no reason it should stop.
This will have the biggest impact on the aforementioned issues.

(2) is a mitigation for the case where GOMAXPROCS=1, because we won't
ever observe a zero idle P count. It does mean that bgsweep is a little
bit higher priority than before because it yields its time less often,
so it could interfere with goroutine scheduling latencies more. However,
by sweeping 10 spans before volunteering time, we directly reduce trace
event production by 90% in all cases. The impact on scheduling latencies
should be fairly minimal, as sweeping a span is already so fast, that
sweeping 10 is unlikely to make a dent in any meaningful end-to-end
latency. In fact, it may even improve application latencies overall by
freeing up spans and sweep work from goroutines allocating memory. It
may be worth considering pushing this number higher in the future.

Another reason to do (2) is to reduce contention on npidle, which will
be checked as part of (1), but this is a fairly minor concern. The main
reason is to capture the GOMAXPROCS=1 case.

Fixes #54767.

Change-Id: I4361400f17197b8ab84c01f56203f20575b29fc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/429615
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
21 months agoruntime/metrics: add /sync/mutex/wait/total:seconds metric
Michael Anthony Knyszek [Wed, 31 Aug 2022 21:34:23 +0000 (21:34 +0000)]
runtime/metrics: add /sync/mutex/wait/total:seconds metric

This change adds a metric to the runtime/metrics package which tracks
total mutex wait time for sync.Mutex and sync.RWMutex. The purpose of
this metric is to be able to quickly get an idea of the total mutex wait
time.

The implementation of this metric piggybacks off of the existing G
runnable tracking infrastructure, as well as the wait reason set on a G
when it goes into _Gwaiting.

Fixes #49881.

Change-Id: I4691abf64ac3574bec69b4d7d4428b1573130517
Reviewed-on: https://go-review.googlesource.com/c/go/+/427618
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agoruntime: set G wait reason more consistently
Michael Anthony Knyszek [Wed, 31 Aug 2022 18:21:48 +0000 (18:21 +0000)]
runtime: set G wait reason more consistently

Currently, wait reasons are set somewhat inconsistently. In a follow-up
CL, we're going to want to rely on the wait reason being there for
casgstatus, so the status quo isn't really going to work for that. Plus
this inconsistency means there are a whole bunch of cases where we could
be more specific about the G's status but aren't.

So, this change adds a new function, casGToWaiting which is like
casgstatus but also sets the wait reason. The goal is that by using this
API it'll be harder to forget to set a wait reason (or the lack thereof
will at least be explicit). This change then updates all casgstatus(gp,
..., _Gwaiting) calls to casGToWaiting(gp, ..., waitReasonX) instead.
For a number of these cases, we're missing a wait reason, and it
wouldn't hurt to add a wait reason for them, so this change also adds
those wait reasons.

For #49881.

Change-Id: Ia95e06ecb74ed17bb7bb94f1a362ebfe6bec1518
Reviewed-on: https://go-review.googlesource.com/c/go/+/427617
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agoruntime: make the wait reason for a g blocked on a mutex more specific
Michael Anthony Knyszek [Tue, 30 Aug 2022 22:18:01 +0000 (22:18 +0000)]
runtime: make the wait reason for a g blocked on a mutex more specific

This change adds 3 new waitReasons that correspond to sync.Mutex.Lock,
sync.RWMutex.RLock, and sync.RWMutex.Lock that are plumbed down into
semacquire1 by exporting new functions to the sync package from the
runtime.

Currently these three functions show up as "semacquire" in backtraces
which isn't very clear, though the stack trace itself should reveal
what's really going on. This represents a minor improvement to backtrace
readability, though blocking on an RWMutex.w.Lock will still show up as
blocking on a regular mutex (I suppose technically it is).

This is a step toward helping the runtime identify when a goroutine is
blocked on a mutex of some kind.

For #49881.

Change-Id: Ia409b4d27e117fe4bfdc25fa541e9c58d6d587b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/427616
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

21 months agoruntime/metrics: add CPU stats
Michael Anthony Knyszek [Fri, 6 May 2022 20:11:28 +0000 (20:11 +0000)]
runtime/metrics: add CPU stats

This changes adds a breakdown for estimated CPU usage by time. These
estimates are not based on real on-CPU counters, so each metric has a
disclaimer explaining so. They can, however, be more reasonably
compared to a total CPU time metric that this change also adds.

Fixes #47216.

Change-Id: I125006526be9f8e0d609200e193da5a78d9935be
Reviewed-on: https://go-review.googlesource.com/c/go/+/404307
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Josh MacDonald <jmacd@lightstep.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agoruntime: shrink time histogram buckets
Michael Anthony Knyszek [Tue, 30 Aug 2022 03:13:36 +0000 (03:13 +0000)]
runtime: shrink time histogram buckets

There are lots of useless buckets with too much precision. Introduce a
minimum level of precision with a minimum bucket bit. This cuts down on
the size of a time histogram dramatically (~3x). Also, pick a smaller
sub bucket count; we don't need 6% precision.

Also, rename super-buckets to buckets to more closely line up with HDR
histogram literature.

Change-Id: I199449650e4b34f2a6dca3cf1d8edb071c6655c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/427615
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
21 months agotesting: allow go test -run=^$ testing
Russ Cox [Fri, 16 Sep 2022 16:05:57 +0000 (12:05 -0400)]
testing: allow go test -run=^$ testing

This should fix the ssacheck builder.

Change-Id: I4b6172df33d6447f7ec8fd8e301c6380efb92588
Reviewed-on: https://go-review.googlesource.com/c/go/+/431336
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agogo/types, types2: allow (string...) signature with NewSignatureType
Robert Griesemer [Mon, 12 Sep 2022 22:51:32 +0000 (15:51 -0700)]
go/types, types2: allow (string...) signature with NewSignatureType

Includes cases where the core type of the variadic parameter is
a slice or bytestring. Permits a client to create the signature
for various instantiations of append.

Fixes #55030.

Change-Id: I0f4983eb00c088cbe1d87954ee0b2df0ccc3bc49
Reviewed-on: https://go-review.googlesource.com/c/go/+/430455
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

21 months agocmd/link: suppress -no_pie deprecation warning on darwin
Cherry Mui [Thu, 15 Sep 2022 01:01:04 +0000 (21:01 -0400)]
cmd/link: suppress -no_pie deprecation warning on darwin

Apparently the new darwin linker starts to emit a warning about
-no_pie deprecation. Maybe we want to switch to PIE by default.
For now, suppress the warning. This also makes it easier for
backporting to previous releases.

For #54482.

Change-Id: I1a3b74c237a9d00ec3b030fc3a9940a31e5cd37e
Reviewed-on: https://go-review.googlesource.com/c/go/+/430937
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agocmd/dist: simplify exec.Cmd helpers for Go 1.19
Austin Clements [Mon, 29 Aug 2022 21:30:12 +0000 (17:30 -0400)]
cmd/dist: simplify exec.Cmd helpers for Go 1.19

When running on Go 1.19, we can further simplify some of the exec.Cmd
helpers due to API improvements. There's not much point in doing this
while the bootstrap is still 1.17, but this will queue up this
simplification in an obvious way for when we next upgrade the
bootstrap toolchain (#54265).

Updates #44505.

Change-Id: I2ebc3d5c584375ec862a1d48138ab134bd9b2366
Reviewed-on: https://go-review.googlesource.com/c/go/+/427958
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
21 months agocmd/dist: simplify exec.Cmd helpers
Austin Clements [Mon, 29 Aug 2022 21:24:01 +0000 (17:24 -0400)]
cmd/dist: simplify exec.Cmd helpers

Now that the required Go bootstrap version is 1.17, we can simplify
some of the logic for working with exec.Cmd.Env as those APIs have
been simplified.

Updates #44505.

Change-Id: Ia62ab9830320c7daf65a15f2313471dfaba687b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/427957
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
21 months agogo/printer: make ExampleFprint correctly run as online example
Shengyu Zhang [Tue, 23 Aug 2022 02:27:04 +0000 (02:27 +0000)]
go/printer: make ExampleFprint correctly run as online example

function "ExampleFprint" will be rewritten to function "main"
when displayed on the godoc pages, so the online example is failed to
run:

    Output:

    panic: function not found

    goroutine 1 [running]:
    main.parseFunc({0x4f772e, 0xf}, {0x4f713f, 0xd})
            /tmp/sandbox1264544227/prog.go:23 +0x13b
    main.main()
            /tmp/sandbox1264544227/prog.go:30 +0x45

See: https://pkg.go.dev/go/printer#example-Fprint

Add printSelf function to prevent the function not found when running in godoc
sandbox. Beside, deleting the dummy test function to make the example show
the entire file, as we want to show the newly added printSelf function.

Change-Id: Ia2b772937081b58a0fce9860838959c95f2d650c
GitHub-Last-Rev: bac11891735e48b8ffe99cd1096bcb3f08c6575d
GitHub-Pull-Request: golang/go#53141
Reviewed-on: https://go-review.googlesource.com/c/go/+/409314
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
21 months agocmd/go: delete useless env var setting in test
Russ Cox [Tue, 13 Sep 2022 13:51:13 +0000 (09:51 -0400)]
cmd/go: delete useless env var setting in test

The correct spelling is asyncpreemptoff=1,
but clearly this test doesn't need it.

Change-Id: Ic69cf5be04bf90d357a6e4d8ae3f9011f1779922
Reviewed-on: https://go-review.googlesource.com/c/go/+/430575
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
21 months agocmd/go, testing: add go test -skip flag
Russ Cox [Fri, 5 Aug 2022 18:15:03 +0000 (14:15 -0400)]
cmd/go, testing: add go test -skip flag

For proposal #41583, add a new 'go test -skip' flag to make it easy
to disable specific tests, benchmarks, examples, or fuzz targets.

Fixes #41583.

Change-Id: Id12a6575f505dafdce4a149aedc454a002e93afa
Reviewed-on: https://go-review.googlesource.com/c/go/+/421439
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
21 months agocmd/internal/objabi: record GO$GOARCH setting in object header
Russ Cox [Wed, 31 Aug 2022 18:37:11 +0000 (14:37 -0400)]
cmd/internal/objabi: record GO$GOARCH setting in object header

The object header string is meant to record the relevant toolchain
configuration, so that we don't import or link object files that are
incompatible with each other. One important part of compatibility
is the sub-architecture version (GOARM for GOARCH=arm, and so on).

Add the sub-architecture info to the object header line so that
binaries cannot be built that have inconsistent sub-architecture
configurations across the build.

This check is only important when the build system makes a mistake.
Builds using the go command don't make this kind of mistake anymore,
but we just debugged a difficult problem inside Google where a custom
build system had built part of a program with GOARM=5 and part of
a program with GOARM=7, resulting in corrupted execution when
signal-based preemption was attempted. Updating the check will avoid
this kind of problem in the future, in any custom build system, or if the
go command makes a mistake.

After this change:

% sed 3q pkg/darwin_amd64/runtime.a
!<arch>
__.PKGDEF       0           0     0     644     30525     `
go object darwin amd64 devel go1.20-102ebe10b7 Wed Aug 17 14:31:01 2022 -0400 GOAMD64=v1 X:regabiwrappers,regabiargs
%

Change-Id: I901e0758f1002dd2c58292dc65e2d06da86e4495
Reviewed-on: https://go-review.googlesource.com/c/go/+/427174
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agoruntime: switch FreeBSD to use the non-COMPAT_FREEBSD11 version of the kevent syscall
Yuval Pavel Zholkover [Sat, 18 Jun 2022 19:02:14 +0000 (22:02 +0300)]
runtime: switch FreeBSD to use the non-COMPAT_FREEBSD11 version of the kevent syscall

Update #53280

Change-Id: I1c8d4510fbe8bdfe9a41575bde54ea2fbf6b67e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/413174
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Yuval Pavel Zholkover <paulzhol@gmail.com>

21 months agosyscall: remove FreeBSD 11 and below 64bit inode compatibility shims
Yuval Pavel Zholkover [Sat, 11 Jun 2022 10:25:57 +0000 (13:25 +0300)]
syscall: remove FreeBSD 11 and below 64bit inode compatibility shims

Update #53280

Change-Id: Iaa7c0cf5dbefaa8e14c2de499f99755911c17672
Reviewed-on: https://go-review.googlesource.com/c/go/+/411596
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Yuval Pavel Zholkover <paulzhol@gmail.com>
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
21 months agoreflect: allow conversion from slice to array
Cuong Manh Le [Tue, 13 Sep 2022 05:19:37 +0000 (12:19 +0700)]
reflect: allow conversion from slice to array

Updates #46505

Change-Id: Ib8f52d6ae199338f278731267c966da85dd0acdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/430475
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

21 months agotext/template/parse: simplify I/O in lexing
Rob Pike [Thu, 16 Jun 2022 07:35:05 +0000 (17:35 +1000)]
text/template/parse: simplify I/O in lexing

The concurrent model for delivering tokens was fine for pedagogy,
but has caused a few problems as the package has evolved (that is,
got more complicated). It's easy to eliminate it, simplifying or
removing some of the hacks used to work around these prolems.

The old lexer would deliver tokens over a channel to the parsing
goroutine, and continue running until EOF. In this rewrite, we
instead run the machine until a token is ready, and shut it down
until the next token is needed. The mechanism is just to return nil
as the state function, which requires a bit more threading of return
values through the state functions but is not difficult. The change
is modest.

A couple of error messages change, but otherwise the change has no
external effect. This is just an internal cleanup, long overdue.

benchmark                      old ns/op     new ns/op     delta
BenchmarkParseLarge-20         12222729      6769966       -44.61%
BenchmarkVariableString-20     73.5          73.4          -0.16%
BenchmarkListString-20         1827          1841          +0.77%

benchmark                      old allocs     new allocs     delta
BenchmarkVariableString-20     3              3              +0.00%
BenchmarkListString-20         31             31             +0.00%

benchmark                      old bytes     new bytes     delta
BenchmarkVariableString-20     72            72            +0.00%
BenchmarkListString-20         1473          1473          +0.00%

Fixes #53261

Change-Id: I4133bed2f8df16d398b707fb9509230325765c57
Reviewed-on: https://go-review.googlesource.com/c/go/+/421883
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
21 months agocmd/internal/obj/ppc64: add ISA 3.1 instructions
Paul E. Murphy [Fri, 21 May 2021 16:26:01 +0000 (11:26 -0500)]
cmd/internal/obj/ppc64: add ISA 3.1 instructions

Use ppc64map (from x/arch) to generate ISA 3.1 support for the
assembler. A new file asm9_gtables.go is added which contains
generated code to encode ISA 3.1 instructions, a function to assist
filling out the oprange structure, a lookup table for the fixed
bits of each instructions, and a slice of string name. Generated
functions are shared if their bitwise encoding match, and the
translation from an obj.Prog structure matches.

The generated file is entirely self-contained, and does not require
regenerating any other files for changes within it. If opcodes in
a.out.go are reordered or changed, anames.go must be updated in
the same way as before.

Future improvements could shrink the generated opcode table
to 32 bit entries as there is much less variation of the
encoding of the prefix word, but it is not always identical
for instructions which share a similar encoding of arguments
(e.g PLWA and PLWZ).

Updates #44549

Change-Id: Ie83fa02497c9ad2280678d68391043d3aae63175
Reviewed-on: https://go-review.googlesource.com/c/go/+/419535
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>

21 months agocmd/asm, cmd/internal/obj/ppc64: increase asm test coverage for PPC64
Archana R [Mon, 12 Sep 2022 17:13:12 +0000 (12:13 -0500)]
cmd/asm, cmd/internal/obj/ppc64: increase asm test coverage for PPC64

This CL adds tests for some of the instructions that were
missing. A minor change was made to asm9.go to ensure EXTSWSLICC
test works.

Change-Id: I95cd096c85778fc93856d213aa4fb14c35228cec
Reviewed-on: https://go-review.googlesource.com/c/go/+/430376
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>

21 months agoos: convert Process.isdone to atomic type
cuiweixie [Sat, 27 Aug 2022 02:13:50 +0000 (10:13 +0800)]
os: convert Process.isdone to atomic type

Change-Id: Ia3213d22678be0d56bf4f34dfe458441f7f5da97
Reviewed-on: https://go-review.googlesource.com/c/go/+/426077
Run-TryBot: Michael Pratt <mpratt@google.com>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>

21 months agodatabase: convert DB.{waitDuration,numClosed} to atomic type
cuiweixie [Sat, 27 Aug 2022 03:34:08 +0000 (11:34 +0800)]
database: convert DB.{waitDuration,numClosed} to atomic type

Change-Id: I4a67a5e51a98938c07b3c38442f8d852db97cb2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/426085
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
21 months agocmd/link: support -fno-plt compiled gcc objects on ppc64le
Paul E. Murphy [Mon, 13 Jun 2022 15:59:31 +0000 (10:59 -0500)]
cmd/link: support -fno-plt compiled gcc objects on ppc64le

This is the initial trivial implemenation. Further improvements can be
made for local calls.

A test is added, but the -fno-plt option is ignored by gcc if binutils
does not support inline plt relocations, so the test is effectively
skipped on such hosts.

Fixes #53345

Change-Id: Ibf31c26b1a8551c942b21019df8782c00b7a563e
Reviewed-on: https://go-review.googlesource.com/c/go/+/412714
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>

21 months agotime: move RFC 3339 optimizations to separate file
Joe Tsai [Tue, 13 Sep 2022 17:54:07 +0000 (10:54 -0700)]
time: move RFC 3339 optimizations to separate file

The optimizations were added in CL 425197 and CL 421877.
Move this functionality to a separate file to keep format.go smaller
and to document the justification for why this optimization exists.

Change-Id: I1e4e1ace19f9d596d8c0cf49ab6062f63a87b5bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/430675
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>

21 months agosyscall: use fcntl F_DUP2FD_CLOEXEC in forkAndExecInChild on dragonfly
Tobias Klauser [Tue, 13 Sep 2022 10:15:02 +0000 (12:15 +0200)]
syscall: use fcntl F_DUP2FD_CLOEXEC in forkAndExecInChild on dragonfly

Use fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd) to duplicate the file
descriptor and mark is as close-on-exec instead of dup2 & fcntl.

DragonFly BSD implements dup3 like this in libc since version 5.4.

Change-Id: I80c765faa288add8ffb236284c9e8c4f8e6c6769
Reviewed-on: https://go-review.googlesource.com/c/go/+/430535
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
21 months agostrconv: add a test case when base is illegal
cui fliter [Mon, 12 Sep 2022 09:27:11 +0000 (09:27 +0000)]
strconv: add a test case when base is illegal

Increase unit test coverage of strconv/itoa.go from 83.8% to 85%

Change-Id: I0abdfc70a3f06251106f229c12ffb105eeb43fc8
GitHub-Last-Rev: da9755368b5db41123c8f945fecedd135e9f894a
GitHub-Pull-Request: golang/go#55014
Reviewed-on: https://go-review.googlesource.com/c/go/+/430137
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>

21 months agohash/crc32: remove redundant code
Erik Pellizzon [Wed, 14 Sep 2022 10:13:06 +0000 (10:13 +0000)]
hash/crc32: remove redundant code

Merge the CRC32 Update and Write functions using an unexported function, to avoid duplication of code and make it more readable.
The only difference between them is the check of the initialization of the IEEE table, and a boolean value specifies that.

Throughout the crc32.go file, in the switches the default value is inserted inside the switch statement, this change uniforms the style of the MakeTable function, making it like the other pieces of code.

Change-Id: I3889f6c6671210c82f0d7250cea67907bccf3ce7
GitHub-Last-Rev: b8777ee213f2ebad0bb4a5dcdb812fd356d6d086
GitHub-Pull-Request: golang/go#55044
Reviewed-on: https://go-review.googlesource.com/c/go/+/430456
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

21 months agosyscall: use fcntl F_DUP2FD_CLOEXEC in forkAndExecInChild on solaris
Tobias Klauser [Wed, 14 Sep 2022 08:45:15 +0000 (10:45 +0200)]
syscall: use fcntl F_DUP2FD_CLOEXEC in forkAndExecInChild on solaris

Use fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd) to duplicate the file
descriptor and mark is as close-on-exec instead of dup2 & fcntl.

Note that the value for F_DUP2FD_CLOEXEC is different on Solaris and
Illumos and thus the definition is moved from zerrors_solaris_amd64.go
to solaris/illumos specific files.

Change-Id: I9a52801d1a01471ec3f065520575e3fafee92855
Reviewed-on: https://go-review.googlesource.com/c/go/+/428375
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

21 months agotext/template: fixed typo in a nested template definition
kurochan [Thu, 15 Sep 2022 00:02:32 +0000 (00:02 +0000)]
text/template: fixed typo in a nested template definition

The text was mistakenly quoted with backquotes.

Change-Id: I77ed4adac8c78b719bea61c08f1c377ed4ac4c9d
GitHub-Last-Rev: 6f1430fe167ad34effd75e8f2ac441436a81a878
GitHub-Pull-Request: golang/go#55059
Reviewed-on: https://go-review.googlesource.com/c/go/+/430775
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>

21 months agocmd/compile: make encoding/binary appends cheaper to inline
Wayne Zuo [Thu, 15 Sep 2022 07:14:52 +0000 (15:14 +0800)]
cmd/compile: make encoding/binary appends cheaper to inline

Go 1.19 introduce new append-like APIs in package encoding/binary, this
change teaches the inliner to treat calls to these methods as cheap, so
that code using them will be more inlineable.

Updates #42958

Change-Id: Ie3dd4906e285430f435bdedbf8a11fdffce9302d
Reviewed-on: https://go-review.googlesource.com/c/go/+/431015
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
21 months agocmd/compile: avoid sign extension after word arithmetic on riscv64
Wayne Zuo [Wed, 7 Sep 2022 09:40:11 +0000 (17:40 +0800)]
cmd/compile: avoid sign extension after word arithmetic on riscv64

These instructions already do sign extension on output, so we can get rid of it.

Note: (MOVWreg (MULW x y)) may araise from divisions by constant,
generic rules replace them with multiply and may produce (Rsh32x64 (Mul32 _ _) _).

Change-Id: I41bc9b519e38bc6027311de604dadb962cd0bbf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/429757
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
21 months agocmd/go: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 12:36:49 +0000 (20:36 +0800)]
cmd/go: use strings.Builder

Change-Id: I0db93b7bdcd622ce9e23df183de4737744e6d6ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/428294
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>

21 months agointernal/syscall/unix: remove superfluous var declarations in {Unlink,Open}at
Tobias Klauser [Thu, 15 Sep 2022 18:26:46 +0000 (20:26 +0200)]
internal/syscall/unix: remove superfluous var declarations in {Unlink,Open}at

Change-Id: Id58e3aebf325433768675523bf34c0b7e0e34aea
Reviewed-on: https://go-review.googlesource.com/c/go/+/431235
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agocompress/flate: update NewReader documentation
Joe Tsai [Mon, 12 Sep 2022 17:15:37 +0000 (10:15 -0700)]
compress/flate: update NewReader documentation

Calling close is no longer necessary.
It was was originally necessary to cleanup goroutines
spawned to decompress the stream.
This has not been the case since CL 4548079.

Update the documentation to mention how it handles trailing data
after the end of the DEFLATE stream.

Change-Id: Ieacba264230560713b7b8d604665223fd096f4ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/430377
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
21 months agoruntime: optimise memclrNoHeapPointers on riscv64
Joel Sing [Sat, 27 Aug 2022 19:31:18 +0000 (05:31 +1000)]
runtime: optimise memclrNoHeapPointers on riscv64

Implement a more optimised memclrNoHeapPointers on riscv64, where up
to 64 bytes are zeroed per loop after achieving alignment.

name                     old time/op    new time/op     delta
Memclr/5-4                 53.1ns _ 0%     37.0ns _ 4%   -30.37%  (p=0.002 n=3+3)
Memclr/16-4                42.3ns _ 0%     34.8ns _ 0%   -17.81%  (p=0.000 n=3+3)
Memclr/64-4                67.8ns _ 0%     44.0ns _ 1%   -35.09%  (p=0.000 n=3+3)
Memclr/256-4                185ns _ 0%       78ns _ 1%   -57.52%  (p=0.000 n=3+3)
Memclr/4096-4              2.50_s _ 1%     0.76_s _ 1%   -69.72%  (p=0.000 n=3+3)
Memclr/65536-4             55.6_s _ 0%     31.4_s _ 0%   -43.56%  (p=0.000 n=3+3)
Memclr/1M-4                1.15ms _ 0%     0.72ms _ 1%   -37.14%  (p=0.000 n=3+3)
Memclr/4M-4                12.1ms _ 3%     10.1ms _ 0%   -16.51%  (p=0.007 n=3+3)
Memclr/8M-4                25.2ms _ 1%     21.5ms _ 0%   -14.75%  (p=0.001 n=3+3)
Memclr/16M-4               52.8ms _ 5%     43.4ms _ 0%   -17.95%  (p=0.019 n=3+3)
Memclr/64M-4                202ms _ 1%      173ms _ 0%   -14.42%  (p=0.001 n=3+3)
MemclrRange/1K_2K-4        54.0_s _ 1%     22.0_s _ 0%   -59.26%  (p=0.000 n=3+3)
MemclrRange/2K_8K-4         176_s _ 1%       64_s _ 1%   -63.77%  (p=0.000 n=3+3)
MemclrRange/4K_16K-4        172_s _ 6%       60_s _ 0%   -65.38%  (p=0.002 n=3+3)
MemclrRange/160K_228K-4    1.54ms _ 1%     0.91ms _ 0%   -40.60%  (p=0.000 n=3+3)

name                     old speed      new speed       delta
Memclr/5-4               94.1MB/s _ 0%  135.3MB/s _ 4%   +43.70%  (p=0.004 n=3+3)
Memclr/16-4               378MB/s _ 0%    460MB/s _ 0%   +21.67%  (p=0.000 n=3+3)
Memclr/64-4               943MB/s _ 0%   1454MB/s _ 1%   +54.07%  (p=0.000 n=3+3)
Memclr/256-4             1.39GB/s _ 0%   3.26GB/s _ 1%  +135.38%  (p=0.000 n=3+3)
Memclr/4096-4            1.64GB/s _ 1%   5.41GB/s _ 1%  +230.28%  (p=0.000 n=3+3)
Memclr/65536-4           1.18GB/s _ 0%   2.09GB/s _ 0%   +77.19%  (p=0.000 n=3+3)
Memclr/1M-4               914MB/s _ 0%   1454MB/s _ 1%   +59.08%  (p=0.000 n=3+3)
Memclr/4M-4               346MB/s _ 3%    415MB/s _ 0%   +19.73%  (p=0.004 n=3+3)
Memclr/8M-4               332MB/s _ 1%    390MB/s _ 0%   +17.29%  (p=0.000 n=3+3)
Memclr/16M-4              318MB/s _ 5%    387MB/s _ 0%   +21.72%  (p=0.013 n=3+3)
Memclr/64M-4              333MB/s _ 1%    389MB/s _ 0%   +16.84%  (p=0.001 n=3+3)
MemclrRange/1K_2K-4      1.78GB/s _ 1%   4.36GB/s _ 0%  +145.48%  (p=0.000 n=3+3)
MemclrRange/2K_8K-4      1.89GB/s _ 1%   5.22GB/s _ 1%  +176.03%  (p=0.000 n=3+3)
MemclrRange/4K_16K-4     1.88GB/s _ 5%   5.42GB/s _ 0%  +188.40%  (p=0.000 n=3+3)
MemclrRange/160K_228K-4  1.08GB/s _ 1%   1.82GB/s _ 0%   +68.35%  (p=0.000 n=3+3)

Change-Id: Ide566f148f890f70217ed08fd472ee5893d3511c
Reviewed-on: https://go-review.googlesource.com/c/go/+/426255
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
21 months agocmd/link: stop passing -pagezero_size to darwin linker
Cherry Mui [Wed, 14 Sep 2022 23:50:00 +0000 (19:50 -0400)]
cmd/link: stop passing -pagezero_size to darwin linker

We added -pagezero_size in CL 72730, where it was intented for iOS.
The current code passes it only on macOS/AMD64 instead. It is not
really necessary there. Also, the new darwin linker starts to emit
a warning about deprecation of the flag. Stop passing it.

For #54482.

Change-Id: If9db7a1645c37d4284e48f075856912df8d8c1a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/430936
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

21 months agoruntime/race: introduce subarch versioning of race syso
Keith Randall [Mon, 15 Aug 2022 21:58:02 +0000 (14:58 -0700)]
runtime/race: introduce subarch versioning of race syso

Allow us to select a race .syso file based on subarch values.

Note that this doesn't actually change the syso used. This CL
just moves things around in preparation for adding v3-specific
versions in future CLs.

Change-Id: I14e3c273a7c6f07b13b22193b7a851ea94c765cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/424034
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

21 months agocmd, syscall: use syscall.Mmap on solaris for Go ≥ 1.20
Tobias Klauser [Wed, 14 Sep 2022 15:08:15 +0000 (17:08 +0200)]
cmd, syscall: use syscall.Mmap on solaris for Go ≥ 1.20

CL 413374 added syscall.Mmap on solaris. Use it in cmd/compile and
cmd/link if the bootstrap toolchain is Go ≥ 1.20.

For #52875
For #54265

Change-Id: I9a0534bf97926eecf0c6f1f9218e855344ba158f
Reviewed-on: https://go-review.googlesource.com/c/go/+/430496
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

21 months agonet/http/httputil: forward 1xx responses in ReverseProxy
Kévin Dunglas [Tue, 30 Aug 2022 10:18:50 +0000 (10:18 +0000)]
net/http/httputil: forward 1xx responses in ReverseProxy

Support for 1xx responses has recently been merged in
net/http (CL 269997).

As discussed in this CL
(https://go-review.googlesource.com/c/go/+/269997/comments/1ff70bef_c25a829a),
support for forwarding 1xx responses in ReverseProxy has been extracted
in this separate patch.

According to RFC 7231, "a proxy MUST forward 1xx responses unless the
proxy itself requested the generation of the 1xx response".
Consequently, all received 1xx responses are automatically forwarded as long as the
underlying transport supports ClientTrace.Got1xxResponse.

Fixes #26088
Fixes #51914

Change-Id: I3a35ea023b798bfe56b7fb8696d5a49695229cfd
GitHub-Last-Rev: dab8a461fb65b547306cae9b4c664e60020a8fa6
GitHub-Pull-Request: golang/go#53164
Reviewed-on: https://go-review.googlesource.com/c/go/+/409536
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Rhys Hiltner <rhys@justin.tv>
Run-TryBot: hopehook <hopehook@golangcn.org>

21 months agoall: remove unnecessary allocations from w.WriteString(fmt.Sprint*(...)) by fmt.Fprin...
Emmanuel T Odeke [Fri, 9 Sep 2022 16:59:21 +0000 (09:59 -0700)]
all: remove unnecessary allocations from w.WriteString(fmt.Sprint*(...)) by fmt.Fprint*(w, ...)

Noticed in a manual audit from a customer codebase that the pattern

    w.WriteString(fmt.Sprint*(args...))

was less efficient and in most cases we can just invoke:

    fmt.Fprint*(w, args...)

and from the simple benchmarks we can see quick wins in all dimensions:

$ benchstat before.txt after.txt
name            old time/op    new time/op    delta
DetailString-8    5.48µs ±23%    4.40µs ±11%  -19.79%  (p=0.000 n=20+17)

name            old alloc/op   new alloc/op   delta
DetailString-8    2.63kB ± 0%    2.11kB ± 0%  -19.76%  (p=0.000 n=20+20)

name            old allocs/op  new allocs/op  delta
DetailString-8      63.0 ± 0%      50.0 ± 0%  -20.63%  (p=0.000 n=20+20)

Change-Id: I47a2827cd34d6b92644900b1bd5f4c0a3287bdb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/429861
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
21 months agogo/types, types2: improve readability of _InvalidUntypedConversion docs
Ali Yousefi Sabzevar [Tue, 13 Sep 2022 07:39:19 +0000 (09:39 +0200)]
go/types, types2: improve readability of _InvalidUntypedConversion docs

Remove an unnecessary 'an' from errorcodes.go.

Change-Id: Iabe8ce479077cbfff936d57c788a9b39d7e5b34e
Reviewed-on: https://go-review.googlesource.com/c/go/+/430495
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

21 months agostrings: reuse the input string for Repeat count of 1
Anuraag Agrawal [Fri, 10 Jun 2022 05:41:02 +0000 (05:41 +0000)]
strings: reuse the input string for Repeat count of 1

The existing implementation allocates a new string even when the
count is 1, where we know the output is the same as the input.
While we wouldn't expect a count of 1 for hardcoded values of the
parameter, it is expected when the parameter is computed based on
a different value (e.g., the length of a input slice).

name            old time/op  new time/op  delta
Repeat/5x0-10   2.03ns ± 0%  2.02ns ± 0%   ~     (p=1.000 n=1+1)
Repeat/5x1-10   13.7ns ± 0%   2.0ns ± 0%   ~     (p=1.000 n=1+1)
Repeat/5x2-10   18.2ns ± 0%  18.1ns ± 0%   ~     (p=1.000 n=1+1)
Repeat/5x6-10   27.0ns ± 0%  27.0ns ± 0%   ~     (p=1.000 n=1+1)
Repeat/10x0-10  2.02ns ± 0%  2.02ns ± 0%   ~     (p=1.000 n=1+1)
Repeat/10x1-10  16.1ns ± 0%   2.0ns ± 0%   ~     (p=1.000 n=1+1)
Repeat/10x2-10  20.8ns ± 0%  20.9ns ± 0%   ~     (p=1.000 n=1+1)
Repeat/10x6-10  29.2ns ± 0%  29.4ns ± 0%   ~     (p=1.000 n=1+1)

Change-Id: I48e08e08f8f6d6914d62b3d6a61d563d637bec59
GitHub-Last-Rev: 068f58e08b8f5c4105e7a210f242ca1ff3a61177
GitHub-Pull-Request: golang/go#53321
Reviewed-on: https://go-review.googlesource.com/c/go/+/411477
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
21 months agogo/build: remove unnecessary copies of package variables
Ian Lance Taylor [Fri, 9 Sep 2022 00:17:55 +0000 (17:17 -0700)]
go/build: remove unnecessary copies of package variables

These variables never change, we don't need second copies of them.

Also rename bPlusBuild to plusBuild, since it is the only remaining
variable with a "b" prefix.

Change-Id: I97089b001d23e9b0f2096e19d9ceed7a9bbb377d
Reviewed-on: https://go-review.googlesource.com/c/go/+/429636
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
21 months agocmd/go/testdata/script: remove reference to fixed issue
Bryan C. Mills [Thu, 25 Aug 2022 18:55:00 +0000 (14:55 -0400)]
cmd/go/testdata/script: remove reference to fixed issue

The issue referenced in work_prune.txt was fixed in CL 362754, but we
forgot to update the TODO or mark the issue as fixed in the commit
message.

Updates #48331.

Change-Id: Id2115e496aeaef275dd3c8d32c5c5564e6addb07
Reviewed-on: https://go-review.googlesource.com/c/go/+/425485
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
21 months agopath/filepath: document that WalkDir uses OS paths
Ian Lance Taylor [Tue, 10 May 2022 23:16:19 +0000 (16:16 -0700)]
path/filepath: document that WalkDir uses OS paths

Fixes #52812

Change-Id: Idb70d0540bbf9ecdc64293c62a23f07ee3be883c
Reviewed-on: https://go-review.googlesource.com/c/go/+/405615
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Caleb Spare <cespare@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agoall: move //go:build lines below copyright notice
Tobias Klauser [Fri, 9 Sep 2022 08:34:58 +0000 (10:34 +0200)]
all: move //go:build lines below copyright notice

Change-Id: Ib6196f01b1927ea8a84c095f445320f03a514dd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/429796
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
21 months agocmd/go/internal/vcs: replace [A-Za-z0-9_] with \w in regexps
jiepeng [Wed, 7 Sep 2022 02:59:46 +0000 (02:59 +0000)]
cmd/go/internal/vcs: replace [A-Za-z0-9_] with \w in regexps

Change-Id: Ibcc7dbb528585b019ff1b743792a52f43a4c2233
GitHub-Last-Rev: e907fb00e3202ce394750542084569058b7d960e
GitHub-Pull-Request: golang/go#54882
Reviewed-on: https://go-review.googlesource.com/c/go/+/428535
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agocmd/compile: don't use R25 as input for LoweredMove on ARM64
Cherry Mui [Fri, 9 Sep 2022 22:43:08 +0000 (18:43 -0400)]
cmd/compile: don't use R25 as input for LoweredMove on ARM64

The rule uses R25 as a scratch register. If the input is R25 it
will be clobbered on the way, causing wrong result.

Change-Id: I464eadbdef0f3a5e90f9ef8c818393baa4335b87
Reviewed-on: https://go-review.googlesource.com/c/go/+/430015
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
21 months agoruntime: convert timer.status to atomic type
cui fliter [Thu, 8 Sep 2022 11:29:09 +0000 (11:29 +0000)]
runtime: convert timer.status to atomic type

For #53821

Change-Id: I7cb6a16626964d5023b96609d9921bfe4a679d8f
GitHub-Last-Rev: ddfce125be4aa565aa4d2081841c649bf2f71459
GitHub-Pull-Request: golang/go#54865
Reviewed-on: https://go-review.googlesource.com/c/go/+/428196
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agonet/http: make DefaultTransport docs about HTTP proxy consistent
Vladimir Varankin [Sat, 10 Sep 2022 20:07:36 +0000 (20:07 +0000)]
net/http: make DefaultTransport docs about HTTP proxy consistent

The changes improve the documentation for DefaultTransport, making
the style with how the HTTP proxy environment variables are being
referred to, consistent with the rest of the project's
documentation.

Also mention HTTPS_PROXY environment variables, as suggested in #32649.

Change-Id: I4e6b49881d7b30b5a0d4699531fa7c2929fc49f7
GitHub-Last-Rev: 2fc751937be685aa45acf43cf37b8ba2da124e4e
GitHub-Pull-Request: golang/go#54996
Reviewed-on: https://go-review.googlesource.com/c/go/+/430135
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agoreflect: move benchmarks to its own file
Cuong Manh Le [Fri, 9 Sep 2022 03:49:50 +0000 (10:49 +0700)]
reflect: move benchmarks to its own file

all_test.go is quite big, so let it contain tests only.

Change-Id: I5003db4a8b1e2384ea8470f5e89e1c26d61d10ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/429759
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

21 months agoruntime: set userForced while holding gcsema
Leonard Wang [Sun, 24 Apr 2022 04:14:13 +0000 (12:14 +0800)]
runtime: set userForced while holding gcsema

Fixes #52515

Change-Id: If10068a97733daf61aba72da5ed3935db8eed8b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/401776
Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agosyscall: simplify unsafe.Slice usage
Cuong Manh Le [Fri, 9 Sep 2022 18:43:16 +0000 (01:43 +0700)]
syscall: simplify unsafe.Slice usage

Same as CL 429915.

Change-Id: I83f4d3bd980294d5bae387d875368b069be2d91a
Reviewed-on: https://go-review.googlesource.com/c/go/+/429955
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>

21 months agocmd/internal/objabi: declare HeadType String on a non-pointer receiver
Joel Sing [Tue, 13 Sep 2022 09:32:34 +0000 (19:32 +1000)]
cmd/internal/objabi: declare HeadType String on a non-pointer receiver

objabi.HeadType is typically used as a non-pointer type, however the String function
is declared on a pointer receiver. This means that in most cases its integer value
is printed, rather than the value from the String function.

Change-Id: I3d28d9680e88a714bc1152ed5e1df4ac43d7a33f
Reviewed-on: https://go-review.googlesource.com/c/go/+/430556
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Jenny Rakoczy <jenny@golang.org>

21 months agostrings: add a test case of growLen is negative
cui fliter [Mon, 12 Sep 2022 15:50:04 +0000 (15:50 +0000)]
strings: add a test case of growLen is negative

Before committing,  the test coverage of strings/builder.go is 97.4%
After committing,  the test coverage of strings/builder.go is 100%

Change-Id: I22643b1c4632b5ca7ef98362f32bb85faae80bad
GitHub-Last-Rev: 2a55ca3e33d3aabd2ccc047de580abcfe05d6bb4
GitHub-Pull-Request: golang/go#55004
Reviewed-on: https://go-review.googlesource.com/c/go/+/430156
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
21 months agocmd/link: generate an error if the entry symbol cannot be found
Joel Sing [Tue, 13 Sep 2022 09:28:58 +0000 (19:28 +1000)]
cmd/link: generate an error if the entry symbol cannot be found

If the entry symbol cannot be found (for example, a new port is being brought
up and no rt0 code has been provided), the linker will currently panic. Rather
than panicing, generate an error that aids in debugging:

missing entry symbol "_rt0_arm64_openbsd"

Change-Id: I9cc38eaab48f730d596ca7fa9e9e3d68250ae4d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/430555
Auto-Submit: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
21 months agotime: optimize Parse for RFC3339 and RFC3339Nano
Joe Tsai [Mon, 22 Aug 2022 18:29:03 +0000 (11:29 -0700)]
time: optimize Parse for RFC3339 and RFC3339Nano

RFC 3339 is the most common time representation,
being used in an overwhelming 57.3% of all specified formats,
while the next competitor only holds 7.5% usage.
Specially optimize parsing to handle the RFC 3339 format.
To reduce the complexity of error checking,
parseRFC3339 simply returns a bool indicating parsing success.
It leaves error handling to the general parse path.

To assist in fuzzing, the internal parse function was left unmodified
so that we could test that parseRFC3339 and parse agree with each other.

Performance:

name             old time/op  new time/op  delta
ParseRFC3339UTC  112ns ± 1%   37ns ± 1%    -67.37%  (p=0.000 n=9+9)
ParseRFC3339TZ   259ns ± 2%   67ns ± 1%    -73.92%  (p=0.000 n=10+9)

Credit goes to Amarjeet Anand for a prior CL attemping to optimize this.
See CL 425014.

Fixes #54093

Change-Id: I14f4e8c52b092d44ceef6863f261842ed7e83f4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/425197
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
21 months agoruntime: replace stringStruct with unsafe.String where appropriate
Cuong Manh Le [Wed, 7 Sep 2022 06:23:10 +0000 (13:23 +0700)]
runtime: replace stringStruct with unsafe.String where appropriate

Simplify the code a bit, no significant performance changes.

name                             old time/op    new time/op    delta
HashStringSpeed-8                  9.64ns ±11%    8.91ns ± 9%   -7.60%  (p=0.007 n=10+10)
HashStringArraySpeed-8             19.8ns ± 3%    19.5ns ± 2%     ~     (p=0.085 n=10+10)
MapStringKeysEight_16-8            10.7ns ± 3%    10.2ns ± 2%   -4.48%  (p=0.000 n=10+10)
MapStringKeysEight_32-8            8.89ns ± 3%    8.71ns ± 3%     ~     (p=0.082 n=9+10)
MapStringKeysEight_64-8            8.84ns ± 2%    8.60ns ± 3%   -2.73%  (p=0.004 n=9+10)
MapStringKeysEight_1M-8            8.90ns ± 3%    8.62ns ± 3%   -3.15%  (p=0.000 n=10+10)
MapStringConversion/32/simple-8    8.62ns ± 3%    8.61ns ± 2%     ~     (p=0.895 n=10+10)
MapStringConversion/32/struct-8    8.53ns ± 2%    8.63ns ± 2%     ~     (p=0.123 n=10+10)
MapStringConversion/32/array-8     8.54ns ± 2%    8.50ns ± 1%     ~     (p=0.590 n=9+9)
MapStringConversion/64/simple-8    8.44ns ± 2%    8.38ns ± 2%     ~     (p=0.353 n=10+10)
MapStringConversion/64/struct-8    8.41ns ± 2%    8.48ns ± 2%     ~     (p=0.143 n=10+10)
MapStringConversion/64/array-8     8.42ns ± 2%    8.44ns ± 2%     ~     (p=0.739 n=10+10)
MapInterfaceString-8               13.6ns ±26%    13.6ns ±20%     ~     (p=0.736 n=10+9)
AppendGrowString-8                 38.9ms ± 9%    40.2ms ±13%     ~     (p=0.481 n=10+10)
CompareStringEqual-8               3.03ns ± 2%    2.86ns ± 3%   -5.58%  (p=0.000 n=10+10)
CompareStringIdentical-8           1.20ns ± 3%    1.01ns ± 4%  -16.16%  (p=0.000 n=10+10)
CompareStringSameLength-8          2.11ns ± 3%    1.85ns ± 3%  -12.33%  (p=0.000 n=10+10)
CompareStringDifferentLength-8     0.30ns ± 0%    0.30ns ± 0%     ~     (p=0.508 n=10+9)
CompareStringBigUnaligned-8        43.0µs ± 1%    42.8µs ± 2%     ~     (p=0.165 n=10+10)
CompareStringBig-8                 43.2µs ± 2%    43.4µs ± 2%     ~     (p=0.661 n=9+10)
ConcatStringAndBytes-8             15.1ns ± 1%    14.9ns ± 1%   -1.57%  (p=0.001 n=8+10)
SliceByteToString/1-8              2.45ns ± 2%    2.39ns ± 2%   -2.64%  (p=0.000 n=10+10)
SliceByteToString/2-8              10.9ns ± 2%    10.8ns ± 4%     ~     (p=0.060 n=10+10)
SliceByteToString/4-8              11.9ns ± 0%    11.8ns ± 1%   -0.97%  (p=0.000 n=8+8)
SliceByteToString/8-8              13.9ns ± 1%    13.9ns ± 1%   +0.57%  (p=0.009 n=9+9)
SliceByteToString/16-8             18.0ns ± 3%    18.6ns ± 5%   +2.78%  (p=0.001 n=9+10)
SliceByteToString/32-8             20.1ns ± 3%    20.5ns ± 5%   +2.10%  (p=0.034 n=10+10)
SliceByteToString/64-8             24.3ns ± 3%    24.9ns ± 3%   +2.28%  (p=0.001 n=9+10)
SliceByteToString/128-8            33.8ns ± 1%    34.5ns ± 4%     ~     (p=0.264 n=8+10)

Updates #54854

Change-Id: I7ce57a92c5f590fa8cb31a48969d281147eb05f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/428759
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
21 months agocmd/link/internal/ld, syscall: use libc based msync on darwin for Go ≥ 1.20
Tobias Klauser [Tue, 13 Sep 2022 09:23:50 +0000 (11:23 +0200)]
cmd/link/internal/ld, syscall: use libc based msync on darwin for Go ≥ 1.20

Direct syscalls should no longer be used on darwin. Instead, directly
call libc's msync when using Go ≥ 1.20 for bootstrap.

For #54265

Change-Id: Ie3f1e6ccd1a06e7f0ddd88cdef5067393a69e8db
Reviewed-on: https://go-review.googlesource.com/c/go/+/430336
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

21 months agocmd/link/internal/ld: drop Go 1.12 compatibility on darwin
Tobias Klauser [Mon, 12 Sep 2022 15:18:49 +0000 (17:18 +0200)]
cmd/link/internal/ld: drop Go 1.12 compatibility on darwin

Go 1.17 is the minimum required version for bootstrap as of Go 1.20.
Also, the package no longer builds with Go 1.12 used for bootstrap.
Thus, drop the Go 1.12 compatibility and used linkname unconditionally.

For #44505

Change-Id: Ic160aba4a33d580987b4633a3db03a025804d090
Reviewed-on: https://go-review.googlesource.com/c/go/+/430335
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

21 months agogo/types, types2: don't print function parameter names when showing type differences
Robert Griesemer [Mon, 12 Sep 2022 22:04:20 +0000 (15:04 -0700)]
go/types, types2: don't print function parameter names when showing type differences

Add a new flag 'paramNames' to typeWriter struct to control whether
function parameter names are written or not (set by default). Unset
it when we want the function signature w/o parameter names, e.g. when
showing two signatures that are not identical. This makes is much
easier to see the typw differences in the error message.

To avoid needing to provide yet another (rarely used) boolean parameter
to typeString, remove that function in favor of setting the paramNames
flag explicitly. Adjust the code in errors.go that used typeString; the
resulting code is also more efficient (fewer bytes.Buffer allocations).

While at it, rename the typeWriter 'debug' field to 'tpSubscripts'
because that is what it controls.

Add test case and adjusted existing expected output for existing tests.

Fixes #54942.

Change-Id: I625eae30c403c39ce89951b8ea6214d783c92c75
Reviewed-on: https://go-review.googlesource.com/c/go/+/430416
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
21 months agogo/types, types2: consistently use _UnsupportedFeature error code
Robert Griesemer [Thu, 8 Sep 2022 23:33:08 +0000 (16:33 -0700)]
go/types, types2: consistently use _UnsupportedFeature error code

Change-Id: Ie880871bb855e1c1f6e543508bdc7dd415451ba3
Reviewed-on: https://go-review.googlesource.com/c/go/+/429735
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
21 months agotypes2: provide error codes to error reporting
Robert Griesemer [Thu, 8 Sep 2022 01:45:09 +0000 (18:45 -0700)]
types2: provide error codes to error reporting

This CL adds a suitable error code to every error reporting,
matching what go/types already does.

For now, the error codes are not progagated through the API,
but eventually they will be available to clients.

Also, for now the errorcodes.go file is a 1:1 copy (with
adjusted package name) of go/types/errorcodes.go.
A subsequent CL will factor out this file.

In contrast to go/types, for errors due to incorrect Go version,
the error code is always _UnsupportedFeature. In go/types, the
error sometimes is related to the specific operation.

Change-Id: I18771bc3d00bbdbf6d705bf25f2aea3c3d977b1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/429355
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

21 months agointernal/syscall/windows: simplify unsafe.Slice usage
Cuong Manh Le [Fri, 9 Sep 2022 18:34:35 +0000 (01:34 +0700)]
internal/syscall/windows: simplify unsafe.Slice usage

CL 428780 used unsafe.Slice instead of unsafeheader for simplifiying the
code. However, it can be even simpler, since "p" is already a *uin16,
the unsafe cast is not necessary.

Change-Id: Idc492b73518637997e85c0b33f8591bd19b7929f
Reviewed-on: https://go-review.googlesource.com/c/go/+/429915
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
21 months agocmd/go: record the -buildmode flag in debug.BuildInfo
cuiweixie [Thu, 8 Sep 2022 02:18:50 +0000 (02:18 +0000)]
cmd/go: record the -buildmode flag in debug.BuildInfo

Fixes #53856

Change-Id: Ib533e9fbe063b74c81f6512464a4dac5e2af0ccc
GitHub-Last-Rev: c2ae8d6f75badd55ba6cf8e093c496c9bd1baa49
GitHub-Pull-Request: golang/go#54218
Reviewed-on: https://go-review.googlesource.com/c/go/+/420937
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: xie cui <523516579@qq.com>

21 months agonet/http: convert allowQuerySemicolonsInUse to atomic type
cui fliter [Thu, 8 Sep 2022 09:26:37 +0000 (09:26 +0000)]
net/http: convert allowQuerySemicolonsInUse to atomic type

For #53821

Change-Id: I135783bd5472011f6a74d2f5ee34ce96ff49ad2b
GitHub-Last-Rev: 4da2d67ff3d19424c306e1de6a4152fc93785a97
GitHub-Pull-Request: golang/go#54863
Reviewed-on: https://go-review.googlesource.com/c/go/+/428336
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
21 months agosync: convert RWMutex.{readerCount,readerWait} to atomic type
Cuong Manh Le [Fri, 9 Sep 2022 13:53:13 +0000 (20:53 +0700)]
sync: convert RWMutex.{readerCount,readerWait} to atomic type

Change-Id: I7fd9c0636cd00891f5cdf36c0f68f897772042f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/429767
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

21 months agosync/atomic: reduce inlining cost for atomic types methods
Cuong Manh Le [Fri, 9 Sep 2022 13:38:18 +0000 (20:38 +0700)]
sync/atomic: reduce inlining cost for atomic types methods

The "&x.v" cost us 2 inline cost budget, causing extra inline cost for
the caller. By taking the fact that "v" is laid out in memory as the
first field of all atomic types, we can accessing it without addressing.

Discovering why attempting to convert sync.RWMutex.readerCount to atomic
type. RWMutex.RUnlock have the inline cost 75, with extra 7 inline cost
from Int32.Add causing it not inlinable anymore.

With this change, Int32.Add only has 5 inline cost budget, RWMutex can
use it while still be inlinable.

Change-Id: Iabe1d1bf53389b0b8b5f56b4611231b732fd9df5
Reviewed-on: https://go-review.googlesource.com/c/go/+/429766
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

21 months agointernal/poll, syscall: convert writev to direct libc call on openbsd (except mips64)
Tobias Klauser [Tue, 6 Sep 2022 22:50:53 +0000 (00:50 +0200)]
internal/poll, syscall: convert writev to direct libc call on openbsd (except mips64)

Add and use a writev libc wrapper instead of using syscall(2).

Updates golang/go#36435

Change-Id: I3c67665388ac276d9ef36868e368e91efb92800e
Reviewed-on: https://go-review.googlesource.com/c/go/+/428776
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
21 months agoruntime/race: also unmap memory if TestNonGoMemory fails
Tobias Klauser [Wed, 7 Sep 2022 11:35:24 +0000 (13:35 +0200)]
runtime/race: also unmap memory if TestNonGoMemory fails

Change-Id: I7ea150e4896fc9b2e3a6dbdd9a1c2b651e74b844
Reviewed-on: https://go-review.googlesource.com/c/go/+/428778
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agogo/ast: use strings.Builder
cui fliter [Wed, 7 Sep 2022 03:33:43 +0000 (03:33 +0000)]
go/ast: use strings.Builder

Change-Id: I9c4c3ada3a8f5d8d198cc42a4afc06972ee00c61
GitHub-Last-Rev: 4ed80119e3aef2e5bcfdb58a2d53ed64ef40892b
GitHub-Pull-Request: golang/go#54916
Reviewed-on: https://go-review.googlesource.com/c/go/+/428921
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agointernal/poll: drop redundant ENOSYS in CopyFileRange
Andy Pan [Tue, 6 Sep 2022 12:08:05 +0000 (20:08 +0800)]
internal/poll: drop redundant ENOSYS in CopyFileRange

Update CL 425881 and CL 428396

I browsed the source code related to copy_file_range in the kernel and found that the latest kernel may still return EXDEV errors in copy_file_range(2) due to certain cases, for details see: https://elixir.bootlin.com/linux/v5.19.7/source/fs/read_write.c#L1559, https://elixir.bootlin.com/linux/v5.19.7/source/fs/read_write.c#L1479, and
https://elixir.bootlin.com/linux/v5.19.7/source/fs/read_write.c#L1439.

Therefore, the EXDEV still needs to be kept, but the ENOSYS error can be safely removed.

Change-Id: I47026b8dd33f7ffc4de1306af6b67c7b4d2062d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/428555
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Andy Pan <panjf2000@gmail.com>

21 months agoos: add a test case of copying a file itself via io.Copy
Andy Pan [Mon, 5 Sep 2022 16:11:54 +0000 (00:11 +0800)]
os: add a test case of copying a file itself via io.Copy

Change-Id: Ib9746cb4f27625cb22620271b280d2da242b2fba
Reviewed-on: https://go-review.googlesource.com/c/go/+/428437
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

21 months agosyscall: add CgroupFD support for ForkExec on Linux
Kir Kolyshkin [Fri, 15 Jul 2022 04:18:15 +0000 (21:18 -0700)]
syscall: add CgroupFD support for ForkExec on Linux

Implement CLONE_INTO_CGROUP feature, allowing to put a child in a
specified cgroup in a clean and simple way. Note that the feature only
works for cgroup v2, and requires Linux kernel 5.7 or newer.

Using the feature requires a new syscall, clone3. Currently this is the
only reason to use clone3, but the code is structured in a way so that
other cases may be easily added in the future.

Add a test case.

While at it, try to simplify the syscall calling code in
forkAndExecInChild1, which became complicated over time because:

1. It was using either rawVforkSyscall or RawSyscall6 depending on
   whether CLONE_NEWUSER was set.

2. On Linux/s390, the first two arguments to clone(2) system call are
   swapped (which deserved a mention in Linux ABI hall of shame). It
   was worked around in rawVforkSyscall on s390, but had to be
   implemented via a switch/case when using RawSyscall6, making the code
   less clear.

Let's

 - modify rawVforkSyscall to have two arguments (which is also required
   for clone3);

 - remove the arguments workaround from s390 asm, instead implementing
   arguments swap in the caller (which still looks ugly but at least
   it's done once and is clearly documented now);

 - use rawVforkSyscall for all cases (since it is essentially similar to
   RawSyscall6, except for having less parameters, not returning r2, and
   saving/restoring the return address before/after syscall on 386 and
   amd64).

Updates #51246.

Change-Id: Ifcd418ebead9257177338ffbcccd0bdecb94474e
Reviewed-on: https://go-review.googlesource.com/c/go/+/417695
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

21 months agosyscall: use unsafe.Slice instead of unsafeheader package
Tobias Klauser [Wed, 7 Sep 2022 07:51:35 +0000 (09:51 +0200)]
syscall: use unsafe.Slice instead of unsafeheader package

Change-Id: I9de5aafb36d05bdc90bbdba516367eb2b200a7e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/428777
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
21 months agocmd/go/internal/modload: use atomic.Pointer for Requirements.graph
Abirdcfly [Wed, 7 Sep 2022 04:25:08 +0000 (04:25 +0000)]
cmd/go/internal/modload: use atomic.Pointer for Requirements.graph

Change-Id: Ie543e1b1df667cfaf3aafa4be727881461ee8b7d
GitHub-Last-Rev: ed993dbe2445c4797303138b62f6c7e26050dcd4
GitHub-Pull-Request: golang/go#54888
Reviewed-on: https://go-review.googlesource.com/c/go/+/428716
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
21 months agogo/printer: reduce allocations to improve performance
Daniel Martí [Fri, 19 Aug 2022 11:00:01 +0000 (12:00 +0100)]
go/printer: reduce allocations to improve performance

First, we know that Go source files almost always weigh at least a few
kilobytes, so we can kickstart the output buffer to be a reasonable size
and reduce the initial number of incremental allocations and copies when
appending bytes or strings to output.

Second, in nodeSize we use a nested printer, but we don't actually need
its printed bytes - we only need to know how many bytes it prints.
For that reason, use a throwaway buffer: the part of our output buffer
between length and capacity, as we haven't used it yet.

Third, use a sync.Pool to reuse allocated printers.
The current API doesn't allow reusing printers,
and some programs like gofmt will print many files in sequence.

Those changes combined result in a modest reduction in allocations and
CPU usage. The benchmark uses testdata/parser.go, which has just over
two thousand lines of code, which is pretty standard size-wise.

We also split the Print benchmark to cover both a medium-sized ast.File
as well as a pretty small ast.Decl node. The latter is a somewhat common
scenario in gopls, which has code actions which alter small bits of the
AST and print them back out to rewrite only a few lines in a file.

name          old time/op    new time/op     delta
PrintFile-16    5.43ms ± 1%     4.85ms ± 3%  -10.68%  (p=0.000 n=9+10)
PrintDecl-16    19.1µs ± 0%     18.5µs ± 1%   -3.04%  (p=0.000 n=10+10)

name          old speed      new speed       delta
PrintFile-16  9.56MB/s ± 1%  10.69MB/s ± 3%  +11.81%  (p=0.000 n=8+10)
PrintDecl-16  1.67MB/s ± 0%   1.73MB/s ± 1%   +3.05%  (p=0.000 n=10+10)

name          old alloc/op   new alloc/op    delta
PrintFile-16     332kB ± 0%      107kB ± 2%  -67.87%  (p=0.000 n=10+10)
PrintDecl-16    3.92kB ± 0%     3.28kB ± 0%  -16.38%  (p=0.000 n=10+10)

name          old allocs/op  new allocs/op   delta
PrintFile-16     3.45k ± 0%      2.42k ± 0%  -29.90%  (p=0.000 n=10+10)
PrintDecl-16      56.0 ± 0%       46.0 ± 0%  -17.86%  (p=0.000 n=10+10)

Change-Id: I475a3babca77532b2d51888f49710f74763d81d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/424924
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
21 months agointernal/syscall/windows: use unsafe.Slice instead of unsafeheader package
Tobias Klauser [Wed, 7 Sep 2022 15:23:03 +0000 (17:23 +0200)]
internal/syscall/windows: use unsafe.Slice instead of unsafeheader package

Follow CL 428777.

Change-Id: I5ce49322e92c5d6539bb08248e3366187c30dcd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/428780
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

21 months agoall: transfer reflect.{SliceHeader, StringHeader} to unsafeheader.{Slice, String}
hopehook [Fri, 9 Sep 2022 00:48:34 +0000 (08:48 +0800)]
all: transfer reflect.{SliceHeader, StringHeader} to unsafeheader.{Slice, String}

After we deprecated reflect.{SliceHeader, StringHeader}, it is recommended
to use unsafe.{Slice, String} to replace its work. However, the compiler
and linker cannot be migrated for the time being.

As a temporary strategy, using the "internal/unsafeheader" package like
other code is the most suitable choice at present.

For #53003.

Change-Id: I69d0ef72e2d95caabd0706bbb247a719d225c758
Reviewed-on: https://go-review.googlesource.com/c/go/+/429755
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>

21 months agoreflect: deprecate SliceHeader and StringHeader
hopehook [Fri, 9 Sep 2022 00:43:10 +0000 (08:43 +0800)]
reflect: deprecate SliceHeader and StringHeader

As discussed in CL 401434 there are substantial misuses of these in the
wild, and they are a potential source of unsafety even for code that
does not use them directly.

Since proposal #53003 has already been implemented, now is the right
time to deprecate reflect.{SliceHeader, StringHeader}.

For #53003.

Change-Id: I724cf46d4b22d2ed3cbf2b948e6aac5ee4bf0f6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/428757
Run-TryBot: hopehook <hopehook@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

21 months agocmd/asm/internal/asm: don't set testOut in testErrors
Ian Lance Taylor [Wed, 7 Sep 2022 00:24:23 +0000 (17:24 -0700)]
cmd/asm/internal/asm: don't set testOut in testErrors

It's set but the output is never used.

Change-Id: I36ecb9c5f087a85289529907ede9f9bfc295d739
Reviewed-on: https://go-review.googlesource.com/c/go/+/428637
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

21 months agostrconv: remove redundant type conversion
cui fliter [Wed, 7 Sep 2022 08:04:36 +0000 (08:04 +0000)]
strconv: remove redundant type conversion

Change-Id: I25c8e8b701d6489f360fea30d09090826276b950
GitHub-Last-Rev: c2c8319dd5fa2a53fe82b10ecbf45eb54b5d6a68
GitHub-Pull-Request: golang/go#54924
Reviewed-on: https://go-review.googlesource.com/c/go/+/428976
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
21 months agoos: fix wrong error msg from TestDoubleCloseError
Kir Kolyshkin [Wed, 7 Sep 2022 01:09:11 +0000 (18:09 -0700)]
os: fix wrong error msg from TestDoubleCloseError

When the type assertion fails, the test mistakenly prints the expected
(rather than the actual) type.

When the error string doesn't match, the text mistakenly prints the
original (rather than the converted) error (although there might not be
any difference in the output, the code looks wrong).

Fix both issues.

Change-Id: Ia7dd0632fc677f458fec25d899c46268a12f76e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/428916
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
21 months agoos: use unsafe.{Slice,StringData} instead of unsafeheader package
Tobias Klauser [Wed, 7 Sep 2022 12:07:12 +0000 (14:07 +0200)]
os: use unsafe.{Slice,StringData} instead of unsafeheader package

Change-Id: I213b078effa4b7049c44498d651de5b938e5404b
Reviewed-on: https://go-review.googlesource.com/c/go/+/428779
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: hopehook <hopehook@golangcn.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>