]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agobufio: reject UnreadByte or UnreadRune after a Discard or WriteTo
Bryan C. Mills [Thu, 23 Sep 2021 15:56:16 +0000 (11:56 -0400)]
bufio: reject UnreadByte or UnreadRune after a Discard or WriteTo

Discard is not really a read operation, and in theory it could
Seek the underlying Reader without actually reading anything,
so an UnreadByte following a Discard is disallowed.

Similarly, although WriteTo usually does end up calling Read on the
underlying buffer, if the underlying Reader implements io.WriterTo it
may instead terminate in a call to WriteTo, without ever buffering or
even seeing the last byte written. (It is conceptually read-like, but
not strictly “a read operation”.)

Fixes #48446

Change-Id: Ide6f2b157332b423486810399f66140c914144e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/351810
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
3 years agocmd/compile/internal/types2: mark implicit interfaces as such
Robert Griesemer [Thu, 30 Sep 2021 20:37:30 +0000 (13:37 -0700)]
cmd/compile/internal/types2: mark implicit interfaces as such

Provide an accessor for clients, and don't print the interface
around implicitly wrapped embedded types.

For #48424.

Change-Id: Ib2c76315508fc749ea4337d52e13d17de80e04da
Reviewed-on: https://go-review.googlesource.com/c/go/+/353396
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>
3 years agocmd/compile: accept constraint literals with elided interfaces
Robert Griesemer [Thu, 30 Sep 2021 17:04:46 +0000 (10:04 -0700)]
cmd/compile: accept constraint literals with elided interfaces

This change enables the relaxed syntax for constraint literals
as proposed in issue #48424 and adds a simple smoke test for
the compiler. (Most of the relevant changes are in the syntax
and types2 package which have more extensive tests for this.)

This makes it possible to experiment with the new syntax while
we contemplate the fate of #48424.

If #48424 is accepted, this change can remain. If #48424 is
not accepted, reverting this CL will remove this feature in
the compiler.

For #48424.

Change-Id: I624fbb37c2f616ee9ad692e17e4fc75c9d5b06e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/353389
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/compile/internal/types2: accept constraint literals with elided interfaces
Robert Griesemer [Thu, 30 Sep 2021 03:56:36 +0000 (20:56 -0700)]
cmd/compile/internal/types2: accept constraint literals with elided interfaces

When collecting type parameters, wrap constraint literals of the
form ~T or A|B into interfaces so the type checker doesn't have
to deal with these type set expressions syntactically anywhere
else but in interfaces (i.e., union types continue to appear
only as embedded elements in interfaces).

Since a type constraint doesn't need to be an interface anymore,
we can remove the respective restriction. Instead, when accessing
the constraint interface via TypeParam.iface, wrap non-interface
constraints at that point and update the constraint so it happens
only once. By computing the types sets of all type parameters at
before the end of type-checking, we ensure that type constraints
are in their final form when accessed through the API.

For #48424.

Change-Id: I3a47a644ad4ab20f91d93ee39fcf3214bb5a81f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/353139
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>
3 years agocmd/compile/internal/syntax: allow eliding interface in constraint literals
Robert Griesemer [Wed, 29 Sep 2021 18:14:05 +0000 (11:14 -0700)]
cmd/compile/internal/syntax: allow eliding interface in constraint literals

This CL permits an arbitrary type as well as the type sets  ~T and A|B
in constraint position, without the need of a surrrounding interface.
For instance, the type parameter list

[P interface{ ~map[K]V }, K comparable, V interface{ ~string }]

may be written as

[P ~map[K]V, K comparable, V ~string]

The feature must be enabled explicitly with the AllowTypeSets mode
and is only available if AllowGenerics is set as well.

For #48424.

Change-Id: Ic70bb97a49ff75e67e040853eac10e6aed0fef1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/353133
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>
3 years agogo/types: remove Environment type
jiahua wang [Fri, 1 Oct 2021 13:58:51 +0000 (21:58 +0800)]
go/types: remove Environment type

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

3 years agocmd/link: correct type..importpath symbol handling
Cherry Mui [Thu, 30 Sep 2021 22:09:24 +0000 (18:09 -0400)]
cmd/link: correct type..importpath symbol handling

The linker specially handles go.importpath symbols. But the
compiler doesn't actually generate such symbols. Instead, it
generates type..importpath symbols. It is already in the type
section as the name starts with "type.". Also set its alignment
to 1, as it is string data.

Change-Id: I771f5529a0ff41a5bb476b3a02c8cc75729792de
Reviewed-on: https://go-review.googlesource.com/c/go/+/353489
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/link: set alignment for string symbols in symtab pass
Cherry Mui [Thu, 30 Sep 2021 21:42:15 +0000 (17:42 -0400)]
cmd/link: set alignment for string symbols in symtab pass

Set alignment for string symbols in symtab pass, so we don't need
to look at symbol name in symalign in dodata pass. (Ideally we
should not use symbol name like this in symtab pass either, but
we already use the names there anyway.)

Change-Id: I9fd61e0dd0824c50e3d0d7c07f75b967c8654796
Reviewed-on: https://go-review.googlesource.com/c/go/+/353470
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/link: reduce alignment for some funcdata symbols
Cherry Mui [Thu, 30 Sep 2021 15:46:00 +0000 (11:46 -0400)]
cmd/link: reduce alignment for some funcdata symbols

Funcdata like opendefer info and traceback arginfo are varints or
bytes. There is no need to align them.

GC liveness map and inline tree have 32-bit fields, so continue
align them to 4 bytes.

Change-Id: I9d5dd750a926c65a910efe5817f9f5c473019bc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/353469
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile/internal/types2: removed deprecated API entry points
Robert Griesemer [Thu, 30 Sep 2021 21:21:18 +0000 (14:21 -0700)]
cmd/compile/internal/types2: removed deprecated API entry points

We don't need to keep them around in types2.
Switched a couple of uses of NewSignature to NewSignatureType.

Change-Id: I62880c2b49ec82caa9362ed8a798cfc3bcea300e
Reviewed-on: https://go-review.googlesource.com/c/go/+/353397
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/types: switch uses of NewSignature to NewSignatureType (cleanup)
Robert Griesemer [Thu, 30 Sep 2021 21:39:52 +0000 (14:39 -0700)]
go/types: switch uses of NewSignature to NewSignatureType (cleanup)

Change-Id: I05ed5806e2a35a57ef3e8c9275a157574abcb0ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/353399
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/internal/gccgoimporter: change all .gox files to text
Ian Lance Taylor [Mon, 27 Sep 2021 15:59:46 +0000 (08:59 -0700)]
go/internal/gccgoimporter: change all .gox files to text

Avoid problems with distro scanning by not using files that look like
object files.

For #48548

Change-Id: I4a06d5690d0870d6253f176e510faa5eebf2d057
Reviewed-on: https://go-review.googlesource.com/c/go/+/352450
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
3 years agocmd/dist: consistently set PWD when executing a command in a different directory
Bryan C. Mills [Thu, 30 Sep 2021 19:15:45 +0000 (15:15 -0400)]
cmd/dist: consistently set PWD when executing a command in a different directory

For #33598

Change-Id: If0de906ffa2fcc83bb2a90f9e80a5b29d7667398
Reviewed-on: https://go-review.googlesource.com/c/go/+/353449
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: correct comment: walkSwitch -> walkSelect
wangyuntao [Sat, 10 Jul 2021 04:11:22 +0000 (04:11 +0000)]
cmd/compile: correct comment: walkSwitch -> walkSelect

fix typo

Change-Id: Ie2470e494ba95eed067ad42677520b35b383555f
GitHub-Last-Rev: 831f1973194f55b435dcdc6ef30290848228a114
GitHub-Pull-Request: golang/go#47117
Reviewed-on: https://go-review.googlesource.com/c/go/+/333789
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Keith Randall <khr@golang.org>

3 years ago.github: update IRC server
Sean Liao [Fri, 23 Jul 2021 18:14:14 +0000 (20:14 +0200)]
.github: update IRC server

Updates #46281

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

3 years agocmd/link: use "CC --print-prog-name" to locate tools
Cherry Mui [Thu, 22 Jul 2021 22:57:52 +0000 (18:57 -0400)]
cmd/link: use "CC --print-prog-name" to locate tools

When building for macOS with external linking, we currently use
"xcrun" to invoke "dsymutil" and "strip" tools. That doesn't work
well for cross compilation. Use "CC --print-prog-name" to find the
tool path instead.

Fixes #47316.

Change-Id: Ib30c6494c48bfb6a505dc26fe644ef543d777076
Reviewed-on: https://go-review.googlesource.com/c/go/+/336769
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agoruntime: avoid run TestSyscallN in parallel
Changkun Ou [Fri, 27 Aug 2021 15:08:23 +0000 (17:08 +0200)]
runtime: avoid run TestSyscallN in parallel

Fixes #48012

Change-Id: Ie27eb864ac387ecf5155a3aefa81661f1448ace5
Reviewed-on: https://go-review.googlesource.com/c/go/+/345670
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/link: add runtime.text.N symbols to Mach-O symbol table
Cherry Mui [Wed, 29 Sep 2021 20:47:12 +0000 (16:47 -0400)]
cmd/link: add runtime.text.N symbols to Mach-O symbol table

On Darwin/ARM64 when external linking, for very large text we
split it into multiple sections. For each section (other than the
first) we create runtime.text.N marker symbols. In CL 316050 I
forgot to add those symbols to the symbol table. This CL does it.

It doesn't actually matter for program execution. But we add them
on ELF when splitting text sections, so we do it here as well.
Also, this makes it easier to tell if we split text sections.

Change-Id: Ida7f8e9431867881e5ee2bc1a2129eeaf83cb878
Reviewed-on: https://go-review.googlesource.com/c/go/+/353209
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agodebug/gosym: run TestPCLine on Linux/AMD64 in short mode
Cherry Mui [Thu, 30 Sep 2021 16:02:56 +0000 (12:02 -0400)]
debug/gosym: run TestPCLine on Linux/AMD64 in short mode

Currently TestPCLine is skipped in short mode. The test builds a
Linux/AMD64 binary, so it makes sense to skip it if we're cross
compiling, as building the runtime takes a while. But if we are
on Linux/AMD64, it will only build a small amount of code, which
isn't really slow. The test runs in 0.14 second on my machine.
I think it is acceptable to run in short mode. Then we'll have
trybot coverage for this test.

Change-Id: If682f88c28050f7daafde35b4f9e59c03b764a35
Reviewed-on: https://go-review.googlesource.com/c/go/+/353330
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>
3 years agodebug/gosym: fix version check in file table access
Cherry Mui [Thu, 30 Sep 2021 15:46:41 +0000 (11:46 -0400)]
debug/gosym: fix version check in file table access

Go 1.16 and 1.18 table are the same for that part. Accept 1.18
version number in that code.

Fixes #48699.

Change-Id: I44eafa279a94bd06444f61518aedd541b25390fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/353329
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocrypto: document the extended key interfaces
Filippo Valsorda [Wed, 29 Sep 2021 11:09:34 +0000 (13:09 +0200)]
crypto: document the extended key interfaces

Change-Id: Iaff3f77b0a168e8bde981c791035a6451b3a49ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/353049
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
3 years agotime: add doc comment about tzdata package
Leigh McCulloch [Wed, 29 Sep 2021 02:19:34 +0000 (02:19 +0000)]
time: add doc comment about tzdata package

Add doc comment about the time/tzdata package to the time.LoadLocation
function. The time.LoadLocation function was changed in Go 1.15 to add an extra
source that it considers for the time zone database. That location is the
time/tzdata package. It is not easy to discover this behavior because the
documentation for the time package doesn't mention it in the discussion on the
time.LoadLocation function when discussing the different sources. It would be helpful to
describe all possible sources that time.LoadLocation considers when loading the
time zone database, and so I think it would be worthwhile to mention
time/tzdata.

Change-Id: I408fbe188bf9d4ba797e59ec17eb677136d6a9c2
GitHub-Last-Rev: 3dac204326960a18c4e44d3ea24fd428e91e9fcb
GitHub-Pull-Request: golang/go#48673
Reviewed-on: https://go-review.googlesource.com/c/go/+/352830
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Heschi Kreinick <heschi@google.com>

3 years agoREADME.md: update contribute URL
180909 [Tue, 31 Aug 2021 17:57:33 +0000 (17:57 +0000)]
README.md: update contribute URL

/doc/contribute.html now redirects to /doc/contribute.

Change-Id: Ib342d515bf6e74bb5807ce21f8df3d985bc7e490
GitHub-Last-Rev: c491a060da22d1bb456283f5ed0ae2894f0365ca
GitHub-Pull-Request: golang/go#48005
Reviewed-on: https://go-review.googlesource.com/c/go/+/345590
Trust: Cherry Mui <cherryyz@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
3 years agocmd/asm: add error check for move constant instructions on arm64
fanzha02 [Tue, 28 Sep 2021 05:46:14 +0000 (13:46 +0800)]
cmd/asm: add error check for move constant instructions on arm64

The current Go assembler encodes "MOVK $(0<<16|32|48), Rd" as the
same binary with "MOVK $0, Rd", but for arm64 move constant instructions
MOVK, MOVN and MOVZ, "op $0, Rd" and "op $(0<<16|32|48), Rd" have
different semantics. In order not to change the way the assembler
frontend parses constants, this patch adds a check for the zero shifts.

Change-Id: Ia844c419ce49f63605b549e3a2e98d9075dd1cf1
Reviewed-on: https://go-review.googlesource.com/c/go/+/275812
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/link: make funcSize a constant
Josh Bleecher Snyder [Wed, 29 Sep 2021 00:26:24 +0000 (17:26 -0700)]
cmd/link: make funcSize a constant

Now that it no longer depends on the size of a pointer,
we can make it a constant, which simplifies a bit of code.

Change-Id: I1b7c3b1b648da5c8960378a02b9263e2cc902441
Reviewed-on: https://go-review.googlesource.com/c/go/+/352952
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/link, runtime: use offset for _func.entry
Josh Bleecher Snyder [Wed, 29 Sep 2021 00:06:56 +0000 (17:06 -0700)]
cmd/link, runtime: use offset for _func.entry

The first field of the func data stored by the linker is the
entry PC for the function. Prior to this change, this was stored
as a relocation to the function. Change this to be an offset
relative to runtime.text.

This reduces the number of relocations on darwin/arm64 by about 10%.
It also slightly shrinks binaries:

file      before    after     Δ       %
addr2line 3803058   3791298   -11760  -0.309%
api       5140114   5104242   -35872  -0.698%
asm       4886850   4840626   -46224  -0.946%
buildid   2512466   2503042   -9424   -0.375%
cgo       4374770   4342274   -32496  -0.743%
compile   22920530  22769202  -151328 -0.660%
cover     4624626   4588242   -36384  -0.787%
dist      3217570   3205522   -12048  -0.374%
doc       3715026   3684498   -30528  -0.822%
fix       3148226   3119266   -28960  -0.920%
link      6350226   6313362   -36864  -0.581%
nm        3768850   3757106   -11744  -0.312%
objdump   4140594   4127618   -12976  -0.313%
pack      2227474   2218818   -8656   -0.389%
pprof     13598706  13506786  -91920  -0.676%
test2json 2497234   2487426   -9808   -0.393%
trace     10198066  10118498  -79568  -0.780%
vet       6930658   6889074   -41584  -0.600%
total     108055044 107366900 -688144 -0.637%

It should also incrementally speed up binary launching.

This is the first step towards removing enough relocations
that pages that were previously dirtied by the loader may remain clean,
which will offer memory savings useful in constrained environments.

Change-Id: Icfba55e696ba2f9c99c4f179125ba5a3ba4369c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/351463
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: extract text address calculation into a separate method
Josh Bleecher Snyder [Wed, 29 Sep 2021 16:49:54 +0000 (09:49 -0700)]
runtime: extract text address calculation into a separate method

Pure code movement.

Change-Id: I7216e50fe14afa3d19c5047c92e515c90838f834
Reviewed-on: https://go-review.googlesource.com/c/go/+/353129
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agodebug/gosym: refactor handling of funcdata
Josh Bleecher Snyder [Thu, 23 Sep 2021 20:11:04 +0000 (13:11 -0700)]
debug/gosym: refactor handling of funcdata

We do a bunch of manual offset calculations everywhere.
Add a bit of type safety and some helpers.
In addition to making the code clearer and providing a place
to hang some documentation, it also makes upcoming changes easier.

name                old time/op    new time/op    delta
115/NewLineTable-8    79.9ns ± 1%    90.2ns ±23%    ~     (p=0.234 n=9+10)
115/NewTable-8        72.0µs ± 1%    73.4µs ± 1%  +1.96%  (p=0.000 n=8+8)
115/LineToPC-8        53.3µs ± 1%    54.4µs ± 1%  +2.02%  (p=0.000 n=10+10)
115/PCToLine-8         249ns ± 0%     249ns ± 2%    ~     (p=0.147 n=9+10)

name                old alloc/op   new alloc/op   delta
115/NewLineTable-8      384B ± 0%      384B ± 0%    ~     (all equal)
115/NewTable-8         164kB ± 0%     164kB ± 0%    ~     (p=0.610 n=10+10)
115/LineToPC-8         0.00B          0.00B         ~     (all equal)
115/PCToLine-8         0.00B          0.00B         ~     (all equal)

name                old allocs/op  new allocs/op  delta
115/NewLineTable-8      3.00 ± 0%      3.00 ± 0%    ~     (all equal)
115/NewTable-8         1.04k ± 0%     1.04k ± 0%    ~     (all equal)
115/LineToPC-8          0.00           0.00         ~     (all equal)
115/PCToLine-8          0.00           0.00         ~     (all equal)

Change-Id: If357dce5ae4277e6ddc6d90ba6b5b83e470b9121
Reviewed-on: https://go-review.googlesource.com/c/go/+/352951
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go/internal/modcmd: fix "go mod editwork" error text
citizen233 [Tue, 28 Sep 2021 06:05:20 +0000 (14:05 +0800)]
cmd/go/internal/modcmd: fix "go mod editwork" error text

Fixes #48583

Change-Id: I863ece5c546c383a2f46b8b1a36cbf9f2526d3ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/352709
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agodebug/gosym: add benchmark
Josh Bleecher Snyder [Wed, 29 Sep 2021 17:16:47 +0000 (10:16 -0700)]
debug/gosym: add benchmark

Use a Go 1.15 executable for the benchmark, because it is handy.
Most of the code paths are shared for Go 1.2+.

Change-Id: Id7ddc76a05d76335108c58ff9f1ab2ff837b7227
Reviewed-on: https://go-review.googlesource.com/c/go/+/353131
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agointernal/fuzz: disconnect stdout and stderr from the worker
Katie Hockman [Tue, 28 Sep 2021 19:59:34 +0000 (15:59 -0400)]
internal/fuzz: disconnect stdout and stderr from the worker

This was useful for debugging while we were developing
the feature, but is now causing extraneous prints that
make the command output difficult to read.

This change also prevents the go command from printing
an extraneous "FAIL" when fuzzing is enabled.

Fixes #48633
Fixes #46631

Change-Id: I636e65f305a20f6dcd843e62090ae228741a3725
Reviewed-on: https://go-review.googlesource.com/c/go/+/352892
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agotext/template: check final value for short-circuit and/or
Ian Lance Taylor [Wed, 29 Sep 2021 17:50:18 +0000 (10:50 -0700)]
text/template: check final value for short-circuit and/or

There was a bug in the short-circuit code for and/or added in CL 321490:
it ignored the value passed in by an earlier pipeline.

For #31103

Change-Id: Ic31f4d7cedfe563ef968cbb712ecfb2413c42eb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/353130
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: rename some types2.Context variables from env to ctxt
Robert Findley [Wed, 29 Sep 2021 17:05:37 +0000 (13:05 -0400)]
cmd/compile: rename some types2.Context variables from env to ctxt

Rename some variables in the compiler that were missed in CL 353089.

Change-Id: Ie748fe9b64e584a841d08ff60c439c93aae412d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/353149
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoruntime: use unsafe.Slice in getStackMap
Josh Bleecher Snyder [Wed, 29 Sep 2021 00:42:05 +0000 (17:42 -0700)]
runtime: use unsafe.Slice in getStackMap

It's not less code, but it is clearer code.

Change-Id: I32239baf92487a56900a4edd8a2593014f37d093
Reviewed-on: https://go-review.googlesource.com/c/go/+/352953
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agotest: update test/codegen/noextend.go to work with either ABI on ppc64x
Lynn Boger [Wed, 29 Sep 2021 14:24:50 +0000 (09:24 -0500)]
test: update test/codegen/noextend.go to work with either ABI on ppc64x

This updates the codegen tests in noextend.go so they are not
dependent on the ABI.

Change-Id: I8433bea9dc78830c143290a7e0cf901b2397d38a
Reviewed-on: https://go-review.googlesource.com/c/go/+/353070
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/go: prevent necessary GCFlag from being removed
Katie Hockman [Mon, 27 Sep 2021 20:12:05 +0000 (16:12 -0400)]
cmd/go: prevent necessary GCFlag from being removed

There are special flags that must be passed to the
compiler at build time in order to instrument the
testing binary for fuzzing.
One potential option would be to add these flags to
p.Internal.Gcflags inside cmd/go/internal/test. However,
future calls to setToolFlags can cause these flags to
get cleared about before the build starts, removing
virtually all coverage guidance. This change moves the
logic to add the flag deeper down the call stack,
preventing it from being cleared.

Change-Id: I40eadb0cacc18f29cee75379cd9380f9e73bb8da
Reviewed-on: https://go-review.googlesource.com/c/go/+/352511
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types, types2: rename Environment to Context
Robert Findley [Wed, 29 Sep 2021 13:35:02 +0000 (09:35 -0400)]
go/types, types2: rename Environment to Context

Replace the name Environment with Context, as discussed in #47916. Along
the way, fix some stale or inaccurate comments.

The Environment type remains temporarily as an alias for Context, to
allow the x/tools Trybot to pass until dependency on types.Environment
can be removed.

Updates #47916

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

3 years agocmd/compile: add PPC64-specific inlining for runtime.memmove
Archana R [Fri, 24 Sep 2021 15:31:20 +0000 (10:31 -0500)]
cmd/compile: add PPC64-specific inlining for runtime.memmove

Add rule to PPC64.rules to inline runtime.memmove in more cases, as is
done for other target architectures
Updated tests in codegen/copy.go to verify changes are done on
ppc64/ppc64le

Updates #41662

Change-Id: Id937ce21f9b4f4047b3e66dfa3c960128ee16a2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/352054
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

3 years agodebug/gosym: adjust go12* method comments
Josh Bleecher Snyder [Tue, 28 Sep 2021 22:57:09 +0000 (15:57 -0700)]
debug/gosym: adjust go12* method comments

These methods are for use with Go 1.2 _and later_ pcln tables.
Make that clearer.

Change-Id: Iee06e0828fd5895639b654363b6d91bf9151d224
Reviewed-on: https://go-review.googlesource.com/c/go/+/352950
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agodebug/gosym: add hook to disable recovers
Josh Bleecher Snyder [Tue, 28 Sep 2021 20:13:49 +0000 (13:13 -0700)]
debug/gosym: add hook to disable recovers

debug/gosym assumes throughout that bogus input means a malformed file.
That's generally true, but not when you're changing the package.
In that case, the panic usually indicates a newly introduced bug,
and seeing the panic is really useful.

Add a manually-enabled way to make panics panic.

Change-Id: I07af6c7b982c4cf61180db29f07aa63576ba7837
Reviewed-on: https://go-review.googlesource.com/c/go/+/352949
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile: make sure shapes have proper indexes for sub-instantiation
Dan Scales [Wed, 29 Sep 2021 04:14:17 +0000 (21:14 -0700)]
cmd/compile: make sure shapes have proper indexes for sub-instantiation

The computation for determining the shapes to use at the top of
getInstantation was not always creating shapes with the proper indexes.
If an instantiation is being called from another instantiated function,
we cannot just copy the shape types unchanged, because their indexes may
have changed. So, for type args that already shapes, we still call
Shapify() with the correct index.

Fixes #48645

Change-Id: Ibb61c6f9a3c317220fb85135ca87eb5ad4dcff9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/353030
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>
3 years agoruntime: drop nowritebarrier from gcParkAssist
Michael Pratt [Tue, 28 Sep 2021 18:35:03 +0000 (14:35 -0400)]
runtime: drop nowritebarrier from gcParkAssist

Nothing in this function is at odds with having write barriers. It
originally inherited the annotation from gcAssistAlloc
http://golang.org/cl/30700, which subsequently dropped the annotation in
http://golang.org/cl/32431 as it was unnecessary.

Change-Id: Ie464e6b4ed957f57e922ec043728ff4e15bf35ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/352811
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 years agogo/types: avoid infinite recursion in unification
Robert Griesemer [Wed, 29 Sep 2021 03:42:45 +0000 (20:42 -0700)]
go/types: avoid infinite recursion in unification

This is an almost clean port of CL 352832 from types2 to go/types:
The nest files and unify.go where copied verbatim; unify.go was
adjusted with correct package name, a slightly different comment
was restored to what it was. The test files got adjustments for
error position. infer.go got a missing _Todo error code.

For #48619.
For #48656.

Change-Id: Ia1a2d09e8bb37a85032b4b7e7c7a0b08e8c793a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/353029
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/internal/goobj, cmd/link: remove funcdataoff
Cherry Mui [Tue, 28 Sep 2021 21:07:01 +0000 (17:07 -0400)]
cmd/internal/goobj, cmd/link: remove funcdataoff

FUNCDATA is always a symbol reference with 0 offset. Assert the
offset is 0 and remove funcdataoff.

Change-Id: I326815365c9db5aeef6b869df5d78a9957bc16a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/352894
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/link: access pcdata via aux symbols
Cherry Mui [Tue, 28 Sep 2021 20:20:29 +0000 (16:20 -0400)]
cmd/link: access pcdata via aux symbols

Pcdata are now separate aux symbols. Read them from aux, instead
of using funcinfo.

Now we can remove pcdata fields from funcinfo.

Change-Id: Ie65e3962edecc0f39127a5f6963dc59d1f141e67
Reviewed-on: https://go-review.googlesource.com/c/go/+/352893
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile/internal/types2: avoid infinite recursion in unification
Robert Griesemer [Tue, 28 Sep 2021 20:50:15 +0000 (13:50 -0700)]
cmd/compile/internal/types2: avoid infinite recursion in unification

If the type T inferred for a type parameter P is P itself (or a derived
type containing P), a subsequent unification step leads to infinite
recursion: at each encounter of P with the already inferred type T
(which is or contains P), P stands for that T and the recursive matching
process continues with T, which inevitably contains P again and recursion
never terminates.

This CL introduces a set of masks, one for each type parameter.
When a type parameter is encountered for which a type has already
been inferred, the type parameter is "masked" for the recursive
matching of the inferred type. Masking makes the type parameter
"invisible" such that it will be handled like any other type and
not unpacked further.

Fixes #48619.
For #48656.

Change-Id: Ic1d938322be51fd44323ea14f925303f58b27c97
Reviewed-on: https://go-review.googlesource.com/c/go/+/352832
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agointernal/bytealg: port bytealg functions to reg ABI on ppc64x
Lynn Boger [Tue, 21 Sep 2021 14:36:40 +0000 (09:36 -0500)]
internal/bytealg: port bytealg functions to reg ABI on ppc64x

This adds support for the reg ABI to the bytes functions for
ppc64/ppc64le. These are initially under control of the
GOEXPERIMENT macro until all changes are in.

Change-Id: Id82f31056af8caa8541e27c6735f6b815a5dbf5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/351190
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: port memmove, memclr to register ABI on ppc64x
Lynn Boger [Tue, 28 Sep 2021 19:43:58 +0000 (14:43 -0500)]
runtime: port memmove, memclr to register ABI on ppc64x

This allows memmove and memclr to be invoked using the new
register ABI on ppc64x.

Change-Id: Ie397a942d7ebf76f62896924c3bb5b3a3dbba73e
Reviewed-on: https://go-review.googlesource.com/c/go/+/352891
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

3 years agocompress/gzip: add missing license
jiahua wang [Mon, 27 Sep 2021 14:54:16 +0000 (22:54 +0800)]
compress/gzip: add missing license

Change-Id: I80c2c6054f6a5be3555c72056159a47f927f9a44
Reviewed-on: https://go-review.googlesource.com/c/go/+/352409
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Heschi Kreinick <heschi@google.com>

3 years agoio: add examples for (*SectionReader) Read/Size
jiahua wang [Sat, 25 Sep 2021 01:24:04 +0000 (09:24 +0800)]
io: add examples for (*SectionReader) Read/Size

Change-Id: Ie804f9a5d1d6beec210d2f8075c030a5c60a78ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/352152
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Heschi Kreinick <heschi@google.com>

3 years agoreflect,runtime: add reflect support for regabi on PPC64
Lynn Boger [Mon, 27 Sep 2021 12:48:33 +0000 (07:48 -0500)]
reflect,runtime: add reflect support for regabi on PPC64

This adds the regabi support needed for reflect including:
- implementation of the makeFuncSub and methodValueCall for
reflect
- implementations of archFloat32FromReg and archFloat32ToReg
needed for PPC64 due to differences in the way float32 are
represented in registers as compared to other platforms
- change needed to stack.go due to the functions that are
changed above

Change-Id: Ida40d831370e39b91711ccb9616492b7fad3debf
Reviewed-on: https://go-review.googlesource.com/c/go/+/352429
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

3 years agoruntime: add mp parameter for getMCache
Leonard Wang [Sat, 11 Sep 2021 12:53:24 +0000 (20:53 +0800)]
runtime: add mp parameter for getMCache

Since all callers of getMCache appear to have mp available,
we pass the mp to getMCache, and reduce one call to getg.
And after modification, getMCache is also inlined.

Change-Id: Ib7880c118336acc026ecd7c60c5a88722c3ddfc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/349329
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Trust: Carlos Amedee <carlos@golang.org>

3 years agocmd/compile/internal/types2: add Interface.IsMethodSet, remove Interface.IsContraint
Robert Griesemer [Tue, 28 Sep 2021 16:56:38 +0000 (09:56 -0700)]
cmd/compile/internal/types2: add Interface.IsMethodSet, remove Interface.IsContraint

This is a port of CL 352616 from go/types to types2. It also removes
Interface.IsConstraint and adjusts all uses to use IsMethodSet. The
dual changes are made to the (unexported) type set implementation.

Change-Id: I292b741d1f7cdbaefb483eed75faf7b85a8d2792
Reviewed-on: https://go-review.googlesource.com/c/go/+/352872
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/go: add release note for 'go get' changes
Jay Conrod [Fri, 24 Sep 2021 20:54:52 +0000 (13:54 -0700)]
cmd/go: add release note for 'go get' changes

For #43684

Change-Id: I9ce47de82203ec87e7d3683f56e6c6d61ae255f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/352151
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>
3 years agocmd/go: change 'go get -d' to 'go get' in tests
Jay Conrod [Fri, 24 Sep 2021 20:51:39 +0000 (13:51 -0700)]
cmd/go: change 'go get -d' to 'go get' in tests

The -d flag has no effect in module mode.

GOPATH tests are left alone.

For #43684

Change-Id: If0f0aad73d8b543ca4058fe9c9fea9d7fd7f95bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/352150
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>
3 years agocmd/go: make 'go get' fail with an error when outside a module
Jay Conrod [Fri, 24 Sep 2021 20:26:35 +0000 (13:26 -0700)]
cmd/go: make 'go get' fail with an error when outside a module

There's no go.mod file for 'go get' to update, so it has no effect,
other than checking arguments and filling the module cache. That might
be useul in some cases, but it seems better to fail loudly in case the
user hasn't seen the deprecation warning, for example, inside a
script.

For #43684

Change-Id: I6e67c782e3a1cb7046eac5c9df17eda7a31c7bce
Reviewed-on: https://go-review.googlesource.com/c/go/+/352149
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>
3 years agocmd/go: 'go get' no longer builds or installs packages
Jay Conrod [Tue, 14 Sep 2021 23:23:10 +0000 (16:23 -0700)]
cmd/go: 'go get' no longer builds or installs packages

As part of #40267, 'go install' is now fully responsible for building
and installing executables. 'go get' will only be used to change
versions in go.mod. The -d flag no longer has any effect; its behavior
is the default.

When 'go get' is invoked inside a module on a main package outside of
the main module, it no longer prints any warning. In 1.16-1.17, we
suggested using -d in this situation, but we want
'go get example.com/cmd' to be able to upgrade a tool dependency
without needing -d to suppress the warning.

For #43684

Change-Id: I9daf29c123a5a0e382aa326d62721cb26fc26c19
Reviewed-on: https://go-review.googlesource.com/c/go/+/349997
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>
3 years agoio: update ByteScanner and RuneScanner docs to match long-standing implementations
Bryan C. Mills [Thu, 23 Sep 2021 15:37:52 +0000 (11:37 -0400)]
io: update ByteScanner and RuneScanner docs to match long-standing implementations

Do not require the byte or rune unread by the call to match the last
return from ReadByte or ReadRune, since in practice the
implementations of these methods (especially ReadByte) may also unread
bytes from other Read-style methods without reporting an error.

Explicitly allow the Seek-like behavior implemented by bytes.Reader
and bufio.Reader, which can “unread” bytes that were never actually
read.

Explicitly allow ReadByte or ReadRune to return an error after a call
to a non-ReadByte or non-ReadRune operation respectively.
(In practice, implementations today allow very liberal calls to
ReadByte and tend to be more strict about ReadRune, but it seems
simpler to keep the two definitions completely parallel.)

Like CL 349054, this is techincally a breaking change, but given the
long-standing behavior of the implementations in the Go standard
library (such as strings.Reader, bytes.Buffer, and bufio.Reader),
I believe it falls under the “specification errors” exception to the
Go 1 compatibility policy.

Fixes #48449

Change-Id: I61696a59770fe83c667377ba25a072762d3f6f19
Reviewed-on: https://go-review.googlesource.com/c/go/+/351809
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
3 years agocmd/compile/internal/types2: add a NewSignatureType constructor accepting type parameters
Robert Griesemer [Tue, 28 Sep 2021 16:45:24 +0000 (09:45 -0700)]
cmd/compile/internal/types2: add a NewSignatureType constructor accepting type parameters

This is a clean port of CL 352615 from go/types to types2 with
renames from types -> types2.

Change-Id: Ib9bae3fd8b93c3bd6c56e4e039a296cb34b0eb47
Reviewed-on: https://go-review.googlesource.com/c/go/+/352869
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: record all instances, not just inferred instances
Robert Griesemer [Wed, 22 Sep 2021 16:55:10 +0000 (09:55 -0700)]
cmd/compile/internal/types2: record all instances, not just inferred instances

This is a port of CL 349629 from go/types to types2, adjusted to
make it work for types2. It also includes the necessary compiler
changes, provided by mdempsky.

Change-Id: If8de174cee9c69df0d0642fcec1ee7622b7c3852
Reviewed-on: https://go-review.googlesource.com/c/go/+/351455
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/internal/objfile: use aux symbol for pcdata references
Cherry Mui [Mon, 27 Sep 2021 19:55:53 +0000 (15:55 -0400)]
cmd/internal/objfile: use aux symbol for pcdata references

Pcdata are now separate aux symbols. Read them from aux, instead
of using funcinfo.

Change-Id: Ib3e4b5cff1e3329d0600504a8829a969a9c9f517
Reviewed-on: https://go-review.googlesource.com/c/go/+/352612
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>
3 years agocmd/internal/obj: index pcdata symbols in NumberSyms
Cherry Mui [Mon, 27 Sep 2021 19:35:46 +0000 (15:35 -0400)]
cmd/internal/obj: index pcdata symbols in NumberSyms

When writing an object file, most symbols are indexed in
NumberSyms. Currently, pcdata symbols are indexed late and
separately. This is not really necessary, as pcdata symbols
already exist at the time of NumberSyms. Just do it there.

As pcdata symbols are laid out in the pclntab in a special way at
link time, distinguish them from other symbols in the content
hash. (In the old code this was partly achieved by indexing them
late.)

Change-Id: Ie9e721382b0af2cfb39350d031e2e66d79095a3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/352611
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>
3 years agogo/types: add the Interface.IsMethodSet method
Robert Findley [Mon, 27 Sep 2021 23:49:38 +0000 (19:49 -0400)]
go/types: add the Interface.IsMethodSet method

As pointed out in #47916, the IsConstraint method becomes ambiguously
named if ever we allow interfaces with structural restrictions outside
of constraint position.

Add instead an IsMethodSet method, which has the opposite sense and
avoids this ambiguity. In a subsequent CL the IsConstraint method will
be removed, once x/tools has been updated to use the IsMethodSet API.

Updates #47916

Change-Id: I82ad16b111464b0cd2f354b8ecdd4b3f14796cd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/352616
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>
3 years agogo/types: add a NewSignatureType constructor accepting type parameters
Robert Findley [Mon, 27 Sep 2021 23:23:17 +0000 (19:23 -0400)]
go/types: add a NewSignatureType constructor accepting type parameters

In #47916, consensus has emerged that adding a new constructor is
preferable to using setters for type parameters. This is more consistent
with the rest of the type API, which is immutable except in cases where
mutation is necessary to break cycles (such as Named.SetUnderlying).

This CL adds a new constructor NewSignatureType that accepts type
parameters and receiver type parameters, deprecating the existing
NewSignature constructor. SetTypeParams and SetRecvTypeParams are not
yet removed: this will be done in a follow-up CL once x/tools no longer
has a dependency on the old APIs.

Updates #47916

Change-Id: I9d04dcfd304344d2aa08e527b371c3faa9d738e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/352615
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>
3 years agocmd/internal/obj: refactor code to separate content-addressable symbols by section
Josh Bleecher Snyder [Mon, 27 Sep 2021 20:39:43 +0000 (13:39 -0700)]
cmd/internal/obj: refactor code to separate content-addressable symbols by section

The goal of this change is to improve the documentation
and make it easier to keep Link.NumberSyms and writer.contentHash aligned.
No functional changes.

A subsequent change will add conditions to contentHashSection.

Change-Id: I0a274f6974459d34d5a8553081f33ea4cd87f248
Reviewed-on: https://go-review.googlesource.com/c/go/+/352669
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/goobj: remove Pcdata from object file
Cherry Mui [Mon, 27 Sep 2021 17:52:53 +0000 (13:52 -0400)]
cmd/internal/goobj: remove Pcdata from object file

As of CL 247399 we use separate symbols for PCDATA. There is no
more need for writing PCDATA directly into the object file as a
separate block.

Change-Id: I942d1a372540415e0cc07fb2a01f79718a264142
Reviewed-on: https://go-review.googlesource.com/c/go/+/352610
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>
3 years agoio: avoid integer overflow in NewSectionReader
Ian Lance Taylor [Mon, 27 Sep 2021 21:27:59 +0000 (14:27 -0700)]
io: avoid integer overflow in NewSectionReader

Fixes #48620

Change-Id: I37a5909ad27dc4a170929cb2e2ed1045cf524d59
Reviewed-on: https://go-review.googlesource.com/c/go/+/352629
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime: fix and simplify printing on bad ftab
Josh Bleecher Snyder [Fri, 24 Sep 2021 17:57:27 +0000 (10:57 -0700)]
runtime: fix and simplify printing on bad ftab

Unilaterally print plugin.
Use println instead of print.

Change-Id: Ib58f187bff9c3dbedfa2725c44754a222807cc36
Reviewed-on: https://go-review.googlesource.com/c/go/+/352072
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/link: put type descriptor method arginfo in the correct section
Josh Bleecher Snyder [Fri, 24 Sep 2021 01:03:56 +0000 (18:03 -0700)]
cmd/link: put type descriptor method arginfo in the correct section

We were putting type descriptor funcdata,
such as type..eq.[2]interface {}.arginfo1
in type.* or typerel.* instead of go.func.*.

Fix that.

Change-Id: I779e6be3dd91c8029f2c3dc0e10a7d597c16678f
Reviewed-on: https://go-review.googlesource.com/c/go/+/352071
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agodebug/gosym: add pcHeader parsing helpers
Josh Bleecher Snyder [Wed, 22 Sep 2021 18:13:20 +0000 (11:13 -0700)]
debug/gosym: add pcHeader parsing helpers

A subsequent change will duplicate most of case ver116.
Make it easier to read.

Change-Id: I3a93181c7f094b12715b8a618e9efef7a1438a27
Reviewed-on: https://go-review.googlesource.com/c/go/+/351909
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime/pprof: skip TestTimeVDSO on Android
Cherry Mui [Mon, 27 Sep 2021 18:37:13 +0000 (14:37 -0400)]
runtime/pprof: skip TestTimeVDSO on Android

The test is flaky on Android. VDSO may not be enabled so it may
not have the original problem anyway.

Change-Id: I73c2902c682a44d893e0d4e34f006c2377ef8816
Reviewed-on: https://go-review.googlesource.com/c/go/+/352509
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agoreflect: add Value.{CanInt, CanUint, CanFloat, CanComplex}
Fabio Falzoi [Sat, 25 Sep 2021 16:44:24 +0000 (18:44 +0200)]
reflect: add Value.{CanInt, CanUint, CanFloat, CanComplex}

As discussed in #47658, Value already has CanAddr and CanInterface to
test if a call to Addr or Inteface, respectively, does not result in a
panic.
Therefore we add CanInt, CanUint, CanFloat and CanComplex to ease the
test for a possible panic in calling, respectively, Int, Uint, Float and
Complex.

Fixes #47658

Change-Id: I58b77d77e6eec9f34234e985f631eab72b5b935e
Reviewed-on: https://go-review.googlesource.com/c/go/+/352131
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: David Chase <drchase@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agoruntime, cmd/link: minor cleanup
Josh Bleecher Snyder [Tue, 21 Sep 2021 16:45:34 +0000 (09:45 -0700)]
runtime, cmd/link: minor cleanup

Fix some comments.
Adjust capitalization for initialisms.
Use a println directly instead of emulating it.

Change-Id: I0d8fa0eb39547e2db8113fd0358136285b86f16a
Reviewed-on: https://go-review.googlesource.com/c/go/+/351462
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agoruntime: move entry method from _func to funcInfo
Josh Bleecher Snyder [Tue, 21 Sep 2021 21:22:51 +0000 (14:22 -0700)]
runtime: move entry method from _func to funcInfo

This will be required when we change from storing entry PCs in _func
to entry PC offsets, which are relative to the containing module.

Notably, almost all uses of the entry method were already called
on a funcInfo. Only Func.Entry incurs the additional module
lookup cost.

This makes Entry considerably slower, but it is probably
still fast enough in absolute terms that it is OK.

name             old time/op  new time/op  delta
Func/Name-8      8.86ns ± 0%  8.33ns ± 2%    -5.92%  (p=0.000 n=12+13)
Func/Entry-8     0.64ns ± 0%  2.62ns ±36%  +310.07%  (p=0.000 n=14+15)
Func/FileLine-8  24.5ns ± 0%  25.0ns ± 4%    +2.21%  (p=0.015 n=14+13)

Change-Id: Ia2d5de5f2f83fab334f1875452b9e8e87651d340
Reviewed-on: https://go-review.googlesource.com/c/go/+/351461
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: convert _func.entry to a method
Josh Bleecher Snyder [Tue, 21 Sep 2021 21:05:57 +0000 (14:05 -0700)]
runtime: convert _func.entry to a method

A subsequent change will alter the semantics of _func.entry.
To make that change obvious and clear, change _func.entry to a method,
and rename the field to _func.entryPC.

Change-Id: I05d66b54d06c5956d4537b0729ddf4290c3e2635
Reviewed-on: https://go-review.googlesource.com/c/go/+/351460
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: change funcinl sentinel value from 0 to ^0
Josh Bleecher Snyder [Tue, 21 Sep 2021 20:48:23 +0000 (13:48 -0700)]
runtime: change funcinl sentinel value from 0 to ^0

_func and funcinl are type-punned.
We distinguish them at runtime by inspecting the first word.

Prior to this change, we used 0 as the sentinel value
that means that a Func is a funcinl.
That worked because _func's first word is the functions' entry PC,
and 0 is not a valid PC. I plan to make *_func's entry PC relative
to the containing module. As a result, 0 will be a valid value,
for the first function in the module.

Switch to ^0 as the new sentinel value, which is neither a valid
entry PC nor a valid PC offset.

Change-Id: I4c718523a083ed6edd57767c3548640681993522
Reviewed-on: https://go-review.googlesource.com/c/go/+/351459
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: look up funcInfo by func pointer
Josh Bleecher Snyder [Tue, 21 Sep 2021 19:18:38 +0000 (12:18 -0700)]
runtime: look up funcInfo by func pointer

runtime.Func.{Name,FileLine} need to be able to
go from a *_func to a funcInfo. The missing bit of
information is what module contains that *_func.

The existing implementation looked up the module
using the *_func's entry PC. A subsequent change will
store *_func's entry PC relative to the containing module.
Change the module lookup to instead for the module
whose pclntable contains the *_func,
cutting all dependencies on the contents of the *_func.

Change-Id: I2dbbfec043ebc2e9a6ef19bbdec623ac84353b10
Reviewed-on: https://go-review.googlesource.com/c/go/+/351458
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoruntime: add Func method benchmarks
Josh Bleecher Snyder [Tue, 21 Sep 2021 21:31:09 +0000 (14:31 -0700)]
runtime: add Func method benchmarks

Change-Id: Ib76872c22b1be9e611199b84fd96b59beedf786c
Reviewed-on: https://go-review.googlesource.com/c/go/+/351457
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agoruntime: make slice growth formula a bit smoother
Keith Randall [Tue, 7 Sep 2021 16:44:29 +0000 (09:44 -0700)]
runtime: make slice growth formula a bit smoother

Instead of growing 2x for < 1024 elements and 1.25x for >= 1024 elements,
use a somewhat smoother formula for the growth factor. Start reducing
the growth factor after 256 elements, but slowly.

starting cap    growth factor
256             2.0
512             1.63
1024            1.44
2048            1.35
4096            1.30

(Note that the real growth factor, both before and now, is somewhat
larger because we round up to the next size class.)

This CL also makes the growth monotonic (larger initial capacities
make larger final capacities, which was not true before). See discussion
at https://groups.google.com/g/golang-nuts/c/UaVlMQ8Nz3o

256 was chosen as the threshold to roughly match the total number of
reallocations when appending to eventually make a very large
slice. (We allocate smaller when appending to capacities [256,1024]
and larger with capacities [1024,...]).

Change-Id: I876df09fdc9ae911bb94e41cb62675229cb10512
Reviewed-on: https://go-review.googlesource.com/c/go/+/347917
Trust: Keith Randall <khr@golang.org>
Trust: Martin Möhrmann <martin@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
3 years agocmd/compile: keep methods on generic types from being deadcode eliminated
Keith Randall [Fri, 10 Sep 2021 22:24:16 +0000 (15:24 -0700)]
cmd/compile: keep methods on generic types from being deadcode eliminated

We currently make dictionaries contain a relocation pointing to
methods that generic code might use, so that those methods are not
deadcode eliminated. However, with inlining we can end up not using
the dictionary, making the reference from the dictionary to the method
no longer keep the method alive.

Fix this by keeping the dictionary alive at generic interface call sites.
It's a bit of overkill, as we only need to keep the dictionary statically
alive. We don't actually need it dynamically alive, which is what KeepAlive
does. But it works. It ends up generating a LEAQ + stack spill that aren't
necessary, but that's pretty low overhead.

To make this work, I needed to stop generating methods on shape types.
We should do this anyway, as we shouldn't ever need them. But currently
we do use them! issue44688.go has a test that only works because it calls
a method on a shape type. I've disabled that test for now, will work on it
in a subsequent CL.

Fixes #48047

Change-Id: I78968868d6486c1745f51b8b43be0898931432a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/349169
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile: allow methods on shape types (but no bodies)
Dan Scales [Thu, 23 Sep 2021 03:20:09 +0000 (20:20 -0700)]
cmd/compile: allow methods on shape types (but no bodies)

In a previous change, I was too aggressive in substInstType() in not
generating methods for shape types during import. We do actually want to
generate the method nodes - we just don't want to generate method bodies
(which we would never use). We may need the method nodes for checking
types later in the compile (especially with inlining).

So, we do generate method nodes for shape types during import. In
order to avoid the name collision we previously had, we now add
".nofunc." to the method nodes for shape types (during import and in the
type substituter). We do that by passing in a 'isMethodNode' arg to
MakeInstSym. We keep the normal name (without ".nofunc") for any other
method nodes, and for the instantiated functions that help with
implementing the methods of fully-instantiated types. The ".nofunc"
names will never appear in the executable, since we don't generate any
method bodies for the method nodes of shape types.

Change-Id: I3e57e328691214140ca5f48d32011552d2a0d45d
Reviewed-on: https://go-review.googlesource.com/c/go/+/352470
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/go/testdata/script: fix incorrect comments
Zvonimir Pavlinovic [Thu, 23 Sep 2021 22:50:22 +0000 (15:50 -0700)]
cmd/go/testdata/script: fix incorrect comments

Change-Id: I675d66c229a4293146366bc9b927e0fd2d7a3eeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/351929
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ingo Oeser <nightlyone@googlemail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Than McIntosh <thanm@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>

3 years agocmd/compile: leave dictionary argument out of traceback argument list
Keith Randall [Fri, 24 Sep 2021 22:07:59 +0000 (15:07 -0700)]
cmd/compile: leave dictionary argument out of traceback argument list

The dictionary argument is implicit; the user doesn't need to see it.

Update #48578

Change-Id: I367ba4b6622119d3e01aaded90463d16823915a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/352119
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agoruntime: elide instantiated types in tracebacks
Keith Randall [Fri, 24 Sep 2021 21:55:06 +0000 (14:55 -0700)]
runtime: elide instantiated types in tracebacks

They tend to be things like ".shape.int" which are noisy, if not
otherwise confusing.

It would be nice to somehow print the real instantiations here, but that
requires keeping track of the dictionary argument so the instantiating
types could be found. One day, maybe, but not today.

Fixes #48578

Change-Id: I0968d24e110b6d47c9468c45372a6979575a8d29
Reviewed-on: https://go-review.googlesource.com/c/go/+/352118
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agoruntime: use per-thread profiler for SetCgoTraceback platforms
Rhys Hiltner [Fri, 13 Aug 2021 16:01:13 +0000 (09:01 -0700)]
runtime: use per-thread profiler for SetCgoTraceback platforms

Updates #35057

Change-Id: I61d772a2cbfb27540fb70c14676c68593076ca94
Reviewed-on: https://go-review.googlesource.com/c/go/+/342054
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agoruntime: move sigprofNonGo
Rhys Hiltner [Thu, 23 Sep 2021 23:46:58 +0000 (16:46 -0700)]
runtime: move sigprofNonGo

The sigprofNonGo and sigprofNonGoPC functions are only used on unix-like
platforms. In preparation for unix-specific changes to sigprofNonGo,
move it (plus its close relative) to a unix-specific file.

Updates #35057

Change-Id: I9c814127c58612ea9a9fbd28a992b04ace5c604d
Reviewed-on: https://go-review.googlesource.com/c/go/+/351790
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: David Chase <drchase@google.com>

3 years agoruntime: profile with per-thread timers on Linux
Rhys Hiltner [Fri, 13 Aug 2021 15:58:40 +0000 (08:58 -0700)]
runtime: profile with per-thread timers on Linux

Using setitimer on Linux to request SIGPROF signal deliveries in
proportion to the process's on-CPU time results in under-reporting when
the program uses several goroutines in parallel. Linux calculates the
process's total CPU spend on a regular basis (often every 4ms); if the
process has spent enough CPU time since the last calculation to warrant
more than one SIGPROF (usually 10ms for the default sample rate of 100
Hz), the kernel is often able to deliver only one of them. With these
common settings, that results in Go CPU profiles being attenuated for
programs that use more than 2.5 goroutines in parallel.

To avoid in effect overflowing the kernel's process-wide CPU counter,
and relying on Linux's typical behavior of having the active thread
handle the resulting process-targeted signal, use timer_create to
request a timer for each OS thread that the Go runtime manages. Have
each timer track the CPU time of a single thread, with the resulting
SIGPROF going directly to that thread.

To continue tracking CPU time spent on threads that don't interact with
the Go runtime (such as those created and used in cgo), keep using
setitimer in addition to the new mechanism. When a SIGPROF signal
arrives, check whether it's due to setitimer or timer_create and filter
as appropriate: If the thread is known to Go (has an M) and has a
timer_create timer, ignore SIGPROF signals from setitimer. If the thread
is not known to Go (does not have an M), ignore SIGPROF signals that are
not from setitimer.

Counteract the new bias that per-thread profiling adds against
short-lived threads (or those that are only active on occasion for a
short time, such as garbage collection workers on mostly-idle systems)
by configuring the timers' initial trigger to be from a uniform random
distribution between "immediate trigger" and the full requested sample
period.

Updates #35057

Change-Id: Iab753c4e5101bdc09ef9132eec84a75478e05579
Reviewed-on: https://go-review.googlesource.com/c/go/+/324129
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: David Chase <drchase@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agoruntime: allow per-OS changes to unix profiler
Rhys Hiltner [Fri, 13 Aug 2021 15:51:46 +0000 (08:51 -0700)]
runtime: allow per-OS changes to unix profiler

Updates #35057

Change-Id: I56ea8f4750022847f0866c85e237a2cea40e0ff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/342053
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agoruntime: add timer_create syscalls for Linux
Rhys Hiltner [Fri, 13 Aug 2021 15:34:25 +0000 (08:34 -0700)]
runtime: add timer_create syscalls for Linux

Updates #35057

Change-Id: Id702b502fa4e4005ba1e450a945bc4420a8a8b8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/342052
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Than McIntosh <thanm@google.com>

3 years agogo/types, types2: factor out some code, fix/add comments (cleanups)
Robert Griesemer [Mon, 27 Sep 2021 03:45:54 +0000 (20:45 -0700)]
go/types, types2: factor out some code, fix/add comments (cleanups)

Change-Id: Id6a2e3eadc9099abbdd21b6880e1ff3ac9cfb599
Reviewed-on: https://go-review.googlesource.com/c/go/+/352312
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agoruntime: mark race functions as ABIInternal
Lynn Boger [Mon, 27 Sep 2021 13:10:20 +0000 (08:10 -0500)]
runtime: mark race functions as ABIInternal

This adds ABIInternal to the race function declarations.

Change-Id: I99f8a310972ff09b4d56eedbcc6e9609bab0f224
Reviewed-on: https://go-review.googlesource.com/c/go/+/352369
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile: clean up remnants of amd64p32 in OnesCount
nimelehin [Fri, 24 Sep 2021 18:11:21 +0000 (21:11 +0300)]
cmd/compile: clean up remnants of amd64p32 in OnesCount

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

3 years agoencoding/base32: Add examples for Encode/Decode
jiahua wang [Wed, 22 Sep 2021 14:32:55 +0000 (22:32 +0800)]
encoding/base32: Add examples for Encode/Decode

Updates golang/go#37595

Change-Id: I7568e7416d5504e9dc67061c79f66e3a0d597dee
Reviewed-on: https://go-review.googlesource.com/c/go/+/351470
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: David Chase <drchase@google.com>

3 years agocmd/internal/obj: fix wording in a comment
DQNEO [Sat, 18 Sep 2021 14:24:07 +0000 (23:24 +0900)]
cmd/internal/obj: fix wording in a comment

Change-Id: I9921ba5c29ada6ff06d147f6d9b46a29101c449c
Reviewed-on: https://go-review.googlesource.com/c/go/+/350694
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: David Chase <drchase@google.com>

3 years agobytes: add example for (*Buffer).Next
jiahua wang [Fri, 24 Sep 2021 02:07:44 +0000 (10:07 +0800)]
bytes: add example for (*Buffer).Next

Change-Id: Ic0a97fd7bb89865448e436e5c092415a29d8badf
Reviewed-on: https://go-review.googlesource.com/c/go/+/352009
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: David Chase <drchase@google.com>

3 years agocmd/go: remove references to 'go help fuzz'
Muhammad Falak R Wani [Mon, 27 Sep 2021 04:20:34 +0000 (04:20 +0000)]
cmd/go: remove references to 'go help fuzz'

Fixes: #48623
Change-Id: Idab917b90ceb332cf49b6ca2a6b79be97ac56e18
GitHub-Last-Rev: 3143ce8b95e70a0466c836ce9be3e13a3e85c12e
GitHub-Pull-Request: golang/go#48640
Reviewed-on: https://go-review.googlesource.com/c/go/+/352313
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/internal/obj/ppc64: add a test for long branch fixups
Paul E. Murphy [Mon, 30 Aug 2021 16:56:58 +0000 (11:56 -0500)]
cmd/internal/obj/ppc64: add a test for long branch fixups

Cribbed and modified from arm64, verify each transformation
rewrites a too-far conditional branch as expected.

Change-Id: I87d35085158ed7d7478aa9725b273401fcd0bd01
Reviewed-on: https://go-review.googlesource.com/c/go/+/347049
Trust: David Chase <drchase@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
3 years agoruntime: add runtime changes for register ABI on ppc64x
Lynn Boger [Wed, 22 Sep 2021 19:50:29 +0000 (14:50 -0500)]
runtime: add runtime changes for register ABI on ppc64x

This adds the changes for the register ABI in the runtime
functions for ppc64x:
- Add spill functions used by runtime
- Add ABIInternal to functions

Some changes were needed to the stubs files
due to vet issues when compiling for linux/ppc64.

Change-Id: I010ddbc774ed4f22e1f9d77833bd55b919d95c99
Reviewed-on: https://go-review.googlesource.com/c/go/+/351590
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoimage/draw: add RGBA64Image fast path for RGBA dst
Nigel Tao [Fri, 24 Sep 2021 00:43:55 +0000 (10:43 +1000)]
image/draw: add RGBA64Image fast path for RGBA dst

This should have been part of https://golang.org/cl/340049 but I
overlooked it. That commit added fast path code when the destination
image was *not* an *image.RGBA. This commit edits func drawRGBA.

name               old time/op  new time/op  delta
RGBA1-4            5.11ms ± 1%  1.12ms ± 1%  -78.01%  (p=0.008 n=5+5)
RGBA2-4            8.69ms ± 1%  2.98ms ± 1%  -65.77%  (p=0.008 n=5+5)

Updates #44808.
Updates #46395.

Change-Id: I899d46d985634fc81ea47ff4f0d436630e8a961c
Reviewed-on: https://go-review.googlesource.com/c/go/+/351852
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agocmd/compile: fix stencil call expression
korzhao [Fri, 24 Sep 2021 20:42:57 +0000 (04:42 +0800)]
cmd/compile: fix stencil call expression

In CL 349613,we have supported types.IdentityStrict() that does strict
type comparison.
Therefore, OCONVNOP becomes a possible case in call.X.Op().

Fixes #48604

Change-Id: Ibab27ffcf09656e3380314662f05f38294c1c6ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/351857
Trust: Dan Scales <danscales@google.com>
Trust: David Chase <drchase@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>