1
0
mirror of https://github.com/golang/go synced 2024-11-17 07:45:09 -07:00
Commit Graph

51895 Commits

Author SHA1 Message Date
Keith Randall
bdd0f0f780 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>
2022-03-31 20:19:48 +00:00
Michael Anthony Knyszek
23756207fb 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>
2022-03-31 20:03:04 +00:00
Michael Anthony Knyszek
f990b0f1e8 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>
2022-03-31 20:02:55 +00:00
Michael Anthony Knyszek
4a56ba1c45 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>
2022-03-31 20:02:31 +00:00
Michael Anthony Knyszek
3334afd760 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>
2022-03-31 20:02:10 +00:00
Michael Anthony Knyszek
f1b5c048d7 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>
2022-03-31 20:01:47 +00:00
vpachkov
12acf9b0f0 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>
2022-03-31 19:46:55 +00:00
Than McIntosh
cc3a3519af 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>
2022-03-31 19:40:29 +00:00
Than McIntosh
f7670b9f94 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>
2022-03-31 19:40:16 +00:00
nimelehin
96081f8545 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>
2022-03-31 19:39:37 +00:00
Ian Lance Taylor
9743fdd097 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>
2022-03-31 19:36:46 +00:00
Wayne Zuo
40504892c1 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>
2022-03-31 19:27:54 +00:00
Jakub Ciolek
913ecf492d 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>
2022-03-31 19:18:14 +00:00
Than McIntosh
c5c66d78b2 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>
2022-03-31 19:13:25 +00:00
Cherry Mui
b1e83c0513 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>
2022-03-31 18:59:23 +00:00
Robert Griesemer
b76f8df133 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>
2022-03-31 18:30:44 +00:00
Filippo Valsorda
37065847d8 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>
2022-03-31 16:58:48 +00:00
Than McIntosh
5138401209 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>
2022-03-31 15:59:22 +00:00
Than McIntosh
1edc2769ca 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>
2022-03-31 15:59:05 +00:00
Than McIntosh
378221bd6e 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>
2022-03-31 14:57:35 +00:00
Than McIntosh
cdee8004ab 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>
2022-03-31 14:57:20 +00:00
Robert Griesemer
2ea9376266 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>
2022-03-31 14:51:17 +00:00
Ian Lance Taylor
109a18dce7 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>
2022-03-31 14:47:33 +00:00
Than McIntosh
a9d13a9c23 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>
2022-03-31 14:08:58 +00:00
Than McIntosh
821420d6bb 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>
2022-03-31 12:55:38 +00:00
Than McIntosh
0a5bbba366 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>
2022-03-31 12:55:00 +00:00
Shang Ding
ebe624dd30 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>
2022-03-31 06:40:26 +00:00
Sean Liao
2b8178c14d 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>
2022-03-31 05:34:15 +00:00
Shulhan
a80070e0cf 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>
2022-03-31 05:26:15 +00:00
Philippe Antoine
cc46cac3bc strings: limits allocation size for SplitN
So that `strings.SplitN("", "T", int(144115188075855872))` does not panic.

Change-Id: Iea00417e61780bcaf0fee02fa2b18026d89bc545
GitHub-Last-Rev: d1f45b44a8
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>
2022-03-31 05:24:51 +00:00
qmuntal
90b29e1865 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>
2022-03-31 05:02:05 +00:00
qmuntal
3943d97dc7 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>
2022-03-31 04:40:46 +00:00
Robert Griesemer
ea858734be 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>
2022-03-31 01:01:43 +00:00
Emmanuel T Odeke
81f1cc52ab 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>
2022-03-31 00:54:34 +00:00
Robert Griesemer
0a6ddcc4f0 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>
2022-03-31 00:27:01 +00:00
Robert Griesemer
0775730180 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>
2022-03-31 00:26:58 +00:00
David Chase
3b7fce24cd 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>
2022-03-30 22:30:03 +00:00
Bryan C. Mills
1ac1658642 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>
2022-03-30 19:14:04 +00:00
Dmitri Shuralyov
ca1e509552 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>
2022-03-30 18:25:30 +00:00
Filippo Valsorda
83e9a97f62 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>
2022-03-30 18:03:55 +00:00
Robert Griesemer
a7e76b8e80 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>
2022-03-30 18:02:38 +00:00
Robert Griesemer
bf408e741c 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>
2022-03-30 18:02:31 +00:00
Robert Griesemer
717056da1a 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>
2022-03-30 18:02:18 +00:00
Robert Findley
c05c0ca8cf 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>
2022-03-30 17:10:11 +00:00
Robert Findley
83327b4ae4 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>
2022-03-30 16:23:37 +00:00
Cuong Manh Le
2d34af0fd6 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>
2022-03-30 15:06:59 +00:00
Cuong Manh Le
f5a42cd4b4 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>
2022-03-30 02:40:41 +00:00
Nigel Tao
d1060d8e82 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>
2022-03-30 02:16:17 +00:00
eric fang
eee6f9f825 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>
2022-03-30 01:28:43 +00:00
Meng Zhuo
63169c8bdf 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>
2022-03-30 01:13:21 +00:00