Commit graph

40505 commits

Author SHA1 Message Date
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
Jay Conrod 814c5ff138 cmd/go: support module deprecation
A module is deprecated if its author adds a comment containing a
paragraph starting with "Deprecated:" to its go.mod file. The comment
must appear immediately before the "module" directive or as a suffix
on the same line. The deprecation message runs from just after
"Deprecated:" to the end of the paragraph. This is implemented in
CL 301089.

'go list -m -u' loads deprecation messages from the latest version of
each module, not considering retractions (i.e., deprecations and
retractions are loaded from the same version). By default, deprecated
modules are printed with a "(deprecated)" suffix. The full deprecation
message is available in the -f and -json output.

'go get' prints deprecation warnings for modules named on the command
line. It also prints warnings for modules needed to build packages
named on the command line if those modules are direct dependencies of
the main module.

For #40357

Change-Id: Id81fb2b24710681b025becd6cd74f746f4378e78
Reviewed-on: https://go-review.googlesource.com/c/go/+/306334
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-09 18:20:48 +00:00
Jay Conrod 952187af12 cmd/go: upgrade and vendor golang.org/x/mod
To pull in CL 301089.

For #40357

Change-Id: I8aa9bc8d7a75f804adc7982adaaa1c926b43d0ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/306333
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-09 18:19:42 +00:00
Austin Clements fcf8a6640b cmd/compile/abi-internal: declare R14 completely fixed
Currently, we allow R14, the current goroutine pointer, to be
clobbered in function bodies as long as the function restores it. This
is unnecessary complexity and could lead to confusing inconsistencies
with other architectures that can't simply restore it from TLS.

Updates #40724.

Change-Id: I4c052f0dd0b31d31afeb0c5aff05c314d7a852f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/309009
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-09 18:11:15 +00:00
Austin Clements 0ad46889a1 cmd/compile/abi-internal: declare X15 scratch in function bodies
X15 must be zero at function calls and returns, but can be used as
scratch in the middle of a function. This allows things like memmove
and the hashing functions to use X15 temporarily, as long as they set
it back to 0 before returning.

This CL also clarifies the distinction between register meanings on
function call versus function return, since some of them have fixed
meanings at both call and return, while others only have a fixed
meaning at calls.

Updates #40724.

Change-Id: I9dad3abde42cd4d2788e8435cde6d55073dd75a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/308929
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-09 17:56:50 +00:00
Austin Clements 2698be4905 runtime: use sigpanic0 on all OSes
With the register ABI, it's important to inject sigpanic0 instead of
sigpanic so we can set up function entry registers. This was already
happening on most OSes. This CL gets the remaining ones.

Change-Id: I6bc4d912b6497e03ed54d0a9c1eae8fd099d2cea
Reviewed-on: https://go-review.googlesource.com/c/go/+/308930
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-09 17:49:01 +00:00
David Chase 6951da56b0 Revert "cmd/compile: ensure spills of int/float reg args land in abi slots"
This reverts CL 308510.

Reason for revert: It breaks "GOEXPERIMENT=regabi,regabiargs ./make.bash"

Change-Id: I553654690ec73120f8a6258dd80623853c430df0
Reviewed-on: https://go-review.googlesource.com/c/go/+/308932
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-09 15:01:13 +00:00
Bryan C. Mills 77b3269fb5 cmd/go: in TestScript, set GOTRACEBACK and use SIGQUIT to terminate hung subprocesses
This should produce more useful outputs if a cmd/go invocation hangs
during a test.

(In some cases the outputs will be very verbose, but verbose is still
better than uninformative.)

For #36460
For #38768

Change-Id: Ibaf2d0fbf7387dfab1aad8981140ecb11901fc4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/308809
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-09 14:36:20 +00:00
David Chase a690a5d75f cmd/compile: ensure spills of int/float reg args land in abi slots
We noticed a while ago that register argument spills were not always
landing where they should.

Updates #40724.

Change-Id: I0b7c3279a2f6270577481c252bae4568cbb6e796
Reviewed-on: https://go-review.googlesource.com/c/go/+/308510
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-09 14:33:44 +00:00
Bryan C. Mills dcc801ef81 cmd/go/internal/modload: actually set the depth field passed to newRequirements
This was missed in CL 308515, and didn't show up in testing because so
few codepaths (and tests) actually depend on this behavior so far.

For #36460

Change-Id: I98b1962eb64d371884e15a3356c95f7ea80c7d21
Reviewed-on: https://go-review.googlesource.com/c/go/+/308810
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-04-09 13:19:10 +00:00
Jason A. Donenfeld c432917061 cmd/link: link libgcc archive after mingw archives
When compiling with the race detector using modern mingw, this prevents:

    libgcc(.text): relocation target ___chkstk_ms not defined

Change-Id: I2095ad09a535505b54f9ff2d3075fd20ac85e515
Reviewed-on: https://go-review.googlesource.com/c/go/+/295910
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-04-09 13:10:36 +00:00
Dan Scales 519f223aa2 cmd/compile: reduce overhead of RParams in types.Type
Changed RParams in types.Type to be a pointer to a slice, rather than a
slice itself, in order to reduce it from three words to one words, since
the large majority of types will not be generic or instantiated from a
generic type.

Additional cleanup: remove operation OTYPEINST, which we don't have need
of, since all type instantiations are either handled by types2 or happen
automatically during some form of stenciling.

Both of these are useful cleanups before the Go 1.17 freeze.

Change-Id: I61ad56b3c698b30d2cb5a2cdd12263202c54f49c
Reviewed-on: https://go-review.googlesource.com/c/go/+/308770
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-04-09 12:56:04 +00:00
Manlio Perillo 4d7d7a4c50 os: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: Ib8e62a13ddff884e4d34b3a0fdc9a10db2b68da6
Reviewed-on: https://go-review.googlesource.com/c/go/+/308109
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-09 09:01:07 +00:00
ian woolf 8518aac314 crypto/x509: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: Ifb1fa5232a0fa1be62e886643cec9deaa3b312ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/308409
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-09 04:03:50 +00:00
Cherry Zhang d25c4fbe05 test: do not run softfloat test with regabiargs
Softfloat mode with register ABI is not implemented yet. In
particular, we did not rewrite the float types in AuxCalls to
integer types, so arguments are still passed in floating point
registers, which do not exist in softfloat mode. To make it work
I think we may want to reorder softfloat pass with expand_calls
pass. We also need to rewrite the OpArgFloatRegs for the spilling
of non-SSA-able arguments, which may involve renumbering interger
arguments. Maybe in softfloat mode we want to just define the
ABI with 0 float registers. They are not fundamentally hard, but
may be not worth doing for the moment, as we don't use softfloat
mode on AMD64 anyway.

Run the test with noregabiargs. Also in the compiler reject
-d=softfloat if regabiargs is enabled.

Change-Id: I8cc0c2cfa88a138bc1338ed8710670245f1bd2cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/308710
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-09 00:11:25 +00:00
Cherry Zhang 19034fa855 cmd/objdump: update test with register ABI
With register ABI, the disassembly of the function may not
contain a "movq" instruction (which used to be e.g. storing
arguments to stack). Look for "jmp" instruction instead. This is
also in consistent with the test for Go assembly syntax.

Change-Id: Ifc9e48bbc4f85c4e4aace5981b3a0f8ae925f6d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/308652
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-09 00:09:47 +00:00
Jay Conrod 5811605df9 cmd/go: fix mod_list_update_nolatest on windows
Fixes #45456

Change-Id: I7d313d7fbe29813f2abb062b6feec43280c2d283
Reviewed-on: https://go-review.googlesource.com/c/go/+/308653
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-08 22:45:16 +00:00
Manlio Perillo d67e739989 os/exec: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: Idbd8067759d58bc57c52ede4ddccc98ab0ae18fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/308129
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-04-08 21:58:35 +00:00
Cherry Zhang ec367e5b05 cmd/compile: adjust interface conversion function selection with 0-sized fields
0-sized fields do not affect how arguments are passed under the
register ABI. But it does affect the size and alignment of the
type, and may affect the choice of interface conversion function.
Specifically, struct { a [0]int32; b [4]byte } should be passed in
memory, therefore should not use convT32.

Change-Id: Idfa21af79b81c196b50253b0be1fa4edecd12b45
Reviewed-on: https://go-review.googlesource.com/c/go/+/308651
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-08 21:26:36 +00:00
Cherry Zhang 6c98ecda10 cmd/compile: don't use fast32/64 map functions for aggregates
Under register ABI, aggregates like [2]uint32 is passed
differently than a uint64. For now, don't use the fast version
of the map functions for non-trivial aggregates.

GOEXPERIMENT=regabi,regabiargs can now pass make.bash, modulo
staleness checks.

TODO: maybe find some way to use the fast functions. Maybe
unsafe-cast to uint32/64 then call the map function. But need to
make the type checker happy.

Change-Id: If42717280dde12636fb970798cf1ca8fb29a3d06
Reviewed-on: https://go-review.googlesource.com/c/go/+/308650
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-04-08 21:02:58 +00:00
David Chase a9e475a15a cmd/compile: add recursive-invalidate Value method, use in expand_calls
This removes more unused values during transformation.
Leaving them in the tree can create type conflicts in OpArg* references.

Updates #40724.
Updates #44816.
Fixes #45417.

Change-Id: I07dcb7b4b2bf8d79e22e0543cb2fb52c2ececb96
Reviewed-on: https://go-review.googlesource.com/c/go/+/308589
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-08 20:26:47 +00:00
Ian Lance Taylor 7e583806d8 runtime/cgo: clarify Handle documentation
Fixes #45427

Change-Id: Ic67630a5f39d8789a4a30c6b4ee30946bc50382e
Reviewed-on: https://go-review.googlesource.com/c/go/+/308230
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ainar Garipov <gugl.zadolbal@gmail.com>
Reviewed-by: Changkun Ou <euryugasaki@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-08 20:24:09 +00:00
Than McIntosh bb76193a7f cmd/compile: fix buglet in walk convert phase relating to convF32/64
The helper function used by the compiler's walk phase to determine
whether a param can be passed in a single float register wasn't quite
correct (didn't allow for the possibility of struct with two fields,
first zero size and second float). Fix up the helper to take this
case into account.

Updates #40724.

Change-Id: I55b42a1b17ea86de1d696788f029ad3aae4a179c
Reviewed-on: https://go-review.googlesource.com/c/go/+/308689
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-08 19:58:50 +00:00
Austin Clements 793844207d cmd/go: strip GOEXPERIMENT from hash salt
The go command salts cache hashes using runtime.Version() (the Go
version the go command was built with) in order to separate objects
built with different versions of Go.

CL 307820 added the active GOEXPERIMENTs to the result of
runtime.Version, which affected cmd/go's hash salt. Since dist builds
go_bootstrap with all GOEXPERIMENTs disabled, but then go_bootstrap
builds the final go binary with the GOEXPERIMENTs passed to make.bash,
if any GOEXPERIMENTs were passed, go_bootstrap and the final go binary
produce different cache hashes. At the very end of dist, it uses the
final go binary to check the hashes of all packages, but these hashes
were produced by go_bootstrap, so it concludes everything is stale.

This should fix the builders that enable GOEXPERIMENTs, including the
regabi and staticlockranking builders.

Change-Id: Ie389929dff6f7b6eff2b19a2f43507e72be5f32e
Reviewed-on: https://go-review.googlesource.com/c/go/+/308591
Trust: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-08 19:52:03 +00:00
Jason A. Donenfeld 98dd205fa4 runtime: see whether gp==nil before checking preemption state
Recent we changed from using gFromTLS to using gFromSP, which apparently
sometimes returns nil. This causes crashes when dereferenced. Fix that
by not checking for preemption in the case that gFromSP returns nil.

Fixes #44679.

Change-Id: I0199ebe7cd113379c5fa35c27932d913df79092a
Reviewed-on: https://go-review.googlesource.com/c/go/+/297390
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-04-08 19:51:32 +00:00
Dan Scales 46ffbec1d6 cmd/compile: break out transformations of tcCompLit into transformCompLit
Create transformCompLit, which does the transformations done by
tcCompLit without the typechecking. This removes the final use of the
old typechecker in the noder2 pass.

Other changes:

 - Used the transformCompLit in stringstorunelit(), which creates an
   OCOMPLIT that needs transformation as well.

 - Fixed one place in transformIndex where we were still using
   typecheck.AssignConv, when we should be using its equivalent
   noder.assignconvfn.

The go/test tests always run with -G=3, and I also tested that the "go
test" tests continue to run correctly with -G=3.

Change-Id: I4a976534ab7311cf2a5f43841026dbf7401e62b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/308529
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-08 19:32:37 +00:00
Bryan C. Mills ecca94a7d1 cmd/go/internal/modload: add a dormant depth type
This change adds the depth constants 'lazy' and 'eager', but leaves
the go117EnableLazyLoading constant set to false so that the depth in
effect is still always 'eager'.

The go117EnableLazyLoading constant can be toggled to true once the
module loader has been updated to maintain the lazy-loading invariants
in the go.mod file. In the meantime, this will allow me to
progressively replace uses of go117LazyTODO with real conditions and
locally toggle lazy-mode on to see which tests are still failing
(or which behaviors are missing test coverage).

For #36460

Change-Id: Ifd358265a3903a5000003c2072f28171f336e15c
Reviewed-on: https://go-review.googlesource.com/c/go/+/308515
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-08 19:30:34 +00:00
Cherry Zhang 96a6745088 runtime: use register ABI in panicIndex/Slice functions
runtime.panicIndex*/panicSlice* functions move the arguments in
the right place then tail calls goPanicIndex*/Slice* using
internal ABI. (It uses internal ABI to avoid wrappers, because
the callee needs to get the caller's PC, to know whether it panics
in the runtime.) This CL makes it to use the register ABI if it
is enabled.

Change-Id: Id2ebb51b4bfb3e9aa7cb66d0a9aee63fccee5ecd
Reviewed-on: https://go-review.googlesource.com/c/go/+/308649
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-08 18:47:17 +00:00
Than McIntosh ca8540affd cmd/compile: fix buglet in walk convert phase relating to convT64
The function runtime.convT64 accepts a single uint64 argument, but the
compiler's rules in the walk phase for determining whether is it ok to
pass a value of type T to a call to runtime.convT64 were slightly off.
In particular the test was allowing a type T with size less than eight
bytes but with more than one internal element (e.g. a struct). This
patch tightens up the rules somewhat to prevent this from happening.

Updates #40724.

Change-Id: I3b909267534db59429b0aa73a3d73333e1bd6432
Reviewed-on: https://go-review.googlesource.com/c/go/+/308069
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-08 17:44:21 +00:00
Jay Conrod 23e1d36a87 cmd/go: in 'go list -m', ignore "not found" errors loading updates
"Not found" and "no matching version" errors usually indicate the user
is offline or the proxy doesn't have a version of go.mod that could
provide retractions. 'go list -m -u' should still succeed.

We should still report unclassified errors though. Previously, we
reported most errors loading retractions but did not report errors
loading updates. This change makes those operations more consistent.

Fixes #45305

Change-Id: I2f23a566c9481bc7ff229a177f39d78f6a8aae77
Reviewed-on: https://go-review.googlesource.com/c/go/+/306572
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-08 17:18:24 +00:00
Bryan C. Mills 0e09e4143e cmd/go: assume Go 1.16 semantics uniformly for unversioned modules
However, still only trigger -mod=vendor automatically (and only apply
the more stringent Go 1.14 vendor consistency checks) if the 'go'
version is explicit. This provides maximal compatibility with Go 1.16
and earlier: Go 1.11 modules will continue not to fail vendor
consistency checks, but scripts that assume semantics up to Go 1.16
for unversioned modules will continue to work unmodified.

Fixes #44976
For #36460

Change-Id: Idb05ca320023f57249c71fc8079218e8991d1ff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/308509
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-08 16:55:27 +00:00
Michael Anthony Knyszek 31d2556273 runtime: set up read-only dummy TLS space for needm on Windows
On Windows, TLS is uninitialized for C threads calling into Go code.
In this path, before calling into user Go code, we call into needm which
runs without an m, but whose purpose is to pick one up. While in Go
code, we may occasionally restore the G register from TLS for a number
of reasons. Rather than try to flag all these cases, given that needm
(and its callees) are already somewhat special, just set up a dummy TLS
space for it that's read-only. If it ever actually tries to write to
this space (it shouldn't), it will fail loudly. Otherwise, code that
restores the G register will simply load a zero value, but that's OK
since needm is careful never to require the G at any point, because it
doesn't yet have a valid G. Furthermore, by the time needm returns, it
will have set up TLS properly for a Windows C thread, so there's no need
to do anything extra afterwards.

For #40724.

Change-Id: I34e8095059817e4ee663505e89cda8785b634b98
Reviewed-on: https://go-review.googlesource.com/c/go/+/307872
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-08 16:37:24 +00:00
David Chase 283b02063b cmd/compile: sanitize before/after expansion OpSelectN references
In expand_calls, OpSelectN occurs both before and after the rewriting.
Attempting to rewrite a post-expansion OpSelectN is bad.
(The only ones rewritten in place are the ones returning mem;
others are synthesized to replace other selection chains with
register references.)

Updates #40724.
Updates #44816#issuecomment-815258897.

Change-Id: I7b6022cfb47f808d3ce6cc796c067245f36047f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/308309
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-08 15:03:31 +00:00
Austin Clements 1be8be4acc cmd/go: fix TestNewReleaseRebuildsStalePackagesInGOPATH
CL 307818 added a package that the runtime depends on, but didn't
update the list of runtime dependencies in this test.

This should fix the longtest builder failures.

Change-Id: I5f3be31b069652e05ac3db9b1ce84dd5dfe0f66f
Reviewed-on: https://go-review.googlesource.com/c/go/+/308469
Trust: Austin Clements <austin@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-08 15:02:51 +00:00
David Chase 912c4e29d3 reflect: fix typo in result-in-registers case
t is the type of the function that was called
tv is the type of the result

This fixes the failures for
GOEXPERIMENT=regabi,regabiargs go test go test text/template
GOEXPERIMENT=regabi,regabiargs go test go test html/template

Updates #40724.

Change-Id: Ic9b02d72d18ff48c9de1209987cc39da619c2241
Reviewed-on: https://go-review.googlesource.com/c/go/+/308189
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-08 14:23:47 +00:00
panchenglong01 1749f3915e sync: update misleading comment in map.go about entry type
As discussed in: https://github.com/golang/go/issues/45429,  about entry
type comments, it is possible for p == nil when m.dirty != nil, so
update the commemt about it.

Fixes #45429

Change-Id: I7ef96ee5b6948df9ac736481d177a59ab66d7d4d
GitHub-Last-Rev: 202c598a0a
GitHub-Pull-Request: golang/go#45443
Reviewed-on: https://go-review.googlesource.com/c/go/+/308292
Reviewed-by: Changkun Ou <euryugasaki@gmail.com>
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-08 14:08:29 +00:00
ianwoolf a7e16abb22 runtime: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: I3aa82fc2486b4de49b45388bbab24f5ffe558f91
Reviewed-on: https://go-review.googlesource.com/c/go/+/307989
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-08 07:33:58 +00:00
Matthew Dempsky 2123dfba65 Revert "cmd/compile/internal/noder: limit the number of goroutine"
This reverts commit c274a7c03b.

Reason for revert: this can cause a compiler deadlock, and there's
no demonstrable benefit to making the change.

Change-Id: I42325ddea68d37db16fd0061c5baaee112b755b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/308369
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-08 06:08:49 +00:00
Austin Clements 8752454ece cmd/internal/objabi: clarify initialization of Experiments
Currently objabi.Experiments is set via side-effect from an init
function, which makes their initialization process somewhat unclear
(indeed, I've messed this up before) and opens the possibility of
accessing them from another init function before it's initialized.

Originally, this init function set several variables, but at this
point it sets only objabi.Experiments, so switch to just using a
variable initializer to make the initialization process clear.

Change-Id: Id0d2ac76ae463824bbf37a9305e8643a275f1365
Reviewed-on: https://go-review.googlesource.com/c/go/+/307821
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08 02:17:23 +00:00
Austin Clements 5159c83641 runtime,cmd/link: include GOEXPERIMENTs in runtime.Version(), "go version X"
This adds the set of GOEXPERIMENTs to the build version if it differs
from the default set of experiments. This exposes the experiment
settings via runtime.Version() and "go version <binary>".

Change-Id: I143dbbc50f66a4cf175469199974e18848075af6
Reviewed-on: https://go-review.googlesource.com/c/go/+/307820
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08 02:17:22 +00:00
Austin Clements a8e55538af cmd/internal/objabi: make GOEXPERIMENT be a diff from default experiments
Right now the rules around handling default-on experiments are
complicated and a bit inconsistent. Notably, objabi.GOEXPERIMENT is
set to a comma-separated list of enabled experiments, but this may not
be the string a user should set the GOEXPERIMENT environment variable
to get that list of experiments: if an experiment is enabled by
default but gets turned off by GOEXPERIMENT, then the string we report
needs to include "no"+experiment to capture that default override.

This complication also seeps into the version string we print for "go
tool compile -V", etc. This logic is further complicated by the fact
that it only wants to include an experiment string if the set of
experiments varies from the default.

This CL rethinks how we handle default-on experiments. Now that
experiment state is all captured in a struct, we can simplify a lot of
this logic. objabi.GOEXPERIMENT will be set based on the delta from
the default set of experiments, which reflects what a user would
actually need to pass on the command line. Likewise, we include this
delta in the "-V" output, which simplifies this logic because if
there's nothing to show in the version string, the delta will be
empty.

Change-Id: I7ed307329541fc2c9f90edd463fbaf8e0cc9e8ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/307819
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08 02:17:20 +00:00
Austin Clements 89ca1ce9a8 cmd/compile,cmd/internal/objabi: abstract out object header string
Change-Id: Idbbb4cb7127b93afa34a8aa18bbdaad1f206ab6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/308090
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08 02:17:19 +00:00
Austin Clements b675e52e95 internal/goexperiment: consolidate experiment-enabled constants
Currently, we have boolean and integral constants for GOEXPERIMENTs in
various places. Consolidate these into automatically generated
constants in the internal/goexperiment package.

Change-Id: I42a49aba2a3b4c722fedea23a613162cd8a67bee
Reviewed-on: https://go-review.googlesource.com/c/go/+/307818
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: Matthew Dempsky <mdempsky@google.com>
2021-04-08 02:17:18 +00:00
Austin Clements 6304b401e4 internal/goexperiment,cmd: consolidate GOEXPERIMENTs into a new package
Currently there's knowledge about the list of GOEXPERIMENTs in a few
different places. This CL introduces a new package and consolidates
the list into one place: the internal/goexperiment.Flags struct type.

This package gives us a central place to document the experiments as
well as the GOEXPERIMENT environment variable itself. It will also
give us a place to put built-time constants derived from the enabled
experiments.

Now the objabi package constructs experiment names by reflecting over
this struct type rather than having a separate list of these names
(this is similar to how the compiler handles command-line flags and
debug options). We also expose a better-typed API to the toolchain for
propagating enabled experiments.

Change-Id: I06e026712b59fe2bd7cd11a869aedb48ffe5a4b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/307817
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08 02:17:16 +00:00
Austin Clements 0c4a08cb74 cmd/asm,runtime: reduce spellings of GOEXPERIMENTs
Currently, the objabi.Experiment fields use Go-standard CamelCase, the
GOEXPERIMENT environment variable flags and build tags use all
lowercase, and the asm macros use upper-case with underscores.

This CL makes asm use the lowercase names for macros so there is one
less spelling, e.g., GOEXPERIMENT_regabiargs. This also makes them
consistent with the GOOS_* and GOARCH_* macros, which also use lower
case.

Change-Id: I305cd89af5e8cd1a89cc148746c034bcfd76db3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/307816
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08 02:17:15 +00:00
Austin Clements aeaa4519b5 runtime: drop haveexperiment, sys.GOEXPERIMENT
We have ways to statically access experiments now, so we don't need a
relatively clunky string-parsing dynamic way to do it.

Change-Id: I5d75480916eef4bde2c30d5fe30593180da77ff2
Reviewed-on: https://go-review.googlesource.com/c/go/+/307815
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: Matthew Dempsky <mdempsky@google.com>
2021-04-08 02:17:13 +00:00
ianwoolf f60aa7a18c syscall: replace os.MkdirTemp with T.TempDir
Updates #45402

Change-Id: I573133d6b987e8ac23e3e2018652612af684c755
Reviewed-on: https://go-review.googlesource.com/c/go/+/307990
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: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-07 23:00:58 +00:00
Paul E. Murphy fca51ba24a cmd/internal/obj: remove ppc64 msr support from MOV* insns
These are privileged instructions, and thus will never work with
usermode code. I don't think there is a case where this isn't
true.  The motivation is to simplify handling of MOV* opcodes.

Assembler support for recognizing the MSR as a register is
retained.

Change-Id: Ic33f021a20057b64e69df8ea125e23dd8937e38d
Reviewed-on: https://go-review.googlesource.com/c/go/+/307814
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-07 20:23:47 +00:00
Makdon e306d06063 runtime/map: update comment for gc/reflect
update comment cause gc/reflect.go has been moved to reflectdata/reflect.go

In the commit (attach below), gc/reflect.go is moved to reflectdata/reflect.go
So the  comment referring gc/reflect.go should be updated to reflectdata/reflect.go

There maybe other places that refers gc/reflect.go that should be updated.
I would work around it soon.

commit:
de65151e50
e4895ab4c0

Change-Id: Ieed5c48049ffe6889c08e164972fc7825653ac05
GitHub-Last-Rev: eec9c2328d
GitHub-Pull-Request: golang/go#45421
Reviewed-on: https://go-review.googlesource.com/c/go/+/307930
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-07 18:44:30 +00:00
Robert Griesemer b3064b66d0 cmd/compile/internal/types2: combine two loops (cleanup of TODO)
Follow-up on https://golang.org/cl/306170.

Change-Id: I71b451382b6780101a0c94174ebe579e8a0684c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/307949
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-07 16:57:40 +00:00
Tobias Klauser 4520da486b cmd/pack: use testing.T.TempDir in tests
Change-Id: I7371259cf5d64f04698ae1477c3de1255664178d
Reviewed-on: https://go-review.googlesource.com/c/go/+/307969
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-07 13:24:10 +00:00
Cherry Zhang b55d900529 cmd/compile: correct argument area size for typedmemmove/typedmemclr
When the write barrier pass emits typedmemmove/typedmemclr calls,
even the arguments are in registers, we still need to leave space
for the spill slots. Count that space. Otherwise when the callee
spills arguments it may clobber locals on the caller's frame.

Change-Id: I5326943427feaf66cab7658a5bef55b3baf5d345
Reviewed-on: https://go-review.googlesource.com/c/go/+/307824
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-07 13:14:57 +00:00
徐志伟 d6aa162f30 embed, testing/fstest: small optimization for ReadDir
Change-Id: If8dc6d917b55119b5662ce5b0b87328d220d684d
GitHub-Last-Rev: cc9a1d5a7e
GitHub-Pull-Request: golang/go#45388
Reviewed-on: https://go-review.googlesource.com/c/go/+/307250
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-07 09:59:58 +00:00
ianwoolf 5d5f779db4 net/http: replace os.MkdirTemp with T.TempDir
Updates: #45402
Change-Id: Ia61f422d058bf57fc3688abc25597d6cc1692c51
Reviewed-on: https://go-review.googlesource.com/c/go/+/307653
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-07 06:53:34 +00:00
Robert Griesemer 4bbe046aad cmd/compile/internal/syntax: add "~" operator
Change-Id: I7991103d97b97260d9615b7f5baf7ec75ad87d1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/307370
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-07 05:19:41 +00:00
Robert Griesemer 836356bdaa cmd/compile/internal/types2: process errors in src order during testing
Follow-up on https://golang.org/cl/305573.
As a consequence, re-enable test case that caused problems with that CL.

Change-Id: Ibffee3f016f4885a55b8e527a5680dd437322209
Reviewed-on: https://go-review.googlesource.com/c/go/+/307216
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-07 05:19:36 +00:00
Robert Griesemer 8f1099b585 cmd/compile/internal/syntax, types2: move cmpPos to pos.Cmp
Make position comparison generally available.

Change-Id: I94b6f658fa19a15b30574dbb2181879115c131a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/307215
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-07 05:19:29 +00:00