]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agoos: mark pipes returned by os.Pipe() as inheritable by default
Jason A. Donenfeld [Sun, 31 Jan 2021 18:51:45 +0000 (19:51 +0100)]
os: mark pipes returned by os.Pipe() as inheritable by default

Now that we don't automatically pass all inheritable handles to new
processes, we can make pipes returned by os.Pipe() inheritable, just
like they are on Unix. This then allows them to be passed through the
SysProcAttr.AdditionalInheritedHandles parameter simply.

Updates #44011.
Fixes #21085.

Change-Id: I8eae329fbc74f9dc7962136fa9aae8fb66879751
Reviewed-on: https://go-review.googlesource.com/c/go/+/288299
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agocmd/compile: check frame offsets against abi
David Chase [Tue, 9 Feb 2021 23:09:47 +0000 (18:09 -0500)]
cmd/compile: check frame offsets against abi

this is in preparation for turning off calculation of frame offsets
in types.CalcSize

For #40724.

Change-Id: I2c29fd289c014674076e5ec5170055dbca5ea64b
Reviewed-on: https://go-review.googlesource.com/c/go/+/293392
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agocmd/compile: fix escape analysis of heap-allocated results
Matthew Dempsky [Sat, 27 Feb 2021 17:41:19 +0000 (09:41 -0800)]
cmd/compile: fix escape analysis of heap-allocated results

One of escape analysis's responsibilities is to summarize whether/how
each function parameter flows to the heap so we can correctly
incorporate those flows into callers' escape analysis data flow
graphs.

As an optimization, we separately record when parameters flow to
result parameters, so that we can more precisely analyze parameter
flows based on how the results are used at the call site. However, if
a named result parameter itself needs to be heap allocated, this
optimization isn't safe and the parameter needs to be recorded as
flowing to heap rather than flowing to result.

Escape analysis used to get this correct because it conservatively
rewalked the data-flow graph multiple times. So even though it would
incorrectly record the result parameter flow, it would separately find
a flow to the heap. However, CL 196811 (specifically, case 3)
optimized the walking logic to reduce unnecessary rewalks causing us
to stop finding the extra heap flow.

This CL fixes the issue by correcting location.leakTo to be sensitive
to sink.escapes and not record result-flows when the result parameter
escapes to the heap.

Fixes #44614.

Change-Id: I48742ed35a6cab591094e2d23a439e205bd65c50
Reviewed-on: https://go-review.googlesource.com/c/go/+/297289
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: fixed which-result confusion in presence of 0-width types
David Chase [Fri, 26 Feb 2021 22:37:26 +0000 (17:37 -0500)]
cmd/compile: fixed which-result confusion in presence of 0-width types

A function returning multiple results, some of them zero-width,
will have more than one result present at an offset.  Be sure
that offset AND type match.

Includes test.

Change-Id: I3eb1f56116d989b4e73f533fefabb1bf554c901b
Reviewed-on: https://go-review.googlesource.com/c/go/+/297169
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agotime: correct unusual extension string cases
Ian Lance Taylor [Thu, 25 Feb 2021 18:01:56 +0000 (10:01 -0800)]
time: correct unusual extension string cases

This fixes two uncommon cases.

First, the tzdata code permits timezone offsets up to 24 * 7, although
the POSIX TZ parsing does not. The tzdata code uses this to specify a
day of week in some cases.

Second, we incorrectly rejected a negative time offset for when a time
zone change comes into effect.

Fixes #44385

Change-Id: I5f2efc1d385e9bfa974a0de3fa81e7a94b827602
Reviewed-on: https://go-review.googlesource.com/c/go/+/296392
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>
4 years agoreflect: fix register ABI spill space calculation
Michael Anthony Knyszek [Wed, 17 Feb 2021 19:14:03 +0000 (19:14 +0000)]
reflect: fix register ABI spill space calculation

Currently this does things the old way by computing the number of
registers, but we're going to be using their ABI0 layout for the spill
space for now.

Change-Id: Ibcef1ee48fd834af7cbdaabe704bcabe066ed358
Reviewed-on: https://go-review.googlesource.com/c/go/+/293011
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

4 years agocmd/compile: deal with closures in generic functions and instantiated function values
Dan Scales [Sun, 21 Feb 2021 18:54:38 +0000 (10:54 -0800)]
cmd/compile: deal with closures in generic functions and instantiated function values

 - Deal with closures in generic functions by fixing the stenciling code

 - Deal with instantiated function values (instantiated generic
   functions that are not immediately called) during stenciling. This
   requires changing the OFUNCINST node to an ONAME node for the
   appropriately instantiated function. We do this in a second pass,
   since this is uncommon, but requires editing the tree at multiple
   levels.

 - Check global assignments (as well as functions) for generic function
   instantiations.

 - Fix a bug in (*subst).typ where a generic type in a generic function
   may definitely not use all the type args of the function, so we need
   to translate the rparams of the type based on the tparams/targs of
   the function.

 - Added new test combine.go that tests out closures in generic
   functions and instantiated function values.

 - Added one new variant to the settable test.

 - Enabling inlining functions with closures for -G=3. (For now, set
   Ntype on closures in -G=3 mode to keep compatibility with later parts
   of compiler, and allow inlining of functions with closures.)

Change-Id: Iea63d5704c322e42e2f750a83adc8b44f911d4ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/296269
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>

4 years agosyscall: introduce SysProcAttr.ParentProcess on Windows
Jason A. Donenfeld [Sun, 31 Jan 2021 17:14:56 +0000 (18:14 +0100)]
syscall: introduce SysProcAttr.ParentProcess on Windows

This allows users to specify which process should be used as the parent
process when creating a new process.

Note that this doesn't just trivially pass the handle onward to
PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, because inherited handles must be
valid in the parent process, so if we're changing the destination
process, then we must also change the origin of the parent handles. And,
the StartProcess function must clean up these handles successfully when
exiting, regardless of where the duplication happened. So, we take care
in this commit to use DuplicateHandle for both duplicating and for
closing the inherited handles.

The test was taken originally from CL 288272 and adjusted for use here.

Fixes #44011.

Change-Id: Ib3b132028dcab1aded3dc0e65126c8abebfa35eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/288300
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agosyscall: introduce SysProcAttr.AdditionalInheritedHandles on Windows
Jason A. Donenfeld [Sun, 31 Jan 2021 17:07:43 +0000 (18:07 +0100)]
syscall: introduce SysProcAttr.AdditionalInheritedHandles on Windows

This allows users to specify handles that they explicitly want to be
inherited by the new process. These handles must already be marked as
inheritable.

Updates #44011.
Updates #21085.

Change-Id: Ib18322e7dc2909e68c4209e80385492804fa15d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/288298
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agosyscall: restrict inherited handles on Windows
Jason A. Donenfeld [Sun, 31 Jan 2021 16:54:27 +0000 (17:54 +0100)]
syscall: restrict inherited handles on Windows

Windows does not have CLOEXEC, but rather handles are marked explicitly
for being inherited by new processes. This can cause problems when
different Windows functions create new processes from different threads.
syscall.StartProcess has traditionally used a mutex to prevent races
with itself, but this doesn't handle races with other win32 functions.

Fortunately there's a solution: PROC_THREAD_ATTRIBUTE_HANDLE_LIST allows
us to pass the entire list of handles that we want to be inherited. This
lets us get rid of the mutex and also makes process creation safe across
the Go runtime, no matter the context.

Updates #44011.

Change-Id: Ia3424cd2ec64868849cbd6cbb5b0d765224bf4ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/288297
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agosyscall: add support for proc thread attribute lists
Jason A. Donenfeld [Sun, 31 Jan 2021 16:37:20 +0000 (17:37 +0100)]
syscall: add support for proc thread attribute lists

This will allow us to pass additional attributes when starting
processes.

Updates #44011.

Change-Id: I4af365c5544a6d421830f247593ec970200e5e03
Reviewed-on: https://go-review.googlesource.com/c/go/+/288296
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agocmd/link: recognize ARM64 PE files and relocations
Jason A. Donenfeld [Wed, 3 Feb 2021 23:11:12 +0000 (00:11 +0100)]
cmd/link: recognize ARM64 PE files and relocations

For now, this only add a single relocation type, which is sufficient for
Windows resources. Later we'll see if we need more for cgo.

In order to ensure these code paths are actually tested, this expands
the rsrc tests to include all the architectures of PE objects that we
need to be recognizing, and splits things more clearly between binutils
and llvm objects, which have a slightly different layout, so that we
test both.

This CL is part of a stack adding windows/arm64
support (#36439), intended to land in the Go 1.17 cycle.

Change-Id: Ia1ee840265e9d12c0b12dd1c5d0810f8b300e557
Reviewed-on: https://go-review.googlesource.com/c/go/+/289429
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: handle types as converted to interface when dynlink
Cherry Zhang [Fri, 26 Feb 2021 01:01:53 +0000 (20:01 -0500)]
cmd/link: handle types as converted to interface when dynlink

When using plugins, a type (whose value) may be pass to a plugin
and get converted to interface there, or vice versa. We need to
treat the type as potentially converted to interface, and retain
its methods.

Should fix #44586.

Change-Id: I80dd35e68baedaa852a317543ccd78d94628d13b
Reviewed-on: https://go-review.googlesource.com/c/go/+/296709
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>
4 years agocmd/compile: fix mishandling of unsafe-uintptr arguments with call method in go/defer
Cuong Manh Le [Fri, 26 Feb 2021 03:17:09 +0000 (10:17 +0700)]
cmd/compile: fix mishandling of unsafe-uintptr arguments with call method in go/defer

In CL 253457, we did the same fix for direct function calls. But for
method calls, the receiver argument also need to be passed through the
wrapper function, which we are not doing so the compiler crashes with
the code in #44415.

It will be nicer if we can rewrite OCALLMETHOD to normal OCALLFUNC, but
that will be for future CL. The passing receiver argument to wrapper
function is easier for backporting to go1.16 branch.

Fixes #44415

Change-Id: I03607a64429042c6066ce673931db9769deb3124
Reviewed-on: https://go-review.googlesource.com/c/go/+/296490
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: change StaticCall to return a "Results"
David Chase [Thu, 4 Feb 2021 21:42:35 +0000 (16:42 -0500)]
cmd/compile: change StaticCall to return a "Results"

StaticLECall (multiple value in +mem, multiple value result +mem) ->
StaticCall (multiple ergister value in +mem,
   multiple register-sized-value result +mem) ->
ARCH CallStatic (multiple ergister value in +mem,
   multiple register-sized-value result +mem)

But the architecture-dependent stuff is indifferent to whether
it is mem->mem or (mem)->(mem) until Prog generation.

Deal with OpSelectN -> Prog in ssagen/ssa.go, others, as they
appear.

For #40724.

Change-Id: I1d0436f6371054f1881862641d8e7e418e4a6a16
Reviewed-on: https://go-review.googlesource.com/c/go/+/293391
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>
4 years agocmd/compile: fix missing descend in Addrtaken for closures.
Dan Scales [Thu, 25 Feb 2021 20:13:23 +0000 (12:13 -0800)]
cmd/compile:  fix missing descend in Addrtaken for closures.

ComputeAddrtaken needs to descend into closures, now that imported
bodies can include closures. The bug was that we weren't properly
setting Addrtaken for a variable inside a closure inside a function that
we were importing.

For now, still disable inlining of functions with closures for -G mode.
I'll enable it in a later change -- there are just a few fixes related
to the fact that we don't need to set Ntype for closure functions.

Added a test derived from the cilium repro in the issue.

Fixes #44370

Change-Id: Ida2a403636bf8740b471b3ad68b5474951811e19
Reviewed-on: https://go-review.googlesource.com/c/go/+/296649
Run-TryBot: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/internal/obj: add Prog.SetFrom3{Reg,Const}
Josh Bleecher Snyder [Thu, 7 Jan 2021 22:01:29 +0000 (14:01 -0800)]
cmd/internal/obj: add Prog.SetFrom3{Reg,Const}

These are the the most common uses, and they reduce line noise.

I don't love adding new deprecated APIs,
but since they're trivial wrappers,
it'll be very easy to update them along with the rest.
No functional changes; passes toolstash-check.

Change-Id: I691a8175cfef9081180e463c63f326376af3f3a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/296009
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agosyscall: comment on fields omitted from the win32finddata1 struct
Bryan C. Mills [Fri, 15 Jan 2021 14:48:39 +0000 (09:48 -0500)]
syscall: comment on fields omitted from the win32finddata1 struct

Updates #42637

Change-Id: I4c7d38034b60c2c04efdeb530a97d96deddfd6fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/284152
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agoRevert "cmd/compile: fix mishandling of unsafe-uintptr arguments with call method...
Matthew Dempsky [Thu, 25 Feb 2021 21:32:29 +0000 (21:32 +0000)]
Revert "cmd/compile: fix mishandling of unsafe-uintptr arguments with call method in go/defer"

This reverts commit CL 294849.

Reason for revert: this doesn't actually fix the issue, as revealed
by the noopt builder's failures.

Change-Id: Ib4ea9ceb4d75e46b3b91ec348b365fd8c83316ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/296629
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agoreflect: add Method.IsExported and StructField.IsExported methods
Joe Tsai [Thu, 15 Oct 2020 01:41:16 +0000 (18:41 -0700)]
reflect: add Method.IsExported and StructField.IsExported methods

The IsExported method is a more intuitive helper for checking whether
the method or field is exported than checking whether PkgPath is empty.

In the same CL, modify the standard library to make use of this helper.

Fixes #41563

Change-Id: Iaacfb3b74449501f98e2707aa32095a32bd3c3c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/266197
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/internal/obj: fix typo in docs
Josh Bleecher Snyder [Thu, 25 Feb 2021 17:58:05 +0000 (09:58 -0800)]
cmd/internal/obj: fix typo in docs

Change-Id: I5a3d26a4cc59b327d46ca24bcb01ef594758c230
Reviewed-on: https://go-review.googlesource.com/c/go/+/296531
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: declare inlined result params early for empty returns
Matthew Dempsky [Thu, 18 Feb 2021 01:49:40 +0000 (17:49 -0800)]
cmd/compile: declare inlined result params early for empty returns

The code for delayed declaration of inlined result parameters only
handles non-empty return statements. This is generally okay, because
we already early declare if there are any (non-blank) named result
parameters.

But if a user writes a function with only blank result parameters and
with exactly one return statement, which is empty, then they could end
up hitting the dreaded "Value live at entry" ICE.

This CL fixes the issue by ensuring we always early declare inlined
result parameters if there are any empty return statements.

Fixes #44355.

Change-Id: I315f3853be436452883b1ce31da1bdffdf24d506
Reviewed-on: https://go-review.googlesource.com/c/go/+/293293
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
4 years agoos: avoid allocation in File.WriteString
Josh Bleecher Snyder [Sat, 7 Nov 2020 01:37:03 +0000 (17:37 -0800)]
os: avoid allocation in File.WriteString

Instead of alloc+copy to convert the string
to a byte slice, do an unsafe conversion.

Rely on the kernel not to scribble on the
buffer during the write.

Fixes #42406

Change-Id: I66f4838b43a11bcc3d67bbfa1706726318d55343
Reviewed-on: https://go-review.googlesource.com/c/go/+/268020
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
4 years agodatabase/sql: close driver.Connector if it implements io.Closer
Ivan Trubach [Thu, 25 Feb 2021 19:15:04 +0000 (19:15 +0000)]
database/sql: close driver.Connector if it implements io.Closer

This change allows driver implementations to manage resources in
driver.Connector, e.g. to share the same underlying database handle
between multiple connections. That is, it allows embedded databases
with in-memory backends like SQLite and Genji to safely release the
resources once the sql.DB is closed.

This makes it possible to address oddities with in-memory stores in
SQLite and Genji drivers without introducing too much complexity in
the driver implementations.

See also:
- https://github.com/mattn/go-sqlite3/issues/204
- https://github.com/mattn/go-sqlite3/issues/511
- https://github.com/genjidb/genji/issues/210

Fixes #41790

Change-Id: Idbd19763134438ed38288b9d44f16608e4e97fd7
GitHub-Last-Rev: 962c785dfb3bb6ad98b2216bcedd84ba383fe872
GitHub-Pull-Request: golang/go#41710
Reviewed-on: https://go-review.googlesource.com/c/go/+/258360
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: automate resultInArg0 register checks
Josh Bleecher Snyder [Fri, 8 Jan 2021 03:08:37 +0000 (19:08 -0800)]
cmd/compile: automate resultInArg0 register checks

No functional changes; passes toolstash-check.
No measureable performance changes.

Change-Id: I2629f73d4a3cc56d80f512f33cf57cf41d8f15d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/296010
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: fix mishandling of unsafe-uintptr arguments with call method in go/defer
Cuong Manh Le [Sun, 21 Feb 2021 15:09:03 +0000 (22:09 +0700)]
cmd/compile: fix mishandling of unsafe-uintptr arguments with call method in go/defer

In CL 253457, we did the same fix for direct function calls. But for
method calls, the receiver argument also need to be passed through the
wrapper function, which we are not doing so the compiler crashes with
the code in #44415.

As we already rewrite t.M(...) into T.M(t, ...) during walkCall1, to fix
this, we can do the same trick in wrapCall, so the receiver argument
will be treated as others.

Fixes #44415

Change-Id: I396182983c85d9c5e4494657da79d25636e8a079
Reviewed-on: https://go-review.googlesource.com/c/go/+/294849
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: use pipe2 for nonblockingPipe on dragonfly
Tobias Klauser [Wed, 24 Feb 2021 08:43:59 +0000 (09:43 +0100)]
runtime: use pipe2 for nonblockingPipe on dragonfly

The pipe2 syscall is available since DragonflyBSD 4.2, see
https://www.dragonflybsd.org/release42/

Change-Id: Ifc67c4935cc59bae29be459167e2fa765843ac03
Reviewed-on: https://go-review.googlesource.com/c/go/+/295471
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>
4 years agoruntime: batch moving gFree list between local p and global schedt
Andy Pan [Mon, 23 Nov 2020 07:42:48 +0000 (15:42 +0800)]
runtime: batch moving gFree list between local p and global schedt

Change-Id: I0ca1fcee6d3f08bdfcfa51f0dc774118d7355636
Reviewed-on: https://go-review.googlesource.com/c/go/+/271914
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd: upgrade golang.org/x/mod to fix go.mod parser
Jay Conrod [Wed, 24 Feb 2021 23:24:45 +0000 (18:24 -0500)]
cmd: upgrade golang.org/x/mod to fix go.mod parser

modfile.Parse passed an empty string to the VersionFixer for the
module path. This caused errors for v2+ versions.

Fixes #44494

Change-Id: I13b86b6ecf6815c4bc9a96ec0668284c9228c205
Reviewed-on: https://go-review.googlesource.com/c/go/+/296131
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>
4 years agocmd/go: add a script test corresponding to the downhiddenartifact MVS test
Bryan C. Mills [Fri, 19 Feb 2021 19:41:02 +0000 (14:41 -0500)]
cmd/go: add a script test corresponding to the downhiddenartifact MVS test

For #36460

Change-Id: I95abff45bb325732a19eb8b9c0d3fc34df08b4d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/294293
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>
4 years agocmd/go/internal/mvs: add test cases for downgrade interaction with hidden versions
Bryan C. Mills [Fri, 19 Feb 2021 01:20:12 +0000 (20:20 -0500)]
cmd/go/internal/mvs: add test cases for downgrade interaction with hidden versions

For #36460

Change-Id: I889c4ece0d2caff7528cf437f89f7446dbd83955
Reviewed-on: https://go-review.googlesource.com/c/go/+/294292
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>
4 years agotest: add test case that failed with gccgo
Ian Lance Taylor [Mon, 15 Feb 2021 01:59:48 +0000 (17:59 -0800)]
test: add test case that failed with gccgo

bug511.dir/b.go:10:14: error: reference to undefined field or method 'M'

Change-Id: I9f96dc5c7254b310bc3e15b0bc588d62718cb4b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/292009
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>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotesting/fstest: treat dash specially when building glob
Ian Lance Taylor [Sun, 21 Feb 2021 23:28:41 +0000 (15:28 -0800)]
testing/fstest: treat dash specially when building glob

"[-]" is not a valid path.Match pattern.

Fixes #44474

Change-Id: I0932bbf08ffb8ad0c5337d69d0893f53c1ba89ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/294869
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agosyscall: return error if GetQueuedCompletionStatus truncates key
Jason A. Donenfeld [Thu, 25 Feb 2021 01:58:04 +0000 (02:58 +0100)]
syscall: return error if GetQueuedCompletionStatus truncates key

This function has the wrong signature, so return an error when that
actually might lead to unexpected results. Users should switch to
x/sys/windows for the real version of this function.

Updates #44538.

Change-Id: I4d1f3d1e380815733ecfea683f939b1d25dcc32a
Reviewed-on: https://go-review.googlesource.com/c/go/+/296154
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agosyscall, os: use pipe2 syscall on DragonflyBSD instead of pipe
Tobias Klauser [Tue, 23 Feb 2021 13:58:32 +0000 (14:58 +0100)]
syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe

Follow the implementation used by the other BSDs and account for the
intricacy of having to pass the fds array even though the file
descriptors are returned.

Re-submit of CL 130996 with corrected pipe2 wrapper.

Change-Id: Ie36d8214cba60c4fdb579f18bfc1c1ab3ead3ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/295372
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>
4 years agocmd/compile: fix typo in rewrite_test.go
Ikko Ashimine [Thu, 25 Feb 2021 03:03:45 +0000 (03:03 +0000)]
cmd/compile: fix typo in rewrite_test.go

insted -> instead

Change-Id: Ib8a0423cf99f615976f058468873fb576dd96db6
GitHub-Last-Rev: 8e1a1d08807a35c55d65a2e3f8bb28418a43b3a8
GitHub-Pull-Request: golang/go#44598
Reviewed-on: https://go-review.googlesource.com/c/go/+/296309
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agotest: fix inline.go test for linux-amd64-noopt
Egon Elbre [Wed, 24 Feb 2021 19:08:52 +0000 (21:08 +0200)]
test: fix inline.go test for linux-amd64-noopt

math.Float32bits was not being inlined across package boundaries.
Create a private func that can be inlined with -l.

Change-Id: Ic50bf4727dd8ade09d011eb204006b7ee88db34a
Reviewed-on: https://go-review.googlesource.com/c/go/+/295989
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: subtract one from ip when determining abort
Jason A. Donenfeld [Thu, 25 Feb 2021 00:29:58 +0000 (01:29 +0100)]
runtime: subtract one from ip when determining abort

On windows/arm, the abort is given from one byte off of the function
address, perhaps because Windows wants to simulate x86/amd64 modes, or
because it's jumping from thumb mode. This is not the case with
windows/arm64, though.

This prevents a failure in the builders with the TestAbort test:

    crash_test.go:727: output contains BAD:
        panic: runtime error: invalid memory address or nil pointer dereference [recovered]
                panic: BAD: recovered from abort
        [signal 0xc0000005 code=0x0 addr=0x0 pc=0x6a5721]

Change-Id: I8939c60611863cc0c325e179a772601acea9fd4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/296153
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agosyscall: restore broken GetQueuedCompletionStatus signature but make it not crash
Jason A. Donenfeld [Wed, 24 Feb 2021 21:59:59 +0000 (22:59 +0100)]
syscall: restore broken GetQueuedCompletionStatus signature but make it not crash

This reverts commit dc4698f52b5ad3f0251e0cc25bc7ffbd10e23f2c, and then
fixes the memory corruption issue. It also suggests users switch to
x/sys/windows for the proper function.

This requires CL 295174 to be submitted first.

Updates #44538.

Change-Id: I0ee602f1c1d6a89cc585aff426833a4cb3f2be50
Reviewed-on: https://go-review.googlesource.com/c/go/+/296149
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: plumb abi info into expandCalls
David Chase [Mon, 1 Feb 2021 18:26:47 +0000 (13:26 -0500)]
cmd/compile: plumb abi info into expandCalls

Work in progress.

TODO:
- insert debugging output for all the steps listed below
- emit modified call instructions w/ multiple register inputs
  and Result-typed outputs (next CL)
  - initially just change output from "mem" to "Result{mem}"
  = most places this hits will be future work.
- change OpArg to use registerized variants
  - (done) match abi paramresultinfo with particular arg, use Name
  - (this CL) push register offsets for "loads" and "stores" into
    recursive decomposition.
- hand registerized Result to exit block

For #40724.

Change-Id: Ie5de9d71f8fd4e092f5ee9260b54de35abf91016
Reviewed-on: https://go-review.googlesource.com/c/go/+/293390
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agocmd/compile: disable inlining functions with closures for now
Dan Scales [Wed, 24 Feb 2021 21:03:17 +0000 (13:03 -0800)]
cmd/compile: disable inlining functions with closures for now

Added a flag '-d=inlfuncswithclosures=1' to allow inlining functions with
closures, and change the default to off for now, until #44370 is fixed.

Updates #44370.

Change-Id: Ic17723aa5c091d91f5f5004d8b63ec7125257acf
Reviewed-on: https://go-review.googlesource.com/c/go/+/296049
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>

4 years agocmd/link: use ctxt.Logf instead of package log
Josh Bleecher Snyder [Wed, 24 Feb 2021 19:48:09 +0000 (11:48 -0800)]
cmd/link: use ctxt.Logf instead of package log

Fixes #43601

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

4 years agocmd/compile: ARM64 optimize []float64 and []float32 access
Egon Elbre [Fri, 27 Nov 2020 15:10:33 +0000 (17:10 +0200)]
cmd/compile: ARM64 optimize []float64 and []float32 access

Optimize load and store to []float64 and []float32.
Previously it used LSL instead of shifted register indexed load/store.

Before:

    LSL   $3, R0, R0
    FMOVD F0, (R1)(R0)

After:

    FMOVD F0, (R1)(R0<<3)

Fixes #42798

Change-Id: I0c0912140c3dce5aa6abc27097c0eb93833cc589
Reviewed-on: https://go-review.googlesource.com/c/go/+/273706
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Giovanni Bajo <rasky@develer.com>

4 years agocmd/compile/internal-abi: fix ABI0-equivalence for zero-sized values
Austin Clements [Wed, 24 Feb 2021 01:48:22 +0000 (20:48 -0500)]
cmd/compile/internal-abi: fix ABI0-equivalence for zero-sized values

This fixes a bug in the internal ABI specification that made it not
equivalent to ABI0 even with zero architectural argument registers in
the case of a zero-sized argument with alignment > 1.

In ABI0, even zero-sized arguments cause alignment padding in the
stack frame.

Currently, in the internal ABI, zero-sized arguments get
register-assigned even if there are no registers because they don't
consume any registers. Hence, they don't create alignment padding in
the stack frame.

Fix this by stack-assigning zero-sized arguments.

For #40724.

Change-Id: I1f5a95a94fed8b5313a360e5e76875701ba5f562
Reviewed-on: https://go-review.googlesource.com/c/go/+/295791
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile/internal-abi: update internal ABI spec for g register
Austin Clements [Wed, 24 Feb 2021 02:22:20 +0000 (21:22 -0500)]
cmd/compile/internal-abi: update internal ABI spec for g register

We've already implemented dedicating R14 as the G register on amd64,
so remove the TODO saying we might want to hold off on this.

For #40724.

Change-Id: I45b24ced03cac862127b53f5e9a4b4bcf6b1f86c
Reviewed-on: https://go-review.googlesource.com/c/go/+/295790
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile/internal-abi: use x87 mode, not MMX mode
Austin Clements [Wed, 24 Feb 2021 03:03:29 +0000 (22:03 -0500)]
cmd/compile/internal-abi: use x87 mode, not MMX mode

Florian Weimer pointed out that my justification for using MMX mode
was nonsense and that staying in x87 mode simplifies transitions to
and from C. Hence, switch the spec to say we're always in x87 mode.

For #40724.

Change-Id: Iad916b2c376db41f95614aa6897f6b1184576bb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/295789
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: add rule to coalesce writes
Alejandro García Montoro [Wed, 30 Dec 2020 17:41:36 +0000 (18:41 +0100)]
cmd/compile: add rule to coalesce writes

The code generated when storing eight bytes loaded from memory created a
series of small writes instead of a single, large one. The specific
pattern of instructions generated stored 1 byte, then 2 bytes, then 4
bytes, and finally 1 byte.

The new rules match this specific pattern both for amd64 and for s390x,
and convert it into a single instruction to store the 8 bytes. arm64 and
ppc64le already generated the right code, but the new codegen test
covers also those architectures.

Fixes #41663

Change-Id: Ifb9b464be2d59c2ed5034acf7b9c3e473f344030
Reviewed-on: https://go-review.googlesource.com/c/go/+/280456
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/internal/goobj: add test case for object file reader
Than McIntosh [Tue, 15 Dec 2020 21:01:34 +0000 (16:01 -0500)]
cmd/internal/goobj: add test case for object file reader

Add test in which a input Go object file contains a very large number
of relocations (more than 1<<20).

Updates #41621.

Change-Id: If1ebf3c4fefbf55ddec4e05c5299e7c48fc697d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/278493
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>

4 years agocontext: avoid importing context package twice
Kevin Burke [Wed, 24 Feb 2021 17:12:34 +0000 (09:12 -0800)]
context: avoid importing context package twice

Change-Id: Id0a127e080dda8ee62738922c6de8caf3719dd68
Reviewed-on: https://go-review.googlesource.com/c/go/+/295949
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Kevin Burke <kev@inburke.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agosyscall: do not overflow key memory in GetQueuedCompletionStatus
Jason A. Donenfeld [Tue, 23 Feb 2021 12:29:40 +0000 (13:29 +0100)]
syscall: do not overflow key memory in GetQueuedCompletionStatus

The third argument to GetQueuedCompletionStatus is a pointer to a
uintptr, not a uint32. Users of this functions have therefore been
corrupting their memory every time they used it. Either that memory
corruption was silent (dangerous), or their programs didn't work so they
chose a different API to use.

Fixes #44538.

RELNOTES=yes

Change-Id: Idf48d4c712d13da29791e9a460159255f963105b
Reviewed-on: https://go-review.googlesource.com/c/go/+/295371
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: plumb abi info into ssagen/ssa
David Chase [Thu, 21 Jan 2021 17:04:46 +0000 (12:04 -0500)]
cmd/compile: plumb abi info into ssagen/ssa

Plumb abi information into ssa/ssagen for plain calls
and plain functions (not methods).  Does not extend all the
way through the compiler (yet).

One test disabled because it extends far enough to break the test.

Normalized all the compiler's register args TODOs to
// TODO(register args) ...

For #40724.

Change-Id: I0173a4579f032ac3c9db3aef1749d40da5ea01ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/293389
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>
4 years agocmd/compile: reduce inline cost of OCONVOP
Egon Elbre [Sat, 2 Jan 2021 14:28:11 +0000 (16:28 +0200)]
cmd/compile: reduce inline cost of OCONVOP

OCONVOP doesn't have effect in the compiled code so, it can be safely
excluded from inline cost calculation.

Also make sequence ODEREF OCONVNOP* OADDR cost 1. This is rather common
conversion, such as *(*uint32)(unsafe.Pointer(&x)).

Fixes #42788

Change-Id: I5001f7e89d985c198b6405694cdd5b819cf3f47a
Reviewed-on: https://go-review.googlesource.com/c/go/+/281232
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Elias Naur <mail@eliasnaur.com>

4 years agotesting: print late arriving log line in panic
Josh Bleecher Snyder [Thu, 14 Jan 2021 22:38:55 +0000 (14:38 -0800)]
testing: print late arriving log line in panic

When you log after a test has completed,
the testing package panics.

Print the logged line as part of that panic,
to aid in debugging.

Change-Id: I3d6689d1eed57c03e300afe37db0c15b2f4acda4
Reviewed-on: https://go-review.googlesource.com/c/go/+/283972
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocontext: reduce contention in cancelCtx.Done
Josh Bleecher Snyder [Fri, 29 Jan 2021 23:41:18 +0000 (15:41 -0800)]
context: reduce contention in cancelCtx.Done

Use an atomic.Value to hold the done channel.
Conveniently, we have a mutex handy to coordinate writes to it.

name                 old time/op  new time/op  delta
ContextCancelDone-8  67.5ns Â±10%   2.2ns Â±11%  -96.74%  (p=0.000 n=30+28)

Fixes #42564

Change-Id: I5d72e0e87fb221d4e230209e5fb4698bea4053c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/288193
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Sameer Ajmani <sameer@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: fix version validation in 'go mod edit -exclude'
Bryan C. Mills [Mon, 22 Feb 2021 20:05:20 +0000 (15:05 -0500)]
cmd/go: fix version validation in 'go mod edit -exclude'

The fix is to pull in CL 295089 from the x/mod repo.

Fixes #44497

Change-Id: I008b58d0f4bb48c09d4f1e6ed31d11a714f87dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/295150
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>
4 years agocmd/go, cmd/cgo: pass -mfp32 and -mhard/soft-float to MIPS GCC
YunQiang Su [Tue, 9 Jun 2020 04:09:58 +0000 (04:09 +0000)]
cmd/go, cmd/cgo: pass -mfp32 and -mhard/soft-float to MIPS GCC

For mips32 currently, we are using FP32, while the gcc may be FPXX,
which may generate .MIPS.abiflags and .gnu.attributes section with
value as FPXX. So the kernel will treat the exe as FPXX, and may
choose to use FR=1 FPU mode for it.
Currently, in Go, we use 2 lwc1 to load both half of a double value
to a pair of even-odd FPR. This behavior can only work with FR=0 mode.

In FR=1 mode, all of 32 FPR are 64bit. If we lwc1 the high-half of a double
value to an odd FPR, and try to use the previous even FPR to compute, the
real high-half of even FPR will be unpredicatable.
We set -mfp32 to force the gcc generate FP32 code and section value.

More details about FP32/FPXX/FP64 are explained in:
https://web.archive.org/web/20180828210612/https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking

When GOMIPS/GOMIPS64 is set as softfloat, we should also pass
 -msoft-float to gcc.

Here we also add -mno-odd-spreg option, since Loongson's CPU cannot use
odd-number FR in FR=0 mode.

Fixes #39435

Change-Id: I54026ad416a815fe43a9261ebf6d02e5519c3930
Reviewed-on: https://go-review.googlesource.com/c/go/+/237058
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Meng Zhuo <mzh@golangcn.org>

4 years agoio/ioutil: forward TempFile and TempDir to os package
Ian Lance Taylor [Fri, 22 Jan 2021 00:59:29 +0000 (16:59 -0800)]
io/ioutil: forward TempFile and TempDir to os package

For #42026
Fixes #44311

Change-Id: I3dabcf902d155f95800b4adf1d7578906a194ce6
Reviewed-on: https://go-review.googlesource.com/c/go/+/285378
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
4 years agoencoding/json: reduce allocated space in Unmarshal
Josh Bleecher Snyder [Wed, 18 Nov 2020 20:50:29 +0000 (12:50 -0800)]
encoding/json: reduce allocated space in Unmarshal

The decodeState type is a large part of the allocated space during Unmarshal.
The errorContext field is infrequently used, and only on error.
Extract it into a pointer and allocate it separate when necessary.

name                old time/op    new time/op    delta
UnmarshalString-8      115ns Â± 5%     114ns Â± 3%     ~     (p=0.170 n=15+15)
UnmarshalFloat64-8     113ns Â± 2%     106ns Â± 1%   -6.42%  (p=0.000 n=15+14)
UnmarshalInt64-8      93.3ns Â± 1%    86.9ns Â± 4%   -6.89%  (p=0.000 n=14+15)

name                old alloc/op   new alloc/op   delta
UnmarshalString-8       192B Â± 0%      160B Â± 0%  -16.67%  (p=0.000 n=15+15)
UnmarshalFloat64-8      180B Â± 0%      148B Â± 0%  -17.78%  (p=0.000 n=15+15)
UnmarshalInt64-8        176B Â± 0%      144B Â± 0%  -18.18%  (p=0.000 n=15+15)

name                old allocs/op  new allocs/op  delta
UnmarshalString-8       2.00 Â± 0%      2.00 Â± 0%     ~     (all equal)
UnmarshalFloat64-8      2.00 Â± 0%      2.00 Â± 0%     ~     (all equal)
UnmarshalInt64-8        1.00 Â± 0%      1.00 Â± 0%     ~     (all equal)

Change-Id: I53f3f468e6c65f77a12e5138a2626455b197012d
Reviewed-on: https://go-review.googlesource.com/c/go/+/271338
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agodatabase: remove race in TestTxContextWait
Josh Bleecher Snyder [Mon, 1 Feb 2021 16:35:36 +0000 (08:35 -0800)]
database: remove race in TestTxContextWait

This test contained a data race.
On line 437, db.BeginTx starts a goroutine that runs tx.awaitDone,
which reads tx.keepConnOnRollback.
On line 445, the test writes to tx.keepConnOnRollback.
tx.awaitDone waits on ctx, but because ctx is timeout-based,
there's no ordering guarantee between the write and the read.

The race detector never caught this before
because the context package implementation of Done
contained enough synchronization to make it safe.
That synchronization is not package of the context API or guarantees,
and the first several releases it was not present.
Another commit soon will remove that synchronization,
exposing the latent data race.

To fix the race, emulate a time-based context
using an explicit cancellation-based context.
This gives us enough control to avoid the race.

Change-Id: I103fe9b987b1d4c02e7a20ac3c22a682652128b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/288493
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
4 years agogo/types: review of call.go
Rob Findley [Tue, 23 Feb 2021 17:01:26 +0000 (12:01 -0500)]
go/types: review of call.go

The changes from the (reviewed) dev.regabi copy of call.go can be seen
by comparing patchset 1 and 4. The actual changes are removing the
"// REVIEW INCOMPLETE" marker, deleting some leftover handling of type
instantiation in Checker.call, and adding a comment that exprOrTypeList
should be refactored.

I started to refactor exprOrTypeList, but thought it best to mark this
code as reviewed before diverging from types2.

Change-Id: Icf7fbff5a8def49c5f1781472fd7ba7b73dd9a9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/295531
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>
4 years agohash/maphash: remove duplicate from Hash documentation
Alberto Donizetti [Sun, 14 Feb 2021 10:19:39 +0000 (11:19 +0100)]
hash/maphash: remove duplicate from Hash documentation

Fixes #44255

Change-Id: I14d2edbee0a0c39e04111414a57d70ee2fdfb6af
Reviewed-on: https://go-review.googlesource.com/c/go/+/291631
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: remove unused const stackSystem on dragonfly
Tobias Klauser [Tue, 23 Feb 2021 14:35:43 +0000 (15:35 +0100)]
runtime: remove unused const stackSystem on dragonfly

Change-Id: I778c2bd7cf0b12275bae344cb2130a7959500481
Reviewed-on: https://go-review.googlesource.com/c/go/+/295470
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>
4 years agospec: improve sentence structure for passing a slice
DQNEO [Wed, 10 Feb 2021 13:34:09 +0000 (22:34 +0900)]
spec: improve sentence structure for passing a slice

Change-Id: I453d06da2f596eb0b99905aec46a05547d73c62c
Reviewed-on: https://go-review.googlesource.com/c/go/+/290872
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Robert Griesemer <gri@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agodocs: fix spelling
John Bampton [Wed, 17 Feb 2021 01:48:21 +0000 (01:48 +0000)]
docs: fix spelling

Change-Id: Ib689e5793d9cb372e759c4f34af71f004010c822
GitHub-Last-Rev: d63798388e5dcccb984689b0ae39b87453b97393
GitHub-Pull-Request: golang/go#44259
Reviewed-on: https://go-review.googlesource.com/c/go/+/291949
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>

4 years agobufio, bytes, strings: handle negative runes in WriteRune
David Benjamin [Fri, 25 Dec 2020 17:02:04 +0000 (12:02 -0500)]
bufio, bytes, strings: handle negative runes in WriteRune

Updates #43254

Change-Id: I7d4bf3b99cc36ca2156af5bb01a1c595419d1d3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/280492
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Rob Pike <r@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agounicode: correctly handle negative runes
David Benjamin [Fri, 25 Dec 2020 17:02:55 +0000 (12:02 -0500)]
unicode: correctly handle negative runes

Is and isExcludingLatin did not handle negative runes when dispatching
to is16. TestNegativeRune covers this along with the existing uint32
casts in IsGraphic, etc. (For tests, I picked the smallest non-Latin-1
code point in each range.)

Updates #43254

Change-Id: I17261b91f0d2b5b5125d19219411b45c480df74f
Reviewed-on: https://go-review.googlesource.com/c/go/+/280493
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agoimage: resolve the TODO of doc comment style
Andy Pan [Tue, 10 Nov 2020 09:56:33 +0000 (17:56 +0800)]
image: resolve the TODO of doc comment style

Change-Id: Ic7701a9e4635fe1a331c9a1df776ed580759eb9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/268758
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Trust: Rob Pike <r@golang.org>

4 years agogo/types: minor updates to comments to align with types2
Rob Findley [Tue, 23 Feb 2021 16:48:15 +0000 (11:48 -0500)]
go/types: minor updates to comments to align with types2

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

4 years agocontext: fix XTestInterlockedCancels
Keiichi Hirobe [Sun, 21 Feb 2021 03:22:13 +0000 (12:22 +0900)]
context: fix XTestInterlockedCancels

The test does not use Done channel, so fix that.

Change-Id: I795feab2e95de815b8b6ee7a7fd90f19f7af7db1
Reviewed-on: https://go-review.googlesource.com/c/go/+/294749
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Trust: Sameer Ajmani <sameer@golang.org>
Trust: Cody Oss <codyoss@google.com>
Run-TryBot: Sameer Ajmani <sameer@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agotesting/race: fixing intermittent test failure
Daniel S. Fava [Fri, 12 Feb 2021 08:54:50 +0000 (09:54 +0100)]
testing/race: fixing intermittent test failure

Test NoRaceMutexPureHappensBefore in runtime/race/testdata/mutex_test.go
expects the second spawned goroutine to run after the first.  The test
attempts to force this scheduling with a 10 millisecond wait.  Following
a suggestion by Bryan Mills, we force this scheduling using a shared
variable whose access take place within the existing mutex.

Fixes #35745.

Change-Id: Ib23ec51492ecfeed4752e020401dd25755a669ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/291292
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: reset stack poison flag accidentally set
David Chase [Tue, 23 Feb 2021 19:02:33 +0000 (14:02 -0500)]
runtime: reset stack poison flag accidentally set

See if this clears failure on openbsd-amd64-68 (ahem).

Change-Id: Ifa60ef711a95e5de8ad91433ffa425f75b36c76f
Reviewed-on: https://go-review.googlesource.com/c/go/+/295629
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agogo/types, types2: constraints may be parenthesized and that includes "any"
Robert Griesemer [Tue, 23 Feb 2021 20:47:08 +0000 (12:47 -0800)]
go/types, types2: constraints may be parenthesized and that includes "any"

Change-Id: I9a234cc1f04ca762375b51ec8ef009fb264c7ed1
Reviewed-on: https://go-review.googlesource.com/c/go/+/295689
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>
4 years agodoc: start draft go1.17 release notes, move go1.16 to x/website
Dmitri Shuralyov [Mon, 22 Feb 2021 22:21:10 +0000 (17:21 -0500)]
doc: start draft go1.17 release notes, move go1.16 to x/website

This template is based on CL 248198 and previous ones like it.
Continue to eagerly include often-used sections, and clarify that
the TODO is about completing the section, or removing if it turns
out not to be needed.

Move the Go 1.16 release notes to x/website, since that's the new
home for past Go release notes as of CL 291711. They're added to
x/website in CL 295249.

'relnote -html' does not report any CLs with RELNOTE annotations
since 2021/02/01.

For #44513.
Updates #40700.

Change-Id: Idd389335500ec4dec2764cbbaa385918cc8a79ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/295209
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
4 years agocmd/go: reproduce issue #44497 in TestScript/mod_edit
Bryan C. Mills [Mon, 22 Feb 2021 20:04:25 +0000 (15:04 -0500)]
cmd/go: reproduce issue #44497 in TestScript/mod_edit

For #44497

Change-Id: Ie5285b9c526506b6b1280a590a5dcbee4074f57b
Reviewed-on: https://go-review.googlesource.com/c/go/+/295149
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>
4 years agoruntime: use BX instead of R15 in race detector
Keith Randall [Wed, 3 Feb 2021 20:25:46 +0000 (12:25 -0800)]
runtime: use BX instead of R15 in race detector

If the race detector were runnable in dynamic linking mode,
then R15 would get clobbered. I don't think it is, so maybe
not a problem, but can't hurt to clean it up.

It also lets CL 283474 pass cleanly when checking the whole stdlib
(together with CL 288452).

Change-Id: I5a5021ecc7e7b8bed1cd3a7067c39b24c09e0783
Reviewed-on: https://go-review.googlesource.com/c/go/+/289270
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: save R15 before checking AVX state
Keith Randall [Mon, 1 Feb 2021 08:45:41 +0000 (00:45 -0800)]
runtime: save R15 before checking AVX state

When in dynlink mode, reading a global can clobber R15.
Just to be safe, save R15 before checking the AVX state to see
if we need to VZEROUPPER or not.

This could cause a problem in buildmodes that aren't supported yet.

Change-Id: I8fda62d3fbe808584774fa5e8d9810a4612a84e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/288452
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: fold MOV*nop and MOV*const
Keith Randall [Wed, 9 Dec 2020 22:59:40 +0000 (14:59 -0800)]
cmd/compile: fold MOV*nop and MOV*const

MOV*nop and MOV*reg seem superfluous. They are there to keep type
information around that would otherwise get thrown away. Not sure
what we need it for. I think our compiler needs a normalization of
how types are represented in SSA, especially after lowering.

MOV*nop gets in the way of some optimization rules firing, like for
load combining.

For now, just fold MOV*nop and MOV*const. It's certainly safe to
do that, as the type info on the MOV*const isn't ever useful.

R=go1.17

Change-Id: I3630a80afc2455a8e9cd9fde10c7abe05ddc3767
Reviewed-on: https://go-review.googlesource.com/c/go/+/276792
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agoruntime: clarify GC fractional mode description
zhengjianxun [Tue, 23 Feb 2021 03:12:56 +0000 (03:12 +0000)]
runtime: clarify GC fractional mode description

nowdays, in runtime/mgc.go,we can see the comment descrition : The fractional worker is necessary when GOMAXPROCS*gcBackgroundUtilization is not an integer.
but it not true such as GOMAXPROCS=5.
in the implemet of startCycle() , Fractional Mode happend only when
GOMAXPROCS<=3 or GOMAXPROCS=6. so utilization can closest to 25%.
Fixes #44380

Change-Id: Id0dd6d9f37759c2c9231f164a013a014216dd442
GitHub-Last-Rev: 5910e76324b2fa908235c325c8b1edafca496256
GitHub-Pull-Request: golang/go#44381
Reviewed-on: https://go-review.googlesource.com/c/go/+/293630
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Pratt <mpratt@google.com>

4 years agoall: use more precise build tags
Tamir Duberstein [Thu, 12 Nov 2020 22:42:58 +0000 (17:42 -0500)]
all: use more precise build tags

s/!gccgo/gc/ in files which use gc-syntax assembly.

Change-Id: Ifdadb62edd1210ebc70e7cd415648b752afaf067
Reviewed-on: https://go-review.googlesource.com/c/go/+/269957
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: David Chase <drchase@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years agocmd/compile: change riscv64 Eq32/Neq32 to zero extend before subtraction
Joel Sing [Mon, 30 Nov 2020 12:47:27 +0000 (23:47 +1100)]
cmd/compile: change riscv64 Eq32/Neq32 to zero extend before subtraction

As done with other equality tests, zero extend before subtraction rather than
after (or in this case, at the same time). While at face value this appears to
require more instructions, in reality it allows for most sign extensions to
be completely eliminated due to correctly typed loads. Existing optimisations
(such as subtraction of zero) then become more effective.

This removes more than 10,000 instructions from the Go binary and in particular,
a writeBarrier check only requires three instructions (AUIPC, LWU, BNEZ) instead
of the current four (AUIPC, LWU, NEGW, BNEZ).

Change-Id: I7afdc1921c4916ddbd414c3b3f5c2089107ec016
Reviewed-on: https://go-review.googlesource.com/c/go/+/274066
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>

4 years agoruntime: fix usleep on windows/arm
Russ Cox [Tue, 23 Feb 2021 16:38:24 +0000 (11:38 -0500)]
runtime: fix usleep on windows/arm

Changed calling convention to pre-multiply the argument by -100,
and then deleted the * 100 but not the negation in the windows/arm assembly.
Delete the negation.

Fixes the current all.bash breakage on windows/arm builder.
(Maybe that will uncover more.)

Change-Id: I13006a44866ecc007586deb180a49c038d70aa99
Reviewed-on: https://go-review.googlesource.com/c/go/+/295529
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>
4 years agocmd/compile: add AMD64 parameter register defs, Arg ops, plumb to ssa.Config
David Chase [Wed, 7 Oct 2020 13:44:16 +0000 (09:44 -0400)]
cmd/compile: add AMD64 parameter register defs, Arg ops, plumb to ssa.Config

This is partial plumbing recycled from the original register abi test work;
these are the parts that translate easily.  Some other bits are deferred till
later when they are ready to be used.

For #40724.

Change-Id: Ica8c55a4526793446189725a2bc3839124feb38f
Reviewed-on: https://go-review.googlesource.com/c/go/+/260539
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: improve bit test code
Keith Randall [Fri, 12 Feb 2021 23:55:25 +0000 (15:55 -0800)]
cmd/compile: improve bit test code

Some bit test instruction generation stopped triggering after
the change to addressing modes. I suspect this was just because
ANDQload was being generated before the rewrite rules could discover
the BTQ. Fix that by decomposing the ANDQload when it is surrounded
by a TESTQ (thus re-enabling the BTQ rules).

Fixes #44228

Change-Id: I489b4a5a7eb01c65fc8db0753f8cec54097cadb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/291749
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
4 years agocmd/go: recognize DLL magic from llvm binaries
Jason A. Donenfeld [Mon, 15 Feb 2021 19:20:15 +0000 (20:20 +0100)]
cmd/go: recognize DLL magic from llvm binaries

When using LLD with c-shared, the magic in the output DLL is slightly
different than for EXEs.

Change-Id: Icc5f34f7bb61f11a9d75494236b7797cc1988b40
Reviewed-on: https://go-review.googlesource.com/c/go/+/291638
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: guard special register usage with GOEXPERIMENT=regabi
Cherry Zhang [Tue, 23 Feb 2021 00:45:21 +0000 (19:45 -0500)]
cmd/compile: guard special register usage with GOEXPERIMENT=regabi

Previously, some special register uses are only guarded with ABI
wrapper generation (-abiwrap). This CL makes it also guarded with
the GOEXPERIMENT. This way we can enable only the wrapper
generation without fully the new ABI, for benchmarking purposes.

Change-Id: I90fc34afa1dc17c9c73e7b06e940e79e4c4bf7f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/295289
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>
4 years agocmd/go: resolve TODO by replacing InDir() function
Andy Pan [Sat, 21 Nov 2020 07:27:00 +0000 (15:27 +0800)]
cmd/go: resolve TODO by replacing InDir() function

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

4 years agogo/build/constraint: fix splitPlusBuild func doc comment
Alberto Donizetti [Tue, 23 Feb 2021 14:05:33 +0000 (15:05 +0100)]
go/build/constraint: fix splitPlusBuild func doc comment

Noticed while reading the code of the new package; likely a copy-paste
from the splitGoBuild function, which is almost identical.

Change-Id: I869272123708d25d237a4f0445f8e853865747f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/295469
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agoruntime: optimize the memory padding in p struct
Andy Pan [Tue, 10 Nov 2020 13:02:18 +0000 (21:02 +0800)]
runtime: optimize the memory padding in p struct

Since allocation for p struct will be rounded up to the next size class,
the two relevant adjacent classes for this case are 9728 bytes and 10240 bytes.

A p is currently 10072 bytes, so it gets rounded up to 10240 bytes when we allocate one,
So the pad in p struct is unnecessary, eliminate it and add comments for
warning the false sharing.

Change-Id: Iae8b32931d1beddbfff1f58044d8401703da6407
Reviewed-on: https://go-review.googlesource.com/c/go/+/268759
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

4 years agoruntime/cgo: use correct lean and mean macro
Jason A. Donenfeld [Sun, 14 Feb 2021 18:43:31 +0000 (19:43 +0100)]
runtime/cgo: use correct lean and mean macro

WIN64_LEAN_AND_MEAN is not the correct macro to use and doesn't ever
exist.

Change-Id: I32a5523cc0f7cc3f3a4d022071cf81f88db39aa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/291634
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agocmd/link: set .ctors COFF section to writable and aligned
Jason A. Donenfeld [Sun, 14 Feb 2021 18:01:39 +0000 (19:01 +0100)]
cmd/link: set .ctors COFF section to writable and aligned

Without setting these flags, LLVM's LLD ignores the .ctors section when
merging objects.

Updates #44250.
Updates #39326.
Updates #38755.
Updates #36439.
Updates #43800.

Change-Id: I8766104508f7acd832088a590ee7d68afa0d6065
Reviewed-on: https://go-review.googlesource.com/c/go/+/291633
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: do not pass -Bsymbolic for PE DLLs
Jason A. Donenfeld [Sun, 14 Feb 2021 13:44:14 +0000 (14:44 +0100)]
cmd/link: do not pass -Bsymbolic for PE DLLs

This is only a valid option on ELF. Binutils accepts it, but LLVM
rejects it, so for Windows, it's best to just omit it.

Updates #44250.
Updates #39326.
Updates #38755.
Updates #36439.
Updates #43800.

Change-Id: Iffd2345d757f23dd737e63bd464cd412527077c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/291632
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: set SizeOfRawData rather than VirtualSize in COFF files for .bss section
Jason A. Donenfeld [Sat, 13 Feb 2021 23:04:48 +0000 (00:04 +0100)]
cmd/link: set SizeOfRawData rather than VirtualSize in COFF files for .bss section

GCC and Clang both set the SizeOfRawData field rather than the
VirtualSize field for communicating the size of the .bss section. As a
consequence, LLD does not look at VirtualSize and collapses the .bss
section into whatever is around it, resulting in runtime crashes. This
commit changes the logic so that if the requested "file size" is 0, then
the SizeOfRawData field is set rather than the VirtualSize field as the
sole length marker.

Fixes #44250.
Fixes #39326.
Updates #38755.
Updates #36439.
Updates #43800.

Change-Id: Ied89ddaa0a717fed840238244c6e4848845aeeb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/291630
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/internal/dwarf: minor cleanups
Than McIntosh [Wed, 6 Jan 2021 18:27:17 +0000 (13:27 -0500)]
cmd/internal/dwarf: minor cleanups

Remove a stale comment, demote PutInlinedFunc from public to private,
and remove an unused interface originally used for sorting vars.
No change in functionality.

Change-Id: I5ee1ad2b10b78b158e2223c6979bab830202db95
Reviewed-on: https://go-review.googlesource.com/c/go/+/295009
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: enable race detector on openbsd/amd64
Joel Sing [Mon, 7 Dec 2020 17:14:34 +0000 (04:14 +1100)]
runtime: enable race detector on openbsd/amd64

Now that this commit[1] has landed in LLVM the .syso file can be generated for
OpenBSD.

With the changes to src/runtime running the sample race[2] detects the data
race as expected.

Based on golang/go#39464 (https://go-review.googlesource.com/c/go/+/237057) from
Aaron Bieber <deftly@gmail.com>, however the race_openbsd_amd64.syso file has
been built on OpenBSD 6.4 and necessary changes added to race.bash.

[1] https://github.com/llvm/llvm-project/commit/fcf6ae2f070eba73074b6ec8d8281e54d29dbeeb
[2] https://golang.org/doc/articles/race_detector.html

Change-Id: Ic2479ccfa91d6b2cb4585346a11d813d96450f68
Reviewed-on: https://go-review.googlesource.com/c/go/+/275892
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agointernal/poll: fix the verbose condition in splice
Andy Pan [Thu, 19 Nov 2020 09:30:27 +0000 (17:30 +0800)]
internal/poll: fix the verbose condition in splice

Change-Id: I0b433ea1a78632de20ea58c48c9be0f1fb6eb083
Reviewed-on: https://go-review.googlesource.com/c/go/+/271499
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

4 years agoios/fs: mention f.dir in (*subFS).fixErr godoc
Tobias Klauser [Tue, 16 Feb 2021 09:36:10 +0000 (10:36 +0100)]
ios/fs: mention f.dir in (*subFS).fixErr godoc

There is no dir parameter to (f *subFS).fixErr.

Change-Id: I49e42bac5e102cfab0d289658d9871429cfec515
Reviewed-on: https://go-review.googlesource.com/c/go/+/292389
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>
4 years agocmd/internal/obj/riscv: prevent constant loads that do not target registers
Joel Sing [Wed, 17 Feb 2021 10:03:59 +0000 (21:03 +1100)]
cmd/internal/obj/riscv: prevent constant loads that do not target registers

Check that the target of a constant load is a register and add test coverage
for this error condition. While here, rename the RISC-V testdata and tests
to be consistent with other platforms.

Change-Id: I7fd0bfcee8cf9df0597d72e65cd74a2d0bfd349a
Reviewed-on: https://go-review.googlesource.com/c/go/+/292895
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/internal/obj/riscv: clean up branch tests
Joel Sing [Fri, 15 Jan 2021 16:09:15 +0000 (03:09 +1100)]
cmd/internal/obj/riscv: clean up branch tests

Address review comments from earlier changes, which would have previously
caused unwanted conflicts.

Change-Id: If2c61ffe977d721cccf276f931825b003521fda1
Reviewed-on: https://go-review.googlesource.com/c/go/+/284116
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>

4 years agoruntime: fix windows/arm signal handling assembly
Russ Cox [Mon, 22 Feb 2021 17:56:33 +0000 (12:56 -0500)]
runtime: fix windows/arm signal handling assembly

Bug introduced in CL 288799: R12 is used but not set.

Fixes windows/arm builder.

Change-Id: I015a5a83cfa3bdd23da1ffb73713623764f2f817
Reviewed-on: https://go-review.googlesource.com/c/go/+/295109
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: remove backend's "scratch mem" support
Cuong Manh Le [Wed, 17 Feb 2021 08:27:42 +0000 (15:27 +0700)]
cmd/compile: remove backend's "scratch mem" support

This CL rebases CL 273987 on top of master with @mdempsky's permission.

The last (only?) use for this feature was 387 support, which was
removed in golang.org/cl/258957.

Change-Id: I4f79fee8d0c336c9b6082bcd5eb6ece52c032dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/292893
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>