Dan Scales [Wed, 13 Oct 2021 17:27:01 +0000 (10:27 -0700)]
cmd/compile: fix inst_test.go for riscv5
On riscv5, apparently extra wrappers (trampolines) are created for some
functions with the suffix "-tramp". Modify inst_test.go to not match
these "-tramp" wrappers.
Change-Id: I754c724f03555c30f8e1b5cfc08152555bbbcf17
Reviewed-on: https://go-review.googlesource.com/c/go/+/355650
Run-TryBot: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Matthew Dempsky [Tue, 12 Oct 2021 22:38:52 +0000 (15:38 -0700)]
unsafe: optimize Slice bounds checking
This reduces the number of branches to bounds check non-empty slices
from 5 to 3. It does also increase the number of branches to handle
empty slices from 1 to 3; but for non-panicking calls, they should all
be predictable.
Updates #48798.
Change-Id: I3ffa66857096486f4dee417e1a66eb8fdf7a3777
Reviewed-on: https://go-review.googlesource.com/c/go/+/355490
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>
Matthew Dempsky [Tue, 12 Oct 2021 22:31:25 +0000 (15:31 -0700)]
unsafe: allow unsafe.Slice up to end of address space
Allow the user to construct slices that are larger than the Go heap as
long as they don't overflow the address space.
Updates #48798.
Change-Id: I659c8334d04676e1f253b9c3cd499eab9b9f989a
Reviewed-on: https://go-review.googlesource.com/c/go/+/355489
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
James Harris [Fri, 17 Sep 2021 02:29:00 +0000 (02:29 +0000)]
net/http/httputil: allow MIME parameters when detecting SSE in ReverseProxy
This change allows httputil.ReverseProxy to detect SSE (server-sent events)
content when the response's Content-Type header includes MIME parameters,
such as "text/event-stream;charset=utf-8".
Prior to this change the value of the Content-Type header was compared
directly to the literal "text/event-stream". This caused a false-negative
which failed to set the FlushInterval correctly when MIME parameters were
present.
Change-Id: If8bb43efb78787b6519d7fe7599ca018a0da0023
GitHub-Last-Rev: 224518c5eb9686ee050c79f5f853ebacfdf6fc42
GitHub-Pull-Request: golang/go#48427
Reviewed-on: https://go-review.googlesource.com/c/go/+/350509
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Tamir Duberstein [Tue, 12 Oct 2021 19:03:25 +0000 (15:03 -0400)]
net: remove timeout in TestDialTimeoutMaxDuration
This test seems only to be testing that Dial does not time out
immediately as a result of integer overflow; the precise time taken to
connect is immaterial. Replace naked loop with sub-tests.
Fixes #43069.
Change-Id: Ib5e38a1d8cd191b74c2bc7c26bef57b180e16f68
Reviewed-on: https://go-review.googlesource.com/c/go/+/355390
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Koichi Shiraishi [Mon, 11 Oct 2021 15:33:43 +0000 (00:33 +0900)]
internal/poll,net: support poll.Sendfile for darwin
darwin already supports syscall.Sendfile.
Change-Id: Id3db06591ffad0550b4173bacddeb0acfe355f9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/355109 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>
kjgorman [Sun, 10 Oct 2021 13:30:26 +0000 (14:30 +0100)]
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>
Amelia Downs [Mon, 30 Aug 2021 21:05:36 +0000 (17:05 -0400)]
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>
When a process is forcefully killed (for example, with SIGKILL on unix), its ProccessState.Exited() will return false.
Change-Id: I8cebc8d28f2ba1b687c145f6d941647fc3a10665
GitHub-Last-Rev: 414ae1980fe61dd530c46cc2c7f4de3a5bc83ed5
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>
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>
helbing [Tue, 12 Oct 2021 23:33:50 +0000 (23:33 +0000)]
embed: add example
Change-Id: I4e50e469047ac7efbf4ed464e238000dbdf53d6b
GitHub-Last-Rev: 8d29b73d1160b4498a38aa3ef6530ee5c9353186
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>
nicksherron [Wed, 13 Oct 2021 01:39:13 +0000 (01:39 +0000)]
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: a471e3d123aa6c8bb9b091e65de5d16609fb8db1
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>
Dan Scales [Tue, 12 Oct 2021 19:52:59 +0000 (12:52 -0700)]
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>
Robert Findley [Tue, 12 Oct 2021 15:54:09 +0000 (11:54 -0400)]
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>
Tamir Duberstein [Tue, 12 Oct 2021 20:00:23 +0000 (16:00 -0400)]
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>
Bryan C. Mills [Wed, 18 Mar 2020 01:29:54 +0000 (21:29 -0400)]
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>
Dan Scales [Tue, 10 Aug 2021 21:51:57 +0000 (14:51 -0700)]
[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>
Jay Conrod [Wed, 6 Oct 2021 21:58:22 +0000 (14:58 -0700)]
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>
Dan Scales [Mon, 4 Oct 2021 18:56:12 +0000 (11:56 -0700)]
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>
Robert Findley [Wed, 6 Oct 2021 17:51:21 +0000 (13:51 -0400)]
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>
Jay Conrod [Mon, 11 Oct 2021 22:51:10 +0000 (15:51 -0700)]
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>
Cherry Mui [Tue, 12 Oct 2021 16:38:42 +0000 (12:38 -0400)]
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>
Katie Hockman [Thu, 7 Oct 2021 20:26:36 +0000 (16:26 -0400)]
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>
Paul E. Murphy [Tue, 9 Mar 2021 22:55:20 +0000 (16:55 -0600)]
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>
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>
Ian Lance Taylor [Thu, 7 Oct 2021 20:05:16 +0000 (13:05 -0700)]
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>
Robert Findley [Mon, 11 Oct 2021 13:59:40 +0000 (09:59 -0400)]
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>
Robert Findley [Sun, 10 Oct 2021 14:53:06 +0000 (10:53 -0400)]
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>
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>
Robert Findley [Sun, 10 Oct 2021 14:43:20 +0000 (10:43 -0400)]
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>
Robert Findley [Fri, 8 Oct 2021 20:28:35 +0000 (16:28 -0400)]
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>
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>
Dan Scales [Thu, 7 Oct 2021 19:21:01 +0000 (12:21 -0700)]
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>
Bryan C. Mills [Fri, 1 Oct 2021 15:52:56 +0000 (11:52 -0400)]
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>
Dan Scales [Mon, 11 Oct 2021 16:15:02 +0000 (09:15 -0700)]
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>
Robert Findley [Mon, 11 Oct 2021 16:22:52 +0000 (12:22 -0400)]
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:
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>
Paul E. Murphy [Thu, 26 Aug 2021 22:14:12 +0000 (17:14 -0500)]
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.
Cherry Mui [Fri, 8 Oct 2021 23:55:17 +0000 (19:55 -0400)]
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.
Cherry Mui [Fri, 8 Oct 2021 23:24:53 +0000 (19:24 -0400)]
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>
Russ Cox [Thu, 7 Oct 2021 13:56:29 +0000 (09:56 -0400)]
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>
Robert Findley [Fri, 8 Oct 2021 15:14:35 +0000 (11:14 -0400)]
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>
Alejandro García Montoro [Fri, 14 May 2021 16:42:16 +0000 (18:42 +0200)]
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>
Matthew Dempsky [Fri, 8 Oct 2021 19:19:57 +0000 (12:19 -0700)]
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>
Matthew Dempsky [Fri, 8 Oct 2021 18:23:38 +0000 (11:23 -0700)]
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>
Cherry Mui [Fri, 8 Oct 2021 17:10:08 +0000 (13:10 -0400)]
cmd/link: put gcprog symbols along with gcbits
A stack object record may refer to the object's type's GC mask or
GC program (for very large types). For the latter, currently the GC
program symbol is named "type..gcprog.XXX" which is then laid out
along with type symbols at link time. When relro is used, the type
symbols end up in a different section.
As we now use relative addressing for stack object records to refer
to GC masks or GC programs, it is important that it is laid out in
the rodata section (not rodata.rel.ro). Move GC program symbols to
be along with GC masks, as they are similar and accessed the same
way. They don't have relocations so they don't need to be laid to a
relro section.
Keith Randall [Thu, 7 Oct 2021 20:29:09 +0000 (13:29 -0700)]
runtime: fix uint64->float32 conversion for softfloat
The fix for #48807 in CL 354429 forgot that we also need to fix
the softfloat implementation.
Update #48807
Change-Id: I596fb4e14e78145d1ad43c130b2cc5122b73655c
Reviewed-on: https://go-review.googlesource.com/c/go/+/354613
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Robert Griesemer [Fri, 8 Oct 2021 16:49:22 +0000 (09:49 -0700)]
cmd/compile/internal/types2: use an identifier map rather than isubst for recv type params
This is a port of CL 354643 from go/types to types2 with adjustments:
- use of syntax rather than go/ast package as needed
- adjustments due to the different code for type parameter declarations
- rename of Checker.rparamMap to Checker.recvTParamMap, which seems clearer
Change-Id: I5311a0c05a13c6b87ea1422b250b90c3d05c5dce
Reviewed-on: https://go-review.googlesource.com/c/go/+/354693
Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Dan Scales [Wed, 22 Sep 2021 17:05:33 +0000 (10:05 -0700)]
cmd/compile: allow delaying of transformCompLit, new transformAddr
For this unusual case, where a constraint specifies exactly one type, we
can have a COMPLIT expression with a type that is/has typeparams.
Therefore, we add code to delay transformCompLit for generic functions.
We also need to break out transformAddr (which corresponds to tcAddr),
and added code for delaying it as well. Also, we now need to export
generic functions containing untransformed OCOMPLIT and OKEY nodes, so
added support for that in iexport.go/iimport.go. Untransformed OKEY
nodes include an ir.Ident/ONONAME which we can now export.
Had to adjust some code/asserts in transformCompLit(), since we may now
be transforming an OCOMPLIT from an imported generic function (i.e. from
a non-local package).
Fixes #48537
Change-Id: I09e1b3bd08b4e013c0b098b8a25d082efa1fef51
Reviewed-on: https://go-review.googlesource.com/c/go/+/354354
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>
Robert Findley [Fri, 8 Oct 2021 14:37:54 +0000 (10:37 -0400)]
go/ast, go/types: remove some stale TODOs
We've decided to leave TParams on FuncType, and type list syntax is
no longer part of the proposal.
Change-Id: Id34f6495a358d76994df331384a4b93487275c4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/354751
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>
Change-Id: I0ed80dad99d6920a187af4339e437a08fbe91ade
Reviewed-on: https://go-review.googlesource.com/c/go/+/354572
Trust: Bryan C. Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Robert Findley [Thu, 7 Oct 2021 23:12:16 +0000 (19:12 -0400)]
go/types: use an identifier map rather than isubst for recv type params
Receiver type parameters are the only type expressions allowed to be
blank. Previously this was handled by substitution of synthetic
non-blank names in the receiver type expression, but that introduced
problems related to AST mangling: the scope had extra elements,
Object.Name() was inaccurate, and synthetic nodes were recorded in
types.Info.
Fix this instead by recording a map of *ast.Ident->*TypeParam on the
Checker, which is read in Checker.ident to resolve blank identifiers
denoting receiver type parameters.
Change-Id: I6a7a86b823409f54778c0f141e8bd269a2cc85d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/354643
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>
Nigel Tao [Thu, 7 Oct 2021 23:33:47 +0000 (10:33 +1100)]
image/png: fix interlaced palette out-of-bounds
PNG images can be paletted, where each pixel value (a uint8) indexes a
slice of colors. In terms of wire format, the PLTE chunk explicitly
contains the palette length. However, in practice, some arguably
malformed images contain pixel values greater than or equal to the
explicit PLTE length.
Go's image/png decoder accomodates such images by lengthening the
decoded image's palette if the implicit maximum is larger than the
explicit maximum. This was already done, prior to this commit, by the
"if len(paletted.Palette) <= int(idx)" lines in decoder.readImagePass.
Separately, PNG images can also be interlaced, where the final image is
the result of merging multiple partial images, also called passes. Prior
to this commit, we applied the palette lengthening to the pass images
but not the final image. This commit fixes that.
Fixes #48612
Change-Id: I77606538cc9a504fbd726071756ebcd10c9da73f
Reviewed-on: https://go-review.googlesource.com/c/go/+/354709
Trust: Nigel Tao <nigeltao@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
Robert Griesemer [Fri, 8 Oct 2021 00:02:53 +0000 (17:02 -0700)]
go/types: partial revert of incorrect unification "fix"
This is a port of CL 354690 from types2 to go/types.
Change-Id: I50e7297a67e37d261335260e285b9cb1c0d2a62d
Reviewed-on: https://go-review.googlesource.com/c/go/+/354691
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Robert Griesemer [Thu, 7 Oct 2021 22:53:32 +0000 (15:53 -0700)]
cmd/compile/internal/types2: partial revert of incorrect unification "fix"
The "fix" (CL 352832) for #48619 was incorrect and broke
the unification algorithm in some cases (e.g., #48695).
This CL reverts the changes made by CL 352832 to unify.go,
and comments out code in corresponding tests.
As a result, #48695 will be fixed, and we will re-open #48619.
Fixes #48695.
For #48619.
For #48656.
Change-Id: I91bc492062dbcc8dae7626f6b33f6dfabf48bcb8
Reviewed-on: https://go-review.googlesource.com/c/go/+/354690
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Cherry Mui [Thu, 7 Oct 2021 20:33:43 +0000 (16:33 -0400)]
cmd/link: mark holes in functab with end PC-1
When we have multiple text sections, we need to mark holes between
the sections in the functab. A hole is marked with an entry with
the end PC of the previous section. As we now use offsets instead
of (relocated) PCs, the end offset of a section may be the same of
the start of the next one. Distinguish it by using the end address
-1.
For #48837.
Change-Id: I121aac53b32a869378632cf151cb1b6f98ad3089
Reviewed-on: https://go-review.googlesource.com/c/go/+/354636
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>
Cherry Mui [Thu, 7 Oct 2021 20:26:29 +0000 (16:26 -0400)]
runtime: handle end PC in textAddr
As the func table contains the end marker of the text section, we
sometimes need to get that address from an offset. Currently
textAddr doesn't handle that address, as it is not within any
text section. Instead of letting the callers not call textAddr
with the end offset, just handle it more elegantly in textAddr.
Dan Scales [Thu, 30 Sep 2021 22:45:29 +0000 (15:45 -0700)]
cmd/compile: improving printing of type names in func/meth instantiations
Change to using types.(*Type).LinkString() for printing names of types
in function/method instantiations. (e.g. f[int] or Value[p.Myint].Set())
LinkString already generates a unique string description for t, using
package paths, except that it uses "" for the local package path. The ""
will be expanded in the linker, so the names in the executable will have
full package paths everywhere and de-duplication of function/method
instantiations will work properly. We do need to add an explicit
substitution of "" in ReadImports() for function/method names. We
previously were using NameString(), which doesn't use full package
paths, so is not fully unique.
We had also discussed that we would prefer to minimize spaces in
function/method instantiation names. So, I changed LinkString() to
eliminate all unneeded spaces. In the one case where we need a
separator, which is between field names and types, we use a "#" instead
of a space.
This change has the advantage of eliminating spaces in some existing
non-generic function name - mainly .type.eq functions for anonymous
types (e.g. "type..eq.struct { runtime.gList; runtime.n int32 }") shows
up in a hello-world executable (as Cherry pointed out).
We do not need an analogous function for types2 right now, since we
create all instantiations using types1 types. In the one case where we
need to create an instantiation during types2-to-types1 translation, we
convert the types to types1 first (see (*irgen).instTypeName2).
Change-Id: Iac4748fa0d0d6f89af59bd51076266986daee945
Reviewed-on: https://go-review.googlesource.com/c/go/+/353609
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This is the same output it has while fuzzing, so if
minimization runs for a long time (default allows 1
minute), then it looks like minimization is hanging.
It's also confusing that the execs/sec would continually
decrease.
Now, when minimization is running, the command line
output will look something like this:
Tobias Klauser [Thu, 7 Oct 2021 07:55:43 +0000 (09:55 +0200)]
os: don't use wait6 on netbsd
CL 315281 changed the os package use wait6 on netbsd. This seems to be
causing frequent test failures as reported in #48789. Revert that change
using wait6 on netbsd for now.
Updates #13987
Updates #16028
For #48789
Change-Id: Ieddffc65611c7f449971eaa8ed6f4299a5f742c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/354249
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Jinwen Wo [Thu, 7 Oct 2021 17:24:47 +0000 (17:24 +0000)]
cmd/go/internal/web: improve IP check testing on ipv6 env
The existing implementation lacks consideration of running test on a
machine which has ipv6 address but no ipv4 address. Use net.IP.IsLoopback
and net.IP.IsUnspecified instead of hardcoded addresses.
Fixes: #48575
This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.
Change-Id: I9c3c26d2ba13c7a24065751b59a1e002098ed654
GitHub-Last-Rev: fc45adbf7b944122d8f07bd451a8eeed1e69140c
GitHub-Pull-Request: golang/go#48850
Reviewed-on: https://go-review.googlesource.com/c/go/+/354609 Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Cherry Mui [Thu, 2 Sep 2021 20:51:59 +0000 (16:51 -0400)]
misc/wasm, cmd/link: do not let command line args overwrite global data
On Wasm, wasm_exec.js puts command line arguments at the beginning
of the linear memory (following the "zero page"). Currently there
is no limit for this, and a very long command line can overwrite
the program's data section. Prevent this by limiting the command
line to 4096 bytes, and in the linker ensuring the data section
starts at a high enough address (8192).
(Arguably our address assignment on Wasm is a bit confusing. This
is the minimum fix I can come up with.)
Thanks to Ben Lubar for reporting this issue.
Fixes #48797
Fixes CVE-2021-38297
Change-Id: I0f50fbb2a5b6d0d047e3c134a88988d9133e4ab3
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1205933 Reviewed-by: Roland Shoemaker <bracewell@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/354571 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Keith Randall [Wed, 6 Oct 2021 21:53:32 +0000 (14:53 -0700)]
cmd/compile,runtime: implement uint64->float32 correctly on 32-bit archs
The old way of implementing it, float32(float64(x)), involves 2 roundings
which can cause accuracy errors in some strange cases. Implement a runtime
version of [u]int64tofloat32 which only does one rounding.
Fixes #48807
Change-Id: Ie580be480bee4f3a479e58ef8dce23032f231704
Reviewed-on: https://go-review.googlesource.com/c/go/+/354429
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Matthew Dempsky [Mon, 4 Oct 2021 23:20:57 +0000 (16:20 -0700)]
cmd/cgo: update to handle ast.IndexListExpr
Allows cgo to work with generics.
Updates #47781.
Change-Id: Id1a5d1a0a8193c5b157e3e671b1490d687d10384
Reviewed-on: https://go-review.googlesource.com/c/go/+/353882
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>
Leonard Wang [Thu, 7 Oct 2021 12:14:22 +0000 (20:14 +0800)]
cmd/compile: fix the index variable is shadowed in dictPass
The CL 349613 causes this problem.
In fact, we want to use the outer i to find m.List[i],
but the newly created index variable i in the nearest
for range shadow the outer i.
Fixes #48838.
Change-Id: I10f0bd985340f9443eefaadda6fc56e4e7e9a10c
Reviewed-on: https://go-review.googlesource.com/c/go/+/354549
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Cuong Manh Le [Tue, 5 Oct 2021 16:53:07 +0000 (23:53 +0700)]
go/types: better error message for invalid untyped nil conversion
This is port of CL 354049 for types2 to go/type.
The change is identical, but for some tweaks to the error message/position
in tests, since when go/types reports the exact operation "cannot convert"
instead of the general "invalid operation" like types2.
Updates #48784
Change-Id: I3e99f2721501d23187fd0a8970eb1de28e0c41d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/354050
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Cuong Manh Le [Tue, 5 Oct 2021 15:59:49 +0000 (22:59 +0700)]
cmd/compile: better error message for invalid untyped nil conversion
In case of an invalid untyped nil conversion, the compiler's original
type checker leaves it to the caller to report a suitable error message.
But types2 does not, it always reports the invalid conversion.
CL 328053 made types2 report a better error message, and match the
original compiler behavior. But it ignored the case of untyped nil.
This CL adds that missing case, by checking whether the two operands can
be mixed when untyped nil is present.
Fixes #48784
Change-Id: Idc7d86eb0245aa18ca428e278f4416d6b3679058
Reviewed-on: https://go-review.googlesource.com/c/go/+/354049
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Robert Griesemer [Thu, 7 Oct 2021 02:38:15 +0000 (19:38 -0700)]
go/types: implement copy for generic argument types
This is a port of CL 354432 from types2 to go/types
with minor adjustments:
- an error message has a different position
- the constraint literals are wrapped in interfaces
because the interface-free notation has not been
ported yet
Change-Id: I167094b57b39027566f2b7ce3aa97a071bae4da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/354489
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Robert Griesemer [Thu, 7 Oct 2021 01:23:06 +0000 (18:23 -0700)]
cmd/compile/internal/types2: implement copy for generic argument types
For now, the underlying types of the the argument types' constraints
must be a single type that is a slice (the source operand may also
be a string).
Change-Id: I9e705e3349c9242f126b9c3e0af65e9ffb25fe6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/354432
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
John Kelly [Thu, 29 Jul 2021 19:47:23 +0000 (15:47 -0400)]
net/http: add Cookie.Valid method
The (*http.Cookie).String method used by SetCookie will silently discard
or sanitize any fields it deems invalid, making it difficult to tell
whether a cookie will be sent as expected.
This change introduces a new (*http.Cookie).Valid method which may be
used to check if any cookie fields will be discarded or sanitized prior
to calling (*http.Cookie).String.
Fixes #46370
Change-Id: I2db80078de190d267a9c675a9717c8be8acc8704
Reviewed-on: https://go-review.googlesource.com/c/go/+/338590
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
Trust: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com>
Dan Scales [Tue, 5 Oct 2021 00:54:51 +0000 (17:54 -0700)]
cmd/compile: fix -W=3 output after the # line
I've noticed for a while that there is some duplicated and some useful
information being put out in -W=3 mode after the comment marker (besides
the position).
dumpNodeHeader puts out a comment marker '#' before putting out the
position of a node (which is for almost all nodes). Therefore, we shouldn't
print out anything on the same line after calling dumpNodeHeader().
But we happen to be putting out a duplicate type of the node in some
cases. Also, we put out the Sym() associate with the node after
dumpNodeHeader(). So, I got rid of the duplicate type print-out, and moved
the print-out of n.Sym() to be inside dumpNodeHeader() before the
position information. Also, moved the tc flag to be right after the type
information, which seems like it makes more sense.
Change-Id: I05210fbf9f3b2d8e3b73fc0ceab26a7bce5dc104
Reviewed-on: https://go-review.googlesource.com/c/go/+/354355
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Damien Neil [Wed, 4 Aug 2021 23:07:28 +0000 (16:07 -0700)]
time: fallback to slower TestTicker test after one failure
TestTicker is sensitive to overloaded or slow systems, where a 20ms
ticker running for 10 ticks has a total run time out of the range
[110ms, 290ms]. To counter this flakiness, it tries five times to
get a successful result. This is insufficient--an overloaded test
machine can introduce more than 100ms of delay across the test.
Reduce the five attempts to two, but use a 1s ticker for 8 ticks
in the second attempt.
Updates #46474.
Updates #35692.
Change-Id: Ibd5187b00ccceeb981b652f2af9a1c3766357b78
Reviewed-on: https://go-review.googlesource.com/c/go/+/339892
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Carlo Alberto Ferraris [Fri, 4 Jun 2021 11:58:55 +0000 (20:58 +0900)]
strings,bytes: avoid allocations in Trim/TrimLeft/TrimRight
There is evidence that the vast majority of uses for Trim* involve
cutsets with a single ASCII character, and the vast majority of
remaining uses involve cutsets with a small (<4) ASCII characters.
For this reason it makes sense to provide better fast paths for these
common cases.
Furthermore the current implementation needlessly allocates for unclear
benefits. This CL also replaces all paths to avoid allocations and, as
a side effect, it speeds up also the slow path.
go/build: ignore package main files in TestDependencies
The tree has package main files scattered around
in it for the purposes of running go generate.
They're all marked "// +build ignore",
which gets special handling in TestDependencies.
It would be nice to be able to use other build tags,
such as "generate", as suggested by the go generate
design doc. Plus the build tag syntax is changing.
This change skips all "package main" files.
By definition these aren't importable,
so they can't contribute to the dependency tree.
We can't quite eliminate the "// +build ignore"
check, as it is used by packages runtime and syscall.
But it's still a step in the right direction.
Change-Id: Ib9449acfdba75f570b87a4200afe944910d76222
Reviewed-on: https://go-review.googlesource.com/c/go/+/339592
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Damien Neil [Wed, 6 Oct 2021 19:16:47 +0000 (12:16 -0700)]
all: update go.mod for golang.org/x/net
Somehow CL 353390 managed to update the vendored code to d2e5035098b3,
but not the go.mod and other version references. Fix.
Change-Id: Ic265c10f7bd7ec982671b46c5d9ae50636a13309
Reviewed-on: https://go-review.googlesource.com/c/go/+/354391
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
cmd/compile: make encoding/binary loads/stores cheaper to inline
The encoding/binary little- and big-endian load and store routines are
frequently used in performance sensitive code. They look fairly complex
to the inliner. Though the routines themselves can be inlined,
code using them typically cannot be.
Yet they typically compile down to an instruction or two
on architectures that support merging such loads.
This change teaches the inliner to treat calls to these methods as cheap,
so that code using them will be more inlineable.
It'd be better to teach the inliner that this pattern of code is cheap,
rather than these particular methods. However, that is difficult to do
robustly when working with the IR representation. And the broader project
of which that would be a part, namely to model the rest of the compiler
in the inliner, is probably a non-starter. By way of contrast, imperfect
though it is, this change is an easy, cheap, and useful heuristic.
If/when we base inlining decisions on more accurate information obtained
later in the compilation process, or on PGO/FGO, we can remove this
and other such heuristics.
Newly inlineable functions in the standard library: