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

50047 Commits

Author SHA1 Message Date
kjgorman
3986e5c8e7 bytes: fix Cut godoc typo
If sep does not appear in s, we return nil here
rather than the empty string. Presumably the docs
were copied from the  strings package implementation
and brought that along.

Change-Id: I3706c94fe04abd9e2a2c8840f7cc6116386965c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/354969
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 16:39:23 +00:00
Amelia Downs
69041c79dc net: add examples for remaining IP functions
Fixes #48848

Change-Id: If85fc16ed10a26eca840ed128ab47c5f00776ddd
Reviewed-on: https://go-review.googlesource.com/c/go/+/346289
Reviewed-by: Amelia Downs <adowns@vmware.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 16:36:59 +00:00
Forest Johnson
53260943ea os: explain ProccessState.Exited() SIGKILL interaction
When a process is forcefully killed (for example, with SIGKILL on unix), its ProccessState.Exited() will return false.

Change-Id: I8cebc8d28f2ba1b687c145f6d941647fc3a10665
GitHub-Last-Rev: 414ae1980f
GitHub-Pull-Request: golang/go#48871
Reviewed-on: https://go-review.googlesource.com/c/go/+/354698
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-13 15:56:29 +00:00
Mark Hansen
b8e4df01dd cmd/pprof: update vendored github.com/google/pprof
Pull in the latest published version of github.com/google/pprof

This adds the tagroot and tagleaf options from
7fe48b4c82

Done with:

  go get -d github.com/google/pprof@latest
  go mod tidy
  go mod vendor

Fixes #48839

Change-Id: I85bf0e0689310014eb198c8d5e0bb3a86b0aef1c
GitHub-Last-Rev: b26260f305
GitHub-Pull-Request: golang/go#48856
Reviewed-on: https://go-review.googlesource.com/c/go/+/354692
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 15:38:39 +00:00
zhouguangyuan
f687831e4c cmd/link: disable weak reference in itab if build with "-linkshared"
When build with "-linkshared", we can't tell if the interface method will be used or not. It can be used in shared library.

Fixes #47873

Change-Id: Iba12812f199b7679cf2fd41a304268d6d6dd03c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/350189
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 15:12:46 +00:00
helbing
0454d7346f embed: add example
Change-Id: I4e50e469047ac7efbf4ed464e238000dbdf53d6b
GitHub-Last-Rev: 8d29b73d11
GitHub-Pull-Request: golang/go#48785
Reviewed-on: https://go-review.googlesource.com/c/go/+/353936
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 15:11:16 +00:00
nicksherron
e8f99da8ed all: fix spelling mistakes
Corrections were only made to comments and can be reproduced with the
following sed.

sed -i 's/communciation/communication/g'  src/internal/fuzz/sys_windows.go
sed -i 's/communciation/communication/g'  src/internal/fuzz/sys_posix.go
sed -i 's/substitued/substituted/g'     src/cmd/compile/internal/noder/irgen.go

Change-Id: I435aee2fdb41e73b694e6233d52742559d32cf7e
GitHub-Last-Rev: a471e3d123
GitHub-Pull-Request: golang/go#48932
Reviewed-on: https://go-review.googlesource.com/c/go/+/355494
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-13 04:00:15 +00:00
Dan Scales
4fb2e1cb86 cmd/compile: allow spaces in types.(*Type).LinkString()
Go back to allowing spaces in types.(*Type).LinkSring().

Delve folks prefer that there are spaces in type names, if needed, since
DWARF expects type names to be "a string representing the name as it
appears in the source program". At this point, it doesn't necessarily
seem worth having a separate function that removes spaces, only for use
when printing the type names in a function/method instantiation.

Most names of function/method instantiations will still not have spaces,
since they most type args are named or builtin types. I confirmed that
we are back to the original definition of LinkString(), except for some
comment changes.

Change-Id: Iab7143f659ddea4f099c6230cb134edf8aaef868
Reviewed-on: https://go-review.googlesource.com/c/go/+/355354
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-10-13 00:11:47 +00:00
Robert Findley
78d01be00b cmd/api: use placeholder names for type parameters
Changing type parameter names is not a breaking API change, so we should
not include these names in the output of cmd/api. Instead print a
placeholder '$<index>' wherever type parameters are referenced.

This is valid for cmd/api as there is at most one type parameter list in
scope for any exported declaration. If we ever support method type
parameters, we'll need to revisit this syntax.

Change-Id: I7e677b1dab6ffeb0b79afefdb8d2580bef93891c
Reviewed-on: https://go-review.googlesource.com/c/go/+/355389
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-12 22:26:55 +00:00
Jake Ciolek
732f6fa9d5 cmd/compile: use ANDL for small immediates
We can rewrite ANDQ with an immediate fitting in 32bit with an ANDL, which is shorter to encode.

Looking at Go binary itself, before the change there was:

ANDL: 2337
ANDQ: 4476

After the change:

ANDL: 3790
ANDQ: 3024

So we got rid of 1452 ANDQs

This makes the Linux x86_64 binary 0.03% smaller.

There seems to be an impact on performance.

Intel Cascade Lake benchmarks (with perflock):

name                     old time/op    new time/op    delta
BinaryTree17-8              1.91s ± 1%     1.89s ± 1%  -1.22%  (p=0.000 n=21+18)
Fannkuch11-8                2.34s ± 0%     2.34s ± 0%    ~     (p=0.052 n=20+20)
FmtFprintfEmpty-8          27.7ns ± 1%    27.4ns ± 3%    ~     (p=0.497 n=21+21)
FmtFprintfString-8         53.2ns ± 0%    51.5ns ± 0%  -3.21%  (p=0.000 n=20+19)
FmtFprintfInt-8            57.3ns ± 0%    55.7ns ± 0%  -2.89%  (p=0.000 n=19+19)
FmtFprintfIntInt-8         92.3ns ± 0%    88.4ns ± 1%  -4.23%  (p=0.000 n=20+21)
FmtFprintfPrefixedInt-8     103ns ± 0%     103ns ± 0%  +0.23%  (p=0.000 n=20+21)
FmtFprintfFloat-8           147ns ± 0%     148ns ± 0%  +0.75%  (p=0.000 n=20+21)
FmtManyArgs-8               384ns ± 0%     381ns ± 0%  -0.63%  (p=0.000 n=21+21)
GobDecode-8                3.86ms ± 1%    3.88ms ± 1%  +0.52%  (p=0.000 n=20+21)
GobEncode-8                2.77ms ± 1%    2.77ms ± 0%    ~     (p=0.078 n=21+21)
Gzip-8                      168ms ± 1%     168ms ± 0%  +0.24%  (p=0.000 n=20+20)
Gunzip-8                   25.1ms ± 0%    24.3ms ± 0%  -3.03%  (p=0.000 n=21+21)
HTTPClientServer-8         61.4µs ± 8%    59.1µs ±10%    ~     (p=0.088 n=20+21)
JSONEncode-8               6.86ms ± 0%    6.70ms ± 0%  -2.29%  (p=0.000 n=20+19)
JSONDecode-8               30.8ms ± 1%    30.6ms ± 1%  -0.82%  (p=0.000 n=20+20)
Mandelbrot200-8            3.85ms ± 0%    3.85ms ± 0%    ~     (p=0.191 n=16+17)
GoParse-8                  2.61ms ± 2%    2.60ms ± 1%    ~     (p=0.561 n=21+20)
RegexpMatchEasy0_32-8      48.5ns ± 2%    45.9ns ± 3%  -5.26%  (p=0.000 n=20+21)
RegexpMatchEasy0_1K-8       139ns ± 0%     139ns ± 0%  +0.27%  (p=0.000 n=18+20)
RegexpMatchEasy1_32-8      41.3ns ± 0%    42.1ns ± 4%  +1.95%  (p=0.000 n=17+21)
RegexpMatchEasy1_1K-8       216ns ± 2%     216ns ± 0%  +0.17%  (p=0.020 n=21+19)
RegexpMatchMedium_32-8      790ns ± 7%     803ns ± 8%    ~     (p=0.178 n=21+21)
RegexpMatchMedium_1K-8     23.5µs ± 5%    23.7µs ± 5%    ~     (p=0.421 n=21+21)
RegexpMatchHard_32-8       1.09µs ± 1%    1.09µs ± 1%  -0.53%  (p=0.000 n=19+18)
RegexpMatchHard_1K-8       33.0µs ± 0%    33.0µs ± 0%    ~     (p=0.610 n=21+20)
Revcomp-8                   348ms ± 0%     353ms ± 0%  +1.38%  (p=0.000 n=17+18)
Template-8                 42.0ms ± 1%    41.9ms ± 1%  -0.30%  (p=0.049 n=20+20)
TimeParse-8                 185ns ± 0%     185ns ± 0%    ~     (p=0.387 n=20+18)
TimeFormat-8                237ns ± 1%     241ns ± 1%  +1.57%  (p=0.000 n=21+21)
[Geo mean]                 35.4µs         35.2µs       -0.66%

name                     old speed      new speed      delta
GobDecode-8               199MB/s ± 1%   198MB/s ± 1%  -0.52%  (p=0.000 n=20+21)
GobEncode-8               277MB/s ± 1%   277MB/s ± 0%    ~     (p=0.075 n=21+21)
Gzip-8                    116MB/s ± 1%   115MB/s ± 0%  -0.25%  (p=0.000 n=20+20)
Gunzip-8                  773MB/s ± 0%   797MB/s ± 0%  +3.12%  (p=0.000 n=21+21)
JSONEncode-8              283MB/s ± 0%   290MB/s ± 0%  +2.35%  (p=0.000 n=20+19)
JSONDecode-8             63.0MB/s ± 1%  63.5MB/s ± 1%  +0.82%  (p=0.000 n=20+20)
GoParse-8                22.2MB/s ± 2%  22.3MB/s ± 1%    ~     (p=0.539 n=21+20)
RegexpMatchEasy0_32-8     660MB/s ± 2%   697MB/s ± 3%  +5.57%  (p=0.000 n=20+21)
RegexpMatchEasy0_1K-8    7.36GB/s ± 0%  7.34GB/s ± 0%  -0.26%  (p=0.000 n=18+20)
RegexpMatchEasy1_32-8     775MB/s ± 0%   761MB/s ± 4%  -1.88%  (p=0.000 n=17+21)
RegexpMatchEasy1_1K-8    4.74GB/s ± 2%  4.74GB/s ± 0%  -0.18%  (p=0.020 n=21+19)
RegexpMatchMedium_32-8   40.6MB/s ± 7%  39.9MB/s ± 9%    ~     (p=0.191 n=21+21)
RegexpMatchMedium_1K-8   43.7MB/s ± 5%  43.2MB/s ± 5%    ~     (p=0.435 n=21+21)
RegexpMatchHard_32-8     29.3MB/s ± 1%  29.4MB/s ± 1%  +0.53%  (p=0.000 n=19+18)
RegexpMatchHard_1K-8     31.0MB/s ± 0%  31.0MB/s ± 0%    ~     (p=0.572 n=21+20)
Revcomp-8                 730MB/s ± 0%   720MB/s ± 0%  -1.36%  (p=0.000 n=17+18)
Template-8               46.2MB/s ± 1%  46.3MB/s ± 1%  +0.30%  (p=0.041 n=20+20)
[Geo mean]                204MB/s        205MB/s       +0.30%

Change-Id: Iac75d0ec184a515ce0e65e19559d5fe2e9840514
Reviewed-on: https://go-review.googlesource.com/c/go/+/354970
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-12 22:02:39 +00:00
Tamir Duberstein
3283d1a2f2 os: Simplify size using io.Discard.
Change-Id: Ib7cc86643a3dcae788a94472e54de171e0d655fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/355449
Trust: Michael Pratt <mpratt@google.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-10-12 21:30:45 +00:00
Katie Hockman
61890fb123 internal/fuzz: fix -fuzzminimizetime with 'x' bug
Fixes #48928

Change-Id: I3825ec615ab5fc19389ef4c10ad1042005a3761c
Reviewed-on: https://go-review.googlesource.com/c/go/+/355450
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-12 21:30:42 +00:00
Bryan C. Mills
3d051ba8d4 cmd/dist: run a checkNotStale on the builders before running tests
This should be a no-op, but if the sharded builders are for some
reason distributing stale snapshots — or testing them with mismatched
environments — this should catch them out at a relatively low cost
(#24300 notwithstanding).

Given the frequently at which (*tester).runPending already checks for
staleness, we do not expect the impact of this extra check to be
significant for most builders.

For #33598
Updates #24300

Change-Id: I197d6a69c72e2eec9e4563b459206de76c89e8a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/223755
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-10-12 21:15:50 +00:00
Dan Scales
ac6d706a05 [dev.typeparams] cmd/compile: add test for number of instantiations
Add a test for a generic sort function, operating on several different
pointer types (across two packages), so they should all share the same
shape-based instantiation. Actually check that only one instantiation of
Sort is created using 'go tool nm', and also check that the output is
correct.

In order to do the test on the executable using 'go nm', added this as a
'go test' in cmd/compile/internal/test.

Added the genembed.go test that I meant to include with a previous CL.

Change-Id: I9962913c2f1809484c2b1dfef3b07e4c8770731c
Reviewed-on: https://go-review.googlesource.com/c/go/+/354696
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-10-12 20:53:52 +00:00
Jay Conrod
d032b2b2c8 testing: don't create unique subtest names while fuzzing
T.Run uses a map[string]int64 to keep track of subtest names that may
be returned through T.Name. T.Name can't return duplicate names for
subtests started with T.Run.

If a fuzz target calls T.Run, this map takes a large amount of memory,
since there are a very large number of subtests that would
otherwise have duplicate names, and the map stores one entry per subtest.
The unique suffixes are not useful (and may be confusing) since the
full sequence of tests cannot be re-run deterministically.

This change deletes all entries in the map before each call to the
function being fuzzed. There is a slight change in the contract of
T.Name while fuzzing.

This change was discussed in CL 351452.

Fixes #44517

Change-Id: I3093a2e5568099ce54aca1006fac84a6fd2c3ddf
Reviewed-on: https://go-review.googlesource.com/c/go/+/354430
Trust: Jay Conrod <jayconrod@google.com>
Trust: Katie Hockman <katie@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2021-10-12 20:20:41 +00:00
Dan Scales
4186db6155 cmd/compile: some fixes in type substituter for Instantiate
In the case in (*TSubster).Type() that we were running into an
incomplete underlying type (TFORW), we should just be immediately
returning the type returned by ts.SubstForwFunc(forw), since that call
returns a proper type node, and has set up any remaining work that has
to be done when we get done with the current top-level type definition.
(For import, that function is doInst, which does an Instantiate of the
new substituted type, with the delayed part via deferredInstStack.) We
should not continue doing the later parts of (*TSubster).Type(), since
the underlying type may not yet have its methods filled in, etc.

Also, in Instantiate(), we need to put the desired new type on
deferredInstStack, even if the base type node already exists, if the
type node is in TFORW state. This is now exactly the case when
Instantiate is called from (*TSubster).Type via doInst, since
(*TSubster).Type has already called NewIncompleteNamedType().

Fixes #48716
Fixes #48889

Change-Id: Icd6be5721c4ac75bf8869b8bbdeca50069d632ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/355250
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-10-12 20:09:58 +00:00
Robert Findley
26b6833308 go/types: export TypeParam.Index and remove TypeParam._SetId
This change resolves a TODO regarding a couple uncertain APIs for
types.TypeParam. In the case of TypeParam._Index, we've decided it is
worth exporting. In the case of TypeParam._SetId, we've decided it is
unnecessary.

This aligns go/types with types2 (a doc comment in types2 is also
updated).

Updates #47916

Change-Id: I705e8b3437d014775c473e2f8be6f32b1540bb0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/354370
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-12 18:52:28 +00:00
Jay Conrod
f8bfdc9eda cmd/go: adjust documentation mentioning 'go get'
In module-aware mode, 'go get' no longer builds or installs packages.

- 'go generate' explains build commands do not run generate
  commands. 'go get' is no longer a build command, so this CL removes
  mention of it.
- 'go get' will continue to accept build flags, but they're
  ignored. The documentation no longer mentions them, though it does
  mention -x for printing VCS commands.

For #43684

Change-Id: I1eea7241eecf72ba9f98238b729d91cc77ec7665
Reviewed-on: https://go-review.googlesource.com/c/go/+/355209
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-12 18:31:29 +00:00
Cherry Mui
6e0adde1e9 cmd/compile: do not reuse dead value in expand_calls pass
We reuse a value for the same selector on the same arg. But if the
value is already marked dead, don't reuse it. A use of an
OpInvalid will confuse the compiler.

Fixes #48916.

Change-Id: I15b9e15b49f6e1991fe91df246cd12a193385e85
Reviewed-on: https://go-review.googlesource.com/c/go/+/355409
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-12 18:00:16 +00:00
Katie Hockman
36a265a625 testing: fix -run behavior with fuzz tests
This change fixes some issues with -run, and
the subsequent command line output when running
in verbose mode. It replaces CorpusEntry.Name
with CorpusEntry.Path, and refactors the code
accordingly.

This change also adds a lot of additional tests
which check explicit command line output when
fuzz targets are run without fuzzing. This will
be important to avoid regressions.

Updates #48149

Change-Id: If34b1f51db646317b7b51c3c38ae53231d01f568
Reviewed-on: https://go-review.googlesource.com/c/go/+/354632
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-10-12 14:32:53 +00:00
Paul E. Murphy
46796703d7 cmd/internal/obj/ppc64: support alignment of prefixed insn
Insert machine NOPs when a prefixed instruction crosses a 64B boundary.
ISA 3.1 prohibits prefixed instructions being placed across them. Such
instructions generate SIGILL if executed.

Likewise, adjust the function alignment to guarantee such instructions
can never cross one. And, don't pad the PC based on alignment. The
linker can fit these more optimally.

Likewise, include the function alignment when printing function debug
information. This is needed to verify function alignment happens.

Updates #44549

Change-Id: I434fb0ee4e984ca00dc4566f7569c3bcdf93f910
Reviewed-on: https://go-review.googlesource.com/c/go/+/347050
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-10-12 12:24:09 +00:00
Nigel Tao
9c1dbdf60e compress/lzw: output a Clear code first, per GIF spec
The TestStartsWithClearCode test is new, but if it existed beforehand,
the want strings would be "\x81" and "Hi\x81" without a starting "\x80".

Fixes #26108
Fixes #33748
Updates makeworld-the-better-one/didder#7
Updates nothings/stb#1222

Change-Id: I35ac0ed862ba6ee921ba9aee257bc19828abaa82
Reviewed-on: https://go-review.googlesource.com/c/go/+/354710
Trust: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2021-10-12 11:00:47 +00:00
Tobias Klauser
d887d3be5f cmd/link/internal/ld: use libc based fcntl for (*OutBuf).fallocate on darwin
Direct syscalls are no longer supported on darwin. Instead, use libc
fcntl go:linkname'd from the syscall package.

Change-Id: Ieeec64810452455faedd200f661a8b5839ca1fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/255260
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-12 06:55:50 +00:00
Ian Lance Taylor
6372e7efba cmd/api: support type parameters
Fixes #48706

Change-Id: If0f8d0b49300027e3b2b46f6870302acf2e00f4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/354612
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-12 04:35:19 +00:00
Robert Findley
d90f0b9200 cmd/compile/internal/types2: avoid duplicate errors for invalid bounds
Resolve a TODO from an earlier CL: we should only check type parameter
bounds once in collectTypeParams.

Change-Id: Icf6053ec359f8ac8143cf68ee2defd504f8f86e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/355069
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-11 22:34:49 +00:00
Robert Findley
c1b0ae4154 go/types: mark implicit interfaces as such
This is a straightforward port of CL 353396 to go/types.

For #48424

Change-Id: I3040c2ad3a8c9573026277de01deb9c47953cec8
Reviewed-on: https://go-review.googlesource.com/c/go/+/354991
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-11 22:32:23 +00:00
Robert Findley
b41030e6e0 go/internal/gcimporter: enable importing typeparam/issue48424.go
This is a partial revert of CL 353389, now that go/types supports
eliding interface in constraints.

For #48424

Change-Id: Ibde26fb66bf6bd5a4c919acffd045a57783d1b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/354990
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-11 22:17:47 +00:00
Robert Findley
662c5eed33 go/types: accept constraint literals with elided interfaces
This is a port of CL 353139 to go/types, adjusted for error reporting
and for the different representation of field lists in go/ast. A TODO is
added to verify if types2 produces redundant error messages for type
parameters sharing a bound.

For #48424

Change-Id: I3549942be0328de616d1d87d0ba621311fc53576
Reviewed-on: https://go-review.googlesource.com/c/go/+/354989
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-11 22:17:41 +00:00
Robert Findley
2ecdf9d800 go/parser: allow eliding interface in constraint literals
This is a port of CL 353133 from cmd/compile/internal/syntax, with
significant adjustments for the mechanics of go/parser.

Some additional cleanup is made along the way: parseParameterList can
call parseParamDecl without indirection, and the tparams argument is
redundant with the closing token. Also, the error that "all type
parameters must be named" is positioned on the first unnamed type
parameter.

Error recovery in go/parser is notably worse here than the compiler
parser, so the test data had to be adjusted to synchronize positions.
Fixing this error recovery will have to wait for a later CL.

As with the compiler changes, these changes are guarded behind a flag so
that they may be easily removed if #48424 is not accepted.

For #48424

Change-Id: If87925d246f36aaab11a95442f75f659462d4286
Reviewed-on: https://go-review.googlesource.com/c/go/+/354870
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-11 22:16:44 +00:00
Daniel Martí
d973bb107e encoding/gob: follow documented io.EOF semantics
The docs say:

	If the input is at EOF, Decode returns io.EOF and does not modify e.

However, the added test fails:

	--- FAIL: TestDecodePartial (0.00s)
		encoder_test.go:1263: 31/81: expected io.ErrUnexpectedEOF: EOF
		encoder_test.go:1263: 51/81: expected io.ErrUnexpectedEOF: EOF

In particular, the decoder would return io.EOF after reading a valid
message for a type specification, and then hit EOF before reading a data
item message.

Fix that by only allowing a Decode call to return io.EOF if the reader
hits EOF immediately, without successfully reading any message.
Otherwise, hitting EOF is an ErrUnexpectedEOF, like in other cases.

Also fix a net/rpc test that, coincidentally, expected an io.EOF
as an error when feeding bad non-zero data to a gob decoder.
An io.ErrUnexpectedEOF is clearly better in that scenario.

Fixes #48905.

Change-Id: Ied6a0d8ac8377f89646319a18c0380c4f2b09b85
Reviewed-on: https://go-review.googlesource.com/c/go/+/354972
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2021-10-11 21:58:33 +00:00
Dan Scales
7023535126 cmd/compile: adjust debug/gosym to deal with instantiated types/funcs/methods
This changes debug/gosym so it can deal with instantiated
types/funcs/methods. I also added tests for instantiated names. My
assumption is that the concatenation of PackageName, ReceiverName, and
BaseName in order should cover the entire symbol name, so either the
ReceiverName or the BaseName should include any bracketed information
(either the instantiation of the receiver of a method or the
instantiation of function).

This can provide a model for how to parse instantiated functions and
method names.

Fixes #48032

Change-Id: I476781de2d6fc096efbb4be85c197d6f1cafac21
Reviewed-on: https://go-review.googlesource.com/c/go/+/354689
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-10-11 20:46:14 +00:00
Bryan C. Mills
65ffee6f9a cmd/go: insert goroot to the hash of build cache when the packages include C files
This reverts CL 351851, which itself reverted CL 348991.

The problem with the original CL, as far as I can tell, was due to a
bug in the Go project's builder infrastructure (#33598) and not the
change itself. Once the build infrastructure is fixed, this change
can be resubmitted.

Fixes #48319
Updates #33598

Change-Id: I0fdbcc241eb2bdeb350944aad58bf58774fb591e
Reviewed-on: https://go-review.googlesource.com/c/go/+/353352
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-10-11 19:20:12 +00:00
Dan Scales
52078fa477 cmd/compile: deal with TODO related to generic wrappers with embedded fields
It turns out there is no real TODO here - things are working fine. If we
are generating a wrapper for a method on a generic type that is actually
the method on embedded type, then we should just just generate the
normal embedded wrapper, which calls the wrapper for the real receiver
type on that method. There is no need to do the generic path where we
add in the dictionary argument. So, just updated that TODO comment with
this explanation.

Added a new test case embedded.go, which specifically tests various
situations involving converting to empty and non-empty interfaces.
issue44688.go already tests a bunch of these situations as well.

Also made some other cleanups in reflect.go:

 - The shape test (that I had added) at the top of imethods is useless
   (never true), since it is always an interface type, so removed it.

 - Added usual helper function deref() to make code clearer in several
   places.

 - The shape test in methodWrapper() doesn't have to check HasShape() on
   each targ - it can just check HasShape() on the whole receiver.

 - The comment about disabling the tail call optimization for RegABI is
   no longer true.

 - Simplified code in several places by using the value of existing
   variable 'methodrcvr'.

Change-Id: I8b1a5dc518dad37585824a1f73ceebb7627a9f82
Reviewed-on: https://go-review.googlesource.com/c/go/+/355129
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-10-11 19:15:23 +00:00
Robert Findley
577bb7dba1 all: update vendored golang.org/x/tools
Now that x/tools/go/types/objectpath has been updates to support type
parameters, I ran the following commands to update x/tools inside the
cmd module:

	go get -d golang.org/x/tools@18fa840216958359dc43466f3e70d96add38edbb # main branch
	go mod tidy
	go mod vendor

Updates #48588

Change-Id: Ibebc1ac2f721d6e2eb1a4f6c610918770d4879ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/355012
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-11 17:02:03 +00:00
Paul E. Murphy
aa1c6f5639 cmd/internal/obj/ppc64: fix mtocrf, cleanup other CR ops
Fix "MOVW CRx, Rx" and "MOVFL Rx, constant", The FXM field was not
encoded correctly.

Generate mtocrf instead of mtcrf when a CRx argument is used. This
form is much faster.

Simplify several conditional statements which test if the register
argument is REG_CR or one of REG_CRx if the tested argument is known
to be matched as C_CREG. Likewise, a4 is (the From3 arg) is always
TYPE_NONE in the existing optab entries for type_ 69.

Change-Id: I3a4749b1cbfdfab6a2616586ae59e932e01dae50
Reviewed-on: https://go-review.googlesource.com/c/go/+/352789
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-10-11 16:48:22 +00:00
Cherry Mui
bd41f2d3cd cmd/link: do not mark holes in functab
With multiple text sections, there may be holes (non-Go code) in
the PC range of Go code and covered by the functab. Previously, we
use a linear search with actual PCs to find the functab entry. We
need to use special entries to mark holes, so a PC in the hole can
be distinguished from the previous function.

Now, with the previous CL we find if the PC is in between of the
sections upfront in textOff. There is no need to mark holes in the
functab.

Change-Id: I22ff27279422bfc855c2ca35ba0fdfb63234c113
Reviewed-on: https://go-review.googlesource.com/c/go/+/354874
Trust: Cherry Mui <cherryyz@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-10-11 16:05:38 +00:00
Cherry Mui
2478b6f6d6 runtime: simplify multiple text section handling in findfunc
In findfunc, we first us the relative PC to find the function's
index in functab. When we split text sections, as the external
linker may shift the sections, and the PC may not match the
(virtual) PC we used to build the functab. So the index may be
inaccurate, and we need to do a (forward or backward) linear
search to find the actual entry.

Instead of using the PC directly, we can first compute the
(pre-external-link virtual) relative PC and use that to find the
index in functab. This way, the index will be accurate and we will
not need to do the special backward linear search.

Change-Id: I8ab11c66b7a5a3d79aae00198b98780e10db27b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/354873
Trust: Cherry Mui <cherryyz@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-10-11 15:48:29 +00:00
Yuval Pavel Zholkover
f2141a71c6 doc/go1.18: document FreeBSD 11.x will no longer be supported
Mention future versions will require the COMPAT_FREEBSD12 kernel option
set in the kernel.

For #47694.

Change-Id: Ia94c4f9dbb38c68025d3c1d12dd2e241a5480a6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/354971
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-10-11 15:43:15 +00:00
Russ Cox
702e337174 regexp: document and implement that invalid UTF-8 bytes are the same as U+FFFD
What should it mean to run a regexp match on invalid UTF-8 bytes?
The coherent behavior options are:

1. Invalid UTF-8 does not match any character classes,
   nor a U+FFFD literal (nor \x{fffd}).
2. Each byte of invalid UTF-8 is treated identically to a U+FFFD in the input,
   as a utf8.DecodeRune loop might.

RE2 uses Rule 1.
Because it works byte at a time, it can also provide \C to match any
single byte of input, which matches invalid UTF-8 as well.
This provides the nice property that a match for a regexp without \C
is guaranteed to be valid UTF-8.

Unfortunately, today Go has an incoherent mix of these two, although
mostly Rule 2. This is a deviation from RE2, and it gives up the nice
property, but we probably can't correct that at this point.
In particular .* already matches entire inputs today, valid UTF-8 or
not, and I doubt we can break that.

This CL adopts Rule 2 officially, fixing the few places that deviate from it.

Fixes #48749.

Change-Id: I96402527c5dfb1146212f568ffa09dde91d71244
Reviewed-on: https://go-review.googlesource.com/c/go/+/354569
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2021-10-11 15:28:50 +00:00
Robert Findley
34f7b1f841 go/parser: clean up unnecessary arguments and replace an if statement
Eliminate an unnecessary argument from parseGenericType, and replace an
if statement with a switch.

Change-Id: Iaa8afeface929332579f183c8e523961cca9aca4
Reviewed-on: https://go-review.googlesource.com/c/go/+/354869
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-11 12:53:11 +00:00
Paul E. Murphy
59b2f516e8 cmd/internal/obj/ppc64: remove unused REG_DCR types
The assembler does not support parsing DCRx registers,
nor does the compiler generate opcodes with these.

Likewise, these registers are only available on ISA
2.07 embedded processors which are not supported in
golang.

Change-Id: Iea258e5958a2022bda0eee8348de1b06437148df
Reviewed-on: https://go-review.googlesource.com/c/go/+/352790
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-10-11 12:42:06 +00:00
Keith Randall
d2d21d98e4 cmd/compile: used TESTL instead of TESTQ for cpu feature flag detection
Uses one less byte when encoded. Performance is unchanged.

Change-Id: If400c9c9fc07a033e5ae9bf975ec512e432f7825
Reviewed-on: https://go-review.googlesource.com/c/go/+/354949
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-10-10 15:11:26 +00:00
Jake Ciolek
b99abf3cce cmd/compile: use the shorter version of XOR for breaking POPCNT register
dependency

XORL accomplishes the same thing while being shorter to encode.

Change-Id: I4397999ff617edb61a7fb7d1eca757a202ab8134
Reviewed-on: https://go-review.googlesource.com/c/go/+/354832
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
2021-10-09 23:29:26 +00:00
Jake Ciolek
ba2c9fef03 cmd/compile: mark NOT as an op that doesn't clobber flags on i386/AMD64
NOT does not affect any FLAGS register values on i386/AMD64 so we do not
need to mark it as an Op that clobbers them.

Change-Id: I6d99cad49cfa2568b01e58190256582b18fb3b7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/354831
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
2021-10-09 17:34:04 +00:00
Sean Liao
eba91e83b0 sync: use example.com for url in ExampleWaitGroup
Fixes #48886

Change-Id: I1093ae0ba30dab5a73d4d6bcfd083564d13877a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/354830
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2021-10-09 14:53:12 +00:00
Alejandro García Montoro
e1c294a56d cmd/compile: eliminate successive swaps
The code generated when storing eight bytes loaded from memory in big
endian introduced two successive byte swaps that did not actually
modified the data.

The new rules match this specific pattern both for amd64 and for arm64,
eliminating the double swap.

Fixes #41684

Change-Id: Icb6dc20b68e4393cef4fe6a07b33aba0d18c3ff3
Reviewed-on: https://go-review.googlesource.com/c/go/+/320073
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-10-09 01:04:29 +00:00
Matthew Dempsky
74abcabf30 cmd/internal/obj: rename MOVBE{LL,QQ,WW} to just MOVBE{L,Q,W}
The double suffix doesn't seem to serve any purpose, and we can keep
the old spelling as a backwards compatible alias in cmd/asm.

Change-Id: I3f01fc7249fb093ac1b25bd75c1cb9f39b8f62a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/354700
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2021-10-08 21:38:44 +00:00
Bryan C. Mills
7fcf9a1e58 cmd/go: do not expect a specific timing in test_fuzz_minimize
Empirically, it may take more than 3 seconds for minimization to begin.
If that is the case, the "elapsed:" message may start at 4s or higher.

Fixes #48870

Change-Id: I6bb4367b61377454b0af664d80232fdb46e7c245
Reviewed-on: https://go-review.googlesource.com/c/go/+/354794
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-10-08 19:41:16 +00:00
Tobias Klauser
f430bda258 go/build, internal/goarch: sort goarchList alphabetically
Change-Id: I0534b61e34d78104cb85124b805fd90f3250e6c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/354829
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-08 19:30:58 +00:00
Matthew Dempsky
b9e1e1ba3d cmd/cgo: use "!compiler_bootstrap" tag instead of "go1.18"
The illumos builder is using a Go 1.18 prerelease toolchain for
bootstrapping, which doesn't have ast.IndexListExpr. But we can
instead check for the "compiler_bootstrap" build tag that's already
used for distinguishing binaries built for toolchain1.

Fixes #48863.

Change-Id: I87b672322eee22a60ab8d0bb3be5f76cffc97545
Reviewed-on: https://go-review.googlesource.com/c/go/+/354695
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-08 19:19:09 +00:00