1
0
mirror of https://github.com/golang/go synced 2024-11-07 09:06:20 -07:00
Commit Graph

47962 Commits

Author SHA1 Message Date
Bryan C. Mills
69c94ad55f cmd/go/internal/modload: split updateRoots into separate functions for updating and tidying
In CL 293689, I fused the mvs.Reqs calls that were formerly in MinReqs
and TidyBuildList into a single function, updateRoots, in the hope
that it expressed a fundamental operation. As I have been working on
the lazy equivalents, I have come to realize that these functions are
deeply related but fundamentally different.

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

For #36460

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

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

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

For #36460
For #40775

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

For #33174

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

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

Fixes #45548.

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

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

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

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

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

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

Fixes #395

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

Updates #395

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

Updates #395

Change-Id: I90f4bff2da5d8f3148ba06d2482084f32b25c29a
Reviewed-on: https://go-review.googlesource.com/c/go/+/301650
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-21 00:53:48 +00:00
Josh Bleecher Snyder
1c268431f4 spec: allow conversion from slice to array ptr
Implementation follows in subsequent changes.

Updates #395

Change-Id: Ic97ee822805e4c236fdd9d224e776cb2ae62c817
Reviewed-on: https://go-review.googlesource.com/c/go/+/216424
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2021-04-20 23:47:34 +00:00
Keith Randall
e12b0afa54 cmd/compile: separate out parameter and field export encoding
These two types of *types.Field encode different concepts, so we
encode them separately (and ignore fields that don't matter for
each concept).

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

Reason for revert: Breaks longtest builders:

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

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

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

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

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

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

This CL should have no functional changes.

For #43997
For #44313

Change-Id: I6d3060fcecda9920a3471ff338f73d53b1d848a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/307914
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-20 20:58:52 +00:00
Jinzhu
7473a6a0eb reflect: fix stack overflow panic when using haveIdenticalUnderlyingType
haveIdenticalUnderlyingType raises stack overflow when compares
self-referential structs having same structure in different packages.

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

Should fix the freeBSD builder.

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

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

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

This CL should have no functional changes.

For #43997.
For #44313.

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

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

Updates #45639

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

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

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

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

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

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

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

Fixes #45635

Change-Id: I8ab1720f3e27a6002bc925f0eea943ec6f778341
Reviewed-on: https://go-review.googlesource.com/c/go/+/311669
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20 00:14:27 +00:00
Cherry Zhang
3711ea0b5d cmd/compile: do not clobber arguments for reflect.callReflect and callMethod's ABI wrappers
reflect.callReflect and reflect.callMethod are called from special
functions makeFuncStub and methodValueCall. The runtime expects
that it can find the first argument (ctxt) at 0(SP) in
makeFuncStub and methodValueCall's frame. Normally callReflect and
callMethod already do not modify the argument, and keep it alive.
But the compiler-generated ABI wrappers don't do that. Special
case the wrappers to not clobber its arguments.

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

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

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

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

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

Fixes #45526

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

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

Fixes #42765

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

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

Reserve the space.

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

Fixed #38627

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

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

This has a few redundant moves.

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

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

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

(with regabiargs enabled.)

Change-Id: I69e1bdf745f2c90bb791f6d7c45b37384af1e874
Reviewed-on: https://go-review.googlesource.com/c/go/+/311371
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-19 16:21:39 +00:00
Cherry Zhang
b21e739f87 test: add test for CL 310589
Change-Id: Iff0876bd17c2a93db72dc90678f3a46ef8effd74
Reviewed-on: https://go-review.googlesource.com/c/go/+/311370
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-19 14:51:24 +00:00
Cherry Zhang
a9c244a849 test: add liveness test for regabi
With defer/go wrapping and register arguments, some liveness info
changed and live.go test was disabled for regabi. This CL adds a
new one for regabi.

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

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

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

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

Fixes #45258

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

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

This should fix the *-regabi builders.

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

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

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

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

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

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

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

For #40724.

Change-Id: I0fb95be42f756d412e729a396be607d629ae2bab
Reviewed-on: https://go-review.googlesource.com/c/go/+/310609
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-16 22:45:02 +00:00
Leonard Wang
94817890c2 runtime: remove useless nFlushCacheRoots
Change-Id: I70cb8f8e9a0eec68ea11f22ca8699aa7e0c91ede
Reviewed-on: https://go-review.googlesource.com/c/go/+/310710
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-16 21:50:38 +00:00