1
0
mirror of https://github.com/golang/go synced 2024-09-29 03:34:33 -06:00
Commit Graph

47874 Commits

Author SHA1 Message Date
Russ Cox
073f913949 debug/dwarf: skip over zero-length compilation units
DWARF sections generated by mingw-clang seem to include these
(not often - only one out of many in the binary that I am looking at).
Skipping over them, everything parses correctly.

This makes TestDefaultLinkerDWARF pass on windows/arm64.

Change-Id: Ie4a7daa1423f51cbc8c4aac88b1d27c3b52ee880
Reviewed-on: https://go-review.googlesource.com/c/go/+/312031
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-23 21:42:56 +00:00
Russ Cox
cef3a442ea cmd/asm, cmd/link: use full objabi header
The cmd/link check of the objabi header was a bit lax because
historically the assembler has not included the full version string.
And the assembler didn't do that because it didn't have access to it:
that was buried inside the compiler.

But now that we have cmd/internal/objabi, all the tools have full
access to the expected string, and they can use it, which simplifies
the cmd/link consistency check.

Do that.

Change-Id: I33bd2f9d36c373cc3c32ff02ec6368365088b011
Reviewed-on: https://go-review.googlesource.com/c/go/+/312030
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-23 21:42:54 +00:00
Russ Cox
19470dc535 misc/cgo/test: do not redeclare exported Go functions
An exported Go function like

	//export F
	func F() {}

gets declared in _cgo_export.h as something like

	extern void F(void);

The exact declaration varies by operating system.
In particular, Windows adds __declspec(dllimport).

Clang on Windows/ARM64 rejects code that contains
conflicting declarations for F, like:

	extern void F(void);
	extern void __declspec(dllimport) F(void);

This means that F must not be declared separately from _cgo_export.h:
any code that wants to refer to F must use #include "_cgo_export.h".

Unfortunately, the cgo prologue itself (the commented code before import "C")
cannot include "_cgo_export.h", because that file is itself produced from the
cgo Go sources and therefore cannot be a dependency of the cgo Go sources.

This CL rewrites misc/cgo/test to avoid redeclaring exported functions.
Most of the time, this is not a significant problem: just move the code
that needs the header into a .c file, perhaps with a wrapper exposed
to the cgo Go sources.

The one case that is potentially problematic is f7665, which is part of
the test for golang.org/issue/7665. That bug report explicitly identified
a bug in referring to the C name for an exported function in the same
Go source file as it was exported function. That is now impossible,
at least on Windows/ARM64, so the test is modified a bit and possibly
does not test what the original bug was. But the original bug should
be long gone: that part of the compiler has been rewritten.

Change-Id: I0d14d9336632f0e5e3db4273d9d32ef2cca0298d
Reviewed-on: https://go-review.googlesource.com/c/go/+/312029
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-23 21:42:52 +00:00
Cherry Zhang
1421516973 cmd/compile, internal/abi: add FuncPCABIxxx intrinsics
When ABI wrappers are used, there are cases where in Go code we
need the PC of the defined function instead of the ABI wrapper.
Currently we work around this by define such functions as
ABIInternal, even if they do not actually follow the internal ABI.

This CL introduces internal/abi.FuncPCABIxxx functions as compiler
intrinsics, which return the underlying defined function's entry
PC if the argument is a direct reference of a function of the
expected ABI, and reject it if it is of a different ABI.

As a proof of concept, change runtime.goexit back to ABI0 and use
internal/abi.FuncPCABI0 to retrieve its PC.

Updates #44065.

Change-Id: I02286f0f9d99e6a3090f9e8169dbafc6804a2da6
Reviewed-on: https://go-review.googlesource.com/c/go/+/304232
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-23 21:05:39 +00:00
Matthew Dempsky
691e1b84c1 cmd/compile: generalize fix for lvalue-init evaluation
The previous fix to ensure early evaluation of lvalue-init statements
(CL 312632) added it after we'd already peeled away any array-OINDEX
expressions. But those might have init statements too, so we need to
do this earlier actually and perhaps more than once.

Longer term, lvalue expressions shouldn't have init statements anyway.
But rsc and I both spent a while looking into this earlier in the dev
cycle and couldn't come up with anything reasonable.

Fixes #45706.

Change-Id: I2d19c5ba421b3f019c62eec45774c84cf04b30ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/313011
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-23 20:57:54 +00:00
Bryan C. Mills
768a39975d cmd/go/internal/modload: remove the addedModuleFor map
At one point this map checked for infinite loops during package iteration.
The last write to the map was mistakenly removed in CL 251445.

However, looking at the code before that change, the map-based
termination strategy was never quite right to begin with: it checked
whether we had ever added any module for the given package, not
whether we had already added the module being proposed right now. (For
packages within nested modules, we could try adding multiple different
modules for a given package without looping.)

Moreover, the "looping trying to add package" failure message was only
marginally helpful. Users are capable of noticing that an invocation
of the 'go' command is taking too long, and will report a bug for an
infinite loop just as readily as a "looping trying to add package"
error.

We could try to add this tracking back in, but it's no substitute for
a proper proof of convergence, and the code is simpler without it.
Instead I'm going to add a proper proof of convergence — or, barring
that, a more accurate and useful check for failure to converge. In the
meantime, this invariantly-empty map isn't doing anybody any good.

For #36460

Change-Id: I2c111d4b4bf59159af0d7e62d1c0ef4ce0a43a71
Reviewed-on: https://go-review.googlesource.com/c/go/+/312929
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-04-23 19:38:27 +00:00
Sean Liao
c3e2ed711c cmd/go: use builtin version and reexec for env
Skip execing for version (most reliable) and attempt to reexec
for env, falling back to the go in GOROOT

Fixes #43981

Change-Id: I17fb84d36036807274eecca3d4f64b3add9b9483
Reviewed-on: https://go-review.googlesource.com/c/go/+/288693
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
2021-04-23 19:08:32 +00:00
Filippo Valsorda
d2f96f2f75 math/rand: make the security warning clearer and more prominent
It is still a common misconception that math/rand can be used for
security-sensitive work if seeded with crypto/rand
(lazyledger/lazyledger-core#270). It can not.

Change-Id: I8598c352d1750eabeada50be9976ab68cbb42cc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/310350
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-23 17:50:33 +00:00
Cuong Manh Le
8c66669764 cmd/compile: make sure ascompatee walk lhs init statements
CL 281152 improved ascompatee by removing the call to safeExpr on lhs.
But we forgot that lhs int statements, if any, must be walked prior
saving subexpressions, which cause the bug in #45706.

Fixes #45706

Change-Id: I0064315056ef4ca92ebf3c332c2e3a9bb2b26f68
Reviewed-on: https://go-review.googlesource.com/c/go/+/312632
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-23 17:36:11 +00:00
David Chase
d4bfe00615 cmd/go: make build cache tag sensitive to GOSSADIR; remove unused
GOSSADIR is a useful compiler flag for debugging.
Removed GO_SSA_PHI_LOC_CUTOFF, it is no longer mentioned in the compiler.

Change-Id: I3600f4c6ded95c9d34b85a6f0da6ba89b17a13ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/312290
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-23 14:06:54 +00:00
Michael Pratt
bedfeed54a runtime,runtime/metrics: add metric to track scheduling latencies
This change adds a metric to track scheduling latencies, defined as the
cumulative amount of time a goroutine spends being runnable before
running again. The metric is an approximations and samples instead of
trying to record every goroutine scheduling latency.

This change was primarily authored by mknyszek@google.com.

Change-Id: Ie0be7e6e7be421572eb2317d3dd8dd6f3d6aa152
Reviewed-on: https://go-review.googlesource.com/c/go/+/308933
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-23 13:48:10 +00:00
Egon Elbre
105a6e9518 os: skip TestExecutableDeleted on aix
aix does not support reading deleted executable name.

Change-Id: I955ed2c22bd0693440e2c889a4d3132d0a375c48
Reviewed-on: https://go-review.googlesource.com/c/go/+/312392
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-23 11:33:03 +00:00
Cuong Manh Le
5963f0a332 cmd/vendor: get golang.org/x/tools@f946a157eef
To bring in the fix for sigchanyzer pass to detect valid usage of
unbuffer channel to builtin make.

Fixes #45043

Change-Id: I60d2ee90f7c111183b33747008903a7df88b76ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/312631
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-23 05:38:47 +00:00
Cuong Manh Le
d310b2a6b8 cmd/compile: set correct Defn for inlined vars
Currently, when copying definition node of an inlined var, we do not
update var Defn field to point to new copied node. That causes all
inlined vars point to the same Defn, and ir.StaticValue can not find
inlined var in the lhs of its definition.

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

To fix this, we need to do two things:

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

Fixes #45606

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

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

Test written by Cherry.

Updates #40724.

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

Updates #19367.
Updates #40481.

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

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

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

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

Fixes #45667.

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

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

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

Updates #6853

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

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

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

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

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

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

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

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

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

Fixes #43997

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

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

For #36460

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

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

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

For example, for a function

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

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

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

Now prints

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

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

Increase binary sizes by ~1.5%.

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

Updates #40724.

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

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

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

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

Fixes #45693.

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

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

For #45658.

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

Fixes #45091.

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

Also drop a remaining case of 32-bit ARM.

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

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

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

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

For #43087.
For #45652.

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

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

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

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

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

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

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

I hope that this
Fixes #35356

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

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

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

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

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

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

For #40724.

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

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

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

Fixes #44193

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

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

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

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

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

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

Change-Id: I0cc34d56e41c1e66b17edd0ccd3f281d97a6b235
Reviewed-on: https://go-review.googlesource.com/c/go/+/312091
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-04-21 20:35:43 +00:00