]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agocmd/go: allow either test to complete first in TestScript/test_chatty_parallel_succes...
Bryan C. Mills [Thu, 31 Mar 2022 15:03:00 +0000 (11:03 -0400)]
cmd/go: allow either test to complete first in TestScript/test_chatty_parallel_success_run

This fixes a failure mode observed in
https://build.golang.org/log/7b28a914b1914dabe94f7c4e36ad6466ebd4de5d,
in which the expected CONT lines are present but the test completions
are reported in a different (but valid) order.

CONT lines are only printed between interleaved output lines, so if
the ordering of the tests swaps after all output is already generated
the PASS lines can be in arbitrary order.

Fixes #51221 (again).

Change-Id: I051f8ec4331e2e3ab1bb00a7c188c322ad4e0a03
Reviewed-on: https://go-review.googlesource.com/c/go/+/397194
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: better propagation of desired registers
Keith Randall [Sat, 26 Mar 2022 17:05:04 +0000 (10:05 -0700)]
cmd/compile: better propagation of desired registers

This fixes two independent problems:

We normally propagate desired registers backwards through opcodes that
are marked resultInArg0. Unfortunately for the desired register
computation, ADDQconst is not marked as resultInArg0. This is because
the amd64 backend can write it out as LEAQ instead if the input and
output registers don't match. For desired register purposes, we want
to treat ADDQconst as resultInArg0, so that we get an ADDQ instead of
a LEAQ if we can.

Desired registers don't currently work for tuple-generating opcodes.
Declare that the desired register applies to the first element of the
tuple, and propagate the desired register back through Select0.

Noticed when fixing #51964

Change-Id: I83346b988882cd58c2d7e7e5b419a2b9a244ab66
Reviewed-on: https://go-review.googlesource.com/c/go/+/396035
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime: rewrite stale comment about pacer
Michael Anthony Knyszek [Wed, 2 Mar 2022 17:41:49 +0000 (17:41 +0000)]
runtime: rewrite stale comment about pacer

Change-Id: Ieb8015164526da59b042031234146def06f70a1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/393399
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agoruntime: add wrappers for sys* functions and consolidate docs
Michael Anthony Knyszek [Tue, 15 Mar 2022 00:23:26 +0000 (00:23 +0000)]
runtime: add wrappers for sys* functions and consolidate docs

This change lifts all non-platform-specific code out of sys* functions
for each platform up into wrappers, and moves documentation about the OS
virtual memory abstraction layer from malloc.go to mem.go, which
contains those wrappers.

Change-Id: Ie803e4447403eaafc508b34b53a1a47d6cee9388
Reviewed-on: https://go-review.googlesource.com/c/go/+/393398
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agoruntime: remove intermediate fields in memstats for ReadMemStats
Michael Anthony Knyszek [Mon, 14 Mar 2022 23:39:03 +0000 (23:39 +0000)]
runtime: remove intermediate fields in memstats for ReadMemStats

Currently, the ReadMemStats (really this is all happening in
readmemstats_m, but that's just a direct call from ReadMemStats) call
chain first populates some fields in memstats, then copies those into
the final MemStats location. This used to make a lot of sense when
memstats' structure aligned with MemStats, and the values were just
copied from one to other. Sometime in the last few releases, we switched
to populating the MemStats manually because a lot of fields had diverged
from their internal representation. Now, we're left with a lot of fields
in memstats that pollute the structure: they only exist to be updated
for the sake of ReadMemStats. Since we're going to be adding more fields
to memstats in further CLs, this is a good opportunity to clean up.

As a result of this change, updatememstats, which used to just update
the aforementioned intermediate fields in memstats, is no longer
necessary, so it is removed.

Change-Id: Ifabfb3ac3002641105af62e9509a6351165dcd87
Reviewed-on: https://go-review.googlesource.com/c/go/+/393397
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agoruntime: remove old pacer and the PacerRedesign goexperiment
Michael Anthony Knyszek [Mon, 14 Feb 2022 22:36:25 +0000 (22:36 +0000)]
runtime: remove old pacer and the PacerRedesign goexperiment

Now that Go 1.18 has been released, remove the old pacer.

Change-Id: Ie7a7596d67f3fc25d3f375a08fc75eafac2eb834
Reviewed-on: https://go-review.googlesource.com/c/go/+/393396
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agoruntime/internal/atomic: add Bool
Michael Anthony Knyszek [Mon, 14 Feb 2022 19:28:20 +0000 (19:28 +0000)]
runtime/internal/atomic: add Bool

This change adds the Bool type, a convenient wrapper around Uint8 for
atomic bool values.

Change-Id: I86127d6f213b730d6999db5718ca1a5af0c5b538
Reviewed-on: https://go-review.googlesource.com/c/go/+/393395
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agoruntime: remove AVX2less code in memclrNoHeapPointers for GOAMD64 >= 3
vpachkov [Mon, 29 Nov 2021 12:20:37 +0000 (15:20 +0300)]
runtime: remove AVX2less code in memclrNoHeapPointers for GOAMD64 >= 3

Optimize memclr by removing simple case loop along with the
runtime check since AVX2 is guaranteed to be available when
compiling with GOAMD64 >= 3

name             old speed      new speed      delta
Memclr/5-12      2.70GB/s ± 1%  2.73GB/s ± 1%     ~     (p=0.056 n=5+5)
Memclr/16-12     7.00GB/s ± 2%  7.03GB/s ± 1%     ~     (p=1.000 n=5+5)
Memclr/64-12     25.5GB/s ± 1%  25.5GB/s ± 1%     ~     (p=0.548 n=5+5)
Memclr/256-12    53.4GB/s ± 1%  52.7GB/s ± 2%     ~     (p=0.222 n=5+5)
Memclr/4096-12    109GB/s ± 1%   129GB/s ± 0%  +18.57%  (p=0.008 n=5+5)
Memclr/65536-12  75.2GB/s ± 2%  78.3GB/s ± 3%   +4.14%  (p=0.008 n=5+5)
Memclr/1M-12     53.5GB/s ± 2%  54.1GB/s ± 2%     ~     (p=0.310 n=5+5)
Memclr/4M-12     53.1GB/s ± 3%  52.9GB/s ± 2%     ~     (p=1.000 n=5+5)
Memclr/8M-12     44.6GB/s ± 3%  45.1GB/s ± 3%     ~     (p=0.310 n=5+5)
Memclr/16M-12    24.8GB/s ± 2%  24.2GB/s ± 2%     ~     (p=0.056 n=5+5)
Memclr/64M-12    38.3GB/s ± 1%  37.8GB/s ± 1%     ~     (p=0.056 n=5+5)
[Geo mean]       31.0GB/s       31.5GB/s        +1.78%

Change-Id: I6f3014f6338cb3b5a1b94503faa205f043fe2de8
Reviewed-on: https://go-review.googlesource.com/c/go/+/367494
Trust: Cherry Mui <cherryyz@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/link/internal/ld: revise recipe for ASLR enable on windows
Than McIntosh [Tue, 8 Feb 2022 17:41:26 +0000 (12:41 -0500)]
cmd/link/internal/ld: revise recipe for ASLR enable on windows

When doing external linking on windows, the existing Go linker code
assumed that the external linker defaulted to "--no-dynamicbase" (if
no explicit option was given). This assumption doesn't hold for LLD,
which turns on "--dynamicbase" by default for 64-bit apps. Change the
linker to detect whether a more modern toolchain is in use and to
explicitly pass "--dynamicbase" either way , so as to take the
external linker default out of the equation. This also applies to the
"--high-entropy-va" option as well.

Updates #35006.

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

3 years agocmd/go: update TestCgoHandlesWlORIGIN to avoid -rpath on windows
Than McIntosh [Tue, 8 Feb 2022 16:56:10 +0000 (11:56 -0500)]
cmd/go: update TestCgoHandlesWlORIGIN to avoid -rpath on windows

Tweak the cgo recipe for the TestCgoHandlesWlORIGIN testpoint to avoid
using "-rpath" on Windows, where it doesn't make sense to use it. This
change needed to avoid an "unknown flag -rpath" from clang/ldd on
windows.

Updates #35006.

Change-Id: I4fcd649df4687aa3aff5690e11a15fc0e0f42332
Reviewed-on: https://go-review.googlesource.com/c/go/+/384155
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: remove a false dependency for TZCNT
nimelehin [Mon, 6 Dec 2021 15:46:25 +0000 (18:46 +0300)]
cmd/compile: remove a false dependency for TZCNT

LZCNT/TZCNT on some Intel CPUs suffer from a false dependency on
the destination register.

The problem was mentioned in the GCC Ticket: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62011#c7
and fixed with https://gcc.gnu.org/viewcvs?rev=214112&root=gcc&view=rev

Change-Id: I8109e84f03ac85f221b06d3b913612b58320d151
Reviewed-on: https://go-review.googlesource.com/c/go/+/369019
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alex Rakoczy <alex@golang.org>
Run-TryBot: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agogo/build: set allTags even when short-circuiting x_GOOS_GOARCH.go
Ian Lance Taylor [Wed, 30 Mar 2022 23:36:14 +0000 (16:36 -0700)]
go/build: set allTags even when short-circuiting x_GOOS_GOARCH.go

Fixes #52053

Change-Id: I0e1f2737f97a4656913b34a731d8de2c77a15b4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/396918
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: clean up arm64 32bit pointer in Reverse
Wayne Zuo [Sun, 27 Mar 2022 07:12:39 +0000 (15:12 +0800)]
cmd/compile: clean up arm64 32bit pointer in Reverse

Change-Id: I0751270c0f656a501b389f2e2bb0e959d6f5a0e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/396054
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agocmd/compile: fix clobberFlags for BSWAP
Jakub Ciolek [Thu, 10 Mar 2022 14:35:17 +0000 (15:35 +0100)]
cmd/compile: fix clobberFlags for BSWAP

BSWAP does not affect EFLAGS on neither 386 nor x64. Set the clobberFlags value accordingly.

Change-Id: Ib9e88400607fea44bb51fe95dc4d77e7cb54bfec
Reviewed-on: https://go-review.googlesource.com/c/go/+/391494
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agodebug/pe: skip TestReadCOFFSymbolAuxInfo on big-endian systems
Than McIntosh [Thu, 31 Mar 2022 17:15:51 +0000 (13:15 -0400)]
debug/pe: skip TestReadCOFFSymbolAuxInfo on big-endian systems

Disable the new TestReadCOFFSymbolAuxInfo testpoint on big endian
systems, pending resolution of issue 52079. The newly added interfaces
for reading symbol definition aux info is not working properly when
reading PE objects obj big-endian systems.

Updates #52079.

Change-Id: I8d55c7e4c03fc6444ef06a6a8154cb50596ca58a
Reviewed-on: https://go-review.googlesource.com/c/go/+/397294
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile: simplify func value symbol generation
Cherry Mui [Tue, 29 Mar 2022 16:59:12 +0000 (12:59 -0400)]
cmd/compile: simplify func value symbol generation

Currently, in most cases the compiler generates a func value
symbol when it is referenced, except when building a shared object
it generates the func value symbol when the function is declared.

The comment says this was necessary because we cannot deduplicate
DUPOK symbols across DSO boundaries. But the dynamic linker is
just fine to resolve symbols with the same name across DSO
boundaries.

Another problem may be that the address of the PLT stub may be
used. When such a func value is deferred, when the runtime needs
to scan its arguments, it cannot look up the PC to find the
function and therefore cannot find its stack map. This is not a
problem now as deferred functions always have no arguments.

Remove the special case for shared linkage.

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

3 years agotest: update comments in run.go (cleanup)
Robert Griesemer [Thu, 31 Mar 2022 16:34:50 +0000 (09:34 -0700)]
test: update comments in run.go (cleanup)

The -G compiler option doesn't exist anymore. Update some variable
names and comments to reflect the new reality.

Change-Id: I227e9c59a01615c3a40c3869102e8045cb012980
Reviewed-on: https://go-review.googlesource.com/c/go/+/397254
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocrypto/elliptic: tolerate zero-padded scalars in generic P-256
Filippo Valsorda [Thu, 31 Mar 2022 16:31:58 +0000 (12:31 -0400)]
crypto/elliptic: tolerate zero-padded scalars in generic P-256

Fixes #52075

Change-Id: I595a7514c9a0aa1b9c76aedfc2307e1124271f27
Reviewed-on: https://go-review.googlesource.com/c/go/+/397135
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years agoruntime: remove use of -mnop-fun-dllimport from cgotest win.go
Than McIntosh [Mon, 7 Feb 2022 21:32:01 +0000 (16:32 -0500)]
runtime: remove use of -mnop-fun-dllimport from cgotest win.go

This flag is not supported by clang, so remove it from the cgo cflags
when building for windows. It is clear that it was needed at some
point in the past, but it doesn't appear to be needed at the moment,
since all.bash passes on windows without it now.

Updates #35006.

Change-Id: Ib06c891f516654138e3363e06645cd187e46ce4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/383838
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/link/internal/loadpe: add rudimentary COMDAT support
Than McIntosh [Mon, 7 Feb 2022 20:00:46 +0000 (15:00 -0500)]
cmd/link/internal/loadpe: add rudimentary COMDAT support

Add some rudimentary support to the PE file loader for handling
sections in COMDAT when reading host object files. This is needed
in order to link programs with support libraries that are of a more
modern vintage than GCC 5.X.

If a given section XYZ is in COMDAT, the symbol for that section will
be flagged, e.g. section 'Characteristics' field will have the
IMAGE_SCN_LNK_COMDAT bit set, and the symbol will be followed by an
"aux" symbol that includes the COMDAT handling strategy that the
linker needs to use.

This patch supports two COMDAT strategies (IMAGE_COMDAT_SELECT_ANY and
IMAGE_COMDAT_SELECT_SAME_SIZE); more work will have to be done in the
future to support other flavors if it turns out that they are needed.

Updates #35006.

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

3 years agodebug/pe: add APIs for reading section def aux info
Than McIntosh [Tue, 22 Mar 2022 12:49:52 +0000 (08:49 -0400)]
debug/pe: add APIs for reading section def aux info

Add hooks to support reading of section definition symbol aux data
(including COMDAT information) from the aux symbols associated with
section definition symbols. The COFF symbol array made available by
"pe.File" includes entries for aux symbols, but doesn't expose their
structure (since it varies depending on the type of aux symbol). This
patch adds a function for returning a specific class of aux symbol
("type 5") that immediately follows a COFF symbol corresponding to a
section definition.

Updates #35006.
Updates #51868.

Change-Id: I21fcc057150f7a3c64f01a5961aabca0fa43399e
Reviewed-on: https://go-review.googlesource.com/c/go/+/394534
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/link: resolve __CTOR_LIST__/__DTOR_LIST__ refs for PE
Than McIntosh [Mon, 7 Feb 2022 20:30:34 +0000 (15:30 -0500)]
cmd/link: resolve __CTOR_LIST__/__DTOR_LIST__ refs for PE

When doing an internal link on Windows, it's possible to see
unresolved references to the symbols "__CTOR_LIST__" and/or
"__DTOR_LIST__" (which are needed in some circumstances). If these are
still unresolved at the point where we're done reading host objects,
then synthesize dummy versions of them.

Updates #35006.

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

3 years agogo/types, types2: better error message for invalid type parameter term
Robert Griesemer [Wed, 30 Mar 2022 19:19:24 +0000 (12:19 -0700)]
go/types, types2: better error message for invalid type parameter term

The spec says "In a union, a term cannot be a type parameter,...",
but it's really the type in a term that cannot be a type parameter.
(Also, for the spec's purposes, a single term is still a union.)

This CL changes the current error message from:

        "cannot use type parameter in typeset"

to one of two messages:

        "term cannot be a type parameter"           (for term of form P)
        "type in term ~P cannot be a type parameter (for term of form ~P)

which are more specific and match the spec more closely.

Fixes #50420.

Change-Id: Id48503efc8416cabc03d5c40d8e64d5b3a7f078e
Reviewed-on: https://go-review.googlesource.com/c/go/+/396874
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agodebug/elf: check for negative shoff and phoff fields
Ian Lance Taylor [Thu, 31 Mar 2022 01:47:11 +0000 (18:47 -0700)]
debug/elf: check for negative shoff and phoff fields

No test because we could add an infinite number of tests of bogus data.

For #47653
Fixes #52035

Change-Id: Iec7e2fe23f2dd1cf14bad2475422f243f51028f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/396880
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/link: read crt2.o for windows internal-linking CGO
Than McIntosh [Thu, 3 Feb 2022 13:23:10 +0000 (08:23 -0500)]
cmd/link: read crt2.o for windows internal-linking CGO

For Windows internal linking with CGO, when using more modern
LLVM-based compilers, we may need to read in the object file "crt2.o"
so as to have a definition of "atexit" (for example when linking the
runtime/cgo test), and we also need to allow for the possibility that
a given host archive might have to be looked at more than once. The goal
here is to get all.bash working on Windows when using an up to date
mingw C compiler (including those based on clang + LLD).

This patch also adds a new "hostObject" helper routine, similar to
"hostArchive" but specific to individual object files. There is also a
change to hostArchive to modify the pseudo-package name assigned when
reading archive elements: up until this point, a package name of
"libgcc" was used (even when reading a host archive like
"libmingex.a"), which led to very confusing errors messages if symbols
were missing or there were duplicate definitions.

Updates #35006.

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

3 years agocmd/link/internal/loadpe: generalize handling of "__imp_*" syms
Than McIntosh [Thu, 3 Feb 2022 13:11:53 +0000 (08:11 -0500)]
cmd/link/internal/loadpe: generalize handling of "__imp_*" syms

The existing PE file loader has a special case for the symbol
"__acrt_iob_func", whose hosting object file contains both an actual
definition and also a DLL import symbol "__imp___acrt_iob_func". The
normal way of handling __imp_XXX symbols is for the host object loader
to rename them to their intended target (e.g. "XXX") however if the
target is also defined locally, you get a duplicate definition.

This patch generalizes the def/import symbol detection to apply to all
symbols in the object file being loaded (not just a hard-coded set),
since it will be needed when reading things like crt2.o.

Updates #35006.

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

3 years agocmd/link/internal/loadpe: refactor readpesym()
Than McIntosh [Wed, 2 Feb 2022 18:26:16 +0000 (13:26 -0500)]
cmd/link/internal/loadpe: refactor readpesym()

Rewrite the helper "readpesym()" and the code that calls it to pass in
most of the values it needs via a state object (the signature was
getting a bit too busy/lengthy). No change in functionality, this is
just a refactor.

Updates #35006.

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

3 years agonet: clean up redundant if branch in dial
Shang Ding [Thu, 24 Feb 2022 01:35:21 +0000 (19:35 -0600)]
net: clean up redundant if branch in dial

Dialer.DialContext no longer performs a redundant check on the length
of the fallback slice, because dialParallel already handles the
situation where the fallback slice is empty or nil.

Change-Id: Ibb16f4813fc55dec2939c54c10e665ff35bfe163
Reviewed-on: https://go-review.googlesource.com/c/go/+/387795
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years agotext/template: remove newline special casing in documentation
Sean Liao [Tue, 22 Mar 2022 20:53:10 +0000 (20:53 +0000)]
text/template: remove newline special casing in documentation

Updates #29770
Fixes #51872

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

3 years agomath/big: call norm when returning success from Rat SetString
Shulhan [Tue, 16 Nov 2021 18:36:15 +0000 (01:36 +0700)]
math/big: call norm when returning success from Rat SetString

After CL 24430, reflect.DeepEqual no longer returns true when comparing
a *Rat built with (*Rat).SetString("0") with one built with
(*Rat).SetInt64(0).
These should be equivalent, but because (*Rat).SetString does not call
norm() when returning the zero value, the result of reflect.DeepEqual
will be false.

One could suggest that developers should use (*Rat).Cmp instead
of relying on reflect.DeepEqual, but if a (*Rat) is part of a
larger struct that is being compared, this can be cumbersome.

This is fixed by calling z.norm() when returning zero in SetString.

Fixes #50944

Change-Id: Ib84ae975bf82fe02d1203aa9668a01960c0fd59d
Reviewed-on: https://go-review.googlesource.com/c/go/+/364434
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agostrings: limits allocation size for SplitN
Philippe Antoine [Sun, 20 Mar 2022 21:34:42 +0000 (21:34 +0000)]
strings: limits allocation size for SplitN

So that `strings.SplitN("", "T", int(144115188075855872))` does not panic.

Change-Id: Iea00417e61780bcaf0fee02fa2b18026d89bc545
GitHub-Last-Rev: d1f45b44a8011ddb27c71e1bc9983b62b5d3d771
GitHub-Pull-Request: golang/go#51755
Reviewed-on: https://go-review.googlesource.com/c/go/+/393654
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>

3 years agocmd/cgo: use size_t instead of __SIZE_TYPE__
qmuntal [Wed, 19 Jan 2022 16:01:25 +0000 (17:01 +0100)]
cmd/cgo: use size_t instead of __SIZE_TYPE__

__SIZE_TYPE__ is a GCC type which has been superseded
by size_t -define in stddef.h- since ISO C99.

cmd/cgo already uses size_t in many places, but still generates several
files using __SIZE_TYPES__, most notably the _cgo_export.h.

This change replaces all __SIZE_TYPES__ occurrences with size_t.

Updates #36233

Change-Id: Id8a99b5d7763caab9333eab9b585e78249a37415
Reviewed-on: https://go-review.googlesource.com/c/go/+/379474
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years agocmd/go: add comments to C.* special functions
qmuntal [Thu, 17 Feb 2022 09:44:13 +0000 (10:44 +0100)]
cmd/go: add comments to C.* special functions

Adding comments to these functions help IDE tooling to display
meaningful documentation, p.e. on hover.

Tested with gopls and vscode.

Updates #51134

Change-Id: Ie956f7cf192af0e828def4a141783f3a2589f77d
Reviewed-on: https://go-review.googlesource.com/c/go/+/386414
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

3 years agospec: clarify type term restriction for type parameters
Robert Griesemer [Wed, 30 Mar 2022 21:13:39 +0000 (14:13 -0700)]
spec: clarify type term restriction for type parameters

Be clear that the type of a term (not the term itself, which may
be of the form ~P) cannot be a type parameter.

For #50420.

Change-Id: I388d57be0618393d7ebe2c74ec04c1ebe3f33f7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/396915
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agohtml/template: make FuncMap a type alias of text/template.FuncMap
Emmanuel T Odeke [Sat, 5 Mar 2022 11:48:27 +0000 (14:48 +0300)]
html/template: make FuncMap a type alias of text/template.FuncMap

In preparation to make html/template and text/template use a
single generics package, this change make FuncMap a type alias
of text/template.FuncMap.

Fixes #46121

Change-Id: I5e94cc8fdf4fe029ff223992b5cdfe79f9c098ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/389156
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agogo/types, types2: no "imported but not used" error for unimported packages
Robert Griesemer [Wed, 30 Mar 2022 22:09:13 +0000 (15:09 -0700)]
go/types, types2: no "imported but not used" error for unimported packages

If a package could not be imported for whatever reason, the type checker
creates fake package with which it continues for more tolerant type
checking.

Do not report an "imported but not used" error in that case.

Clarify a few comments along the way.

Fixes #43109.

Change-Id: Ifeec0daa688fbf666412dc9176ff1522d02a23ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/396875
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile/internal/syntax: better errors for syntax errors in lists
Robert Griesemer [Wed, 30 Mar 2022 20:23:37 +0000 (13:23 -0700)]
cmd/compile/internal/syntax: better errors for syntax errors in lists

For syntax errors in various (syntactic) lists, instead of reporting
a set of "expected" tokens (which may be incomplete), provide context
and mention "possibly missing" tokens. The result is a friendlier and
more accurate error message.

Fixes #49205.

Change-Id: I38ae7bf62febfe790075e62deb33ec8c17d64476
Reviewed-on: https://go-review.googlesource.com/c/go/+/396914
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd: make go and moddeps tests insensitive to presence of src/go.work
David Chase [Wed, 30 Mar 2022 16:01:21 +0000 (12:01 -0400)]
cmd: make go and moddeps tests insensitive to presence of src/go.work

If there is a go.work file in src, "go test cmd/internal/moddeps"
and "go test cmd/go" fail.  Setting GOWORK=off in various command
invocations avoids this problem.

Change-Id: I89fd021ff94998ceda6a3bbc4c3743f08558f98b
Reviewed-on: https://go-review.googlesource.com/c/go/+/396777
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/go: remove arbitrary sleep in TestScript/test_chatty_parallel_success_sleepy
Bryan C. Mills [Wed, 16 Feb 2022 15:01:20 +0000 (10:01 -0500)]
cmd/go: remove arbitrary sleep in TestScript/test_chatty_parallel_success_sleepy

(Also rename it to no longer describe itself in terms of sleeping.)

This test previously relied on the scheduler to wake up a goroutine to
write the "--- PASS: TestFast" line within 100ms of TestFast actually
finishing. On some platforms, even that long a delay is apparently too
short.

Instead, we now use a deterministic "=== RUN" line instead of a
timing-dependent "--- PASS" line to interrupt the output.

Fixes #51221

Change-Id: I3997640fb7577e29e3866a82d4d49a3a70a4b033
Reviewed-on: https://go-review.googlesource.com/c/go/+/386154
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/dist: delete special case for release branches without VERSION
Dmitri Shuralyov [Sat, 19 Mar 2022 00:15:15 +0000 (20:15 -0400)]
cmd/dist: delete special case for release branches without VERSION

findgoversion has some logic from before the go1 release that only
has effect when on a release branch without a VERSION file.

Starting with release-branch.go1 and the go1 tag a decade ago,
release branch have always had a VERSION file checked in.
(The commit that adds/updates the VERSION file is what is tagged.)

Since we have no need to support old branches like release-branch.r60,
and such scenarios don't come up in modern Go, delete it to simplify
this code a bit. Should the VERSION file situation change, we'd need
to rework this code anyway.

Fixes #42345.

Change-Id: I13f27babd37aaa5cec30fefde1b8e6ccce816461
Reviewed-on: https://go-review.googlesource.com/c/go/+/393954
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocrypto/x509/internal/macos: return errors when CFRef might be NULL
Filippo Valsorda [Tue, 22 Mar 2022 17:35:11 +0000 (13:35 -0400)]
crypto/x509/internal/macos: return errors when CFRef might be NULL

Updates #51759

Change-Id: Ib73fa5ec62d90c7e595150217b048158789f1afd
Reviewed-on: https://go-review.googlesource.com/c/go/+/394674
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years agocmd/compile/internal/syntax: remove code dealing with multiple method names
Robert Griesemer [Wed, 30 Mar 2022 02:38:00 +0000 (19:38 -0700)]
cmd/compile/internal/syntax: remove code dealing with multiple method names

When parsing method declarations in an interface, the parser has
for historic reasons gracefully handled a list of method names with
a single (common) signature, and then reported an error. For example

        interface {
                m1, m2, m3 (x int)
        }

This code originally came from the very first parser for Go which
initially permitted such declarations (or at least assumed that
people would write such declarations). Nobody is doing this at this
point, so there's no need for being extra careful here. Remove the
respective code and adjust the corresponding test.

Change-Id: If6f9b398bbc9e425dcd4328a80d8bf77c37fe8b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/396654
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile/internal/syntax: remove generic-specific parse modes
Robert Griesemer [Wed, 30 Mar 2022 00:30:58 +0000 (17:30 -0700)]
cmd/compile/internal/syntax: remove generic-specific parse modes

Generics have landed; we cannot revert the syntax anymore. Remove
ability to choose between non-generic and generic code. Also remove
mode to enable method type parameters. Adjust code accordingly.

Also remove a couple of TODOs that are not relevant anymore.

Remove tests from types2 which were focussed on method type parameters,
make types2 and go/types tests match up where there was a difference in
this regard.

Change-Id: I989bdcb19eea7414214af739187fa013a044295d
Reviewed-on: https://go-review.googlesource.com/c/go/+/396634
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile/internal/syntax: use .go suffix for test files (cleanup)
Robert Griesemer [Tue, 29 Mar 2022 23:58:49 +0000 (16:58 -0700)]
cmd/compile/internal/syntax: use .go suffix for test files (cleanup)

- Use .go suffix for test files as go fmt doesn't descend into testdata
directories.
- Move test files from testdata/go2 into testdata directory.
- Delete some test files that contained type-checker ERROR markers that
  were ignored by the TestParseGo2 test but would be considered by the
  TestSyntaxErrors test if the files were moved unchanged into the
  testdata directory.
- Remove one (type checker) ERROR marker in testdata/slices.go to make
  it pass the syntax error tests.
- Delete TestParseGo2 test. There's enough coverage with the existing
  TestSyntaxErrors test.
- Add missing copyright notice to testdata/chans.go and gofmt the file.

Change-Id: I449913fe1bd2119987ba33f7152e5e4ba5f3fe31
Reviewed-on: https://go-review.googlesource.com/c/go/+/396518
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agogo/types, types2: add commentary on (non-)guarantees when using contexts
Robert Findley [Wed, 30 Mar 2022 15:57:48 +0000 (11:57 -0400)]
go/types, types2: add commentary on (non-)guarantees when using contexts

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

3 years agogo/types: clarify that contexts do not guarantee deduplication
Robert Findley [Tue, 29 Mar 2022 22:30:06 +0000 (18:30 -0400)]
go/types: clarify that contexts do not guarantee deduplication

Documentation around the use of types.Context is unclear about whether
contexts guarantee deduplication of identical instances. Add explicit
disclaimers that this is not the case.

Fixes golang/go#51680

Change-Id: I6651587315d3cbf9e8d70a69d3e2ec5cedd00da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/396536
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile/internal/walk: fix wrong soleComponent implementation
Cuong Manh Le [Wed, 30 Mar 2022 01:55:22 +0000 (08:55 +0700)]
cmd/compile/internal/walk: fix wrong soleComponent implementation

CL 367755 added soleComponent for handling 1-byte type interface conversion.
This implementation must be kept in sync with Type.SoleComponent, but it
does not. When seeing a blank field in struct, we must continue looking
at the field type to find sole component, if any. The current code just
terminate immediately, which causes wrong sole component type returned.

Fixes #52020

Change-Id: I4f506fe094fa7c5532de23467a4f9139476bb0a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/396614
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/compile/internal/typecheck: simplify checkassign
Cuong Manh Le [Wed, 30 Mar 2022 02:10:06 +0000 (09:10 +0700)]
cmd/compile/internal/typecheck: simplify checkassign

After CL 281543, checkassign do not have to check assignment in range
loop anymore, thus its first parameter is un-used.

Change-Id: Idbc46fcb81c3dd5edc87308d228c1a15ca5faf7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/396615
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocompress/zlib: tighten header CINFO check
Nigel Tao [Thu, 24 Mar 2022 23:33:21 +0000 (10:33 +1100)]
compress/zlib: tighten header CINFO check

RFC 1950 section 2.2 "Data format" says "CINFO (Compression info)... For
CM = 8... Values of CINFO above 7 are not allowed".

Change-Id: Ibbc1213125c7dc045f09901ee7746660e90b5fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/395734
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Nigel Tao <nigeltao@golang.org>

3 years agoruntime: unify C->Go ABI transitions on arm64
eric fang [Thu, 23 Dec 2021 06:53:50 +0000 (06:53 +0000)]
runtime: unify C->Go ABI transitions on arm64

There are several of places that save and restore the C callee-saved registers,
the operation is the same everywhere, so this CL defines several macros
to do this, which will help reduce code redundancy and unify the operation.

This CL also replaced consecutive MOVD instructions with STP and LDP instructions
in several places where these macros do not apply.

Change-Id: I815f39fe484a9ab9b6bd157dfcbc8ad99c1420fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/374397
Trust: Eric Fang <eric.fang@arm.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/link: zero elf addr for debug sections
Meng Zhuo [Sat, 26 Mar 2022 06:44:09 +0000 (14:44 +0800)]
cmd/link: zero elf addr for debug sections

The Addr should be zero if SHF_ALLOC is not set.

Update #51939

Change-Id: I030f6243d05efabe6b9ebf558e9c0201f7922d23
Reviewed-on: https://go-review.googlesource.com/c/go/+/395919
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: add runtime changes for register ABI on riscv64
Meng Zhuo [Wed, 3 Nov 2021 07:04:13 +0000 (15:04 +0800)]
runtime: add runtime changes for register ABI on riscv64

This CL adds
- spill functions used by runtime
- ABIInternal to functions

Adding new stubs_riscv64 file to eliminate vet issues while compiling.

Change-Id: I2a9f6088a1cd2d9708f26b2d97895b4e5f9f87e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/360296
Trust: mzh <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agogo/types, types2: better error message for some invalid receiver errors (cleanup)
Robert Griesemer [Mon, 28 Mar 2022 23:22:22 +0000 (16:22 -0700)]
go/types, types2: better error message for some invalid receiver errors (cleanup)

Use the 1.17 compiler error message together with the receiver base type.
Also, simplify and flatten the receive testing logic for clarity.

Change-Id: I71e58f261900dd7a85d2eb89a310c36b68d1b0b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/396298
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile: add PPC64 ssa ops to support carry chain arithmetic
Paul E. Murphy [Tue, 22 Mar 2022 13:41:34 +0000 (08:41 -0500)]
cmd/compile: add PPC64 ssa ops to support carry chain arithmetic

These are the opcodes required to lower math/bits.Add64 and
math/bits.Sub64 directly into ssa form. Likewise, opcodes which
clobber CA are marked.

This does not alter code generation. It prepares for future changes
to support scheduling carry chaining ops more effectively, and then
changes to lower into PPC64 opcodes.

Change-Id: I2723deee4a98b3c365f691857512df53280ae40f
Reviewed-on: https://go-review.googlesource.com/c/go/+/394594
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: avoid potential hang in TestGdbAutotmpTypes
Paul E. Murphy [Thu, 9 Dec 2021 22:09:24 +0000 (16:09 -0600)]
runtime: avoid potential hang in TestGdbAutotmpTypes

If a GC related task preempts between hitting the main.main breakpoint
and stepping, the test program may halt forever waiting on a GC
operation. This happens if gdb is configured to halt other threads
while executing a step.

Configure gdb to continue running all threads during a step by
setting the scheduler-locking option to off.

Fixes #49852

Change-Id: Iacc9732cbd23526bde0a295e6fa8a0d90f733f59
Reviewed-on: https://go-review.googlesource.com/c/go/+/370775
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Cherry Mui <cherryyz@google.com>

3 years agocmd/compile: make XER allocatable register on PPC64
Paul E. Murphy [Mon, 7 Jun 2021 19:11:20 +0000 (14:11 -0500)]
cmd/compile: make XER allocatable register on PPC64

This is the first step towards decomposing aggregate operations
which create or consume the CA bit of the XER.

This helps optimize the canned sequence of Add64Carry (and
Sub64Borrow if it were implemented similarly) by minimizing
extraneous operations related to loading the CA bit,
reloading CA in chained operations, or extracting it when
unused.

Likewise, mark the operations which clobber CA.

Change-Id: I33e6dd2654a8cc39fcdbb9690a495f03558cdc97
Reviewed-on: https://go-review.googlesource.com/c/go/+/346869
Trust: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agogo/types, types2: better error message for blank interface method name (cleanup)
Robert Griesemer [Mon, 28 Mar 2022 22:42:30 +0000 (15:42 -0700)]
go/types, types2: better error message for blank interface method name (cleanup)

Use the 1.17 compiler error message.

Change-Id: Ic62de5bfc9681674069934afc590f5840729f8e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/396297
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types, types2: better index-out-of-bounds error message (cleanup)
Robert Griesemer [Mon, 28 Mar 2022 22:30:37 +0000 (15:30 -0700)]
go/types, types2: better index-out-of-bounds error message (cleanup)

Use the 1.17 compiler error message, sans "array" prefix.

Change-Id: I0e70781c5ff02dca30a2004ab4d0ea82b0849eae
Reviewed-on: https://go-review.googlesource.com/c/go/+/396296
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agoall: use new "unix" build tag where appropriate
Ian Lance Taylor [Fri, 4 Mar 2022 02:23:35 +0000 (18:23 -0800)]
all: use new "unix" build tag where appropriate

For #20322
For #51572

Change-Id: Id0b4799d097d01128e98ba4cc0092298357bca45
Reviewed-on: https://go-review.googlesource.com/c/go/+/389935
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years agonet/netip: return an error from ParsePrefix with IPv6 zone input
Matt Layher [Tue, 29 Mar 2022 14:42:58 +0000 (10:42 -0400)]
net/netip: return an error from ParsePrefix with IPv6 zone input

net.ParseCIDR already rejects input in the form of 2001:db8::%a/32, but
netip.ParsePrefix previously accepted the input and silently dropped the
zone. Make the two consistent by always returning an error if an IPv6
zone is present in CIDR input for ParsePrefix.

Fixes #51899.

Change-Id: Iee7d8d4a5161e0b54a4ee1bd68b02c1a287ff399
Reviewed-on: https://go-review.googlesource.com/c/go/+/396299
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>

3 years agogo/types, types2: preserve parent scope when substituting receivers
Robert Findley [Thu, 24 Mar 2022 17:29:03 +0000 (13:29 -0400)]
go/types, types2: preserve parent scope when substituting receivers

Fixes #51920

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

3 years agodoc/go1.19: mention new unix build constraint
Ian Lance Taylor [Mon, 28 Mar 2022 22:28:41 +0000 (15:28 -0700)]
doc/go1.19: mention new unix build constraint

For #51572

Change-Id: Ib27be79379c8b3f72e29365b58067d7ee1919e52
Reviewed-on: https://go-review.googlesource.com/c/go/+/396295
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agocmd/internal/obj/riscv: add two-operand form to more instructions
Ben Shi [Mon, 28 Mar 2022 11:40:02 +0000 (11:40 +0000)]
cmd/internal/obj/riscv: add two-operand form to more instructions

Add two-operand form "op rs, rd" to
ADDW/SUBW/SLLW/SRLW/SRAW/SLLIW/SRLIW/SRAIW.

Do the following map:
"ADDW $imm, rd" -> "ADDIW $imm, rd"
"SLLW $imm, rd" -> "SLLIW $imm, rd"
"SRLW $imm, rd" -> "SRLIW $imm, rd"
"SRAW $imm, rd" -> "SRAIW $imm, rd"

Change-Id: Ie9632ba198ba8c05faac91504e4b97fc45ca1196
GitHub-Last-Rev: c6ccc9d5d0612ede1a1ffebb6bbc0309da87f4e1
GitHub-Pull-Request: golang/go#51984
Reviewed-on: https://go-review.googlesource.com/c/go/+/396134
Run-TryBot: Ben Shi <powerman1st@163.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
3 years agocmd/compile/internal/importer: support final unified IR export format
Matthew Dempsky [Tue, 1 Mar 2022 04:42:40 +0000 (20:42 -0800)]
cmd/compile/internal/importer: support final unified IR export format

This updates the cmd/compile/internal/importer to natively support the
"final" unified IR export format. This is really just for unit tests
and symmetry with go/internal/gcimporter though, since
cmd/compile/internal/noder has its own types2.Importer.

Change-Id: I52fbb6134dbc0a903d62c1b04f95d33bd29e0414
Reviewed-on: https://go-review.googlesource.com/c/go/+/388617
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

3 years agogo/build: recognize "unix" build tag
Ian Lance Taylor [Fri, 4 Mar 2022 02:21:37 +0000 (18:21 -0800)]
go/build: recognize "unix" build tag

The new "unix" build tag matches any Unix or Unix-like system.
This is only recognized on go:build lines, not in file names.

For #20322
Fixes #51572

Change-Id: I3a991f9e69353b25e259bc6462709cdcd83640fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/389934
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agobytes: restore old Trim/TrimLeft behavior for nil
Ian Lance Taylor [Fri, 18 Mar 2022 19:14:20 +0000 (12:14 -0700)]
bytes: restore old Trim/TrimLeft behavior for nil

Keep returning nil for the cases where we historically returned nil,
even though this is slightly different for TrimLeft and TrimRight.

Fixes #51793

Change-Id: Ifbdfc6b09d52b8e063cfe6341019f9b2eb8b70e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/393876
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agoio/fs, path/filepath: honor SkipDir on second WalkDirFunc error call
Ian Lance Taylor [Sun, 13 Mar 2022 00:18:23 +0000 (16:18 -0800)]
io/fs, path/filepath: honor SkipDir on second WalkDirFunc error call

Fixes #51617

Change-Id: I03e9e575d9bad1481e7e4f051b50a077ba5f2fe0
Reviewed-on: https://go-review.googlesource.com/c/go/+/392154
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agonet/mail: accept UT as a timezone
Ian Lance Taylor [Mon, 28 Mar 2022 17:18:03 +0000 (10:18 -0700)]
net/mail: accept UT as a timezone

Fixes #39906

Change-Id: I8fcaf4c1ccc4131d770cff08d9c80f520885a6b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/396214
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agointernal/pkgbits: add fingerprints to unified IR export format
Matthew Dempsky [Wed, 23 Mar 2022 19:10:02 +0000 (12:10 -0700)]
internal/pkgbits: add fingerprints to unified IR export format

So far unified IR has been relying on the backwards-compat iexport
data to supply package fingerprints for imports. To be able to drop
the iexport data and natively use unified IR everywhere.

This CL applies basically the same idea that iexport used: simply
hash all of the export data as it's being written out, and then tack
on an 8-byte hash at the end.

Change-Id: Iaca5fbfd7443088bc7f422a1c58be3e762c29014
Reviewed-on: https://go-review.googlesource.com/c/go/+/396196
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/obj: sort relocations
Cherry Mui [Mon, 28 Mar 2022 16:46:46 +0000 (12:46 -0400)]
cmd/internal/obj: sort relocations

At least on some platforms (e.g. PE dynamic loader) relocations
need to be sorted in address order. Currently we don't always emit
relocations in address order: e.g. for array literal with out-of-
order element initializers, or out-of-order DATA instructions in
assembly code. Sort them.

No test for now as I can't reproduce the failure for #51923.

Fixes #51923.

Change-Id: Ifec5d3476e027bb927bcefd6e45c40ebeccee4ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/396195
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile: reallocate FPR31 to XER for PPC64 regalloc
Paul E. Murphy [Fri, 25 Mar 2022 15:37:11 +0000 (10:37 -0500)]
cmd/compile: reallocate FPR31 to XER for PPC64 regalloc

We are limited to 64 registers in the allocator today, and PPC64
has not been allocating F0,F26-F31 for quite some time without
performance impact.

Change-Id: If9d60be5037c94991fdd90a44461c3a6b96315cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/395835
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: make F0,F27-F31 allocatable on PPC64
Paul E. Murphy [Fri, 25 Mar 2022 15:29:27 +0000 (10:29 -0500)]
cmd/compile: make F0,F27-F31 allocatable on PPC64

These FP registers on PPC64 have no restrictions, they can
be used like the others. F27-F31 were sequested long ago for
scratch storage which has long since been reverted, but they
weren't added back to the allocator pool.

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

3 years agoall: delete PPC64 non-register ABI fallback path
Cherry Mui [Fri, 18 Mar 2022 22:49:39 +0000 (18:49 -0400)]
all: delete PPC64 non-register ABI fallback path

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

3 years agocmd/compile/internal/syntax: fix scanner.{op,prec} docs
Matthew Dempsky [Sat, 26 Mar 2022 02:03:37 +0000 (19:03 -0700)]
cmd/compile/internal/syntax: fix scanner.{op,prec} docs

These fields are also valid for _Star.

Change-Id: I2582000ac1737c41416e69f91404f7cac279d718
Reviewed-on: https://go-review.googlesource.com/c/go/+/395916
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agosyscall: optimize Byte{Ptr,Slice}FromString
Kir Kolyshkin [Thu, 2 Dec 2021 03:48:58 +0000 (19:48 -0800)]
syscall: optimize Byte{Ptr,Slice}FromString

Use bytealg.IndexByteString(str, 0) instead of looping through the
string to check for a zero byte. A quick and dirty benchmark shows 10x
performance improvement (on amd64 machine, using go 1.17.3).

BytePtrFromString is used by many functions with string arguments.
This change should make many functions in os package, such as those
accepting a filename (os.Open, os.Stat, etc.), a tad faster.

PS I am aware that syscall package is deprecated and frozen, but this
change is mainly for the os package and the likes. The alternative
would be for os to switch to x/sys, which is a much bigger change.

Change-Id: I18fdd50f9fbfe0a23a4a71bc4bd0a5f5b0eaa475
Reviewed-on: https://go-review.googlesource.com/c/go/+/368457
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoruntime/race: update runtime (v3)
Dmitry Vyukov [Mon, 21 Feb 2022 08:52:14 +0000 (09:52 +0100)]
runtime/race: update runtime (v3)

New tsan runtime (v3) built on llvm commit 1784fe0532a6.

The new runtime features:
 - 2x smaller shadow memory (2x of app memory)
 - faster fully vectorized (on x86) race detection
 - small fixed-size vector clocks (512b)
 - fast vectorized vector clock operations
 - unlimited number of alive threads/goroutines

Some random subset of benchmarks:

encoding/json:
CodeEncoder-72           20.3ms ± 6%     11.7ms ± 4%   -42.02%  (p=0.000 n=10+8)
CodeMarshal-72           22.3ms ±11%     12.7ms ±11%   -43.28%  (p=0.000 n=10+10)
CodeDecoder-72           46.1ms ±42%     20.2ms ± 7%   -56.18%  (p=0.000 n=10+10)
CodeUnmarshal-72         16.7ms ±14%     13.2ms ± 9%   -20.93%  (p=0.000 n=10+10)
CodeUnmarshalReuse-72    17.7ms ±17%     12.8ms ± 8%   -27.58%  (p=0.000 n=10+10)

net/http:
ClientServerParallel4-72         914µs ±18%      72µs ± 5%  -92.16%  (p=0.000 n=20+18)
ClientServerParallel64-72       1.77ms ±16%    0.12ms ±29%  -93.43%  (p=0.000 n=20+17)
ClientServerParallelTLS4-72     1.99ms ±33%    0.20ms ± 5%  -89.83%  (p=0.000 n=19+17)
ClientServerParallelTLS64-72    2.72ms ±26%    0.25ms ±16%  -90.96%  (p=0.000 n=20+16)

compress/flate:
Decode/Digits/Huffman/1e4-72        2.53ms ± 3%     1.47ms ± 4%   -41.72%  (p=0.000 n=9+10)
Decode/Digits/Speed/1e4-72          2.59ms ± 5%     1.52ms ± 3%   -41.44%  (p=0.000 n=8+9)
Decode/Digits/Default/1e4-72        2.56ms ± 6%     1.51ms ± 4%   -40.96%  (p=0.000 n=10+10)
Decode/Digits/Compression/1e4-72    2.54ms ± 6%     1.52ms ± 2%   -40.14%  (p=0.000 n=10+9)
Decode/Newton/Huffman/1e4-72        2.65ms ± 3%     1.58ms ± 4%   -40.45%  (p=0.000 n=10+10)
Decode/Newton/Speed/1e4-72          2.16ms ± 9%     1.28ms ± 5%   -40.59%  (p=0.000 n=10+10)
Decode/Newton/Default/1e4-72        2.01ms ± 8%     1.16ms ± 6%   -42.11%  (p=0.000 n=10+10)
Decode/Newton/Compression/1e4-72    1.99ms ± 6%     1.17ms ± 3%   -41.05%  (p=0.000 n=9+10)
Encode/Digits/Huffman/1e4-72        2.05ms ± 2%     0.75ms ± 5%   -63.32%  (p=0.000 n=10+10)
Encode/Digits/Speed/1e4-72          2.89ms ± 2%     1.37ms ± 2%   -52.56%  (p=0.000 n=9+10)
Encode/Digits/Default/1e4-72        7.55ms ± 2%     3.86ms ± 4%   -48.93%  (p=0.000 n=8+10)
Encode/Digits/Compression/1e4-72    7.46ms ± 4%     3.88ms ± 4%   -48.07%  (p=0.000 n=9+9)
Encode/Newton/Huffman/1e4-72        2.20ms ± 4%     0.90ms ± 6%   -59.01%  (p=0.000 n=10+10)
Encode/Newton/Speed/1e4-72          2.62ms ± 2%     1.30ms ± 4%   -50.52%  (p=0.000 n=9+10)
Encode/Newton/Default/1e4-72        7.40ms ± 5%     3.72ms ± 2%   -49.65%  (p=0.000 n=10+9)
Encode/Newton/Compression/1e4-72    7.67ms ± 9%     3.85ms ± 4%   -49.87%  (p=0.000 n=10+10)

encoding/json short tests:
Time     2.34sec ± 6%   1.67sec ±11%  -28.85%  (p=0.000 n=10+10)
Memory     266MB ± 1%     190MB ± 9%  -28.78%  (p=0.000 n=10+10)

compress/flate short tests:
Time      4.69sec ± 4%   2.78sec ± 3%  -40.61%  (p=0.000 n=10+10)
Memory      284MB ± 5%     181MB ± 4%  -36.04%  (p=0.000 n=10+9)

sync short tests:
Time     4.87sec ± 4%  0.87sec ± 6%  -82.21%  (p=0.000 n=10+10)
Memory     147MB ± 3%     99MB ± 8%  -32.47%  (p=0.000 n=10+9)

Fixes #47056
Fixes #38184

Change-Id: I0cf228f2e4cac7778d34d33e46df7c081645f5d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/333529
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Trust: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoio/ioutil: add deprecation markers to ioutil
Jeff Widman [Mon, 28 Mar 2022 04:13:24 +0000 (04:13 +0000)]
io/ioutil: add deprecation markers to ioutil

All the code in ioutil just forwards functionality to code
in either the io or os packages, per issue 42026.

This change adds the "Deprecated" marker to all the
functions in this package.

For #42026

Fixes #51927

Change-Id: Ia807bc5c0edb06cc80ec7e35917dcfe2ad50f0ea
GitHub-Last-Rev: 3c3603f368e2be517cdd946ae6a666d4e1eda67a
GitHub-Pull-Request: golang/go#51961
Reviewed-on: https://go-review.googlesource.com/c/go/+/395918
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile/internal/ir: remove un-used code for const
Cuong Manh Le [Mon, 28 Mar 2022 14:41:19 +0000 (21:41 +0700)]
cmd/compile/internal/ir: remove un-used code for const

CL 390474 removed last usages of ConstValue, it can now be removed, and
also Float64Val, since when it's only used by ConstValue.

CanInt64 is un-used for a long time, its original form last usage was
removed in CL 221802.

Change-Id: Id142b0da49c319faca73ef1b2090325f81431321
Reviewed-on: https://go-review.googlesource.com/c/go/+/396078
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agoos: use syscall.Timespec.Unix
Ian Lance Taylor [Tue, 28 Dec 2021 18:54:55 +0000 (10:54 -0800)]
os: use syscall.Timespec.Unix

Use the syscall method instead of repeating the type conversions for each OS.

Change-Id: I1db975b3aaa189cf724d7b1b7c5c41bc64dd964d
Reviewed-on: https://go-review.googlesource.com/c/go/+/374574
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
3 years agoRevert "reflect, runtime: add reflect support for regabi on riscv64"
mzh [Sun, 27 Mar 2022 23:08:32 +0000 (23:08 +0000)]
Revert "reflect, runtime: add reflect support for regabi on riscv64"

This reverts commit 56400fc70675cc2f404f33e3ed13386967cfe4da.

Reason for revert: this CL requires CL360296 be merged

Change-Id: I4c48c4d23b73b6e892cf86cbbc864698ebc5c992
Reviewed-on: https://go-review.googlesource.com/c/go/+/396076
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoencoding/xml: expose decoder line and column
Patrick Gundlach [Mon, 19 Apr 2021 10:51:04 +0000 (12:51 +0200)]
encoding/xml: expose decoder line and column

The existing implementation of the xml decoder uses the line number
only for reporting syntax errors. The line number of the last read
token and the column within the line is useful for the users even
in non-error conditions.

Fixes #45628

Change-Id: I37b5033ff5ff8411793d8f5180f96aa4537e83f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/311270
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

3 years agogo/build: remove unused code in TestDependencies
zhangjian [Tue, 22 Mar 2022 16:35:21 +0000 (16:35 +0000)]
go/build: remove unused code in TestDependencies

Change-Id: I7ccffbf96bd30f33bb42b6a2592962e2d4dda9fc
GitHub-Last-Rev: 2d6e214ac50bf505f8edf5ad8bf1c7f02e7b1194
GitHub-Pull-Request: golang/go#51231
Reviewed-on: https://go-review.googlesource.com/c/go/+/386374
Reviewed-by: mzh <mzh@golangcn.org>
Trust: mzh <mzh@golangcn.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agotime: add Duration.Abs
Carl Johnson [Sat, 26 Mar 2022 02:10:29 +0000 (02:10 +0000)]
time: add Duration.Abs

Fixes #51414

Change-Id: Ia3b1674f2a902c8396fe029397536643a3bc1784
GitHub-Last-Rev: 67159648af09e7a8ac2825a1fe71b2de3fb9d748
GitHub-Pull-Request: golang/go#51739
Reviewed-on: https://go-review.googlesource.com/c/go/+/393515
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agoregexp: use input.step() to advance one rune in Regexp.allMatches()
Andy Pan [Thu, 28 Oct 2021 07:39:11 +0000 (15:39 +0800)]
regexp: use input.step() to advance one rune in Regexp.allMatches()

Change-Id: I32944f4ed519419e168e62f9ed6df63961839259
Reviewed-on: https://go-review.googlesource.com/c/go/+/359197
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agotest: fix inline test on noopt builder
Keith Randall [Sat, 26 Mar 2022 19:21:36 +0000 (12:21 -0700)]
test: fix inline test on noopt builder

CL 394074 broke the noopt builder. Something about time.After's inlining
depends on the build flags to make.bash, not the build flags that run.go
passes.

Change-Id: Ib284c66ea2008a4d32829c055d57c54a34ec3fb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/396037
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agocmd/compile: upgrade prove pass to know results of math/bits ops are nonnegative
Keith Randall [Sat, 26 Mar 2022 17:36:10 +0000 (10:36 -0700)]
cmd/compile: upgrade prove pass to know results of math/bits ops are nonnegative

Fixes #51963

Change-Id: Ib9e0521222e6fc41e787f3150b254e058a19addc
Reviewed-on: https://go-review.googlesource.com/c/go/+/396036
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
3 years agocmd/compile: optimize BSRQ with nonzero input
Keith Randall [Sat, 26 Mar 2022 17:03:06 +0000 (10:03 -0700)]
cmd/compile: optimize BSRQ with nonzero input

Same as BSFQ, if the input is known to be nonzero we don't need a CMOV
to correct for the weird all-zero behavior of the BSRQ instruction.

Fixes #51964

Change-Id: Ic1d14fdf3e7e698ff2f47efecfd761d8a036012a
Reviewed-on: https://go-review.googlesource.com/c/go/+/396034
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
3 years agoreflect, runtime: add reflect support for regabi on riscv64
Meng Zhuo [Wed, 3 Nov 2021 10:01:09 +0000 (18:01 +0800)]
reflect, runtime: add reflect support for regabi on riscv64

This CL adds regabi support needed for reflect.

Change-Id: Ib78f8c7765f03e3a7b46e8b115bf8870b8076e6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/360994
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/go/internal/modfetch: remove unused FileRev struct
Baokun Lee [Mon, 20 Dec 2021 06:12:02 +0000 (14:12 +0800)]
cmd/go/internal/modfetch: remove unused FileRev struct

In CL 367756 we remove ReadFileRevs function, We simplified
the implementation of the interface Repo. and the type FileRev
is no longer used.

Change-Id: Iec9e2f0d6bb227f4d0d0f565e897137dcf392a3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/373375
Trust: Lee Baokun <bk@golangcn.org>
Run-TryBot: Lee Baokun <bk@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
3 years agoos: document DirFS implements fs.StatFS
hopehook [Tue, 22 Mar 2022 15:33:48 +0000 (23:33 +0800)]
os: document DirFS implements fs.StatFS

Fixes #51856

Change-Id: I8328d73bbb7bc166d58281180b64785a634e9bab
Reviewed-on: https://go-review.googlesource.com/c/go/+/394555
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agoRevert "cmd/compile: stop interface conversions for generic method calls from allocating"
Keith Randall [Thu, 24 Mar 2022 17:50:06 +0000 (17:50 +0000)]
Revert "cmd/compile: stop interface conversions for generic method calls from allocating"

This reverts commit e550c3054586a224d949cc8fa030bac0887bee51.

Reason for revert: Method bound calls are no longer implemented using interface calls, so it is no longer necessary. Leaving the test, though.

Change-Id: I80f1e4cd921063cd27ca8f07998316ca282e075b
Reviewed-on: https://go-review.googlesource.com/c/go/+/395594
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: use method expression closures to implement bound method calls
Keith Randall [Fri, 11 Feb 2022 20:58:37 +0000 (12:58 -0800)]
cmd/compile: use method expression closures to implement bound method calls

When we have x.M(args) where x is a value of type parameter type, we
currently cast x to the bound of that type parameter (which is an interface)
and then invoke the method on that interface. That's pretty inefficient
because:
 1) We need to convert x to an interface, which often requires allocation.
    With CL 378178 it is at least stack allocation, but allocation nontheless.
 2) We need to call through wrapper functions to unpack the interface
    into the right argument locations for the callee.

Instead, let's just call the target directly. The previous CL to this one
added method expression closures to the dictionary, which is a simple
captureless closure that implements T.M for type parameter T and method M.
So to implement x.M(args) for x of type T, we use methodexpr(T,M)(x, args).
We just need to move x from the receiver slot to the first argument, and
use the dictionary entry to implement the polymorphism. This works because
we stencil by shape, so we know how to marshal x for the call even though
we don't know its exact type.

We should be able to revert CL 378178 after this one, as that optimization
will no longer be necssary as we're not converting values to interfaces
to implement this language construct anymore.

Update #50182

Change-Id: I813de4510e41ab63626e58bd1167f9ae93016202
Reviewed-on: https://go-review.googlesource.com/c/go/+/385274
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: implement generic method expressions with closures in dictionary
Keith Randall [Fri, 11 Feb 2022 00:40:18 +0000 (16:40 -0800)]
cmd/compile: implement generic method expressions with closures in dictionary

Currently we do quite a dance for method expressions on generic
types. We write a new closure, and in that closure convert the
receiver to an interface with the required method, then call the
target using an interface call.

Instead in this CL, we just allocate a (captureless) closure in the
dictionary which implements that method expression.

This CL makes method expressions faster and simpler. But the real win
is some followon CLs, where we can use the same closure to implement
bound method calls using the same closure, instead of converting to
interface and having wrappers convert back. Much faster and simpler.

Still thinking about how to do method values. The receiver still
needs to be captured, so there must be some closure involved, I think.

Update #50182

Change-Id: I1fbd57e7105663f8b049955b8f4111649a5f4aa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/385254
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agointernal/abi: define riscv64 register ABI constants
Meng Zhuo [Wed, 3 Nov 2021 08:17:45 +0000 (16:17 +0800)]
internal/abi: define riscv64 register ABI constants

Add the riscv64 register ABI constants and allow regabi
value to be set for riscv64

Change-Id: I3ce98bf9a29d2acc00f92650b27bc59884ed62ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/359336
Trust: mzh <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile: enable inlining SELECT
Wayne Zuo [Sun, 20 Mar 2022 13:28:46 +0000 (21:28 +0800)]
cmd/compile: enable inlining SELECT

Change-Id: I90c8e12a0be05d82bf6e147b5249859518f35c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/394074
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Keith Randall <khr@golang.org>

3 years agocmd/compile: simplify fingerprint logic
Matthew Dempsky [Wed, 23 Mar 2022 19:22:50 +0000 (12:22 -0700)]
cmd/compile: simplify fingerprint logic

Historically, we sometimes recorded imports based on either package
path ("net/http") or object file path ("net/http.a"). But modern Go
build systems always use package path, and the extra ".a" suffix
doesn't mean anything anyway.

Change-Id: I6060ef8bafa324168710d152a353f4d8db062133
Reviewed-on: https://go-review.googlesource.com/c/go/+/395254
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agonet/netip: fix uses of "IPv4-mapped IPv6" in doc comments
Adam Pritchard [Fri, 25 Mar 2022 19:08:19 +0000 (19:08 +0000)]
net/netip: fix uses of "IPv4-mapped IPv6" in doc comments

The correct (or at least mostly commonly used) name for addresses of the
form ::ffff:192.0.2.128 is "IPv4-mapped IPv6". Some of the comments in
the netip package used that name, but others used "IPv6-mapped IPv4" or
"v6-mapped". This change makes the usage of the term consistent.

Change-Id: Ic01309ddf9252705a2387322d940b777e88800a5
GitHub-Last-Rev: 56044dcb97aeae1aa09bde635118ad46c979bbaf
GitHub-Pull-Request: golang/go#51950
Reviewed-on: https://go-review.googlesource.com/c/go/+/395914
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agonet/mail: improve detection of charset errors
Russ Cox [Wed, 13 Jan 2021 15:53:48 +0000 (10:53 -0500)]
net/mail: improve detection of charset errors

The detection of the "unknown charset" case was too tailored
to one specific address parser. Make it generalize, so that custom
address parsers behave the same way as the default one
for character sets they do not handle.

Fixes #41625.

Change-Id: I347d4bb6844d0a1f23e908b776d21e8be5af3874
Reviewed-on: https://go-review.googlesource.com/c/go/+/283632
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

3 years agocmd/compile/internal/ir: remove NewClosureExpr
Cuong Manh Le [Fri, 25 Mar 2022 17:46:17 +0000 (00:46 +0700)]
cmd/compile/internal/ir: remove NewClosureExpr

The only usage of NewClosureExpr is inside NewClosureFunc, which is its
alternative version. So just remove NewClosureExpr and inline it there.

Change-Id: I1900f4fbb48d7b4f6e6a857f7f7760cd27302671
Reviewed-on: https://go-review.googlesource.com/c/go/+/395855
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agonet/http/httptest: fix race in Server.Close
Maisem Ali [Mon, 21 Mar 2022 17:43:45 +0000 (17:43 +0000)]
net/http/httptest: fix race in Server.Close

When run with race detector the test fails without the fix.

Fixes #51799

Change-Id: I273adb6d3a2b1e0d606b9c27ab4c6a9aa4aa8064
GitHub-Last-Rev: a5ddd146a2a65f2e817eed5133449c79b3af2562
GitHub-Pull-Request: golang/go#51805
Reviewed-on: https://go-review.googlesource.com/c/go/+/393974
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>