1
0
mirror of https://github.com/golang/go synced 2024-11-07 08:26:16 -07:00
Commit Graph

40761 Commits

Author SHA1 Message Date
Cuong Manh Le
5963f0a332 cmd/vendor: get golang.org/x/tools@f946a157eef
To bring in the fix for sigchanyzer pass to detect valid usage of
unbuffer channel to builtin make.

Fixes #45043

Change-Id: I60d2ee90f7c111183b33747008903a7df88b76ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/312631
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: Bryan C. Mills <bcmills@google.com>
2021-04-23 05:38:47 +00:00
Cuong Manh Le
d310b2a6b8 cmd/compile: set correct Defn for inlined vars
Currently, when copying definition node of an inlined var, we do not
update var Defn field to point to new copied node. That causes all
inlined vars point to the same Defn, and ir.StaticValue can not find
inlined var in the lhs of its definition.

clovar creates new ONAME node for local variables or params of closure
inside inlined function, by copying most of the old node fields. So the
new Node.Defn is not modified, its lhs still refer to old node
instead of new one.

To fix this, we need to do two things:

 - In subst.clovar, set a dummy Defn node for inlvar
 - During subst.node, when seeing OAS/OAS2 nodes, after substituting, we
   check if any node in lhs has the dummy Defn, then set it to the current
   OAS/OAS2 node.

Fixes #45606

Change-Id: Ib517b753a7643756dcd61d36deae60f1a0fc53c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/312630
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: Matthew Dempsky <mdempsky@google.com>
2021-04-23 05:10:41 +00:00
Cherry Zhang
1b0a031680 cmd/compile: escape "go" wrapper closure everywhere
For go statement, the wrapper closure needs to esacpe because it
runs asynchronously. Currently, it is not allowed for closures to
escape in the runtime. We have worked around this in the runtime,
so it doesn't "go" any function with arguments and so doesn't
need wrapping. If it ever does, it is not that we can have the
closure not escape, which may lead to miscompilation. Instead,
make the closure escape (which will fail the compilation). In the
future we may allow go'd closure to escape in the runtime.

Change-Id: I5bbe47b524371d2270c242f6c275013cd52abfc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/312889
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-23 02:29:37 +00:00
Than McIntosh
cfac62a1cc cmd/compile: fix bug in defer wrapping
The defer wrapping feature added to the compiler's "order" phase
creates temporaries into which it copies defer arguments. If one of
these temps is large enough that we place it into the defer closure by
address (as opposed to by value), then the temp in question can't be
reused later on in the order phase, nor do we want a VARKILL
annotation for it at the end of the current block scope.

Test written by Cherry.

Updates #40724.

Change-Id: Iec7efd87ec5a3e3d7de41cdcc7f39c093ed1e815
Reviewed-on: https://go-review.googlesource.com/c/go/+/312869
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-23 01:16:19 +00:00
Matthew Dempsky
14056d0d00 cmd/compile/internal/types2: add unsafe.Add and unsafe.Slice
This is a port of CL 312212, CL 312591 (except check_test.go), and
CL 312790 to types2.

Updates #19367.
Updates #40481.

Change-Id: I58ba0b0dad157baba3f82c909d5eb1268b931be4
Reviewed-on: https://go-review.googlesource.com/c/go/+/312511
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-23 00:41:01 +00:00
Matthew Dempsky
050b408dcc go/types: implement unsafe.Add and unsafe.Slice
Updates #19367.
Updates #40481.

Change-Id: Id2b2d2e3e716f91f0dd9e5102689a1ba90a819e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/312213
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-23 00:40:48 +00:00
Matthew Dempsky
1da05eb0ce spec: add unsafe.Add and unsafe.Slice
Updates #19367.
Updates #40481.

Change-Id: I578066ad68d2cd6bea50df1a534cf799e4404a7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/312212
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-04-22 22:03:10 +00:00
Matthew Dempsky
74059685fd go/types: suppress index-out-of-bounds error on Unknown constants
Follow up to CL 312591, which was stumping rfindley and I for a
while. Credit to him for figuring out a repro and explaining the
correct solution.

Change-Id: Ib8578bba05f60fc41d382c34c5266d815441e7a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/312790
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-22 22:01:47 +00:00
Matthew Dempsky
f7afdfd483 go/types: cleanup and fix Checker.index
A couple minor spec compliance issues: constant, typed index operands
must still be representable as type "int", but should also be recorded
as their original type.

Fixes #45667.

Change-Id: Iefeb29f20a8e48350af83a62c9ae0e92198c5ef7
Reviewed-on: https://go-review.googlesource.com/c/go/+/312591
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-22 21:23:59 +00:00
Egon Elbre
cfe5d79c5c os: depend on Readlink only when necessary
Currently Readlink gets linked into the binary even when Executable is
not needed.

This reduces a simple "os.Stdout.Write([]byte("hello"))" by ~10KiB.

Previously the executable path was read during init time, because
deleting the executable would make "Readlink" return "(deleted)" suffix.
There's probably a slight chance that the init time reading would return
it anyways.

Updates #6853

Change-Id: Ic76190c5b64d9320ceb489cd6a553108614653d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/311790
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-22 21:03:32 +00:00
Michael Pratt
ecfce58965 runtime: skip work recheck for non-spinning Ms
When an M transitions from spinning to non-spinning state, it must
recheck most sources of work to avoid missing work submitted between its
initial check and decrementing sched.nmspinning (see "delicate dance"
comment).

Ever since the scheduler rewrite in Go 1.1 (golang.org/cl/7314062), we
have performed this recheck on all Ms before stopping, regardless of
whether or not they were spinning.

Unfortunately, there is a problem with this approach: non-spinning Ms
are not eligible to steal work (note the skip over the stealWork block),
but can detect work during the recheck. If there is work available, this
non-spinning M will jump to top, skip stealing, land in recheck again,
and repeat. i.e., it will spin uselessly.

The spin is bounded. This can only occur if there is another spinning M,
which will either take the work, allowing this M to stop, or take some
other work, allowing this M to upgrade to spinning. But the spinning is
ultimately just a fancy spin-wait.

golang.org/issue/43997 discusses several ways to address this. This CL
takes the simplest approach: skipping the recheck on non-spinning Ms and
allowing them to go to stop.

Results for scheduler-relevant runtime and time benchmarks can be found
at https://perf.golang.org/search?q=upload:20210420.5.

The new BenchmarkCreateGoroutinesSingle is a characteristic example
workload that hits this issue hard. A single M readies lots of work
without itself parking. Other Ms must spin to steal work, which is very
short-lived, forcing those Ms to spin again. Some of the Ms will be
non-spinning and hit the above bug.

With this fixed, that benchmark drops in CPU usage by a massive 68%, and
wall time 24%. BenchmarkNetpollBreak shows similar drops because it is
unintentionally almost the same benchmark (create short-living Gs in a
loop). Typical well-behaved programs show little change.

We also measure scheduling latency (time from goready to execute). Note
that many of these benchmarks are very noisy because they don't involve
much scheduling. Those that do, like CreateGoroutinesSingle, are
expected to increase as we are replacing unintentional spin waiting with
a real park.

Fixes #43997

Change-Id: Ie1d1e1800f393cee1792455412caaa5865d13562
Reviewed-on: https://go-review.googlesource.com/c/go/+/310850
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>
2021-04-22 20:45:37 +00:00
Cherry Zhang
b6ff3c69d5 cmd/link: support more load commands on Mach-O
Change-Id: I74dd9170a51cc93ce3ec5e5860c2eb2912f081f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/312729
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-22 18:17:00 +00:00
Bryan C. Mills
1a5665533b cmd/go/internal/modload: migrate editBuildList to use a structured requirement graph
For #36460

Change-Id: Ic87d7e25402bb938d2872d33d26c4bf397776d1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/308517
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-22 18:07:38 +00:00
Bryan C. Mills
9c1b769d5f cmd/go: add a source file in the multiple-paths module in TestScript/mod_tidy_replace
This situation is analogous to CL 309334: the test expects 'go mod
tidy' to fail due to a module used for more than one path in the build
list, but doesn't actually contain any packages or imports — so no
module is necessarily used at all, and the error only occurs if we
report it prematurely.

For #36460

Change-Id: I5ccecf30f280895eba913a8d62571872b75e710d
Reviewed-on: https://go-review.googlesource.com/c/go/+/312098
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-22 18:05:13 +00:00
Cherry Zhang
537cde0b4b cmd/compile, runtime: add metadata for argument printing in traceback
Currently, when the runtime printing a stack track (at panic, or
when runtime.Stack is called), it prints the function arguments
as words in memory. With a register-based calling convention,
the layout of argument area of the memory changes, so the
printing also needs to change. In particular, the memory order
and the syntax order of the arguments may differ. To address
that, this CL lets the compiler to emit some metadata about the
memory layout of the arguments, and the runtime will use this
information to print arguments in syntax order.

Previously we print the memory contents of the results along with
the arguments. The results are likely uninitialized when the
traceback is taken, so that information is rarely useful. Also,
with a register-based calling convention the results may not
have corresponding locations in memory. This CL changes it to not
print results.

Previously the runtime simply prints the memory contents as
pointer-sized words. With a register-based calling convention,
as the layout changes, arguments that were packed in one word
may no longer be in one word. Also, as the spill slots are not
always initialized, it is possible that some part of a word
contains useful informationwhile the rest contains garbage.
Instead of letting the runtime recreating the ABI0 layout and
print them as words, we now print each component separately.
Aggregate-typed argument/component is surrounded by "{}".

For example, for a function

F(int, [3]byte, byte) int

when called as F(1, [3]byte{2, 3, 4}, 5), it used to print

F(0x1, 0x5040302, 0xXXXXXXXX) // assuming little endian, 0xXXXXXXXX is uninitilized result

Now prints

F(0x1, {0x2, 0x3, 0x4}, 0x5).

Note: the liveness tracking of the spill splots has not been
implemented in this CL. Currently the runtime just assumes all
the slots are live and print them all.

Increase binary sizes by ~1.5%.

                     old          new
hello (println)    1171328      1187712 (+1.4%)
hello (fmt)        1877024      1901600 (+1.3%)
cmd/compile       22326928     22662800 (+1.5%)
cmd/go            13505024     13726208 (+1.6%)

Updates #40724.

Change-Id: I351e0bf497f99bdbb3f91df2fb17e3c2c5c316dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/304470
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-22 17:47:59 +00:00
Paul E. Murphy
d4aa72002e cmd/asm: fix RLDCR const1,reg,const2,reg on ppc64
The extended opcode field (XO) is generated incorrectly. OPVCC
assumes an X-form like layout for the XO field. MD-form insns
also have an XO field, but it is both smaller and in a different
bit position.

This hasn't been noticed since const1 == 0 matches as a register
argument instead of a constant, thus it is unlikely anyone has
attempted to assemble this instruction with a non-zero shift
argument.

Likewise, update all other MD-form instructions using OPVCC
to use the new OPMD function.

Change-Id: Id81fa2727fb701431911a05492c2038415ad0a4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/310851
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-22 17:02:01 +00:00
Cherry Zhang
e8666abd98 cmd/compile: keep call's args in elim dead auto pass
If the address of an auto is used in a Call, we need to keep it,
as we keep the Call itself.

Fixes #45693.

Change-Id: Ie548d6dffc95bf916868a8885d4ab4cf9e86355a
Reviewed-on: https://go-review.googlesource.com/c/go/+/312670
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-04-22 16:38:37 +00:00
Cherry Zhang
d3853fb4e6 runtime: call cgocallbackg indirectly
cgocallback calls cgocallbackg after switching the stack. Call it
indirectly to bypass the linker's nosplit check.

Apparently (at least on Windows) cgocallbackg can use quite a bit
stack space in a nosplit chain. We have been running over the
nosplit limit, or very close to the limit. Since it switches
stack in cgocallback, it is not meaningful to count frames above
cgocallback and below cgocallbackg together. Bypass the check.

For #45658.

Change-Id: Ie22017e3f82d2c1fcc37336696f2d02757856399
Reviewed-on: https://go-review.googlesource.com/c/go/+/312669
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-22 16:15:44 +00:00
Cherry Zhang
d5b2d809b0 cmd/link: emit LC_BUILD_VERSION on Mach-O
LC_VERSION_MIN_MACOSX seems deprecated. Emit LC_BUILD_VERSION
instead. Also emit it on darwin/arm64, where it was not emitted
before.

Fixes #45091.

Change-Id: I18fb80d571f681da3bd258e53beb520e68f354bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/312550
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-22 14:40:40 +00:00
Cherry Zhang
b2a032add8 cmd/link: update machoPlatform selection
Now that we have darwin/arm64 and ios/arm64 ports, make it based
on GOOS, instead of GOARCH.

Also drop a remaining case of 32-bit ARM.

Change-Id: I954fff980712fd3b81b561ddcb6f3a4ef73fa0b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/312549
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-22 14:34:36 +00:00
Aofei Sheng
a4f3ff2205 cmd/go: update TestScript/mod_convert
Fixes #45659

Change-Id: Ie7e07c9acfc500222c244464fbebfcc8e5b14c64
Reviewed-on: https://go-review.googlesource.com/c/go/+/312629
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-04-22 14:28:14 +00:00
Robert Griesemer
14a18b7d25 cmd/compile/internal/types2: move a handful of tests
These tests belong into the fixedbugs directory.
This matches the go/types organization.
No changes to the code.

Change-Id: I36bcf70672d9ea5a40175c445e1d036c603ae76f
Reviewed-on: https://go-review.googlesource.com/c/go/+/312570
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-22 04:07:38 +00:00
Robert Griesemer
a71528ad31 cmd/compile/internal/types2: review fixedbugs tests
These tests match the corresponding tests for go/types
which have been reviewed.
This CL simply removes the UNREVIEWED disclaimer.

Change-Id: I4dfe2aedc1341ebb9ba206aac1a072f32cbe1f78
Reviewed-on: https://go-review.googlesource.com/c/go/+/312569
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-22 04:07:32 +00:00
Robert Griesemer
ece5935364 cmd/compile/internal/types2: better errors for invalid short var decls
- rewrite Checker.shortVarDecl core loop for clarity
- match compiler error messages (#43087)
- don't allow multiple identical redeclarations (#45652)

For #43087.
For #45652.

Change-Id: I8c3329a553aa104d7853fbaea8b88049bc9b3b88
Reviewed-on: https://go-review.googlesource.com/c/go/+/312170
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-22 04:04:47 +00:00
Robert Griesemer
48b368b01f cmd/compile/internal/types2: avoid follow-on errors for invalid [...] array
Fixes #42987.

Change-Id: Iaaa46e1f79525cd1e418c1a81a6414d11f8120b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/311889
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-22 04:04:40 +00:00
Rob Findley
617a83ec68 go/types: re-enable a commented out test
This test was unnecessarily commented out in CL 312190: re-enable it and
update its assertions.

Change-Id: Ic08563e25c9b05a8e35d67690f5d27a761133266
Reviewed-on: https://go-review.googlesource.com/c/go/+/312097
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-22 03:03:48 +00:00
Rob Findley
f0a8101d34 go/types: combine two loops (cleanup of TODO)
This is an exact port of CL 307949 to go/types.

Change-Id: I796f3030a86d76deb80e58bb547460b586480911
Reviewed-on: https://go-review.googlesource.com/c/go/+/312096
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-22 03:03:41 +00:00
eric fang
5daefc5363 cmd/internal/obj/arm64: fix the wrong ROR operator of some instructions
Instructions such as ADD, SUB, CMP do not support ROR shift operations,
but we have not checked this at present. This CL adds this check.

Change-Id: Icac461f61ad6ddb60886a59ba34dddd29df1cc0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/310035
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-22 01:40:02 +00:00
fanzha02
0636d88f6d cmd/compile: add restrictions on the shift amount range of arm64 various instructions
For arm64 constant shift instructions, e.g., LSL(immediate), they use
only the low 6 bits. To conform the semantics of the hardware instructions,
this CL comments in ARM64OPS.go about restricted AuxInt ranges for the
various instructions involved.

Change-Id: I2b6560d6580e22ba7cbfa744a02b046dd5714b8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/303569
Trust: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-04-22 01:29:53 +00:00
Ian Lance Taylor
02a8e83661 runtime: don't run TestCrashDumpsAllThreads in parallel
It sometimes seems to time out on slow systems, perhaps due to
being run at the same time as a lot of other work.

Also move the code to testdata/testprog, so that we don't have to
build it separately.

I hope that this
Fixes #35356

Change-Id: I875b858fa23836513ae14d3116461e22fffd5352
Reviewed-on: https://go-review.googlesource.com/c/go/+/312510
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-22 00:34:25 +00:00
Rob Findley
7bedd47798 go/types: combine all type inference in a single function
This is a port of CL 306170 to go/types, adjusted for the different
positioning API.

Some of the error positions in tests had to be adjusted, but I think the
new locations are better.

Change-Id: Ib157fbb47d7483e3c6302bd57f5070bd74602a36
Reviewed-on: https://go-review.googlesource.com/c/go/+/312191
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-21 23:21:55 +00:00
Michael Anthony Knyszek
6639bb894d runtime: call nanotimeQPC from nanotime1 normally
Currently we call runtimeQPC as ABIInternal because it shaves off 24
bytes by not having an extra wrapper, and at the time we were exceeding
the nosplit stack limit in some cases.

However, this code was written before we had the regabiargs GOEXPERIMENT
flag, and wasn't properly flagged. Naturally, with regabiargs enabled,
it leads to garbage being returned, because it needs to store
runtimeQPC's result to the stack.

We didn't notice this because today runtimeQPC is only used in Wine, not
on any native Windows platform.

Back when I wrote this code, it appeared to be necessary on even native
Windows, but it turns out that's not true anymore. Turn it back into a
native call through a wrapper.

For #40724.

Change-Id: Ia2e5901965ef46c5f299daccef49952026854fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/312429
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-21 23:01:42 +00:00
Andrew G. Morgan
7e97e4e8cc syscall: syscall.AllThreadsSyscall signal handling fixes
The runtime support for syscall.AllThreadsSyscall() functions had
some corner case deadlock issues when signal handling was in use.
This was observed in at least 3 build test failures on ppc64 and
amd64 architecture CGO_ENABLED=0 builds over the last few months.

The fixes involve more controlled handling of signals while the
AllThreads mechanism is being executed. Further details are
discussed in bug #44193.

The all-threads syscall support is new in go1.16, so earlier
releases are not affected by this bug.

Fixes #44193

Change-Id: I01ba8508a6e1bb2d872751f50da86dd07911a41d
Reviewed-on: https://go-review.googlesource.com/c/go/+/305149
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Pratt <mpratt@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-21 21:25:26 +00:00
Lynn Boger
54af9fd9e6 internal/bytealg: add power9 version of bytes index
This adds a power9 version of the bytes.Index function
for little endian.

Here is the improvement on power9 for some of the Index
benchmarks:

Index/10           -0.14%
Index/32           -3.19%
Index/4K          -12.66%
Index/4M          -13.34%
Index/64M         -13.17%
Count/10           -0.59%
Count/32           -2.88%
Count/4K          -12.63%
Count/4M          -13.35%
Count/64M         -13.17%
IndexHard1        -23.03%
IndexHard2        -13.01%
IndexHard3        -22.12%
IndexHard4         +0.16%
CountHard1        -23.02%
CountHard2        -13.01%
CountHard3        -22.12%
IndexPeriodic/IndexPeriodic2  -22.85%
IndexPeriodic/IndexPeriodic4  -23.15%

Change-Id: Id72353e2771eba2efbb1544d5f0be65f8a9f0433
Reviewed-on: https://go-review.googlesource.com/c/go/+/311380
Run-TryBot: Carlos Eduardo Seo <carlos.seo@linaro.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-04-21 21:14:04 +00:00
Rob Findley
122fca49f9 go/types: simplify Checker.Call
This is a direct port of CL 306171 to go/types.

Change-Id: I6f0102c76bad3f1d939074fc4c59f772dd417498
Reviewed-on: https://go-review.googlesource.com/c/go/+/312190
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-21 20:44:00 +00:00
Tobias Klauser
1d2101116f net: don't check nil err twice in interfaceMessages on freebsd
Change-Id: Ie614e49d07b24c5b3dde469561893643bc858d1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/312389
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-21 20:39:43 +00:00
Rob Findley
614a9c2613 go/types: simplify Checker.funcInst
This is a port of CL 306169 to go/types, adjusted only for use of the
typeparams package, and the different positioning API.

Change-Id: I3095f4b0dae4473e75ec2a988ea282bac1a4bab3
Reviewed-on: https://go-review.googlesource.com/c/go/+/312189
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-21 20:36:36 +00:00
Rob Findley
39785912b9 go/types: add sizeof test
This is a direct port of CL 310530 to go/types, adjusted only for names
and to account for the smaller size of objects in go/types, due to
(I assume) token.Pos vs syntax.Pos.

Change-Id: I0cc34d56e41c1e66b17edd0ccd3f281d97a6b235
Reviewed-on: https://go-review.googlesource.com/c/go/+/312091
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-21 20:35:43 +00:00
Ian Lance Taylor
35806efda2 io/fs: document that caller can modify slice returned by ReadFile
Also add a test to testing/fstest.

Fixes #45186

Change-Id: I00e5f46ccd5269dbc266a8f2ebc9a62ebb1297b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/311649
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-04-21 16:46:52 +00:00
Robert Griesemer
b8a359d984 cmd/compile/internal/types2: fix incorrect result type of Checker.index
While at it, add missing "invalid argument: " prefix
to a couple of local error messages, for consistency.

For #45667.

Change-Id: I814800b2f3f3750583e335c98a3f8e27030a9daa
Reviewed-on: https://go-review.googlesource.com/c/go/+/312309
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-21 16:26:01 +00:00
Tobias Klauser
f9e2dbbfc9 syscall: use libc in Exec on openbsd/arm64
Like on openbsd/amd64, use libc instead of direct syscalls on
openbsd/arm64.

This was likely missed in CL 286815. A similar change was done for
openbsd/amd64 in CL 270380.

Updates #36435

Change-Id: Ie496a6130f1a43d30974502777db12217e65c551
Reviewed-on: https://go-review.googlesource.com/c/go/+/312229
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
2021-04-21 15:57:05 +00:00
Cherry Zhang
e5bc4f2a77 cmd/compile: reenable name preservation on copies in expand_calls
This reverts CL 311829, and reenables CL 309330. The issue
should be fixed in the previous CL.

Change-Id: I69db0565c72470a1814f135d8f8ec62c781bfc5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/312094
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-21 14:16:01 +00:00
Cherry Zhang
daee726a0b cmd/compile: don't accumulate duplicated named slots
Currently, in expand_calls, for each appearance of a named
variables's component, we add the named slot to f.Names list. If
a variable appears many times, we add it to f.Names many times.
Furthure, for each duplicated named slot, its entry in
f.NamedValues is a slice that contains all Values associated with
that name. This leads to quadratic behavior when iterating named
values like

	for _, name := range f.Names {
		for _, v := range f.NamedValues[name] {
			...
		}
	}

This CL makes it not to add duplicated entries to f.Names.

Change-Id: I82a8d009db81ecf48b4577e0bca501feff677cdf
Reviewed-on: https://go-review.googlesource.com/c/go/+/312093
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-21 14:15:55 +00:00
Michael Pratt
4d56576ec0 runtime: move timer recheck after GC recheck
When rechecking for work after transitioning from a spinning to
non-spinning M, checking timers before GC isn't useful. That is, if
there is GC work available, it will run immediately and the updated
pollUntil is unused.

Move this check to just before netpoll, where pollUntil is used. While
this technically improves efficiency in the (rare) case that we find
GC work in this block, the primary motivation is simply to improve
clarity by moving the update closer to use.

For #43997

Change-Id: Ibc7fb308ac4a582875c200659c9e272121a89f3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/308654
Trust: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-21 13:38:59 +00:00
Bryan C. Mills
381252f312 cmd/go/internal/modload: use updateRequirements instead of editRequirements to add modules for missing packages
editRequirements does a lot of work in order to respect the upper
bounds of mustSelect, and as a result it doesn't provide many promises
about conserving other things (like root dependencies).

When we add modules for missing packages, we aren't dealing with upper
bounds at all, so we would rather avoid the upper-bound overhead and
preserve the root-dependency invariants instead.
(*loader).updateRequirements does exactly that; it just needs to be
told about the additional dependencies to add.

For #36460

Change-Id: Ie0f2bc0dde18026bbd23e51357bb1d725d201680
Reviewed-on: https://go-review.googlesource.com/c/go/+/310791
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-21 13:27:17 +00:00
Cuong Manh Le
5f1df260a9 cmd/compile: allow export/import OSLICE2ARRPTR
Updates #395
Fixes #45665

Change-Id: Iaf053c0439a573e9193d40942fbdb22ac3b4d3bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/312070
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-21 09:07:09 +00:00
Cuong Manh Le
7735ec96c1 cmd/compile: remove ir.OSTMTEXPR op
It is not used anywhere.

Change-Id: I2b8d64902e16893ab5e1b84943f6d865c6e9c7bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/311950
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: Matthew Dempsky <mdempsky@google.com>
2021-04-21 09:07:02 +00:00
Cuong Manh Le
acf1b46de5 cmd/compile: update ir.Node ops comments
After Russquake, all the Node ops now have different structure, update
comment to reflect that.

Change-Id: I43f859783cda457528ae4d2da9857f2cc0438b62
Reviewed-on: https://go-review.googlesource.com/c/go/+/311949
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: Matthew Dempsky <mdempsky@google.com>
2021-04-21 08:46:51 +00:00
Bryan C. Mills
f53c2fac46 cmd/go/internal/modload: in newRequirements, verify that rootModules is sorted
The comment for the Requirements.rootModules field requires that it be
"sorted and capped to length". I noticed that we were not capping it
correctly — we were capping the local variable (the rorotModules
argument itself) but not the struct field. That prompted me to
question whether we were also at some point failing to sort it
correctly, so I decided to add an explicit check.

With the explicit check, all tests continue to pass.

For #36460

Change-Id: I6687de8ef8ecc5129fa8810d678e5673752fd27b
Reviewed-on: https://go-review.googlesource.com/c/go/+/310790
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>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-21 04:27:01 +00:00
Bryan C. Mills
69c94ad55f cmd/go/internal/modload: split updateRoots into separate functions for updating and tidying
In CL 293689, I fused the mvs.Reqs calls that were formerly in MinReqs
and TidyBuildList into a single function, updateRoots, in the hope
that it expressed a fundamental operation. As I have been working on
the lazy equivalents, I have come to realize that these functions are
deeply related but fundamentally different.

In order to help me reason about the two different roles, I am making
the two functions separate once more, but leaving them colocated in
the code.

For #36460

Change-Id: I851d6d81fbfd84f39411e0d076ee72a9909c60ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/310629
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-21 04:26:11 +00:00
Bryan C. Mills
81fcb18df5 cmd/go: make Tidy an option in PackageOpts rather than a separate call
This eliminates some awkwardly-stateful outside calls to
modload.{Disallow,Allow,}WriteGoMod.

Perhaps more importantly, it gives the loader the opportunity to
reload packages and revise dependencies after the tidied requirements
are computed. With lazy loading, dropping an irrelevant requirement
from the main module's go.mod file may (rarely) cause other test
dependencies for packages outside the main module to become
unresolved, which may require the loader to re-resolve those
dependencies, which may in turn add new roots and increase the
selected versions of modules providing other packages.

This refactoring allows the loader to iterate between tidying the
build list and reloading packages as needed, making the exact
sequencing of loading and tidying an implementation detail of the
modload package.

For #36460
For #40775

Change-Id: Ib6da3672f32153d5bd7d653d85e3672ab96cbe36
Reviewed-on: https://go-review.googlesource.com/c/go/+/310181
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-21 04:23:52 +00:00
Ian Lance Taylor
c33ced6d8a runtime: don't test sig.inuse in sigsend
Signals can be delivered on a different thread. There is no necessary
happens-before relationship between setting sig.inuse in signal_enable
and checking it in sigsend. It is theoretically possible, if unlikely,
that sig.inuse is set by thread 1, thread 2 receives a signal, does not
see that sig.inuse is set, and discards the signal. This could happen
if the signal is received immediately after the first call to signal_enable.

For #33174

Change-Id: Idb0f1c77847b7d4d418bd139e801c0c4460531d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/312131
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-21 02:39:25 +00:00
Robert Griesemer
190cb937f7 cmd/compile/internal/types2: fix type inference
Don't let type parameters that are not filled in with concrete
type arguments escape from constraint type inference - such
inferred types are not "real".

While at it, implement a tparamsList.String method for debugging.

Fixes #45548.

Change-Id: I40f13ff7af08d0357a5c66234bfcdd0b7ed5fdd6
Reviewed-on: https://go-review.googlesource.com/c/go/+/311651
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-21 01:45:15 +00:00
Josh Bleecher Snyder
760d3b2a16 reflect: allow conversion from slice to array ptr
Note that this removes an invariant:

v.Type().ConvertibleTo(t) might return true,
yet v.Convert(t) might panic nevertheless.

This is a fairly unavoidable consequence of the decision
to add the first-ever conversion that can panic.

ConvertibleTo describes a relationship between types,
but whether the conversion panics now depends on the value,
not just the type.

If this turns out to be a problem, we can add v.ConvertibleTo(t),
or something similar, to allow callers to avoid the panic.

This is the last of the changes needed to complete the implementation.

Fixes #395

Change-Id: I79b7e4dd87a67a47723e00a65d0b1ac6090371b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/301652
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-21 00:54:39 +00:00
Josh Bleecher Snyder
c18744377a go/types: allow conversion from slice to array ptr
These match the changes to cmd/compile/internal/types2 in CL 301650.

Updates #395

Change-Id: I1e85b6355c8c8fdba0996c26a2505c65fab908d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/301651
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-21 00:54:01 +00:00
Josh Bleecher Snyder
faa4fa1a6e cmd/compile: allow conversion from slice to array ptr
Panic if the slice is too short.

Updates #395

Change-Id: I90f4bff2da5d8f3148ba06d2482084f32b25c29a
Reviewed-on: https://go-review.googlesource.com/c/go/+/301650
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-21 00:53:48 +00:00
Keith Randall
e12b0afa54 cmd/compile: separate out parameter and field export encoding
These two types of *types.Field encode different concepts, so we
encode them separately (and ignore fields that don't matter for
each concept).

Change-Id: I9d1608413949a109f12a3ebd52cd7af5f476e415
Reviewed-on: https://go-review.googlesource.com/c/go/+/312130
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20 23:41:54 +00:00
Ian Lance Taylor
48e3d92454 Revert "runtime: implement runqdrain() for GC mark worker goroutines"
This reverts CL 310149.

Reason for revert: Breaks longtest builders:

https://build.golang.org/log/6af9fb147fa3101154db10e7ce055e8267cd4c93
https://build.golang.org/log/172ed6e1ec3bb503370333ee421c590fd2a72d0a

Change-Id: Iaf5a8b9eec51d0517311e050d0b0f7569759d292
Reviewed-on: https://go-review.googlesource.com/c/go/+/312129
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20 22:47:50 +00:00
Keith Randall
c7d708e42e cmd/compile: pass struct field note information along in exported info
This is needed to make field tracking work correctly.

Change-Id: I0c3452a48d6f36862f6ee8aacc001813866c0ad4
Reviewed-on: https://go-review.googlesource.com/c/go/+/312069
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20 22:39:22 +00:00
Cherry Zhang
f448cb8ba8 cmd/compile: use f.Nname.Type() in makeABIWrapper
Apparently, f.Nname.Ntype.Type() doesn't work with types2, as it
doesn't set Ntype, unlike the old type checker. f.Nname.Type()
works for both.

Change-Id: I6fa8a81c9fc7b65e008d9f158b88f0d56d84c3ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/312089
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-20 21:59:20 +00:00
Tobias Klauser
57b0d838ed net: pass MSG_CMSG_CLOEXEC in ReadMsgUnix on dragonfly, netbsd and openbsd
Add support for passing MSG_CMSG_CLOEXEC to the recvmsg syscall on
dragonfly, netbsd and openbsd. MSG_CMSG_CLOEXEC on freebsd is currently
broken, see https://reviews.freebsd.org/D29328.

Change-Id: Ie4c6e3cb550cd0ae32a1c2acca12edf77569e96a
Reviewed-on: https://go-review.googlesource.com/c/go/+/311570
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-20 21:00:46 +00:00
Tobias Klauser
3f8e64878a internal/poll, net: fix comments regarding accept and sysSocket
The implementation of accept was moved from package net to internal/poll
in CL 36799.

Change-Id: I6e5964e0ee22e9c84bc444860cdd497817451fec
Reviewed-on: https://go-review.googlesource.com/c/go/+/311571
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-20 21:00:32 +00:00
Michael Pratt
dbade774c3 runtime: refactor findrunnable spinning recheck
Break the main components of the findrunnable spinning -> non-spinning
recheck out into their own functions, which simplifies both findrunnable
and the new functions, which can make use of fancy features like early
returns.

This CL should have no functional changes.

For #43997
For #44313

Change-Id: I6d3060fcecda9920a3471ff338f73d53b1d848a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/307914
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>
2021-04-20 20:58:52 +00:00
Jinzhu
7473a6a0eb reflect: fix stack overflow panic when using haveIdenticalUnderlyingType
haveIdenticalUnderlyingType raises stack overflow when compares
self-referential structs having same structure in different packages.

Change-Id: I7c79ab988edcffadcf7e0730a50b4d31b136bb6a
GitHub-Last-Rev: 4d4217f0c1
GitHub-Pull-Request: golang/go#45543
Reviewed-on: https://go-review.googlesource.com/c/go/+/309729
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-20 20:14:14 +00:00
Andy Pan
fbb600b283 runtime: implement runqdrain() for GC mark worker goroutines
Change-Id: Ida44a2e07f277bee8806538ecee4beee3474cf3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/310149
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20 19:48:29 +00:00
Cherry Zhang
77860ad280 cmd/compile: guard partially live arg spilling with number of registers
The code that does partially live in-register arg spilling is
currently guarded with GOEXPERIMENT=regabiargs. But on platforms
where GOEXPERIMENT=regabiargs is not enabled there are still tests
that use register args. Guard it with actual number of registers
used, so it covers both.

Should fix the freeBSD builder.

Change-Id: I0d3c49d7a2389096cb6b17ca35b9b4ce567bc91e
Reviewed-on: https://go-review.googlesource.com/c/go/+/311830
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-20 18:34:56 +00:00
Cherry Zhang
109d7580a5 cmd/compile: disable name preservation on copies in expand_calls
Apparently CL 309330 caused the compiler OOMing on some large
input (giant generated switch statement). I don't quite understand
it for now. Disable it for now.

Change-Id: I19c84f3f5e158897bff0b32d6217fcff3c66874d
Reviewed-on: https://go-review.googlesource.com/c/go/+/311829
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20 16:44:18 +00:00
Michael Pratt
60ab197bc2 runtime: refactor work stealing to dedicated function
findrunnable has grown very large and hard to follow over the years.
Parts we can split out into logical chunks should help make it more
understandable and easier to change in the future.

The work stealing loop is one such big chunk that is fairly trivial to
split out into its own function, and even has the advantage of
simplifying control flow by removing a goto around work stealing.

This CL should have no functional changes.

For #43997.
For #44313.

Change-Id: Ie69670c7bc60bd6c114e860184918717829adb22
Reviewed-on: https://go-review.googlesource.com/c/go/+/307913
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Chris Hines <chris.cs.guy@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-20 16:00:27 +00:00
Austin Clements
9dd71ba913 internal/buildcfg: enable regabiargs by default
For #40724.

Change-Id: I7509668478d20dd625f210e5a33f5d896a76d6b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/310176
Trust: Austin Clements <austin@google.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-20 15:45:02 +00:00
Rob Findley
24875e3880 cmd/compile/internal/types2: fix some typos in rawLookupFieldOrMethod
Change-Id: Ibc04a82b1d618deeb9bc168ba518dbf1d752fba7
Reviewed-on: https://go-review.googlesource.com/c/go/+/311456
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-20 15:14:05 +00:00
Rob Findley
4ce49b4a15 go/types: support type parameters in NewMethodSet
Add handling for TypeParams in NewMethodSet, to bring it in sync with
lookupFieldOrMethod. Also add a test, since we had none. I wanted this
fix to get gopls completion working with type params, but due to the
subtlety of lookupFieldOrMethod, I left a TODO to confirm that there are
no behavioral differences between the APIs.

Updates #45639

Change-Id: I16723e16d4d944ca4ecb4d87fc196815abb6fcff
Reviewed-on: https://go-review.googlesource.com/c/go/+/311455
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-20 15:13:47 +00:00
Austin Clements
af8a176e91 internal/buildcfg: enable regabidefer by default
For #40724.

Change-Id: If3a66c0e29cb20dd29ac13c8d00aa46ee279ab97
Reviewed-on: https://go-review.googlesource.com/c/go/+/310175
Trust: Austin Clements <austin@google.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-20 14:55:35 +00:00
Cherry Zhang
3ff6ff7f84 cmd/compile: preserve pointerness when creating map key temp
When creating the temporary for map functions, if the key
contains pointer, we need to create pointer-typed temporary. So
if the temporary is live across a function call, the pointer is
live.

Change-Id: Id6e14ec9def8bc7987f0f8ce8423caf1e3754fcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/311379
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-20 14:30:03 +00:00
Ian Lance Taylor
fe26dfadc3 net: use syscall.fcntl on libc systems
Should fix the AIX builder.

Change-Id: I3498805fb2eee2f0ad50268b5afbbf091c5f6e63
Reviewed-on: https://go-review.googlesource.com/c/go/+/311650
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-20 02:42:23 +00:00
Cherry Zhang
0ccdcb2102 runtime: crash the GC when clobberdead pointer is seen
When -clobberdead compiler flag is set, the compiler inserts
instructions that set dead slots a specific value. If the GC sees
this value as a live pointer, something is probably wrong. Crash.

Only do this on AMD64 for now, as it is the only platform where
compiler's clobberdead mode is implemented. And on AMD64 the
clobberdead address can never be a valid address.

Change-Id: Ica687b132b5d3ba2a062500d13264fa730405d11
Reviewed-on: https://go-review.googlesource.com/c/go/+/310330
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-20 01:47:04 +00:00
Yury Smolsky
4f5aec4603 all: remove redundant spaces before . and ,
Change-Id: I6a4bd2544276d0638bddf07ebcf2ee636db30fea
Reviewed-on: https://go-review.googlesource.com/c/go/+/311009
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-20 00:49:17 +00:00
Rob Findley
9f87943424 go/types: fix panic when using multiple type arguments
Fix a panic caused by using type arguments without first unpacking.

This was noticed in the review of CL 300998, but unfortunately not yet
fixed.

Fixes #45635

Change-Id: I8ab1720f3e27a6002bc925f0eea943ec6f778341
Reviewed-on: https://go-review.googlesource.com/c/go/+/311669
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>
2021-04-20 00:14:27 +00:00
Cherry Zhang
3711ea0b5d cmd/compile: do not clobber arguments for reflect.callReflect and callMethod's ABI wrappers
reflect.callReflect and reflect.callMethod are called from special
functions makeFuncStub and methodValueCall. The runtime expects
that it can find the first argument (ctxt) at 0(SP) in
makeFuncStub and methodValueCall's frame. Normally callReflect and
callMethod already do not modify the argument, and keep it alive.
But the compiler-generated ABI wrappers don't do that. Special
case the wrappers to not clobber its arguments.

Change-Id: I1769f49b81c38eabe452d561001c418352814d86
Reviewed-on: https://go-review.googlesource.com/c/go/+/310889
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-19 23:17:10 +00:00
Rob Findley
b3a5640397 go/types: remove the concept of finals
Checker.finals and the corresponding atEnd were added in CL 191418 as a
mechanism to postpone interface type comparison until after all
interfaces were complete. In the intervening CL 195837 we've adopted a
convention of ensuring that interfaces are complete before comparing
them. Since then we've also added the additional case of expansion for
lazily resolving syntax.

Checker.later defers resolution of types until points in the checking
pass where all reachable types can be fully type checked, so the concept
of finals should no longer be necessary.

Change-Id: I58818c1a6b605dccc9b0ecb3a1f6859c138175d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/299590
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-19 23:08:21 +00:00
Rob Findley
62cad233a6 go/types: remove stale commented-out testdata
Change-Id: I44b191204b05cd44ab6e3c662ddd05596aa3af1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/299831
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-19 23:08:09 +00:00
Michael Hudson-Doyle
7252e1e5b6 cmd/link: convert -I foo to -Wl,--dynamic-linker,foo when externally linking
Fixes #22446

Change-Id: Id5b3fbc9cd3a7d6c4bf4e28428b8cb6d45a9ca92
Reviewed-on: https://go-review.googlesource.com/c/go/+/310349
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-19 23:02:15 +00:00
Austin Clements
88655480f3 internal/buildcfg: enable regabireflect by default
For #40724.

Change-Id: Ib3e4a67c3826176f0d51619754270022344ee194
Reviewed-on: https://go-review.googlesource.com/c/go/+/310174
Trust: Austin Clements <austin@google.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-19 22:25:20 +00:00
Michael Fraenkel
bc5de81e70 testing: remove data races so that parallel benchmarks can safely call .Fatal* and .Skip*
Protects the usages of (*common).finished with locks
to prevent data races, thus allowing benchmarks to safely invoke
.Fatal* and .Skip* concurrently.

Fixes #45526

Change-Id: I2b4846f525c426d6c7d3418f8f6c86446adbf986
Reviewed-on: https://go-review.googlesource.com/c/go/+/309572
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-19 22:06:05 +00:00
HowJMay
e97d8eb027 net: pass MSG_CMSG_CLOEXEC flag in ReadMsgUnix
As mentioned in #42765, calling "recvmsg" syscall on Linux should come
with "MSG_CMSG_CLOEXEC" flag.

For other systems which not supports "MSG_CMSG_CLOEXEC". ReadMsgUnix()
would check the header. If the header type is "syscall.SCM_RIGHTS",
then ReadMsgUnix() would parse the SocketControlMessage and call each
fd with "syscall.CloseOnExec"

Fixes #42765

Change-Id: I74347db72b465685d7684bf0f32415d285845ebb
GitHub-Last-Rev: ca59e2c9e0
GitHub-Pull-Request: golang/go#42768
Reviewed-on: https://go-review.googlesource.com/c/go/+/272226
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-19 21:27:43 +00:00
Austin Clements
bbb510ccc9 internal/buildcfg: enable regabig by default
For #40724.

Change-Id: Ibf4ff8b24b501813839657ac195b909682ac7d0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/310173
Trust: Austin Clements <austin@google.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-19 19:24:41 +00:00
Cherry Zhang
f8892147bd runtime: open up space for callee's arg spill slot in mcall (regabi version)
mcall calls fn with an argument. Currently, in the regabi version
of mcall it does not reserve space for that argument's spill slot.
If the callee spills its argument, it may clobber things on the
g0 stack at 0(SP) (e.g. the old SP saved in cgocallback).

Reserve the space.

Change-Id: I85a314273cd996c7fac8fd0b03cd9033faae9c5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/311489
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-19 18:37:15 +00:00
Ariel Mashraki
5780ab4f60 text/template/parse: add a mode to skip func-check on parsing
Following the discussion on #34652 and the proposal of #36911 (gopls),
this CL adds an option to skip the function declartion check on parsing,
in order to make it possible to parse arbitrary template text files and
get their AST.

Fixed #38627

Change-Id: Id1e0360fc726b49dcdd49716ce25563ebaae6c10
Reviewed-on: https://go-review.googlesource.com/c/go/+/301493
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2021-04-19 16:49:40 +00:00
Cherry Zhang
6b8e3e2d06 cmd/compile: reduce redundant register moves for regabi calls
Currently, if we have AX=a and BX=b, and we want to make a call
F(1, a, b), to move arguments into the desired registers it emits

	MOVQ AX, CX
	MOVL $1, AX // AX=1
	MOVQ BX, DX
	MOVQ CX, BX // BX=a
	MOVQ DX, CX // CX=b

This has a few redundant moves.

This is because we process inputs in order. First, allocate 1 to
AX, which kicks out a (in AX) to CX (a free register at the
moment). Then, allocate a to BX, which kicks out b (in BX) to DX.
Finally, put b to CX.

Notice that if we start with allocating CX=b, then BX=a, AX=1,
we will not have redundant moves. This CL reduces redundant moves
by allocating them in different order: First, for inpouts that are
already in place, keep them there. Then allocate free registers.
Then everything else.

                             before       after
cmd/compile binary size     23703888    23609680
            text size        8565899     8533291

(with regabiargs enabled.)

Change-Id: I69e1bdf745f2c90bb791f6d7c45b37384af1e874
Reviewed-on: https://go-review.googlesource.com/c/go/+/311371
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-19 16:21:39 +00:00
Cuong Manh Le
a72622d028 cmd/compile: skip "_" function in reflectdata.MarkUsedIfaceMethod
CL 256798 added compiler ability to retain only used interface methods,
by generating a mark relocation whenever an interface method is used. To
do that, the compiler needs the current function linker object.

However, for unnamed function "func _()", its linker object is nil,
causes the compiler crashes for code in #45258.

CL 283313 fixed the code in #45258 unintentionally, since when the
compiler now does not walk unnamed functions anymore.

This CL fixes the root issue, by making reflectdata.MarkUsedIfaceMethod
skips unnamed functions, and also adding regression test.

Fixes #45258

Change-Id: I4cbefb0a89d9928f70c00dc8a271cb61cd20a49c
Reviewed-on: https://go-review.googlesource.com/c/go/+/311130
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: Keith Randall <khr@golang.org>
2021-04-19 04:37:32 +00:00
Austin Clements
c914e6160d cmd/go: drop GOEXPERIMENT in script tests
TestScript sets the GOEXPERIMENT environment variable to the value of
buildcfg.GOEXPERIMENT() with the intent that tests can use this to
inspect the value of buildcfg.GOEXPERIMENT. This has the unfortunate
side-effect of also affecting the experiments enabled for all builds
done by TestScript. For the most part this is harmless, but
GOEXPERIMENT can be GOOS/GOARCH-sensitive, so if a test changes GOOS
or GOARCH, it will continue to use the GOEXPERIMENT from the host
GOOS/GOARCH rather than what makes sense (or is even allowed) in the
test's GOOS/GOARCH. In fact, prior to CL 307819, TestScript set
GOEXPSTRING instead of GOEXPERIMENT because it previously captured
objabi.Expstring(), so the captured value didn't affect the build.

There's only one experiment that actually uses TestScript's
GOEXPERIMENT and there's a much better way to write that test now such
that it doesn't need to read GOEXPERIMENT at all. Hence, this CL
rewrites this test and drops GOEXPERIMENT from TestScript.

This should fix the *-regabi builders.

Change-Id: I3fcbf1f21e1b471ebc0e953c31333645553ea24c
Reviewed-on: https://go-review.googlesource.com/c/go/+/310969
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-04-19 02:43:30 +00:00
Paschalis Tsilias
4efd581383 archive/zip: fix imports block of biggestZipBytes generator
Fixes #45529

Change-Id: I4d64c40aa6733b783dc4066e222f17abeb7ad413
Reviewed-on: https://go-review.googlesource.com/c/go/+/309357
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-18 17:40:12 +00:00
Austin Clements
fd3612e433 internal/buildcfg: enable regabiwrappers by default
For #40724.

Change-Id: I75d6ba2d3e4e2d858eea8053efd0f3fd4439dab7
Reviewed-on: https://go-review.googlesource.com/c/go/+/310172
Trust: Austin Clements <austin@google.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-17 00:02:01 +00:00
Austin Clements
43466399cb internal/buildcfg: make regabi enable regabiargs
For #40724.

Change-Id: I6e9d7eb91883857479699972a974a39ce3d9d2cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/310849
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 23:21:54 +00:00
Austin Clements
067bad2eef runtime: update stale comment
Missed in CL 310731.

Change-Id: Ia26cd2cedec1508ecfd7f0beb63cd6a6ab546f1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/310909
Trust: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16 22:45:30 +00:00
Austin Clements
14dbd6e776 internal/buildcfg: make regabi an alias for regabi sub-experiments
Currently, specifying GOEXPERIMENT=regabi will turn on all regabi
sub-experiments, but GOEXPERIMENT=noregabi won't turn anything off.
Regabi also isn't a "real" experiment in the sense that nothing in the
code base should depend on it as an experiment flag (it should depend
on the appropriate sub-experiments).

Hence, drop Regabi from goexperiment.Flags and make "regabi" in
GOEXPERIMENT be a real alias for all of the sub-flags, so regabi will
turn on all of the sub-flags and noregabi will turn off all of the
sub-flags.

This way, once we enable the sub-experiments in the baseline
configuration, it will be easy to turn off with "noregabi".

For #40724.

Change-Id: I0fb95be42f756d412e729a396be607d629ae2bab
Reviewed-on: https://go-review.googlesource.com/c/go/+/310609
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 22:45:02 +00:00
Leonard Wang
94817890c2 runtime: remove useless nFlushCacheRoots
Change-Id: I70cb8f8e9a0eec68ea11f22ca8699aa7e0c91ede
Reviewed-on: https://go-review.googlesource.com/c/go/+/310710
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-16 21:50:38 +00:00
Austin Clements
b05903a9f6 cmd/link: fix defaultGOROOT package
CL 310731 moved cmd/internal/objabi.defaultGOROOT to
internal/buildcfg.defaultGOROOT, but didn't update the place in the
linker that sets its value.

Fixes the failing reboot test on the GOEXPERIMENT builders.

Change-Id: I135b6bfc0fdadbe6cfc144d7aa55ca13519ba004
Reviewed-on: https://go-review.googlesource.com/c/go/+/310869
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-16 21:48:46 +00:00
Russ Cox
b65f8589e8 cmd/dist: defend self against misc/reboot test
Change-Id: Ice89ecae980d46b16b5ed32ac733bd23c92115af
Reviewed-on: https://go-review.googlesource.com/c/go/+/310870
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2021-04-16 21:39:59 +00:00
Rob Findley
02a2ff47ef go/parser: add a SkipObjectResolution mode to bypass object resolution
Parser object resolution is an auxiliary feature in which the parser
attempts to resolve identifiers to their declarations. In functionality,
it significantly overlaps with go/types and in fact cannot be correctly
computed at parse-time without type information (for example, it is
generally not possible to resolve k in the composite lit c{k: v}). Due
to these limitations, it is of limited utility and rarely used.

Now that object resolution is isolated as a post-processing pass, it is
trivial to offer a parser mode that skips it entirely. This CL adds that
mode.

Fixes #45104

Change-Id: I5a2c05437e298964ad2039e1ff98e63d6efbd1af
Reviewed-on: https://go-review.googlesource.com/c/go/+/306149
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-16 21:20:31 +00:00
Rob Findley
b91f8a4c0b go/scanner: fix a typo in scanner_test.go
Change-Id: I99f07328da3dd99d34b8da5f913c98206b4dc76a
Reviewed-on: https://go-review.googlesource.com/c/go/+/308609
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-16 21:19:53 +00:00
Rob Findley
9e8a312b71 go/parser: move type params in scope for the function signature
Type parameter resolution is a bit tricky: type parameters are in the
function scope, but unlike ordinary parameters may reference eachother.
When resolving the function scope, we must be careful about the order in
which objects are resolved and declared.

Using ordering allows us to avoid passing around temporary scopes for
field declarations.

Add a bunch of tests for this behavior, and skip "_" in resolution tests
as it just adds noise.

For #45221

Change-Id: Id080cddce3fd76396bf86ba5aba856aedf64a458
Reviewed-on: https://go-review.googlesource.com/c/go/+/304456
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-16 21:19:23 +00:00
Michael Pratt
13368ab56a runtime: clarify which work needs spinning coordination
The overview comments discuss readying goroutines, which is the most
common source of work, but timers and idle-priority GC work also require
the same synchronization w.r.t. spinning Ms.

This CL should have no functional changes.

For #43997
Updates #44313

Change-Id: I7910a7f93764dde07c3ed63666277eb832bf8299
Reviewed-on: https://go-review.googlesource.com/c/go/+/307912
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>
2021-04-16 21:04:16 +00:00
Michael Pratt
800fb11efb runtime: remove redudant tryWakeP component
Here tryWakeP can't already be true, so there is no need to combine the
values.

This CL should have no functional changes.

For #43997.
For #44313.

Change-Id: I640c7bb88a5f70c8d22f89f0b5b146b3f60c0136
Reviewed-on: https://go-review.googlesource.com/c/go/+/307911
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>
2021-04-16 21:03:51 +00:00
Michael Pratt
f6e7fe2711 runtime: move findrunnable timer delay computation closer to use
findrunnable has a couple places where delta is recomputed from a new
pollUntil value. This proves to be a pain in refactoring, as it is easy
to forget to do properly.

Move computation of delta closer to its use, where it is more logical
anyways.

This CL should have no functional changes.

For #43997.
For #44313.

Change-Id: I89980fd7f40f8a4c56c7540cae03ff99e12e1422
Reviewed-on: https://go-review.googlesource.com/c/go/+/307910
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>
2021-04-16 21:03:44 +00:00
Cherry Zhang
9fbcba6664 cmd/compile: in clobberdead mode, don't clobber slots that are live for defers
There are stack slots that are kept live for defers, which are
tracked separately. Don't clobber them.

Change-Id: Ib558345758b5a4fd89c7ff8a3fe08087059add21
Reviewed-on: https://go-review.googlesource.com/c/go/+/310329
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16 20:56:09 +00:00
Cherry Zhang
4fb74e0555 reflect: preserve ctxt across moveMakeFuncArgPtrs
In makeFuncStub and methodValueCall, it stores ctxt (DX) as an
argument of moveMakeFuncArgPtrs, and assumes it does not change
by the call. This is not guaranteed, and it does happen if
-clobberdead compiler flag is used. Store it somewhere else and
reload after the call.

Change-Id: I9307e3cf94db4b38305ab35494088386dfcbaae8
Reviewed-on: https://go-review.googlesource.com/c/go/+/310409
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16 20:18:11 +00:00
David Chase
b6e1c33603 cmd/compile: spill all the parameters around morestack
former code only spilled those parameters mentioned in code
AT THE REGISTER LEVEL, this caused problems with liveness
sometimes (which worked on whole variables including
aggregates).

Updates #40724.

Change-Id: Ib9fdc50d95d1d2b1f1e405dd370540e88582ac71
Reviewed-on: https://go-review.googlesource.com/c/go/+/310690
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 20:12:20 +00:00
Hilko Bengen
fff236e659 net/http/fcgi: eliminate race, keep request id until end of stdin
There was a race condition that could lead to child.serveRequest
removing the request ID before child.handleRequest had read the empty
FCGI_STDIN message that indicates end-of-stream which in turn could
lead to child.serveRequest blocking while trying to consume the
request body.

Now, we remove the request ID from within child.handleRequest after
the end of stdin has been detected, eliminating the race condition.

Since there are no more concurrent modifications/accesses
to child.requests, we remove the accompanying sync.Mutex.

Change-Id: I80c68e65904a988dfa9e3cceec1829496628ff34
GitHub-Last-Rev: b3976111ae
GitHub-Pull-Request: golang/go#42840
Reviewed-on: https://go-review.googlesource.com/c/go/+/273366
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-04-16 19:34:33 +00:00
Johan Brandhorst
ef57834360 crypto/tls: fix flaky handshake cancellation tests
Simplified both tests significantly by removing logic for writing
the client/server side messages. The flake was likely because of a
race between the closing of the local pipe from inside the test
and closing of the pipe from within the handshakeContext goroutine.
Wait to close the local pipe in the test until after the test
has finished running.

Fixes #45106
Fixes #45299

Change-Id: If7ca75aeff7df70cda03c934fa9d8513276d465d
Reviewed-on: https://go-review.googlesource.com/c/go/+/305250
Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-04-16 19:23:29 +00:00
Russ Cox
dba89283ad cmd/go, go/build: add ToolTags to build.Default
The build.Default context really needs to accurately describe
the default build context. The goexperiment tags being a special
case in the go command violates that rule and is the root cause
of the various try-bot failures blocking the enabling of regabi.

(The cleanups I made in golang.org/x/tools were long overdue
but are not strictly necessary for making regabi work; this CL is.)

Having moved the GOEXPERIMENT parsing into internal/buildcfg,
go/build can now use it to set up build.Default, in the new field
ToolTags, meant to hold toolchain-determined tags (for now,
just the experiments). And at the same time we can remove the
duplication of GOOS and GOARCH defaults.

And then once build.Default is set up accurately, the special case
code in cmd/go itself can be removed, and the special case code
in test/run.go is at least a bit less special.

Change-Id: Ib7394e10aa018e492cb9a83fb8fb9a5011a8c25b
Reviewed-on: https://go-review.googlesource.com/c/go/+/310732
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2021-04-16 19:21:48 +00:00
Russ Cox
95ed5c3800 internal/buildcfg: move build configuration out of cmd/internal/objabi
The go/build package needs access to this configuration,
so move it into a new package available to the standard library.

Change-Id: I868a94148b52350c76116451f4ad9191246adcff
Reviewed-on: https://go-review.googlesource.com/c/go/+/310731
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-16 19:20:53 +00:00
Bryan C. Mills
2fc0ebb623 cmd/go/internal/modload: when outside a module, set cfg.BuildMod based on allowMissingModuleImports
For #36460

Change-Id: I50c7018a6841bba1a8c6f8f8eca150df1f685526
Reviewed-on: https://go-review.googlesource.com/c/go/+/310789
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-16 19:01:31 +00:00
HowJMay
c1e8a9a8c6 net/http/cgi: Remove hard-coded ServeHTTP timeout
Close #43624

Change-Id: Ifaea3d8ec2aeabbd923abf5edd7497172dbf855a
GitHub-Last-Rev: ea3ef953a1
GitHub-Pull-Request: golang/go#43803
Reviewed-on: https://go-review.googlesource.com/c/go/+/284778
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Trust: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-16 18:46:27 +00:00
Jay Conrod
492eb059f9 cmd/go: fix mod_install_pkg_version
mainPackagesOnly now includes non-main packages matched by literal
arguments in the returned slice, since their errors must be reported.

GoFilesPackages attaches the same error to its package if
opts.MainOnly is true. This changes the error output of 'go run'
slightly, but it seems like an imporovement.

For #42088

Change-Id: I8f2942470383af5d4c9763022bc94338f5314b07
Reviewed-on: https://go-review.googlesource.com/c/go/+/310829
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-16 18:29:56 +00:00
Austin Clements
60abe01321 cmd/link: fix file-local checks in xcoff
The xcoff writer has several "ldr.SymVersion(s) != 0" checks. The
intent of these is to check for file-local (or static) symbols. Prior
to the introduction of symbol ABIs, this was indeed equivalent since
only file-local symbols has non-zero versions, but ABIs also use the
symbol version space. This still happened to work until much more
recently because we were only ever cgo-exporting version 0 symbols,
but CL 309341 changed this, causing these checks to fail on symbols
that were okay to export.

Replace these checks with ldr.IsFileLocal(s).

This should fix the AIX builder.

(Originally based on CL 309772.)

Fixes #45553.
Updates #40724.

Change-Id: I0a3a7f621ad8f9fe078d34e667286275257691ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/310729
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 17:19:08 +00:00
ian woolf
acb189ea59 net/http: make ReadRequest return an error when requests have multiple Host headers
Fixes #45513

Change-Id: I59e717a4bbd3e71320deff519e4f9587ee5c8756
Reviewed-on: https://go-review.googlesource.com/c/go/+/308952
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-04-16 16:40:34 +00:00
Peng Gao
2f0e5bf907 net/http: using errors.Is in fs error detection
Compare error by errors.Is to detect wrapped fs errors.

Fixes #44923

Change-Id: Idf32b96a661728278b7006c3b3bcc581b8588259
GitHub-Last-Rev: dba01ddae0
GitHub-Pull-Request: golang/go#45314
Reviewed-on: https://go-review.googlesource.com/c/go/+/306051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-16 16:36:57 +00:00
Cherry Zhang
abbb82957d cmd/compile: don't insert VarDef for already-initialized results
Currently, when we about to emit code that sets the function
results and returns, it emits a VarDef. But in some cases, the
result node is actually live and holding useful data. VarDef
means that we are about to (re)initialize it so all previous
data are dead, but that is not true. Don't insert that.

Also don't add VarDef for register results. We are not going to
store anything (currently it doesn't cause problem, just
unnecessary).

Change-Id: I9dd3b70b4a3f5035af028b143fde8fafa2f11fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310589
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16 16:36:45 +00:00
Jay Conrod
04e1176fd2 cmd/go: support 'go run cmd@version'
'go run' can now build a command at a specific version in module-aware
mode, ignoring the go.mod file in the current directory if there is one.

For #42088

Change-Id: I0bd9bcbe40c0442a268cd1cc315a8a2cbb5adeee
Reviewed-on: https://go-review.googlesource.com/c/go/+/310074
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-16 16:11:09 +00:00
Austin Clements
639cb1b629 runtime: mark stdcallN functions cgo_unsafe_args
These functions take the address of an argument and expect to be able
to reach later arguments from that pointer. This means they must be
laid out sequentially in memory (using ABI0) and all arguments must be
live even though they don't all appear to be referenced. This is
exactly what go:cgo_unsafe_args does.

Without this, GOEXPERIMENT=regabi,regabiargs on windows/amd64 crashes
on runtime startup because the stdcall functions are called with their
arguments in registers, so taking the address of one of them has no
bearing on the memory locations of the following arguments.

With this, GOEXPERIMENT=regabi,regabiargs on windows/amd64 passes
all.bash.

For #40724.

Change-Id: I4a4d6a913f85799b43f61c234d21ebb113a9b527
Reviewed-on: https://go-review.googlesource.com/c/go/+/310733
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 16:09:59 +00:00
Jay Conrod
0613c748e8 cmd/go: move 'go install cmd@version' code into internal/load
'go run cmd@version' will use the same code.

This changes error messages a bit.

For #42088

Change-Id: Iaed3997a3d27f9fc0e868013ab765f1fb638a0b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/310410
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-16 14:15:49 +00:00
Jay Conrod
dc76c47565 cmd/go/internal/load: convert two global flags to an options struct
PackageOpts is a new struct type accepted by package loading
functions. It initially has two fields: IgnoreImports, and
ModResolveTests. Previously, these were global variables set by
clients. We'll add more to this in the future.

For #40775

Change-Id: I6956e56502de836d3815ce788bdf16fc5f3e5338
Reviewed-on: https://go-review.googlesource.com/c/go/+/310669
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-16 14:15:42 +00:00
Tobias Klauser
c692f752b5 cmd/link/internal/ld: re-enable tests on darwin
It looks like these are fixed again for darwin on current tip after CL
111258 marked them to be skipped.

Updates #23168

Change-Id: I4abecee1152ccd4f2d44d76d1acdecb0d6140981
Reviewed-on: https://go-review.googlesource.com/c/go/+/308994
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16 12:28:49 +00:00
Tobias Klauser
e1f4feb3d6 cmd/link/internal/ld: fix GOARCH in TestAbstractOriginSanityIssue25459
There is no x86 GOARCH, this should likely be 386.

Change-Id: I16f1cf5edb0cce156d42ecb621b2ae481c8f1789
Reviewed-on: https://go-review.googlesource.com/c/go/+/308995
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16 12:28:37 +00:00
Austin Clements
d26fc68aa1 cmd/internal/objabi,test: use correct GOEXPERIMENT build tags in test/run.go
Currently, run.go sets GOEXPERIMENT build tags based on the
*difference* from the baseline experiment configuration, rather than
the absolute experiment configuration. This differs from cmd/go. As a
result, if we set a baseline configuration and don't override it with
a GOEXPERIMENT setting, run.go won't set any GOEXPERIMENT build tags,
instead of setting the tags corresponding to the baseline
configuration.

Fix this by making compile -V=goexperiment produce the full
GOEXPERIMENT configuration, which run.go can then use to set exactly
the right set of build tags.

For #40724.

Change-Id: Ieda6ea62f1a1fabbe8d749d6d09c198fd5ca8377
Reviewed-on: https://go-review.googlesource.com/c/go/+/310171
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 03:16:55 +00:00
Austin Clements
cf2396c70e internal/goexperiment: move baseline configuration to objabi
We need to adjust baseline experiment configuration based on the
configured GOOS and GOARCH, so it can't live in goexperiment. Move it
to objabi.

Change-Id: I65f4ce56902c6c1a82735050773c58f2d1320cc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/310169
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-04-16 03:16:11 +00:00
Joshua Harshman
f08c552dab net/http: add to deadlines only when positive
The existing implementation allows read / write deadlines to exist
in the past. This updates conditionals to only add to the deadline
when the value is positive.

Fixes: #39177
Change-Id: I841c30ba2849a337e7bc98c8aa136c4527c314ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/235437
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Damien Neil <dneil@google.com>
2021-04-16 01:54:27 +00:00
Austin Clements
bdddfd10ec runtime: improve synchronization in TestFinalizerRegisterABI
Replace busy-wait with a channel.

Change-Id: I51ddfd5dbde15fff56c62c618570e66930902cbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/310630
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-16 00:01:58 +00:00
Paul E. Murphy
c8fb0ec5a0 cmd/compile: fix ANDI/SRWI merge on ppc64
The shift amount should be masked to avoid rotation values
beyond the numer of bits. In this case, if the shift amount
is 0, it should rotate 0, not 32.

Fixes #45589

Change-Id: I1e764497a39d0ec128e29af42352b70c70b2ecc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/310569
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-15 21:57:02 +00:00
Aofei Sheng
699a7c0fe9 cmd/go/internal/modconv: involve GOPROXY in ConvertLegacyConfig
Fixes #33767

Change-Id: Ia2d6dd32bcb0e142f59346232b3b1aa3babb034a
Reviewed-on: https://go-review.googlesource.com/c/go/+/306809
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Aofei Sheng <aofei@aofeisheng.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-15 20:13:20 +00:00
Robert Griesemer
7ed6d1f2fb cmd/compile/internal/types2: add sizeof test
Change-Id: I75d3c8546b7ad51d8c7369e7289036b697d6b913
Reviewed-on: https://go-review.googlesource.com/c/go/+/310530
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-15 19:41:39 +00:00
Robert Griesemer
a63ff398d5 cmd/compile/internal/syntax: fix error message for ... without type
Only complain about missing type; leave it to type-checking
to decide whether "..." is permitted in the first place.

Fixes #43674.

Change-Id: Icbc8f084e364fe3ac16076406a134354219c08d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310209
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>
2021-04-15 19:41:38 +00:00
Paul E. Murphy
ddd8d7c0a6 cmd/internal/obj: consolidate AMOVW and AMOVWZ optab entries
This requires consolidating the register move operations into a
single case entry in asmout.  These moves are also used to
sign/zero-extend register values.

Combine the three asmout cases for register moves.  This allows
AMOVWZ and AMOVW to be handled with the same optab entries.

Likewise, remove the diagnostic error for non-zero constant
loads into R0 using the register move operations, it is not
possible to match this asmout case with a non-zero constant.

Finally, fix the load constant 0 via "MOV[BHW]{,Z} $0, Rx".
These now generate "li Rx, $0" instead of a zero/sign-extend
of the contents of R0.

Change-Id: Ia4a263661582f10feda27ee21cb121e05ea931dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/308190
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-15 18:21:15 +00:00
Lynn Boger
8009a81f7a bytes: add asm implementation for index on ppc64x
This adds an asm implementation of index on ppc64le and
ppc64. It results in a significant improvement in some
of the benchmarks that use bytes.Index.

The implementation is based on a port of the s390x asm
implementation. Comments on the design are found
with the code.

The following improvements occurred on power8:

Index/10       70.7ns ± 0%    18.8ns ± 0%   -73.4
Index/32        165ns ± 0%      95ns ± 0%   -42.6
Index/4K       9.23µs ± 0%    4.91µs ± 0%   -46
Index/4M       9.52ms ± 0%    5.10ms ± 0%   -46.4
Index/64M       155ms ± 0%      85ms ± 0%   -45.1

Count/10       83.0ns ± 0%    32.1ns ± 0%   -61.3
Count/32        178ns ± 0%     109ns ± 0%   -38.8
Count/4K       9.24µs ± 0%    4.93µs ± 0%   -46
Count/4M       9.52ms ± 0%    5.10ms ± 0%   -46.4
Count/64M       155ms ± 0%      85ms ± 0%   -45.1

IndexHard1     2.36ms ± 0%    0.13ms ± 0%   -94.4
IndexHard2     2.36ms ± 0%    1.28ms ± 0%   -45.8
IndexHard3     2.36ms ± 0%    1.19ms ± 0%   -49.4
IndexHard4     2.36ms ± 0%    2.35ms ± 0%    -0.1

CountHard1     2.36ms ± 0%    0.13ms ± 0%   -94.4
CountHard2     2.36ms ± 0%    1.28ms ± 0%   -45.8
CountHard3     2.36ms ± 0%    1.19ms ± 0%   -49.4

IndexPeriodic/IndexPeriodic2  146µs ± 0%       8µs ± 0%   -94
IndexPeriodic/IndexPeriodic4  146µs ± 0%       8µs ± 0%   -94

Change-Id: I7dd2bb7e278726e27f51825ca8b2f8317d460e60
Reviewed-on: https://go-review.googlesource.com/c/go/+/309730
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-04-15 17:32:04 +00:00
Michael Fraenkel
5631c4b3bf net/http: allow multiple dials in TestTransportMaxConnsPerHost
If there is more than the expected single dial, the channel will block.
Allow at least one connection per client, and do the expected cleanup.

Updates #45570

Change-Id: Iaecd45298a7d7c591b7d7b1be13cea6e4a1e2e85
Reviewed-on: https://go-review.googlesource.com/c/go/+/310213
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-15 16:09:16 +00:00
Austin Clements
1d20a362d0 math: avoid assembly stubs
Currently almost all math functions have the following pattern:

func Sin(x float64) float64

func sin(x float64) float64 {
    // ... pure Go implementation ...
}

Architectures that implement a function in assembly provide the
assembly implementation directly as the exported function (e.g., Sin),
and architectures that don't implement it in assembly use a small stub
to jump back to the Go code, like:

TEXT ·Sin(SB), NOSPLIT, $0
	JMP ·sin(SB)

However, most functions are not implemented in assembly on most
architectures, so this jump through assembly is a waste. It defeats
compiler optimizations like inlining. And, with regabi, it actually
adds a small but non-trivial overhead because the jump from assembly
back to Go must go through an ABI0->ABIInternal bridge function.

Hence, this CL reorganizes this structure across the entire package.
It now leans on inlining to achieve peak performance, but allows the
compiler to see all the way through the pure Go implementation.

Now, functions follow this pattern:

func Sin(x float64) float64 {
	if haveArchSin {
		return archSin(x)
	}
	return sin(x)
}

func sin(x float64) float64 {
    // ... pure Go implementation ...
}

Architectures that have assembly implementations use build-tagged
files to set haveArchX to true an provide an archX implementation.
That implementation can also still call back into the Go
implementation (some of them do this).

Prior to this change, enabling ABI wrappers results in a geomean
slowdown of the math benchmarks of 8.77% (full results:
https://perf.golang.org/search?q=upload:20210415.6) and of the Tile38
benchmarks by ~4%. After this change, enabling ABI wrappers is
completely performance-neutral on Tile38 and all but one math
benchmark (full results:
https://perf.golang.org/search?q=upload:20210415.7). ABI wrappers slow
down SqrtIndirectLatency-12 by 2.09%, which makes sense because that
call must still go through an ABI wrapper.

With ABI wrappers disabled (which won't be an option on amd64 much
longer), on linux/amd64, this change is largely performance-neutral
and slightly improves the performance of a few benchmarks:

(Because there are so many benchmarks, I've applied the Šidák
correction to the alpha threshold. It makes relatively little
difference in which benchmarks are statistically significant.)

name                    old time/op  new time/op  delta
Acos-12                 22.3ns ± 0%  18.8ns ± 1%  -15.44%  (p=0.000 n=18+16)
Acosh-12                28.2ns ± 0%  28.2ns ± 0%     ~     (p=0.404 n=18+20)
Asin-12                 18.1ns ± 0%  18.2ns ± 0%   +0.20%  (p=0.000 n=18+16)
Asinh-12                32.8ns ± 0%  32.9ns ± 1%     ~     (p=0.891 n=18+20)
Atan-12                 9.92ns ± 0%  9.90ns ± 1%   -0.24%  (p=0.000 n=17+16)
Atanh-12                27.7ns ± 0%  27.5ns ± 0%   -0.72%  (p=0.000 n=16+20)
Atan2-12                18.5ns ± 0%  18.4ns ± 0%   -0.59%  (p=0.000 n=19+19)
Cbrt-12                 22.1ns ± 0%  22.1ns ± 0%     ~     (p=0.804 n=16+17)
Ceil-12                 0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.663 n=18+16)
Copysign-12             0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.762 n=16+19)
Cos-12                  12.7ns ± 0%  12.7ns ± 1%     ~     (p=0.145 n=19+18)
Cosh-12                 22.2ns ± 0%  22.5ns ± 0%   +1.60%  (p=0.000 n=17+19)
Erf-12                  11.1ns ± 1%  11.1ns ± 1%     ~     (p=0.010 n=19+19)
Erfc-12                 12.6ns ± 1%  12.7ns ± 0%     ~     (p=0.066 n=19+15)
Erfinv-12               16.1ns ± 0%  16.1ns ± 0%     ~     (p=0.462 n=17+20)
Erfcinv-12              16.0ns ± 1%  16.0ns ± 1%     ~     (p=0.015 n=17+16)
Exp-12                  16.3ns ± 0%  16.5ns ± 1%   +1.25%  (p=0.000 n=19+16)
ExpGo-12                36.2ns ± 1%  36.1ns ± 1%     ~     (p=0.242 n=20+18)
Expm1-12                18.6ns ± 0%  18.7ns ± 0%   +0.25%  (p=0.000 n=16+19)
Exp2-12                 34.7ns ± 0%  34.6ns ± 1%     ~     (p=0.010 n=19+18)
Exp2Go-12               34.8ns ± 1%  34.8ns ± 1%     ~     (p=0.372 n=19+19)
Abs-12                  0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.766 n=18+16)
Dim-12                  0.84ns ± 1%  0.84ns ± 1%     ~     (p=0.167 n=17+19)
Floor-12                0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.993 n=18+16)
Max-12                  3.35ns ± 0%  3.35ns ± 0%     ~     (p=0.894 n=17+19)
Min-12                  3.35ns ± 0%  3.36ns ± 1%     ~     (p=0.214 n=18+18)
Mod-12                  35.2ns ± 0%  34.7ns ± 0%   -1.45%  (p=0.000 n=18+17)
Frexp-12                5.31ns ± 0%  4.75ns ± 0%  -10.51%  (p=0.000 n=19+18)
Gamma-12                14.8ns ± 0%  16.2ns ± 1%   +9.21%  (p=0.000 n=20+19)
Hypot-12                6.16ns ± 0%  6.17ns ± 0%   +0.26%  (p=0.000 n=19+20)
HypotGo-12              7.79ns ± 1%  7.78ns ± 0%     ~     (p=0.497 n=18+17)
Ilogb-12                4.47ns ± 0%  4.47ns ± 0%     ~     (p=0.167 n=19+19)
J0-12                   76.0ns ± 0%  76.3ns ± 0%   +0.35%  (p=0.000 n=19+18)
J1-12                   76.8ns ± 1%  75.9ns ± 0%   -1.14%  (p=0.000 n=18+18)
Jn-12                    167ns ± 1%   168ns ± 1%     ~     (p=0.038 n=18+18)
Ldexp-12                6.98ns ± 0%  6.43ns ± 0%   -7.97%  (p=0.000 n=17+18)
Lgamma-12               15.9ns ± 0%  16.0ns ± 1%     ~     (p=0.011 n=20+17)
Log-12                  13.3ns ± 0%  13.4ns ± 1%   +0.37%  (p=0.000 n=15+18)
Logb-12                 4.75ns ± 0%  4.75ns ± 0%     ~     (p=0.831 n=16+18)
Log1p-12                19.5ns ± 0%  19.5ns ± 1%     ~     (p=0.851 n=18+17)
Log10-12                15.9ns ± 0%  14.0ns ± 0%  -11.92%  (p=0.000 n=17+16)
Log2-12                 7.88ns ± 1%  8.01ns ± 0%   +1.72%  (p=0.000 n=20+20)
Modf-12                 4.75ns ± 0%  4.34ns ± 0%   -8.66%  (p=0.000 n=19+17)
Nextafter32-12          5.31ns ± 0%  5.31ns ± 0%     ~     (p=0.389 n=17+18)
Nextafter64-12          5.03ns ± 1%  5.03ns ± 0%     ~     (p=0.774 n=17+18)
PowInt-12               29.9ns ± 0%  28.5ns ± 0%   -4.69%  (p=0.000 n=18+19)
PowFrac-12              91.0ns ± 0%  91.1ns ± 0%     ~     (p=0.029 n=19+19)
Pow10Pos-12             1.12ns ± 0%  1.12ns ± 0%     ~     (p=0.363 n=20+20)
Pow10Neg-12             3.90ns ± 0%  3.90ns ± 0%     ~     (p=0.921 n=17+18)
Round-12                2.31ns ± 0%  2.31ns ± 1%     ~     (p=0.390 n=18+18)
RoundToEven-12          0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.280 n=18+19)
Remainder-12            31.6ns ± 0%  29.6ns ± 0%   -6.16%  (p=0.000 n=18+17)
Signbit-12              0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.385 n=19+18)
Sin-12                  12.5ns ± 0%  12.5ns ± 0%     ~     (p=0.080 n=18+18)
Sincos-12               16.4ns ± 2%  16.4ns ± 2%     ~     (p=0.253 n=20+19)
Sinh-12                 26.1ns ± 0%  26.1ns ± 0%   +0.18%  (p=0.000 n=17+19)
SqrtIndirect-12         3.91ns ± 0%  3.90ns ± 0%     ~     (p=0.133 n=19+19)
SqrtLatency-12          2.79ns ± 0%  2.79ns ± 0%     ~     (p=0.226 n=16+19)
SqrtIndirectLatency-12  6.68ns ± 0%  6.37ns ± 2%   -4.66%  (p=0.000 n=17+20)
SqrtGoLatency-12        49.4ns ± 0%  49.4ns ± 0%     ~     (p=0.289 n=18+16)
SqrtPrime-12            3.18µs ± 0%  3.18µs ± 0%     ~     (p=0.084 n=17+18)
Tan-12                  13.8ns ± 0%  13.9ns ± 2%     ~     (p=0.292 n=19+20)
Tanh-12                 25.4ns ± 0%  25.4ns ± 0%     ~     (p=0.101 n=17+17)
Trunc-12                0.84ns ± 0%  0.84ns ± 0%     ~     (p=0.765 n=18+16)
Y0-12                   75.8ns ± 0%  75.9ns ± 1%     ~     (p=0.805 n=16+18)
Y1-12                   76.3ns ± 0%  75.3ns ± 1%   -1.34%  (p=0.000 n=19+17)
Yn-12                    164ns ± 0%   164ns ± 2%     ~     (p=0.356 n=18+20)
Float64bits-12          0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.383 n=18+18)
Float64frombits-12      0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.066 n=18+19)
Float32bits-12          0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.889 n=16+19)
Float32frombits-12      0.56ns ± 0%  0.56ns ± 0%     ~     (p=0.007 n=18+19)
FMA-12                  23.9ns ± 0%  24.0ns ± 0%   +0.31%  (p=0.000 n=16+17)
[Geo mean]              9.86ns       9.77ns        -0.87%

(https://perf.golang.org/search?q=upload:20210415.5)

For #40724.

Change-Id: I44fbba2a17be930ec9daeb0a8222f55cd50555a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310331
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-15 15:48:19 +00:00
Paul E. Murphy
31e12b953a cmd/link: issue error if elf header overruns
This is probably unlikely in practice, but when debugging alignment
related issues on ppc64 using very small text section splits, the elf
header could grow beyond the preallocated space and quietly stomp
on the first few text sections.

Change-Id: Ided58aa0b1e60f9da4b3cb277e4ebafcee4ec693
Reviewed-on: https://go-review.googlesource.com/c/go/+/307430
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-04-15 14:58:38 +00:00
Austin Clements
7ad496b6f5 runtime: unify C->Go ABI transitions
The previous CL introduced macros for transitions from the Windows ABI
to the Go ABI. This CL does the same for SysV and uses them in almost
all places where we transition from the C ABI to the Go ABI.

Compared to Windows, this transition is much simpler and I didn't find
any places that were getting it wrong. But this does let us unify a
lot of code nicely and introduces some degree of abstraction around
these ABI transitions.

Change-Id: Ib6bdecafce587ce18fca4c8300fcf401284a2bcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/309930
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-15 12:38:13 +00:00
Austin Clements
dba2eab826 runtime,runtime/cgo: save all necessary registers on entry to Go on Windows
There are several assembly functions that transition from the Windows
ABI to the Go ABI. These all need to save all registers that are
callee-save in the Windows ABI and caller-save in the Go ABI and
prepare the register state for Go. However, they all do this slightly
differently and most of them don't save the necessary XMM registers
for this transition (which could corrupt them in the C caller).
Furthermore, now that we have a carefully specified Go ABI, it's clear
that none of these actually get all of the details 100% right.

So, unify this code into two macros in a shared header in
runtime/cgo/abi_amd64.h that handle all necessary registers and setup
and use these macros everywhere on Windows that handles transitions
from C to Go.

Change-Id: I62f41345a507aad1ca383814ac8b7e2a9ffb821e
Reviewed-on: https://go-review.googlesource.com/c/go/+/309769
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-15 12:38:11 +00:00
Austin Clements
3e0b1cdb5d runtime: minor refactoring of _rt0_amd64_lib
This function bounces between the C and Go ABIs a few times. This CL
narrows the scope of the Go -> C transition to just around the branch
that calls C. This lets us take advantage of C callee-save registers
to simplify the code a little.

Change-Id: I1ffa0b9e50325425c5ec66596978aeb6450a6b57
Reviewed-on: https://go-review.googlesource.com/c/go/+/309929
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-15 12:38:09 +00:00
Tobias Klauser
b1c4cc5589 mime: keep builtinTypesLower sorted alphabetically
Updates #44602

Change-Id: I2c32e388143e56928850821587f57d9729434220
Reviewed-on: https://go-review.googlesource.com/c/go/+/310034
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-15 10:21:10 +00:00
Rémy Oudompheng
61a08fc6ce strconv: Implement Ryū algorithm for ftoa shortest mode
This patch implements the algorithm from Ulf Adams,
"Ryū: Fast Float-to-String Conversion" (doi:10.1145/3192366.3192369)
for formatting floating-point numbers with a fixed number of decimal
digits.

It is not a direct translation of the reference C implementation
but still follows the original paper. In particular, it uses full
128-bit powers of 10, which allows for more precision in the other
modes (fixed ftoa, atof).

name                              old time/op  new time/op   delta
AppendFloat/Decimal-4             49.6ns ± 3%   59.3ns ± 0%  +19.59%  (p=0.008 n=5+5)
AppendFloat/Float-4                122ns ± 1%     91ns ± 1%  -25.92%  (p=0.008 n=5+5)
AppendFloat/Exp-4                 89.3ns ± 1%  100.0ns ± 1%  +11.98%  (p=0.008 n=5+5)
AppendFloat/NegExp-4              88.3ns ± 2%   97.1ns ± 1%   +9.87%  (p=0.008 n=5+5)
AppendFloat/LongExp-4              143ns ± 2%    103ns ± 0%  -28.17%  (p=0.016 n=5+4)
AppendFloat/Big-4                  144ns ± 1%    110ns ± 1%  -23.26%  (p=0.008 n=5+5)
AppendFloat/BinaryExp-4           46.2ns ± 2%   46.0ns ± 1%     ~     (p=0.603 n=5+5)
AppendFloat/32Integer-4           49.1ns ± 1%   58.7ns ± 1%  +19.57%  (p=0.008 n=5+5)
AppendFloat/32ExactFraction-4     95.6ns ± 1%   88.6ns ± 1%   -7.30%  (p=0.008 n=5+5)
AppendFloat/32Point-4              122ns ± 1%     87ns ± 1%  -28.63%  (p=0.008 n=5+5)
AppendFloat/32Exp-4               88.6ns ± 2%   95.0ns ± 1%   +7.29%  (p=0.008 n=5+5)
AppendFloat/32NegExp-4            87.2ns ± 1%   91.3ns ± 1%   +4.63%  (p=0.008 n=5+5)
AppendFloat/32Shortest-4           107ns ± 1%     82ns ± 0%  -24.08%  (p=0.008 n=5+5)
AppendFloat/Slowpath64-4          1.00µs ± 1%   0.10µs ± 0%  -89.92%  (p=0.016 n=5+4)
AppendFloat/SlowpathDenormal64-4  34.1µs ± 3%    0.1µs ± 1%  -99.72%  (p=0.008 n=5+5)

Fixes #15672

Change-Id: Ib90dfa245f62490a6666671896013cf3f9a1fb22
Reviewed-on: https://go-review.googlesource.com/c/go/+/170080
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2021-04-15 09:18:03 +00:00
Rémy Oudompheng
0184b445c0 strconv: implement Ryū-like algorithm for fixed precision ftoa
This patch implements a simplified version of Ulf Adams,
"Ryū: Fast Float-to-String Conversion" (doi:10.1145/3192366.3192369)
for formatting floating-point numbers with a fixed number of decimal
digits.

It uses the same principles but does not need to handle
the complex task of finding a shortest representation.
This allows to handle a few more cases than Grisu3, notably
formatting with up to 18 significant digits.

name                         old time/op  new time/op  delta
AppendFloat/32Fixed8Hard-4   72.0ns ± 2%  56.0ns ± 2%  -22.28%  (p=0.000 n=10+10)
AppendFloat/32Fixed9Hard-4   74.8ns ± 0%  64.2ns ± 2%  -14.16%  (p=0.000 n=8+10)
AppendFloat/64Fixed1-4       60.4ns ± 1%  54.2ns ± 1%  -10.31%  (p=0.000 n=10+9)
AppendFloat/64Fixed2-4       66.3ns ± 1%  53.3ns ± 1%  -19.54%  (p=0.000 n=10+9)
AppendFloat/64Fixed3-4       61.0ns ± 1%  55.0ns ± 2%   -9.80%  (p=0.000 n=9+10)
AppendFloat/64Fixed4-4       66.9ns ± 0%  52.0ns ± 2%  -22.20%  (p=0.000 n=8+10)
AppendFloat/64Fixed12-4      95.5ns ± 1%  76.2ns ± 3%  -20.19%  (p=0.000 n=10+9)
AppendFloat/64Fixed16-4      1.62µs ± 0%  0.07µs ± 2%  -95.69%  (p=0.000 n=10+10)
AppendFloat/64Fixed12Hard-4  1.27µs ± 1%  0.07µs ± 1%  -94.83%  (p=0.000 n=9+9)
AppendFloat/64Fixed17Hard-4  3.68µs ± 1%  0.08µs ± 2%  -97.86%  (p=0.000 n=10+9)
AppendFloat/64Fixed18Hard-4  3.67µs ± 0%  3.72µs ± 1%   +1.44%  (p=0.000 n=9+10)

Updates #15672

Change-Id: I160963e141dd48287ad8cf57bcc3c686277788e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/170079
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Nigel Tao <nigeltao@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-15 08:44:21 +00:00
Austin Clements
8f4c5068e0 internal/bytealg: port more performance-critical functions to ABIInternal
CL 308931 ported several runtime assembly functions to ABIInternal so
that compiler-generated ABIInternal calls don't go through ABI
wrappers, but it missed the runtime assembly functions that are
actually defined in internal/bytealg.

This eliminates the cost of wrappers for the BleveQuery and
GopherLuaKNucleotide benchmarks, but there's still more to do for
Tile38.

                                      0-base                1-wrappers
                                     sec/op        sec/op            vs base
BleveQuery                          6.507 ± 0%    6.477 ± 0%  -0.46% (p=0.004 n=20)
GopherLuaKNucleotide                30.39 ± 1%    30.34 ± 0%       ~ (p=0.301 n=20)
Tile38IntersectsCircle100kmRequest 1.038m ± 1%   1.080m ± 2%  +4.03% (p=0.000 n=20)

For #40724.

Change-Id: I0b722443f684fcb997b1d70802c5ed4b8d8f9829
Reviewed-on: https://go-review.googlesource.com/c/go/+/310184
Trust: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-15 04:10:33 +00:00
eric fang
48b7432e3f cmd/internal/obj/arm64: fix the wrong sp dst register of ADDS/SUBS instructions
According the armv8-a specification, the destination register of the ADDS/ADDSW/
SUBS/SUBSW instructions can not be RSP, the current implementation does not
check this and encodes this wrong instruction format as a CMN instruction. This
CL adds a check and test cases for this situation.

Change-Id: I92cc2f8e17dbda70f0dce8fddf1ca6d5d7730589
Reviewed-on: https://go-review.googlesource.com/c/go/+/309989
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-15 01:54:41 +00:00
Damien Neil
566a87c16b time: add missing "os" import to zoneinfo_test.go
Updates #45448

Change-Id: I2e79ae6b9cf43a481aa703578712619ea344e421
Reviewed-on: https://go-review.googlesource.com/c/go/+/310212
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-15 00:40:43 +00:00
Keith Randall
083a26c7d2 cmd/compile: propagate pragmas from generic function to stenciled implementation
Change-Id: I28a1910890659aaa449ffd2a847cd4ced5a8600d
Reviewed-on: https://go-review.googlesource.com/c/go/+/310211
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-04-15 00:29:05 +00:00
Dan Scales
bf634c76b2 cmd/compile: look for function in instantiations in all global assignments
Add in some missing global assignment ops to the list of globals ops
that should be traversed to look for generic function instantiations.
The most common other one for global assigments (and the relevant one
for this bug) is OAS2FUNC, but also look at global assigments with
OAS2DOTTYPE, OAS2MAPR, OAS2RECV, and OASOP.

Bonus small fix: get rid of -G=3 case in ir.IsAddressable. Now that we
don't call the old typechecker from noder2, we don't need this -G-3
check anymore.

Fixes #45547.

Change-Id: I75fecec55ea0d6f62e1c2294d4d77447ed9be6ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/310210
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-15 00:14:55 +00:00
Amit Kumar
567a9322ad mime: add mime type for avif image file format
Fixes #44602

Change-Id: I28b6df5e2523fc2ece6fd8251fcabc83c7c38d89
Reviewed-on: https://go-review.googlesource.com/c/go/+/256478
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-14 23:26:26 +00:00
Manlio Perillo
d27bb8ba2e go/build: replace os.Setenv with T.Setenv
Updates #45448

Change-Id: I4d8e5d7e57818355ef2bc33b57ddf9c8b8da3e62
Reviewed-on: https://go-review.googlesource.com/c/go/+/310030
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
2021-04-14 23:26:15 +00:00
Manlio Perillo
f18715c18f time: replace os.Setenv with T.Setenv
Updates #45448

Change-Id: Ic096fe1c58c124fb8d84ee15c9446e7ed060b24f
Reviewed-on: https://go-review.googlesource.com/c/go/+/310032
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
2021-04-14 23:26:02 +00:00
ian woolf
c3931ab1b7 net/http/httptest: panic on non-3 digit (XXX) status code in Recorder.WriteHeader
This change conforms Recorder with net/http servers, to panic
when a handler writes a non-3 digit XXX status code.

Fixes #45353

Change-Id: Id5ed4af652e8c150ae86bf50402b800d935e2203
Reviewed-on: https://go-review.googlesource.com/c/go/+/308950
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
2021-04-14 21:58:06 +00:00
Bryan C. Mills
cbf9caaf22 cmd/go: add a Go source file in TestScript/mod_sumdb
This test expects 'go mod tidy' to fail if the existing module graph
has a bad checksum. However, there is no intrinsic reason why 'go mod
tidy' should fail in that case: the module contains no packages, and
thus no imports, so 'go mod tidy' can justifiably remove all
requirements without regard to any errors that may have already been
present in the module graph.

Adding a source file that imports a package from the module with the
bad checksum should guarantee that 'go mod tidy' reports the checksum
eror.

For #36460

Change-Id: I59734ac524031288bc03a11f58eed5abe2db76b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/309334
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-14 21:50:26 +00:00
Cherry Zhang
23f8c203f0 cmd/compile: rework/reduce partially lived argument spilling
In CL 307909 we generate code that spills pointer-typed argument
registers if it is part of an SSA-able aggregate. The current
code spill the register unconditionally. Sometimes it is
unnecessary, because it is already spilled, or it is never live.

This CL reworks the spill generation. We move it to the end of
compilation, after liveness analysis, so we have information about
if a spill is necessary, and only generate spills for the
necessary ones.

Change-Id: I8d60be9b2c47651aeda14f5e2d1bbd207c134b26
Reviewed-on: https://go-review.googlesource.com/c/go/+/309331
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-14 21:00:20 +00:00
Than McIntosh
1a8f0a7961 runtime: fix data race in abi finalizer test
Fix a buglet in TestFinalizerRegisterABI that was causing problems
when run with GOEXPERIMENT=regabi.

Updates #40724.

Change-Id: I950c4aa3df69eada23e600f01e6804eb136ce806
Reviewed-on: https://go-review.googlesource.com/c/go/+/310077
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-14 19:57:35 +00:00
Michael Anthony Knyszek
a89ace106f runtime: update debug call protocol for register ABI
The debug call tests currently assume that the target Go function is
ABI0; this is clearly no longer true when we switch to the new ABI, so
make the tests set up argument register state in the debug call handler
and copy back results returned in registers.

A small snag in calling a Go function that follows the new ABI is that
the debug call protocol depends on the AX register being set to a
specific value as it bounces in and out of the handler, but this
register is part of the new register ABI, so results end up being
clobbered. Use R12 instead.

Next, the new desugaring behavior for "go" statements means that
newosproc1 must always call a function with no frame; if it takes any
arguments, it closes over them and they're passed in the context
register. Currently when debugCallWrap creates a new goroutine, it uses
newosproc1 directly and passes a non-zero-sized frame, so that needs to
be updated. To fix this, briefly use the g's param field which is
otherwise only used for channels to pass an explicitly allocated object
containing the "closed over" variables. While we could manually do the
desugaring ourselves (we cannot do so automatically because the Go
compiler prevents heap-allocated closures in the runtime), that bakes in
more ABI details in a place that really doesn't need to care about them.

Finally, there's an old bug here where the context register was set up
in CX, so technically closure calls never worked. Oops. It was otherwise
harmless for other types of calls before, but now CX is an argument
register, so now that interferes with regular calls, too.

For #40724.

Change-Id: I652c25ed56a25741bb04c24cfb603063c099edde
Reviewed-on: https://go-review.googlesource.com/c/go/+/309169
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-14 19:54:26 +00:00
Manlio Perillo
de7a87ef06 go/internal/gccgoimporter: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: Ie84795ed456883c0558fa9b5e3f2186f5f2c0fd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/309356
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-14 19:38:50 +00:00
Martin Sucha
d1f8104b58 time: move slim test tzdata to testdata directory
The lines with tzdata are quite long.

It is easier to just copy a file than to encode it as
a string literal when adding a new test case.

Change-Id: Ibcaf347c3101a0f05b094e582b3473c7c35b685a
Reviewed-on: https://go-review.googlesource.com/c/go/+/308998
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-14 19:38:36 +00:00
Manlio Perillo
b161b57c3f go/build: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: Ic2f696837034de17333a6a53127a4bfd301e96a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/309354
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-14 19:38:22 +00:00
Robert Griesemer
892cad7a9b cmd/compile/internal/types2: add Named.SetTParams and Named.Orig methods
Named.SetTParams sets the type parameters for a named type.

Named.Orig returns the original generic type an instantiated
type is derived from. Added a new field orig for that purpose
and renamed the already existing orig field to fromRHS.

Finally, updated various comments.

Change-Id: Ic9d173e42740422d195713d8bdc62a54dc8c5f54
Reviewed-on: https://go-review.googlesource.com/c/go/+/309832
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-14 19:35:43 +00:00
Rob Findley
283f9fdbd3 cmd/dist: add tests using the typeparams build tag
Now that go/ast changes have been guarded behind the typeparams build
tag, we no longer have coverage for tests involving generic code.

Add a new testing step to cmd/dist to run go/... and cmd/gofmt tests
using -tags=typeparams.

Comment out parser object resolution assertions that currently fail, and
which will be fixed by CL 304456.

Fixes #44933

Change-Id: I481dd4246a016f410307865b6c6c2bb3c8e6e3bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/310071
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-14 19:32:56 +00:00
Rob Findley
bcbde83c20 go/ast: fix broken build with typeparams build constraint
My rebase of https://golang.org/cl/300649 before submitting broke the
build (and tests) when using the typeparams build constraint. In a
subsequent CL I add test coverage back to cmd/dist.

This time, I've tested by running:
 - go test -tags=typeparams go/...
 - go test -tags=typeparams cmd/gofmt

All tests pass except for the new TestResolution/typeparams.go2, which I
will fix in a follow-up CL.

For #44933

Change-Id: I439d387841604cf43a90e2ce41dbe6bbbdb0306d
Reviewed-on: https://go-review.googlesource.com/c/go/+/310070
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-14 19:32:31 +00:00
Manlio Perillo
492faaeda8 os/exec: replace os.Setenv with T.Setenv
Updates #45448

Change-Id: I570e9894c4976d0a875388ef9ea4a2aa31b78013
Reviewed-on: https://go-review.googlesource.com/c/go/+/310031
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-14 19:25:38 +00:00
David Chase
4df3d0e4df cmd/compile: rescue stmt boundaries from OpArgXXXReg and OpSelectN.
Fixes this failure:
go test cmd/compile/internal/ssa -run TestStmtLines -v
=== RUN   TestStmtLines
    stmtlines_test.go:115: Saw too many (amd64, > 1%) lines without
    statement marks, total=88263, nostmt=1930
    ('-run TestStmtLines -v' lists failing lines)

The failure has two causes.

One is that the first-line adjuster in code generation was relocating
"first lines" to instructions that would either not have any code generated,
or would have the statment marker removed by a different believed-good heuristic.

The other was that statement boundaries were getting attached to register
values (that with the old ABI were loads from the stack, hence real instructions).
The register values disappear at code generation.

The fixes are to (1) note that certain instructions are not good choices for
"first value" and skip them, and (2) in an expandCalls post-pass, look for
register valued instructions and under appropriate conditions move their
statement marker to a compatible use.

Also updates TestStmtLines to always log the score, for easier comparison of
minor compiler changes.

Updates #40724.

Change-Id: I485573ce900e292d7c44574adb7629cdb4695c3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/309649
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-14 18:46:08 +00:00
Than McIntosh
4480c822ba cmd/internal/obj: don't emit args_stackmap for ABIInternal asm funcs
The compiler currently emits an "*.args_stackmap" symbol for all
bodyless functions, so that asm functions will have the proper stack
map. At the moment the code in the compiler that emits args_stackmap
assumes ABI0; to avoid misleading stackmaps, turn off args_stackmap
generation for non-ABI0 asm functions.

Updates #40724.

Change-Id: Ia5e3528d56da5fb107e799bd658e52496ba4a331
Reviewed-on: https://go-review.googlesource.com/c/go/+/309790
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-14 16:59:24 +00:00
Than McIntosh
25b25a9ed7 cmd/asm: require NOSPLIT for ABIInternal asm functions
Change the assembler to enforce the requirement that ABIInternal
functions need to be NOSPLIT. At the moment all of the assembly
routines in the runtime that are defined as ABIInternal also
happen to be NOSPLIT, but this CL makes it mandatory.

Updates #40724.

Change-Id: Ief80d22de1782edb44b798fcde9aab8a93548722
Reviewed-on: https://go-review.googlesource.com/c/go/+/309789
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-14 16:59:08 +00:00
Cherry Zhang
ef36e4fd0e reflect: keep pointer register results alive in callMethod
When callMethod calls the underlying method, after reflectcall
it gets the result registers in "Ints" slots but not in "Ptrs"
slots. If the GC runs at this point, it may lose track of those
pointers and free the memory they point to.

To make sure the GC sees the pointer results, copy "Ints" to
"Ptrs", and keep them alive until we return to the caller.

This fixes test/fixedbugs/issue27695.go with register ABI.

Change-Id: I4092c91bcbd6954683740a12d91d689900446875
Reviewed-on: https://go-review.googlesource.com/c/go/+/309909
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-14 16:37:06 +00:00
Austin Clements
ad44dfb0fd cmd/go: clarify comment on HashSeed
Change-Id: I3c8769f52b86ca82611af373b0a493a937dda9d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/310090
Trust: Austin Clements <austin@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-14 16:18:34 +00:00
Bryan C. Mills
c98026c104 cmd/go/internal/modload: fix truncated error message from goModDirtyError
The 'go mod tidy' hint was truncated due to a typo in CL 293689,
and that particular case was not covered by any existing test.

Updates #36460
Updates #40775

Change-Id: Ib6fa872a9dfdafc4e9a112e8add2ff5aecd2dbd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310089
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-14 15:02:11 +00:00
Josh Bleecher Snyder
72483de87a runtime: incorporate hbits advancement in scanobject into loop
This makes it clearer that i and hbits advance together.
As a bonus, it generates slightly better code.

Change-Id: I24d51102535c39f962a59c1a4a7c5c894339aa18
Reviewed-on: https://go-review.googlesource.com/c/go/+/309569
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2021-04-14 14:27:05 +00:00
Michael Anthony Knyszek
7ec7a3cf33 runtime: make gcEffectiveGrowthRatio a method on gcControllerState
For #44167.

Change-Id: Ie3cf8d2960c843a782ec85426fa73c279adaed64
Reviewed-on: https://go-review.googlesource.com/c/go/+/306605
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-14 14:04:06 +00:00
Michael Anthony Knyszek
e9cc31e736 runtime: pass work.userForced to gcController.endCycle explicitly
For #44167.

Change-Id: I15817006f1870d6237cd06dabad988da3f23a6d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/306604
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-14 14:03:55 +00:00
Michael Anthony Knyszek
3eaf75c13a runtime: move next_gc and last_next_gc into gcControllerState
This change moves next_gc and last_next_gc into gcControllerState under
the names heapGoal and lastHeapGoal respectively. These are
fundamentally GC pacer related values, and so it makes sense for them to
live here.

Partially generated by

rf '
    ex . {
	memstats.next_gc -> gcController.heapGoal
	memstats.last_next_gc -> gcController.lastHeapGoal
    }
'

except for updates to comments and gcControllerState methods, where
they're accessed through the receiver, and trace-related renames of
NextGC -> HeapGoal, while we're here.

For #44167.

Change-Id: I1e871ad78a57b01be8d9f71bd662530c84853bed
Reviewed-on: https://go-review.googlesource.com/c/go/+/306603
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-14 14:03:30 +00:00
Leonard Wang
e224787fef runtime: fix formatting of gcMark
Change-Id: I08aed75f3aab0da705544665e532f332adfb075e
Reviewed-on: https://go-review.googlesource.com/c/go/+/308949
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Trust: David Chase <drchase@google.com>
2021-04-14 13:21:14 +00:00
Ruslan Andreev
82e4a6310b runtime: move roots' bases calculation to gcMarkRootPrepare
This patch provides changes according to Austin's TODO. It just moves
calculation of base indexes of each root type from markroot function
to gcMarkRootPrepare.

Change-Id: Ib231de34e7f81e922762fc3ee2b1830921c0c7cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/279461
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2021-04-14 13:13:19 +00:00
El Mostafa Idrassi
ab02cbd29f runtime: increase maxargs to avoid syscall18 crash when called with more than 16 args
Fixes #45524

Change-Id: Id867f45ea98689b73d5b1b141c19317bc7608b05
GitHub-Last-Rev: e9b09fb557
GitHub-Pull-Request: golang/go#45531
Reviewed-on: https://go-review.googlesource.com/c/go/+/309390
Reviewed-by: El Mostafa Idrassi <el.mostafa.idrassi@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-14 09:46:36 +00:00
Tobias Klauser
58fdac04e4 syscall: don't defer close raw Socketpair fds in tests
The raw fds are successively wrapped using os.NewFile and will be closed
by (*os.File).Close. Avoids a double close, in the worst case closing an
unrelated fd.

Change-Id: I86aabe5ed865eff43d264ddae1fb07c935868e97
Reviewed-on: https://go-review.googlesource.com/c/go/+/309353
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-14 05:49:15 +00:00
Keith Randall
6d8ba77896 cmd/compile: fix importing of method expressions
For OMETHEXPR, the Name in the Selection needs to be properly
linked up to the method declaration. Use the same code we
already have for ODOTMETH and OCALLPART to do that.

Fixes #45503

Change-Id: I7d6f886d606bae6faad8c104f50c177f871d41c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/309831
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-04-14 04:02:01 +00:00
Michael Anthony Knyszek
e7ab1a5ba8 runtime: create setGCPercent method for gcControllerState
This change breaks out the computations done by setGCPercent into
a method on gcControllerState for easier testing later. It leaves behind
the global implementation details.

For #44167.

Change-Id: I3b0cf1475b032fcd4ebbd01cf4e80de0b55ce7b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/306602
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-14 03:15:34 +00:00
Michael Anthony Knyszek
9bce7b70fd runtime: create initializer for gcControllerState
Now that gcControllerState contains almost all of the pacer state,
create an initializer for it instead of haphazardly setting some fields.

For #44167.

Change-Id: I4ce1d5dd82003cb7c263fa46697851bb22a32544
Reviewed-on: https://go-review.googlesource.com/c/go/+/306601
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-14 03:15:24 +00:00
Michael Anthony Knyszek
2d4ba2601b runtime: move gcPercent and heapMinimum into gcControllerState
These variables are core to the pacer, and will be need to be non-global
for testing later.

Partially generated via

rf '
    ex . {
	gcPercent -> gcController.gcPercent
	heapMinimum -> gcController.heapMinimum
    }
'

The only exception to this generation is usage of these variables
in gcControllerState methods.

For #44167.

Change-Id: I8b620b3061114f3a3c4b65006f715fd977b180a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/306600
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-14 03:15:00 +00:00
Michael Anthony Knyszek
728e3dc6f9 runtime: make gcSetTriggerRatio a method of gcControllerState
gcSetTriggerRatio's purpose is to set a bunch of downstream values when
we choose to commit to a new trigger ratio computed by the gcController.
Now that almost all the inputs it uses to compute the downstream values
are in gcControllerState anyway, make it a method of gcControllerState.

For #44167.

Change-Id: I1b7ea709e8378566f812ae3450ab169d7fb66aea
Reviewed-on: https://go-review.googlesource.com/c/go/+/306599
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-14 03:14:51 +00:00
Dan Scales
eb433ed5a2 cmd/compile: set types properly for imported funcs with closures
For the new export/import of node types, we were just missing setting
the types of the closure variables (which have the same types as the
captured variables) and the OCLOSURE node itself (which has the same
type as the Func node).

Re-enabled inlining of functions with closures.

Change-Id: I687149b061f3ffeec3244ff02dc6e946659077a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/308974
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-04-14 01:28:16 +00:00
Robert Griesemer
8dcc071063 cmd/compile/internal/types2: use a global atomic counter for type parameter ids
This avoids a dependency on a *Checker when we create type parameters
outside the type checker proper, e.g. in an importer. There may be
better solutions but this does the trick for now.

Change-Id: Icf22c934970cb04c88c2729555ae6a79ef5a2245
Reviewed-on: https://go-review.googlesource.com/c/go/+/309830
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-14 00:25:33 +00:00
David Chase
34620364cb runtime, cgo/test: improve debugging output
tests that run commands should log their actions in a
shell-pasteable way.

Change-Id: Ifeee88397047ef5a76925c5f30c213e83e535038
Reviewed-on: https://go-review.googlesource.com/c/go/+/309770
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-13 23:56:27 +00:00
Michael Anthony Knyszek
f2d5bd1ad3 runtime: move internal GC statistics from memstats to gcController
This change moves certain important but internal-only GC statistics from
memstats into gcController. These statistics are mainly used in pacing
the GC, so it makes sense to keep them in the pacer's state.

This CL was mostly generated via

rf '
    ex . {
	memstats.gc_trigger -> gcController.trigger
	memstats.triggerRatio -> gcController.triggerRatio
	memstats.heap_marked -> gcController.heapMarked
	memstats.heap_live -> gcController.heapLive
	memstats.heap_scan -> gcController.heapScan
    }
'

except for a few special cases, like updating names in comments and when
these fields are used within gcControllerState methods (at which point
they're accessed through the reciever).

For #44167.

Change-Id: I6bd1602585aeeb80818ded24c07d8e6fec992b93
Reviewed-on: https://go-review.googlesource.com/c/go/+/306598
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-13 23:42:29 +00:00
Cherry Zhang
8c2a8b1771 cmd/compile: always zero the temporary in mapKeyTemp
As we are taking its address, always zero it. In many cases the
temporary will be optimized out. But in case it does not (e.g. -N,
-race), this ensures it has the right liveness information.

May fix the noopt builder.

Change-Id: I3d5d617c276d2a1a1aaebff813b4cd60bc691592
Reviewed-on: https://go-review.googlesource.com/c/go/+/309771
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-13 22:55:30 +00:00
David Chase
b4881d930a cmd/compile: don't modify underlying type when creating bitmap for bodyless function
This fixes the build crash for
    GOEXPERIMENT=regabi,regabiargs GOOS=windows go build syscall

Updates #40724.

Change-Id: I4400f6ff2e83e7e7e93ad5e58c6063b327532504
Reviewed-on: https://go-review.googlesource.com/c/go/+/309110
Trust: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-13 22:31:20 +00:00
Rob Findley
efaf75a216 go/*,cmd/gofmt: guard AST changes with the typeparams build tag
This CL changes our approach to guarding type parameter functionality
and API. Previously, we guarded type parameter functionality with the
parser.parseTypeParams parser mode, and were in the process of hiding
the type parameter API behind the go1.18 build constraint.

These mechanisms had several limitations:
 + Requiring the parser.parseTypeParams mode to be set meant that
   existing tooling would have to opt-in to type parameters in all
   places where it parses Go files.
 + The parseTypeParams mode value had to be copied in several places.
 + go1.18 is not specific to typeparams, making it difficult to set up
   the builders to run typeparams tests.

This CL addresses the above limitations, and completes the task of
hiding the AST API, by switching to a new 'typeparams' build constraint
and adding a new go/internal/typeparams helper package.

The typeparams build constraint is used to conditionally compile the new
AST changes. The typeparams package provides utilities for accessing and
writing the new AST data, so that we don't have to fragment our parser
or type checker logic across build constraints. The typeparams.Enabled
const is used to guard tests that require type parameter support.

The parseTypeParams parser mode is gone, replaced by a new
typeparams.DisableParsing mode with the opposite sense. Now, type
parameters are only parsed if go/parser is compiled with the typeparams
build constraint set AND typeparams.DisableParsing not set. This new
parser mode allows opting out of type parameter parsing for tests.

How exactly to run tests on builders is left to a follow-up CL.

Updates #44933

Change-Id: I3091e42a2e5e2f23e8b2ae584f415a784b9fbd65
Reviewed-on: https://go-review.googlesource.com/c/go/+/300649
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-13 22:24:31 +00:00
Michael Anthony Knyszek
693859542e runtime: rename gcpercent, readgogc, and heapminimum to match Go style
Generated with:

rf 'mv gcpercent gcPercent'
rf 'mv readgogc readGOGC'
rf 'mv heapminimum heapMinimum'

After this, comments referencing these symbols were updated via a simple
sed command.

For #44167.

Change-Id: I6bb01597c2130686c01f967d0f106b06860ad2db
Reviewed-on: https://go-review.googlesource.com/c/go/+/306597
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-13 22:07:10 +00:00
Michael Anthony Knyszek
f5f7647107 runtime: break out GC pacer into its own file
This change breaks out the GC pacer into its own file so that it'll be
easier to see the full implementation and change it. It also suggests an
obvious place to put tests (mgcpacer_test.go).

This includes all of gcControllerState, gcSetTriggerRatio, anything
related to GOGC, and all related globals and constants.

This is almost a clean move, except that globals and constants are
formatted into blocks instead of having a separate "var" declaration for
each one.

For #44167.

Change-Id: I85aa84ce85c6cfbe0b33e8a3c91cbe9dc41de8cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/306596
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-04-13 22:06:56 +00:00
Cherry Zhang
9913f821e2 cmd/compile: make map functions ABI insensitive
Following CL 309029, this CL does the same thing for map
functions (mapaccess, mapassign, mapdelete).

For simplicity, always wrap "defer delete(m, k)". With
regabidefers enabled, this call is wrapped in a closure and the
rewriting happens automatically. Without regabidefers, it may not
be wrapped for certain key types, and then we'd need special
handling of the delete (because earlier the order pass does not
handle it). And we will turn on defer wrapping by default anyway.

Change-Id: I30663b1aa8e1d6f98e1fb81bf8c0c0ce607ab80b
Reviewed-on: https://go-review.googlesource.com/c/go/+/309510
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-13 21:18:03 +00:00
Austin Clements
c19759aa48 runtime: eliminate externalthreadhandler
This function is no longer used.

Eliminating this actually fixes several problems:

- It made assumptions about what registers memclrNoHeapPointers would
  preserve. Besides being an abstraction violation and lurking
  maintenance issue, this actively became a problem for regabi because
  the call to memclrNoHeapPointers now happens through an ABI wrapper,
  which is generated by the compiler and hence we can't easily control
  what registers it clobbers.

- The amd64 implementation (at least), does not interact with the host
  ABI correctly. Notably, it doesn't save many of the registers that
  are callee-save in the host ABI but caller-save in the Go ABI.

- It interacts strangely with the NOSPLIT checker because it allocates
  an entire M and G on its stack. It worked around this on arm64, and
  happened to do things the NOSPLIT checker couldn't track on 386 and
  amd64, and happened to be *4 bytes* below the limit on arm (so any
  addition to the m or g structs would cause a NOSPLIT failure). See
  CL 309031 for a more complete explanation.

Fixes #45530.
Updates #40724.

Change-Id: Ic70d4d7e1c17f1d796575b3377b8529449e93576
Reviewed-on: https://go-review.googlesource.com/c/go/+/309634
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-13 21:13:12 +00:00
Austin Clements
e69f02265c runtime: use newm for profileloop
This replaces the externalthreadhandler-based implementation of
profileloop with one that uses newm to start a new thread. This is a
step toward eliminating externalthreadhandler.

For #45530.

Change-Id: Id8e5540423fe2d2004024b649afec6998f77b092
Reviewed-on: https://go-review.googlesource.com/c/go/+/309633
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-13 21:13:11 +00:00
Austin Clements
e512bc2cf0 runtime: use compileCallback for ctrlhandler
This replaces the externalthreadhandler-based implementation of
ctrlhandler with one based on compileCallback. This is a step toward
eliminating externalthreadhandler.

For #45530.

Change-Id: I2de2f2f37777af292db67ccf8057b7566aab81f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/309632
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-13 21:13:09 +00:00
Manlio Perillo
069983e5db archive/tar: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: I296f8c676c68ed1e10b6ad1a17b5b23d2c395252
Reviewed-on: https://go-review.googlesource.com/c/go/+/309355
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-13 21:06:12 +00:00
Ian Lance Taylor
3bf645a633 cmd/link: force external linking for DragonFly cgo programs
Change-Id: Idce4eec2a4698a94aa7b40590dffb6bf9bd45342
Reviewed-on: https://go-review.googlesource.com/c/go/+/309571
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-13 21:05:14 +00:00
Austin Clements
69262d4871 cmd/compile,cmd/link: resolve cgo symbols to the correct Go ABI
Currently, Go functions exported to cgo have some confusion around
ABIs that leads to crashes. The cmd/cgo-generated C code references an
exported Go wrapper function (which calls the underlying exported user
function). The linker resolves this reference to the ABI0 entry-point
to that Go wrapper function because all host object references are
currently assumed to be to version 0 of a symbol. This gets passed via
crosscall2 and winds its way to cgocallbackg1, which puts this ABI0
entry-point into a function value and calls it. Unfortunately,
function values always use the ABIInternal calling convention, so
calling this ABI0 entry-point goes poorly.

Fix this by threading definition ABIs through the cgo export mechanism
so the linker can resolve host object references (which have no
concept of multiple ABIs) to the correct Go symbol. This involves a
few pieces:

- The compiler extends the cgo_export_{static,dynamic} directives that
  get passed on to the linker with symbol definition ABIs.

- The linker parses the ABIs in the cgo_export_{static,dynamic}
  directives to look up the right symbol to apply export attributes to
  and put in the dynexp list.

- For internal linking, the linker's Loader structure tracks the right
  symbol (in particular the right ABI) to resolve host object
  references to, and we use this in all of the host object loaders.

- For external linking, we mangle only the non-ABIInternal symbols
  now, so the external linker is able to resolve the correct reference
  from host objects to Go symbols.

Updates #40724.

Change-Id: I70a0b1610596768c3f473745fa1a3e630afbf1a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/309341
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-13 20:07:47 +00:00
Austin Clements
48531da9e7 cmd/link: build dynexp symbol list directly
Currently, setCgoAttr populates the cgo_export_{static,dynamic} maps
with symbol names of exported symbols, which are then re-looked-up by
deadcode and setupdynexp, which in turn puts the re-looked-up symbols
in ctxt.dynexp. setCgoAttr already looked up the Syms, so simplify all
of this by making setCgoAttr populate ctxt.dynexp directly and
eliminating the cgo_export_{static,dynamic} maps. Recording Syms
directly also sets us up to use correct symbol versions for these
exports, rather than just assuming version 0 for all lookups.

Since setupdynexp doesn't really do any "setting up" of dynexp any
more with this change, we fold the remaining logic from setupdynexp
directly into addexport, where it has better context anyway. This also
eliminates a sorting step, since we no longer do a non-deterministic
map iteration to build the dynexp slice.

For #40724.

Change-Id: I3e1a65165268da8c2bf50d7485f2624133433260
Reviewed-on: https://go-review.googlesource.com/c/go/+/309340
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-13 20:07:46 +00:00
Austin Clements
007e247af1 cmd/link: move cgo export map from loadcgo to setCgoAttr
Currently, both loadcgo and setCgoAttr do some processing of
cgo_export_static and cgo_export_dynamic cgo directives, which means
they both have to parse them. There's no reason to do this in loadcgo,
so move all directive processing to setCgoAttr.

For #40724.

Change-Id: Icb3cdf7ef3517e866dd220e40a5f5dec7fd47e2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/309339
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-13 20:07:45 +00:00
Austin Clements
6208b10d1e cmd/link: refactor setCgoAttr
setCgoAttr takes a lookup function, but there's only a single call and
setCgoAttr already has access to the lookup function passed at that
call. Simplify setCgoAttr by eliminating the lookup parameter and
calling the lookup function directly.

For #40724.

Change-Id: Ib27c0fa2b88c387e30423365f7757e3ba02cf7d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/309338
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-13 20:07:43 +00:00
Austin Clements
10f883deb7 cmd/cgo: document generated cgo directives
This took me a while to figure out. Save the next person some trouble.

Change-Id: Ifab2d426f67c21b08ef225c79125805a9008e578
Reviewed-on: https://go-review.googlesource.com/c/go/+/309336
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-13 20:07:42 +00:00
Ian Lance Taylor
7b19fb1d56 mime: in globs2 file only keep first time extension is seen
Fixes #45534

Change-Id: I9855607e845951f26ab85cb179ec6dea40d92156
Reviewed-on: https://go-review.googlesource.com/c/go/+/309574
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-13 18:08:06 +00:00
Robert Griesemer
39dd96ca5a cmd/compile/internal/types: add example test for type inference
Follow-up on https://golang.org/cl/308372.

For #44799.

Change-Id: I27d149241d465ee31e9c21d5f0935f31efcb5b60
Reviewed-on: https://go-review.googlesource.com/c/go/+/308973
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-13 16:18:08 +00:00
Cherry Zhang
4b00eb7af4 cmd/compile: allow OpArgXXXReg comes before LoweredGetClosurePtr
Both OpArgXXXReg and LoweredGetClosurePtr must come very early,
because they carry registers that are technically live on entry.
But no need to impose ordering requirement between them.

Change-Id: Iee1db6239a75e5b381e0ad25ba5503169333217b
Reviewed-on: https://go-review.googlesource.com/c/go/+/309629
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-13 14:13:57 +00:00
Brad Fitzpatrick
13a4e8c41c all: simplify the spelling of Linux
The prefix didn't help clarify anything.

Change-Id: I897fd4022ce9df42a548b15714e4b592618ca547
Reviewed-on: https://go-review.googlesource.com/c/go/+/309573
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-04-13 13:56:21 +00:00
Paul E. Murphy
3e5bba0a44 cmd/link: support 32b TLS_LE offsets on PPC64
When using the GCC thread sanitizer, it links in additional
code which uses TLS, which causes us to exceed the range of
the 16 bit TLS relocation used by statically compiled go
code.

Rewrite objabi.R_POWER_TLS_LE to handle 32b offsets when
linking internally or externally into an ELF binary. The
elf relocation translation is changed to generate a pair
of R_PPC64_TPREL16_HA/LO relocations instead of a single
R_PPC64_TPREL16.

Likewise, updating the above exposed some behavioral differences
in gnu ld which can rewrite TLS sequences. It expects the
sequence to generate a valid TLS address, not offset. This was
exposed when compiling PIC code. The proper fix is to generate
the full TLS address in the destination register of the
"MOVD tlsaddr, $Rx" pseudo-op. This removes the need to insert
special objabi.R_POWER_TLS relocations elsewhere.

Unfortunately, XCOFF (used by aix) doesn't appear to support 32
bit offsets, so we rewrite this back into a 16b relocation when
externally linking a static binary.

Fixes #45040

Change-Id: I1ee9afd0b427cd79888032aa1f60d3e265073e1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/302209
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-13 13:54:51 +00:00
Jay Conrod
d948b8633d cmd/go: fix 'go help mod edit' JSON documentation
The object representing a module directive may have a "Deprecated"
field but not a "Version" field. Other objects representing module
versions have "Path" and "Version" fields but not "Deprecated".

For #40357

Change-Id: Iad8063dfa6f7ceea22981a8a8f99e65fa3b7ffa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/309337
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-13 13:51:17 +00:00
Cherry Zhang
49e933fc57 cmd/compile: make interface conversion function selection ABI insensitive
Before register ABI, we always pass argument in memory, and the
compiler chooses interface conversion functions solely based on
the memory layout. As long as the two types have identical memory
layout, it is fine to mix and match, e.g. convT64 takes a uint64
argument, but it can be used for things like float64 or
struct { x [4]struct{}; y int64 }.

With register ABI, those types may be passed differently, e.g.
uint64 is passed in an integer register, float64 is passed in a
floating point register, the struct above is passed in memory.
I made a few attempts in the previous CLs to try to choose the
right function based on the argument type, but none of them is
really correct.

Instead, this CL changes it to always pass the argument in the
same type the runtime expects, and do conversion before the call
in the compiler. The conversion can be no-op (e.g. a named type
to its underlying type), direct (e.g. int64 to uint64), or
through memory (e.g. *(*uint64)(unsafe.Pointer(&arg))). This way,
the front end does not need to know the ABI. (It only needs to
know how to convert types, and it already does.)

TODO: do something similar for map functions.

Change-Id: I33fc780a47c3f332b765e09b5e527f52ea1d6b5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/309029
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-04-12 22:50:31 +00:00
Grace Han
841bc14216 os: restore testErrNotExist's working directory on os.Chdir success
The existing implementation calls os.Chdir expecting the call not to
succeed. This change restores the original working directory in the
case that the call does succeed.

Fixes #45407

Change-Id: I61c57f6858b9a9058226e45e24276c7af8913048
Reviewed-on: https://go-review.googlesource.com/c/go/+/308849
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-12 22:19:11 +00:00
Manlio Perillo
3d5e3a15f6 debug/pe: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: I3d83a66270ca38e82d6bb7f8a1367af3d5343a98
Reviewed-on: https://go-review.googlesource.com/c/go/+/309352
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-12 21:59:20 +00:00
Manlio Perillo
c27991bf5b text/template: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: I9d55191c4021387b771550b5c93c91806f694aa6
Reviewed-on: https://go-review.googlesource.com/c/go/+/309351
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-12 21:58:25 +00:00
Manlio Perillo
cccd3ba912 internal/execabs: replace ioutil.WriteFile with os.WriteFile
Fixes #45532.

Change-Id: I844acd50d6fa1ce918969bbb52f79dd7412d289f
Reviewed-on: https://go-review.googlesource.com/c/go/+/309350
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-12 21:57:23 +00:00
Michael Pratt
aad13cbb74 runtime: non-strict InlTreeIndex lookup in expandFinalInlineFrame
This is a follow-up to golang.org/cl/301369, which made the same change
in Frames.Next. The same logic applies here: a profile stack may have
been truncated at an invalid PC provided by cgoTraceback.
expandFinalInlineFrame will then try to lookup the inline tree and
crash.

The same fix applies as well: upon encountering a bad PC, simply leave
it as-is and move on.

Fixes #44971
Fixes #45480

Change-Id: I2823c67a1f3425466b05384cc6d30f5fc8ee6ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/309109
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Michael Pratt <mpratt@google.com>
2021-04-12 21:29:02 +00:00
Josh Rickmar
5c9b6e8e63 net: never probe IPv4 map support on DragonFly BSD, OpenBSD
DragonFly BSD and OpenBSD do not implement mapping IPv4 addresses to
the IPv6 address space, and a runtime check can be avoided.

As the IP stack capabilities probe was only being called from
supportsIPv4map to check for this support, the OS-specific handling
can be added to this function rather than continuing to run the probe.

Change-Id: I5800c197b1be502a6efa79e3edd6356bde8637fb
GitHub-Last-Rev: 7eb67189cd
GitHub-Pull-Request: golang/go#45243
Reviewed-on: https://go-review.googlesource.com/c/go/+/304870
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-12 21:26:59 +00:00
Jacalz
3e8ba91275 mime: support reading shared mime-info database on unix systems
This adds support for reading the FreeDesktop Shared MIME-info Database on Unix systems, if it exists.
It should make lookups work on systems where the mime.types files are not present and
should lead to better mimetype lookup in general. If the shared mimetype database does not exist,
we will fall back to reading mime.types files in common locations.

Related to a bug on Solus bugtracker: https://dev.getsol.us/T9394
This change makes the mime package work on Solus.

Change-Id: If330c22ffe523bf31f7f10807a54fc8858517055
GitHub-Last-Rev: d5fbe8c41a
GitHub-Pull-Request: golang/go#45271
Reviewed-on: https://go-review.googlesource.com/c/go/+/305230
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-12 21:04:48 +00:00
Austin Clements
1b736b3c19 runtime: consolidate "is sweep done" conditions
The runtime currently has two different notions of sweep completion:

1. All spans are either swept or have begun sweeping.

2. The sweeper has *finished* sweeping all spans.

Having both is confusing (it doesn't help that the documentation is
often unclear or wrong). Condition 2 is stronger and the theoretical
slight optimization that condition 1 could impact is never actually
useful. Hence, this CL consolidates both conditions down to condition 2.

Updates #45315.

Change-Id: I55c84d767d74eb31a004a5619eaba2e351162332
Reviewed-on: https://go-review.googlesource.com/c/go/+/307916
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-12 19:22:52 +00:00
Austin Clements
a25a77aed2 runtime: block sweep completion on all sweep paths
The runtime currently has two different notions of sweep completion:

1. All spans are either swept or have begun sweeping.

2. The sweeper has *finished* sweeping all spans.

Most things depend on condition 1. Notably, GC correctness depends on
condition 1, but since all sweep operations a non-preemptible, the STW
at the beginning of GC forces condition 1 to become condition 2.

runtime.GC(), however, depends on condition 2, since the intent is to
complete a complete GC cycle, and also update the heap profile (which
can only be done after sweeping is complete).

However, the way we compute condition 2 is racy right now and may in
fact only indicate condition 1. Specifically, sweepone blocks
condition 2 until all sweepone calls are done, but there are many
other ways to enter the sweeper that don't block this. Hence, sweepone
may see that there are no more spans in the sweep list and see that
it's the last sweepone and declare sweeping done, while there's some
other sweeper still working on a span.

Fix this by making sure every entry to the sweeper participates in the
protocol that blocks condition 2. To make sure we get this right, this
CL introduces a type to track sweep blocking and (lightly) enforces
span sweep ownership via the type system. This has the nice
side-effect of abstracting the pattern of acquiring sweep ownership
that's currently repeated in many different places.

Fixes #45315.

Change-Id: I7fab30170c5ae14c8b2f10998628735b8be6d901
Reviewed-on: https://go-review.googlesource.com/c/go/+/307915
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-12 19:22:50 +00:00
Lynn Boger
07b2fee460 cmd/link: fix TestLargeText
This test is not run in short mode so it was getting
failures that didn't happen with default testing. See
the issue for details on the failures.

Fixes #45406

Change-Id: I51d97cc4c910fe3ba2bc0a12742023a57d101f44
Reviewed-on: https://go-review.googlesource.com/c/go/+/308935
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-04-12 18:32:27 +00:00
Austin Clements
849dba07a5 runtime: port performance-critical functions to regabi
This CL ports a few performance-critical runtime assembly functions to
use register arguments directly. While using the faster ABI is nice,
the real win here is that we avoid ABI wrappers: since these are
"builtin" functions in the compiler, it can generate calls to them
without knowing that their native implementation is ABI0. Hence, it
generates ABIInternal calls that go through ABI wrappers. By porting
them to use ABIInternal natively, we avoid the overhead of the ABI
wrapper.

This significantly improves performance on several benchmarks,
comparing regabiwrappers before and after this change:

name                                old time/op  new time/op  delta
BiogoIgor                            15.7s ± 2%   15.7s ± 2%    ~     (p=0.617 n=25+25)
BiogoKrishna                         18.5s ± 5%   17.7s ± 2%  -4.61%  (p=0.000 n=25+25)
BleveIndexBatch100                   5.91s ± 3%   5.82s ± 3%  -1.60%  (p=0.000 n=25+25)
BleveQuery                           6.76s ± 0%   6.60s ± 1%  -2.31%  (p=0.000 n=22+25)
CompileTemplate                      248ms ± 5%   245ms ± 1%    ~     (p=0.643 n=25+20)
CompileUnicode                      94.4ms ± 3%  93.9ms ± 2%    ~     (p=0.152 n=24+23)
CompileGoTypes                       1.60s ± 2%   1.59s ± 2%    ~     (p=0.059 n=24+24)
CompileCompiler                      104ms ± 3%   103ms ± 1%    ~     (p=0.056 n=25+22)
CompileSSA                           10.9s ± 1%   10.9s ± 1%    ~     (p=0.052 n=25+25)
CompileFlate                         156ms ± 8%   152ms ± 1%  -2.49%  (p=0.008 n=25+21)
CompileGoParser                      248ms ± 1%   249ms ± 2%    ~     (p=0.058 n=21+20)
CompileReflect                       595ms ± 3%   601ms ± 4%    ~     (p=0.182 n=25+25)
CompileTar                           211ms ± 2%   211ms ± 1%    ~     (p=0.663 n=23+23)
CompileXML                           282ms ± 2%   284ms ± 5%    ~     (p=0.456 n=21+23)
CompileStdCmd                        13.6s ± 2%   13.5s ± 2%    ~     (p=0.112 n=25+24)
FoglemanFauxGLRenderRotateBoat       8.69s ± 2%   8.67s ± 0%    ~     (p=0.094 n=22+25)
FoglemanPathTraceRenderGopherIter1   20.2s ± 2%   20.7s ± 3%  +2.53%  (p=0.000 n=24+24)
GopherLuaKNucleotide                 31.4s ± 1%   31.0s ± 1%  -1.28%  (p=0.000 n=25+24)
MarkdownRenderXHTML                  246ms ± 1%   244ms ± 1%  -0.79%  (p=0.000 n=20+21)
Tile38WithinCircle100kmRequest       843µs ± 4%   818µs ± 4%  -2.93%  (p=0.000 n=25+25)
Tile38IntersectsCircle100kmRequest  1.06ms ± 5%  1.05ms ± 3%  -1.19%  (p=0.021 n=24+25)
Tile38KNearestLimit100Request       1.01ms ± 1%  1.01ms ± 2%    ~     (p=0.335 n=22+25)
[Geo mean]                           596ms        592ms       -0.71%

(https://perf.golang.org/search?q=upload:20210411.5)

It also significantly reduces the performance penalty of enabling
regabiwrappers, though it doesn't yet fully close the gap on all
benchmarks:

name                                old time/op  new time/op  delta
BiogoIgor                            15.7s ± 1%   15.7s ± 2%    ~     (p=0.366 n=24+25)
BiogoKrishna                         17.7s ± 2%   17.7s ± 2%    ~     (p=0.315 n=23+25)
BleveIndexBatch100                   5.86s ± 4%   5.82s ± 3%    ~     (p=0.137 n=24+25)
BleveQuery                           6.55s ± 0%   6.60s ± 1%  +0.83%  (p=0.000 n=24+25)
CompileTemplate                      244ms ± 1%   245ms ± 1%    ~     (p=0.208 n=21+20)
CompileUnicode                      94.0ms ± 4%  93.9ms ± 2%    ~     (p=0.666 n=24+23)
CompileGoTypes                       1.60s ± 2%   1.59s ± 2%    ~     (p=0.154 n=25+24)
CompileCompiler                      103ms ± 1%   103ms ± 1%    ~     (p=0.905 n=24+22)
CompileSSA                           10.9s ± 2%   10.9s ± 1%    ~     (p=0.803 n=25+25)
CompileFlate                         153ms ± 1%   152ms ± 1%    ~     (p=0.182 n=23+21)
CompileGoParser                      250ms ± 2%   249ms ± 2%    ~     (p=0.843 n=24+20)
CompileReflect                       595ms ± 4%   601ms ± 4%    ~     (p=0.141 n=25+25)
CompileTar                           212ms ± 3%   211ms ± 1%    ~     (p=0.499 n=23+23)
CompileXML                           282ms ± 1%   284ms ± 5%    ~     (p=0.129 n=20+23)
CompileStdCmd                        13.5s ± 2%   13.5s ± 2%    ~     (p=0.480 n=24+24)
FoglemanFauxGLRenderRotateBoat       8.66s ± 1%   8.67s ± 0%    ~     (p=0.325 n=25+25)
FoglemanPathTraceRenderGopherIter1   20.6s ± 3%   20.7s ± 3%    ~     (p=0.137 n=25+24)
GopherLuaKNucleotide                 30.5s ± 2%   31.0s ± 1%  +1.68%  (p=0.000 n=23+24)
MarkdownRenderXHTML                  243ms ± 1%   244ms ± 1%  +0.51%  (p=0.000 n=23+21)
Tile38WithinCircle100kmRequest       801µs ± 2%   818µs ± 4%  +2.11%  (p=0.000 n=25+25)
Tile38IntersectsCircle100kmRequest  1.01ms ± 2%  1.05ms ± 3%  +4.34%  (p=0.000 n=24+25)
Tile38KNearestLimit100Request       1.00ms ± 1%  1.01ms ± 2%  +0.81%  (p=0.008 n=21+25)
[Geo mean]                           589ms        592ms       +0.50%

(https://perf.golang.org/search?q=upload:20210411.6)

Change-Id: I8f77f010b0abc658064df569a27a9c7a7b1c7bf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/308931
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-12 18:08:47 +00:00
Cherry Zhang
865d2bc78e cmd/compile: do not allocate space for unspilled in-register results
For function results, if in register, we allocate spill slots
within the frame like locals. Currently, even if we never spill
to it the slot is still allocated. This CL makes it not allocate
the slot if it is never used.

Change-Id: Idbd4e3096cfac6d2bdfb501d8efde48ee2191d7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/309150
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-12 17:56:06 +00:00
Ian Lance Taylor
8b859be9c3 internal/poll: ensure that newPoolPipe doesn't return a nil pointer
The function could occasionally return a nil pointer as a non-nil
interface, confusing the calling code.

Fixes #45520

Change-Id: Ifd35613728efa2cee9903177e85d369155074804
Reviewed-on: https://go-review.googlesource.com/c/go/+/309429
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-12 17:32:47 +00:00
Cherry Zhang
2fa7163b06 cmd/compile: look for newobject in register ABI for write barrier elision
If we are assigning a global address to an object that is
immediately returned from runtime.newobject, we omit the write
barrier because we know that both the source (static address) and
the destination (zeroed memory) do not need to be tracked by the
GC. Currently, the code that matches runtime.newobject's result
is specific to ABI0 layout. Update the code to work with register
ABI as well.

Change-Id: I7ab0833c6f745329271881ee4169956928a3a948
Reviewed-on: https://go-review.googlesource.com/c/go/+/308709
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-04-12 17:30:21 +00:00
Paschalis Tsilias
5d80f8a82b runtime: replace outdated documentation link in Windows' nanotime
Fixes #45498

Change-Id: I89365f3517bc84376f0f580c64a57f38aaba0cbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/308997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alex Brainman <alex.brainman@gmail.com>
2021-04-12 17:28:43 +00:00
Cherry Zhang
33d99905da cmd/compile: preserve name association when eliding copies in expand_calls
If v is a Copy of x, we will rewrite v to x. If v has a name
associated to it, let the name associate to x.

Under register ABI, this helps associate in-register Arg values
to the parameters' names. (But does not address all cases.)

Change-Id: I47c779e56c9d0823a88890497e32326bc0290f82
Reviewed-on: https://go-review.googlesource.com/c/go/+/309330
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-12 17:08:49 +00:00
Cherry Zhang
70ed28e5f7 cmd/compile: support memmove inlining with register args
The rule that inlines memmove expects SSA ops that calls memmove
with arguments in memory. This CL adds a version that matches
it with arguments in registers, so the optimization works for
both situations.

Change-Id: Ideb64f65b7521481ab2ca7c9975a6cf7b70d5966
Reviewed-on: https://go-review.googlesource.com/c/go/+/309332
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-04-12 16:44:49 +00:00
Cherry Zhang
585b52261c runtime: remove deferreturn dummy argument
deferreturn has a dummy argument, that is only used for getting
the caller's SP. When generating deferreturn calls, the compiler
does not pass an actual argument or reserve its stack space.
Also, the current code is written with the assumption about where
the argument's address is on the stack. Currently this is correct
for both ABI0 and the register ABI, but it may change in the
future (e.g. if we remove dedicated spill slots). Remove the
argument.

Also remove the argument for getargp.

Change-Id: I96d07efa79a9c1a53ef3fc5adbecc11877e99dc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/309329
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-12 16:30:17 +00:00
Julie Qiu
51a47b7ff2 cmd/go: display helpful error when module cache can't be created
Previously when the module cache specified by GOMODCACHE could not be
created an unhelpful message would be printed multiple times.

This happened because we were fetching several things in parallel then
failing to write them because we can't create the module cache.

We now check if the module cache can be created before fetching.

If not, the following message is printed:

go: could not create module cache

Fixes #45113

Change-Id: Ic9cec787411335edc7f4d0614fde7eaa8a957fb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/304571
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-12 15:51:43 +00:00
Hajime Hoshi
117b1c84d3 cmd/go/internal/work: remove '_test' from import paths in stacktraces when -trimpath is specified
ExampleFrames with -trimpath failed since the content of Frame's File
changed when -trimpath is specified.

This CL fixes the issue by adding a new field OrigImportPath to
PackageInternal, which represents the original import path before adding
'_test' suffix for an external test package, and always using it to
create paths for the build tools.

Fixes golang/go#43380

Change-Id: Ibbc947eb3ae08a7ba81f13f03af67c8745b5c69f
Reviewed-on: https://go-review.googlesource.com/c/go/+/279440
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-12 15:17:33 +00:00
Than McIntosh
c26f954a54 cmd/compile/internal/amd64: follow-on regabi fix for amd64 zerorange
This patch provides a better long-term fix for the compiler's
zerorange() helper function to make it generate code friendly to the
register ABI.

CL 305829 did part of the work, but didn't properly handle the case
where the compiler emits a REP.STOSQ sequence; this patch changes the
REP code to make sure it doesn't clobber any incoming register
parameter values.

Also included is a test that is specifically written to trigger
the REP emit code in the compiler (prior to this, this code was
not being hit on linux/amd64 all.bash).

Updates #45372.
Updates #40724.

Change-Id: Iaf1c4e709e98eda45cd6f3aeebda0fe9160f1f42
Reviewed-on: https://go-review.googlesource.com/c/go/+/307829
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-12 10:30:24 +00:00
Tobias Klauser
16cd770e06 cmd/cgo: throw if C.malloc returns NULL in C.CString or C.CBytes
Change-Id: Iea07b7f3e64f5938cfb1cd1c07bdce4adf8e4470
Reviewed-on: https://go-review.googlesource.com/c/go/+/308992
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-12 05:12:42 +00:00
Tobias Klauser
954bd8203b cmd/cgo: use tabs to indent _cgoPREFIX_Cfunc__CMalloc function body
All other _cgoPREFIX_Cfunc_* functions are indented using tabs.

Change-Id: Ic5cfccd3000d34d0bbe08d035f18640af5e05473
Reviewed-on: https://go-review.googlesource.com/c/go/+/308993
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-12 05:12:28 +00:00
Tobias Klauser
e12abe4bd6 net: fix (*ipStackCapabilities).probe godoc
Change-Id: I2e5db6e7e9a7b3c84449d16b6bc32afe1d0ffee9
Reviewed-on: https://go-review.googlesource.com/c/go/+/308991
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-12 05:11:59 +00:00
Meng Zhuo
7beb988a3b runtime: using wyhash for memhashFallback on 64bit platform
wyhash is a general hash function that:

1. About 8-70% faster that internal maphash
2. Passed Smhasher, BigCrush and PractRand tests

name                  old time/op    new time/op    delta
Hash5                   28.9ns ± 0%    30.0ns ± 0%   +3.77%  (p=0.000 n=9+10)
Hash16                  32.4ns ± 0%    30.2ns ± 0%   -6.74%  (p=0.000 n=10+8)
Hash64                  52.4ns ± 0%    43.4ns ± 0%  -17.20%  (p=0.000 n=9+10)
Hash1024                 415ns ± 0%     258ns ± 2%  -37.89%  (p=0.000 n=10+10)
Hash65536               24.9µs ± 0%    14.6µs ± 0%  -41.22%  (p=0.000 n=9+9)
HashStringSpeed         50.2ns ± 4%    47.8ns ± 4%   -4.88%  (p=0.000 n=10+10)
HashBytesSpeed          90.1ns ± 7%    78.3ns ± 4%  -13.06%  (p=0.000 n=10+10)
HashInt32Speed          33.3ns ± 6%    33.6ns ± 4%     ~     (p=0.071 n=10+10)
HashInt64Speed          32.7ns ± 3%    34.0ns ± 3%   +4.05%  (p=0.000 n=9+10)
HashStringArraySpeed     131ns ± 2%     117ns ± 5%  -10.32%  (p=0.000 n=9+10)
FastrandHashiter        72.2ns ± 1%    75.7ns ±10%   +4.87%  (p=0.019 n=8+10)

name                  old speed      new speed      delta
Hash5                  173MB/s ± 0%   167MB/s ± 0%   -3.63%  (p=0.000 n=9+10)
Hash16                 494MB/s ± 0%   530MB/s ± 0%   +7.23%  (p=0.000 n=10+8)
Hash64                1.22GB/s ± 0%  1.48GB/s ± 0%  +20.77%  (p=0.000 n=9+10)
Hash1024              2.47GB/s ± 0%  3.97GB/s ± 2%  +61.01%  (p=0.000 n=8+10)
Hash65536             2.64GB/s ± 0%  4.48GB/s ± 0%  +70.13%  (p=0.000 n=9+9)

Change-Id: I76af4e2bc1995a18149d11983ea8a149c132865e
Reviewed-on: https://go-review.googlesource.com/c/go/+/279612
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-04-12 02:29:32 +00:00
Manlio Perillo
424abc8d3b os/signal: replace os.MkdirTemp with T.TempDir
Updates #45402.

Change-Id: I6fe356b51bc825a907f979d9c44432a4d43d1f6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/308996
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-12 00:45:40 +00:00
Dan Kortschak
0da9eff503 runtime: simplify syntax for pointer arithmetic in mapaccess functions
This harmonizes the syntax between mapaccess1 and mapaccess2, and
simplifies the code.

Change-Id: I6db25ffdc871018d399f9030259894b3994c5793
Reviewed-on: https://go-review.googlesource.com/c/go/+/308951
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-11 20:41:32 +00:00
Austin Clements
352d329c44 runtime: move zero-sized frame check from newproc to newproc1
If GOEXPERIMENT=regabidefer is enabled, newproc currently checks that
the call frame for new goroutines is empty. But there's one place in
the runtime (debugCallWrap), where we call newproc1, and it happens to
pass a non-empty frame. The current check didn't catch that. Move the
empty call frame check from newproc to newproc1 to catch this.

Updates #40724.

Change-Id: I9998faf1e07e7b7af88e06a8177127f998c40252
Reviewed-on: https://go-review.googlesource.com/c/go/+/309034
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-11 20:07:18 +00:00
6543
189c6946f5 net: reference the correct RFCs and sections for IP.IsPrivate
Properly cite RFC 1918 Section 3 for ipv4,
and RFC 4193 Section 8 for ipv6 comments.

Updates #29146

Change-Id: I8a2df0d7bef50444294bb3301fe09fb09f21ffaf
GitHub-Last-Rev: b0341791c0
GitHub-Pull-Request: golang/go#45500
Reviewed-on: https://go-review.googlesource.com/c/go/+/309249
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-11 15:56:20 +00:00
Robert Griesemer
3f4977bd58 cmd/compile/internal/types2: use combined type and ordinary args for type inference
Fixes #44799.

Change-Id: I51d5b6d6fdfcf47b87bf40b1f7e31c3284c2813f
Reviewed-on: https://go-review.googlesource.com/c/go/+/308372
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>
2021-04-10 19:02:08 +00:00
Robert Griesemer
a6d95b4508 cmd/compile/internal/types2: split out function instantiation from index expr
Also, factor out recording of type/value information after
evaluating an expression into an operand, so that we can
use it when handling instantiation expressions manually.

Change-Id: I6776e6cc243558079d6a203f2fe0a6ae0ecc33de
Reviewed-on: https://go-review.googlesource.com/c/go/+/308371
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>
2021-04-10 19:02:06 +00:00
Robert Griesemer
36c5f902f9 cmd/compile/internal/types2: factor out index/slice expr handling
First step towards lightening the load of Checker.exprInternal by
factoring out the code for index and slice expressions; incl. moving
a couple of related methods (Checker.index, Checker.indexedElts).

The code for handling index/slice expressions is copied 1:1 but
occurrences of "goto Error" are replaced by "x.mode = invalid"
followed by a "return".

Change-Id: I44048dcc4851dc5e24f5f169c17f536a37a6a676
Reviewed-on: https://go-review.googlesource.com/c/go/+/308370
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>
2021-04-10 19:02:05 +00:00
Robert Griesemer
4638545d85 cmd/compile/internal/syntax: accept "~" and "|" interface elements
Type lists continue to be accepted as before.

While at it, print missing filenames in error tests
(which uses an ad-hoc position representation).

Change-Id: I933b3acbc9cf1985ad8f70f6b206e3a1dbd64d1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/307371
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>
2021-04-10 19:02:03 +00:00
Keith Randall
1129a60f1c cmd/compile: include typecheck information in export/import
Include type information on exported function bodies, so that the
importer does not have to re-typecheck the body. This involves
including type information in the encoded output, as well as
avoiding some of the opcode rewriting and other changes that the
old exporter did assuming there would be a re-typechecking pass.

This CL could be considered a cleanup, but is more important than that
because it is an enabling change for generics. Without this CL, we'd
have to upgrade the current typechecker to understand generics. With
this CL, the current typechecker can mostly go away in favor of the
types2 typechecker.

For now, inlining of functions that contain closures is turned off.
We will hopefully resolve this before freeze.

Object files are only 0.07% bigger.

Change-Id: I85c9da09f66bfdc910dc3e26abb2613a1831634d
Reviewed-on: https://go-review.googlesource.com/c/go/+/301291
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-04-10 14:58:18 +00:00
Manlio Perillo
11f159456b path/filepath: replace os.MkdirTemp with T.TempDir
Add the tempDirCanonical function, for tests that need a temporary
directory that does not contain symlinks.

Updates #45402

Change-Id: I3d08ef32ef911331544acce3d7d013b4c3382960
Reviewed-on: https://go-review.googlesource.com/c/go/+/308011
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-10 08:13:32 +00:00
Andy Pan
6382ec1aba internal/poll: fix the intermittent build failures with pipe pool
Correlative CL 308089

Fixes #45059

Change-Id: I1ff9fbf64e6620d651f287ba2a28d40f964d78a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/308329
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-10 03:38:08 +00:00
Naman Gera
52bf14e0e8 all: fix spellings
This follows the spelling choices that the Go project has made for English words.
https://github.com/golang/go/wiki/Spelling

Change-Id: Ie7c586d2cf23020cb492cfff58c0831d2d8d3a78
GitHub-Last-Rev: e16a32cd22
GitHub-Pull-Request: golang/go#45442
Reviewed-on: https://go-review.googlesource.com/c/go/+/308291
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-10 01:46:41 +00:00
Ian Lance Taylor
554d2c4f06 reflect: panic on New of go:notinheap type
For #42076
Fixes #45451

Change-Id: I69646226d3480d5403205412ddd13c0cfc2c8a53
Reviewed-on: https://go-review.googlesource.com/c/go/+/308970
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-04-09 23:54:31 +00:00
Dan Scales
281d168e2d cmd/compile: don't set Ntype in noder2 anymore
Now that we are no longer calling the old typechecker at all during the
noder2 pass, we don't need to create and set an Ntype node ((which is
just a node representation of the type which we already know) for the
Name and Closure nodes. This should reduce memory usage a bit for -G=3.

Change-Id: I6b1345007ce067a89ee64955a53f25645c303f4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/308909
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-09 22:57:48 +00:00
Austin Clements
756e2b1529 cmd/internal/objabi: make GOEXPERIMENT=none mean "no experiment flags"
CL 307819 made GOEXPERIMENT=none mean "restore baseline experiment
configuration". This is arguably what you want because any deviation
from the baseline configuration is an "experiment". However, cmd/dist
requires this to mean "disable all experiment flags", even if some
flags are enabled in the baseline configuration, because its build
system doesn't know how to deal with any enabled experiment flags.

Hence, make GOEXPERIMENT=none mean "disable all experiment flags"
again.

Change-Id: I1e282177c3f62a55eb9c36566c75672808dae9b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/309010
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-09 19:11:12 +00:00
Bryan C. Mills
c3faff7f2d cmd/go/internal/modload: change mvsReqs to store roots instead of a full build list
The mvsReqs implementation has always been a bit ambivalent about
whether the root requirements return the full build list, just the
direct requirements, or some hybrid of the two.

However, a full build list always requires the Target module as the
first entry, and it's easer to remove a redundant leading element from
a slice than to add one. Changing the mvsReqs field to contain
arbitrary roots instead of a full build list eliminates the need to
add redundant elements, at the cost of needing to remove redundant
elements in more places.

For #36460

Change-Id: Idd4c2d6bc7b66f67680037dab1fb9c2d1b40ab93
Reviewed-on: https://go-review.googlesource.com/c/go/+/308811
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-09 18:49:05 +00:00